Announcement Announcement Module
Collapse
No announcement yet.
NoClassFoundError when classes are into WEB-INF\lib\some.jar Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • NoClassFoundError when classes are into WEB-INF\lib\some.jar

    Hello,

    I am using XMLBeans to generate some classes that implements their XMLObject interface. All these classes are packaged into a xmltypes.jar file located into WEB-INF\lib directory.

    I also have a Spring managed bean holding a Map like this:

    MsgType/key | XML Document Class (from XMLBeans)

    "request1" | Request1Document.class
    "request2" | Request2Document.class
    ...

    The problem is that when Spring is initializing that bean I got NoClassFoundError when trying to access any class located in my xmlbeans.jar.

    I tried to manually coppy these classes into WEB-INF\classes directory and it did work as expected.

    So I wonder classes from xmlbeans.jar are not accessible when Spring is initializing my context. Is this correct ?

    Thanks

  • #2
    Spring doesn't do anything special to load classes - if the classes are not found then likely you have a classloading problem inside your application server so some dependency for XMLbeans is missing which in turn, makes the loading of the classes to fail.
    What is your stacktrace?

    Comment


    • #3
      Another jar

      Hi Costin

      For some weird reason sometimes I get NoClassDefFoundError when the required class is inside some jar inside my WEB-INF\lib. I am using Weblogic 8.1 (SP4). In fact I just had the same problem with Quartz:

      Jul 17, 2006 5:02:03 PM org.springframework.web.context.ContextLoader initWebApplicationContext
      SEVERE: Context initialization failed
      org.springframework.beans.factory.BeanDefinitionSt oreException: Error registering bean with name 'tradeJob1' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Class that bean class [org.springframework.scheduling.quartz.JobDetailBea n] depends on not found; nested exception is java.lang.NoClassDefFoundError: org/quartz/JobDetail
      Caused by: java.lang.NoClassDefFoundError: org/quartz/JobDetail
      at java.lang.ClassLoader.defineClass(Ljava.lang.Strin g;[BIILjava.security.ProtectionDomainLjava.lang.Class;(Unknown Source)
      ...
      Sure, I do have quartz-1.5.2.jar within WEB-INF\lib.

      I also tried to use this weblogic tag but without any success:

      <container-descriptor>
      <prefer-web-inf-classes>true</prefer-web-inf-classes>
      </container-descriptor>
      I solved XMLBeans issue by just coping my generated beans (XMLBeans has an Ant tag that takes my XML schemas specs and then generate Java code to reflect XML schema data types and elements) to my WEB-INF\classes. Even so, I will try to use another app server instance and hopefully will be able to post here the cause of this problem.

      Thanks

      Comment

      Working...
      X