views:

3636

answers:

2

Hey Guys, I am having a problem deploying an ear with bundled wars, jars, and configuration files (.properties files) on JBoss 4.3-eap. Here is my ear structure:

+app.ear   
  +lib  
    *.jar libraries that the war's use  
    +classes  
      *.properties and other configuration files 
  +META-INF  
    application.xml  
    jbos-app.xml  
  app.war  
  app2.war  
  appn.war

I have the following in my jboss-app.xml :

<jboss-app>
  <jmx-name>app.startup.JbossStartUpServer:service=JbossStartUpService</jmx-name>
</jboss-app>

My application.xml looks like this:

<application id="app_id">
  <display-name>App>/display-name>
  <description>TheApp>/description>
<!--  
  <module  id="core">
    <java>lib/core.jar</java>
  </module>

  <module id="tag">
    <java>lib/tag.jar</java>
  </module>
-->  
  <module id="app">
    <web>
      <web-uri>app.war</web-uri>
      <context-root>/</context-root>
    </web>
  </module> 

  <module id="app2">
    <web>
      <web-uri>app2.war</web-uri>
      <context-root>/app2</context-root>
    </web>
  </module> 

  <module id="appn">
    <web>
      <web-uri>appn.war</web-uri>
      <context-root>/appn</context-root>
    </web>
  </module>

  <security-role id="secRole">
    <description>users</description>
    <role-name id="appRoleName">users</role-name>
  </security-role>

  <library-directory>lib</library-directory>

</application>

Basically, upon deploying the ear, I run into an issue where one of my wars can't find a class in the core.jar file (java.lang.NoClassDefFoundError). I think this is due to the fact that the war is not finding this library, even though it is in the lib folder/classpath. If I try to uncomment the first two modules to add the first party libraries (core.jar and tag.jar), all of a sudden the properties files can no longer be found (they are located, for now, in lib/classes, so that, I hope anyway, they are picked up by the classloader. Ideally I'd like to put classes in its own directory and add it to the classpath separately, but for now I am just trying to make this work).

I have tried some other things, including manually adding core.jar to the war's manifest.mf file, changing UseJBossWebLoader to true in the jboss-service.xml file under the jboss-web.deployer, and various combinations of the above, to no success. I either lose the classes directory from the classpath (lib folder) and none of my properties files get picked up, or the war can't access the proper class from the jar. I think there must be some configuration that is wrong, and while I've tried reading up on the way JBoss does EAR deployments and classloading, I can't seem to adapt it to my current setup.

Any suggestions would be greatly appreciated.

Here are some sites that I have been looking at:
Raible Designs JBoss ClassLoader Logic

These are just a few of the sites I have looked at. The problems might stem from the setup of the project as well, as this is a large established project that is (to an extent) being migrated from a weblogic deployment to Jboss. So if there is anything that SHOULD work, but doesn't, it might be an issue with some of the code/project configuration. Unfortunately, I am not at the point yet where I can tell if its a JBoss related problem, or a problem with the project.

Keep in mind that I am fairly new to JBoss and this is largly a learn-by-doing experience for me.

+1  A: 

I had JBoss 4.3 issues myself, this link solved my problem:

http://blog.javarnd.com/?p=166

David Rabinowitz
Thanks for the link, seems like a good resource, but unfortunately none of the links to the sample files work on that site.
mike
I spoke with Pavel, the files are back
David Rabinowitz
+3  A: 

The <library-directory> tag in application.xml is a JavaEE5 feature, and I don't think that JBoss 4.3 is fully JavaEE5-compliant (it can do EJB3, yes, but it's only partial support).

So you need to go back to using explicitly declared JAR files:

<module>
    <java>lib/core.jar</java>
</module>

As for your properties files, you need to add the directory that they're in as a java module, so for your example:

<module>
    <java>lib/classes</java>
</module>
skaffman
This solved my problem! Thanks a lot! I'd like to ask a followup question though: if I add those modules to the application.xml, does that mean I don't need the class-path property in the wars' manifest.mf files? Or is this only the case if I set the UseJBossWebLoader attribute in jboss-web.deployer to true?
mike
oh yea and just out of curiosity, how did you fix the formatting issues on my xml in my original post?
mike
I'm not sure about the manifest issue, I haven't tried that myself, I always rely on the default flattened classloader. As for your formatting, don't use the core/pre tags, they don't work very well. Use the formatting icons in the editor.
skaffman