Results 1 to 3 of 3

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

  1. #1
    Join Date
    Dec 2005
    Posts
    4

    Default 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. #2
    Join Date
    Jan 2005
    Location
    Bucharest, Romania
    Posts
    5,403

    Default

    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?
    Costin Leau
    SpringSource - http://www.SpringSource.com- Spring Training, Consulting, and Support - "From the Source"
    http://twitter.com/costinl
    Please use [ c o d e ] [ / c o d e ] tags

  3. #3
    Join Date
    Dec 2005
    Posts
    4

    Default 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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •