Search code examples
eclipsejbosseclipse-wtp

How can I add external files to webapp classpath running with Jboss within eclipse?


I have three projects in my workspace :

  • prjData, a "simple" project (no java nor any other facet) including many configuration files (xml, properties and so on)
  • prjWeb, a "dynamic web" project
  • prjEar, an ear project which has prjWeb in its "project references"

I try to deploy the prjEar on a JBoss 4.2 from inside eclipse (helios).

I created the server (in server view), then added the prdData/config in its wtp launcher's classpath (double clic on the server item, then from the Overview window, clic "Open Launch Configuration", select Classpath tab, Advanced / Add folders).

When I start the server from the server view, console view confirms that Jboss starts the webapp, but fails on all tasks requiring config files actually located in this additional classpath folder, as log4j or OJB configuration.

I'm used to make it that way with Tomcat, and it works quite fine. But for the current project it is mandatory to stick to JBoss.

What is wrong in the way classpath additional folders set in the wtp launcher view are taken (or not ?) into account by Jboss and the webapp ?


Solution

  • Actually there was nothing wrong with Eclipse/WTP to add folders to JBoss runtime.

    The problem was coming from my wrong understanding of OJB configuration loading.

    I was taking on an existing application where the repository.xml file was split into pieces which were included through xml entities. The pieces were in different folders of prjData, but prjData was configured as a java project, with as many "source" directories as needed. Then prjData was included in prjWeb as a java submodule, so pieces in those "source" directories all ended in the same place in WEB-INF/classes, making JBoss happy.

    The problems came when I decided to brake the java nature of prjData and replace its inclusion in prjWeb with classpath inclusions. Then all pieces were in classpath, but still in different folders.

    When repository.xml tried to resolve its xml entities, it failed to find out the pieces (as it looks up files through filesystem organization, not current java classpath), making the whole app fail to start.

    I just had to change the file organisation and relative path in xml entities declaration to make it work again.