Announcement Announcement Module
Collapse
No announcement yet.
Wierd ClassLoader problem Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Wierd ClassLoader problem

    Hi
    I'm getting a strange behaviour with class loading (I'm using JBoss 4.0.2 and it may be a JBoss issue)
    I am learning about web frameworks in Spring
    I have one web app containing code for two approaches to MVC. I have a Spring MVC version which works OK and Struts version which throws a NoClassDefFound error.
    The wierd bit is the class is a value object which is being used by both applications. The class is actually in a separately compiled jar bundled with the war file by Maven.
    The MVC app is quite happy to create it, even if I use Class.forName("blah").newInstance.
    If I try to do exactly the same thing in the Struts version of the app it can't find it. I can put the jar in the JBoss server lib directory and both pieces of code can see it. But since this is application code I don't want to do that and really shouldn't have to.
    I've seen a lot of class loader issue post related to Jboss but none so far give a conclusive solution.

    If anyone has hit this problem and know a solution please out me out of my misery asap

    :-)
    Tom

  • #2
    classloader differences

    re this problem I have found that the two parts of my web app, in the same war file, seem to be using different classloaders. This partly explains my problem but not the cause.
    Spring MVC is using
    18:55:56,953 INFO [EntityTypeFormController] classloader = WebappClassLoader
    delegate: false
    repositories:
    /WEB-INF/classes/
    ----------> Parent Classloader:
    java.net.FactoryURLClassLoader@1611531

    Struts in Spring is using
    18:56:06,687 INFO [MaskRequestProcessorImplementation] classloader = org.jboss.mx.loading.UnifiedClassLoader3@19e9da7{ url=file:/C:/Javawork/jboss-4.0.3SP1/server/default/tmp/deploy/tmp6098TP-0.1.ear ,addedOrder=46}


    any ideas people? Driving me nuts

    Comment


    • #3
      JBoss classloaders; gotta love 'em ;-)

      JAR files that are loaded from server/lib will use a different classloader to those loaded from server/deploy, which will use a different classloader again to those in your webapp. Is it possible that the some of the classes that struts is using are coming from server/lib (the commons-* stuff in particular?)

      Would be worth checking that you've bundled *all* the dependencies for struts and spring into your WEB-INF/lib directory, to make sure that you're not accidentally referencing the ones out of server/lib.

      Comment

      Working...
      X