Hi Andrus,
I tried the 3.0M1 build and am still getting the class not found error
although manifest as a CayenneRuntimeException caused by
ClassNotFoundException.
Here is a trace:
Caused by: org.apache.cayenne.CayenneRuntimeException: [v.3.0M1 Jul 16
2007 22:17:38] Failed to load class com.app.AnnotationType:
com.app.AnnotationType
at org.apache.cayenne.map.ObjEntity.getJavaClass(ObjEntity.java:238)
at org.apache.cayenne.reflect.PersistentDescriptorFactory.getDescriptor(PersistentDescriptorFactory.java:50)
at org.apache.cayenne.reflect.ClassDescriptorMap.createDescriptor(ClassDescriptorMap.java:122)
at org.apache.cayenne.reflect.LazyClassDescriptorDecorator.checkDescriptorInitialized(LazyClassDescriptorDecorator.java:49)
at org.apache.cayenne.reflect.LazyClassDescriptorDecorator.createObject(LazyClassDescriptorDecorator.java:63)
at org.apache.cayenne.access.DataContext.newObject(DataContext.java:752)
... 26 more
Caused by: java.lang.ClassNotFoundException: com.app.AnnotationType
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1359)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1205)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:242)
at org.apache.cayenne.util.Util.getJavaClass(Util.java:566)
at org.apache.cayenne.map.ObjEntity.getJavaClass(ObjEntity.java:235)
... 31 more
The problem is not that Cayenne cannot be found, it occurs when
Cayenne tries to load the mapped classes using the web app class
loader. What I don't get is that why the web app class loader cannot
load the classes.
I am guessing that Axis2 creates a class loader for each web service,
loads the application classes and the jars in the lib folder (thats
why it finds Cayenne jars). But when Cayenne retrieves a class loader
(WebappClassLoader), this class loader is probably the one for the
Axis2 web service, not the one that Axis2 is using to load web
services.
Probably there is a way to get the class loader for the particular web
service within the Axis2 (webapp) servlet.
Best,
- Ajay
On 7/20/07, Andrus Adamchik <andru..bjectstyle.org> wrote:
> This felt like a nested ClassLoader issue from the beginning... I am
> not familiar with the Axis2 archive details, but is it possible to
> put Cayenne jar at the same level as the application classes?
>
> Alternatively you can try upgrading to 3.0M1 (you can grab an
> *unofficial* build from here: http://people.apache.org/~aadamchik/
> release/3.0M1/). 3.0 uses String class names as keys and should
> hopefully be free from this problem. Please let me know if that
> worked - we will definitely need to fix it if it is still broken in 3.0.
>
> > // DataMaps can contain all kinds of garbage...
> > // TODO (Andrus, 10/18/2005) it would be nice
> > to log something
> > // here, but since EntityResolver is used on
> > the client, log4J is
> > // a no-go...
>
> Good catch. This is also obsolete in 3.0 - we can use commons
> logging. Let me clean it up.
>
> Andrus
>
>
>
> > // TODO (Andrus, 10/18/2005) it would be nice
> > to log something
> > // here, but since EntityResolver is used on
> > the client, log4J is
> > // a no-go...
>
>
>
>
> On Jul 20, 2007, at 9:15 PM, Ajay H. Daptardar wrote:
>
> > Hi Andrus,
> >
> > The structure of the Axis2 archive (app.aar) is as follows:
> >
> > META-INF/
> > META-INF/MANIFEST.MF
> > META-INF/services.xml
> > lib/
> > lib/bcel.jar
> > lib/cayenne.jar
> > lib/jibx-bind.jar
> > lib/jibx-extras.jar
> > lib/jibx-genbinding.jar
> > lib/jibx-genschema.jar
> > lib/jibx-run.jar
> > lib/mysql-connector-java-5.0.6-bin.jar
> > lib/qdox-1.6.1.jar
> > lib/stax-api.jar
> > lib/wstx-asl.jar
> > lib/xmlpull_1_1_4.jar
> > lib/xpp3.jar
> > app/<APPLICATION CLASSES>
> >
> > Cayenne jar is in the application's lib folder not axis'. After
> > stepping through the debugger, I found out that even though the
> > application can load the Cayenne data context, the entity resolver,
> > when it PUTS object entities in the cache, it uses the name of the
> > entity and when it tries to GET the object entity, it tries to use the
> > oe.getJavaClass() which throws an exception. This is not logged and
> > the comment there is:
> >
> > // DataMaps can contain all kinds of garbage...
> > // TODO (Andrus, 10/18/2005) it would be nice
> > to log something
> > // here, but since EntityResolver is used on
> > the client, log4J is
> > // a no-go...
> >
> > the Util.getJavaClass() fails to load the (application) class it
> > seems.
> >
> > Thanks,
> > Best,
> > - Ajay
> >
> >
> >
> >
> >
> > On 7/19/07, Andrus Adamchik <andru..bjectstyle.org> wrote:
> >> That is strange... I assume Cayenne jars are in "axis2/WEB-INF/lib",
> >> and not in some shared location?
> >>
> >> Andrus
> >>
> >> On Jul 18, 2007, at 11:53 PM, Ajay H. Daptardar wrote:
> >> > Hello all,
> >> >
> >> > I am trying to use Cayenne within Axis2. I copied the three
> >> > configuration XML files into the classes folder for Axis2:
> >> >
> >> > /opt/apache-tomcat-6.0.13/webapps/axis2/WEB-INF/classes
> >> >
> >> > I can create the data context object but during runtime, data
> >> > context's entity resolver cannot find the mapped class and I get
> >> the
> >> > following:
> >> >
> >> > "Class is not mapped with Cayenne"
> >> >
> >> > However when I run the same application as standalone, I have no
> >> > errors.
> >> >
> >> > Any help much appreciated.
> >> >
> >> > Best,
> >> > - Ajay
> >> >
> >>
> >>
> >
> >
> > --
> > The mind is everything; what you think, you become. -- Buddha
> >
>
>
-- The mind is everything; what you think, you become. -- Buddha
This archive was generated by hypermail 2.0.0 : Fri Jul 20 2007 - 16:25:32 EDT