Hey, all,
I'm having an issue with a third-party API I'm trying to write a web service around. I have my web service built in Eclipse Helios as an
EJB project, which is packaged up in an EAR file and deployed to a
JBOSS 6.0 application server. The API is... well, it's a little different than what I'm used to. Usually, I find that a
Java API will give you one or more .jar files, which you include in your EAR Libraries, and then perhaps some configuration files that you specify. The configuration files are what's giving me trouble here.
The API documentation -- which is, unfortunately, pretty sparse -- instructs me to put the directory containing the config files on the classpath. I've tried a few different ways of doing this, but every time, I deploy my web service and immediately get an error message in the JBOSS console saying that it can't instantiate my class because it cannot locate the .xml file it's looking for. Here's the screwy bit: the exception stack trace actually tells me that it's looking for a specific directory structure -- what I assume is the "default" location of the config file -- of "/opt/<api_name>/conf/<file>.xml". If, however, I put the expected XML file in the exact directory specified in the trace, I still receive the same error.
Looking to simplify the problem a bit and isolate the issue, I constructed a plain Java project, with a main method that simply instantiates the API, retrieves one piece of information to confirm connectivity to the system server, and then exits. I then run this project from Eclipse by right-clicking the main class and choosing Run As... > Java Application. So far, the *only* way I've been able to get a successful result -- meaning that the config file was read correctly and information was retrieved as expected -- is if I include the config file directory as an external class folder.
I've tried exporting the
test project as a runnable .jar file, thinking that I might be able to package the configuration information into that, but received the same error as before. Thinking that perhaps it wasn't including anything from the external source folder in the .jar export because there were no Java classes there, I then packed up the config files into their own .jar file, and added that to the project. This was exported correctly -- I opened the project .jar file after export and confirmed that my config folder was there -- but I still received the error that the program could not find the configuration directory upon running the .jar file. I also tried running the .jar file with the -classpath option pointing to the config directory on the hard drive, but no luck there, either.
I don't expect anyone to be able to tell me why an ancient third-party API that I have no source code for is not able to find it's configuration; that's for me to figure out. What I do know is, when I add the config directory as an external class folder in Eclipse, I can get the program to work as expected, and so far, that's the only way I've been able to do so. Classpath-related issues have always been my weak point with Java, and they only get more complicated when factoring in EJBs, EARs, and application servers.
So, the root question here is,
what is Eclipse doing at the classpath level when you use the Add External Class Folder button in the Project Properties > Java Build Path > Libraries tab? How is that class folder related to the rest of the project? I've tried to provide as much info as I can on the issue at hand, but if I've left out anything glaringly obvious, please let me know. I would appreciate any help that anyone can offer me with this. If I can figure out what Eclipse does when you add one of these class folders, and how it's different from what I have already tried or am trying to do, maybe I can figure out what the real issue here is.
Thanks in advance, everyone.