Return-Path: Delivered-To: apmail-cayenne-user-archive@www.apache.org Received: (qmail 43519 invoked from network); 20 Jul 2007 22:25:58 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 20 Jul 2007 22:25:58 -0000 Received: (qmail 3165 invoked by uid 500); 20 Jul 2007 22:25:59 -0000 Delivered-To: apmail-cayenne-user-archive@cayenne.apache.org Received: (qmail 3151 invoked by uid 500); 20 Jul 2007 22:25:59 -0000 Mailing-List: contact user-help@cayenne.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@cayenne.apache.org Delivered-To: mailing list user@cayenne.apache.org Received: (qmail 3142 invoked by uid 99); 20 Jul 2007 22:25:59 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 20 Jul 2007 15:25:59 -0700 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (herse.apache.org: domain of ajay.daptardar@gmail.com designates 64.233.162.234 as permitted sender) Received: from [64.233.162.234] (HELO nz-out-0506.google.com) (64.233.162.234) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 20 Jul 2007 15:25:57 -0700 Received: by nz-out-0506.google.com with SMTP id f1so2695989nzc for ; Fri, 20 Jul 2007 15:25:36 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=htNKJYC+YJdr7dHw2+A0Amp6cfhj09DIrwBFu2ANuftmxxLSAplkXrM2ZU8r1gsOhoXaZkvOD+whAliGjB8dVfbU40BsmL9uMGB1me6WIQiWMDfQemhSKpi5ycL1Mpn8F6FLycomkyqpUA048BWYQAj3+XtBjwdpGFfzoCX0bns= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=Aa87K40idBJLa6SgjViGc+mzh6/GepazSQTXUZxjiC8ihjjWEeQPiXMKs7gsbIUMbrc3ldBDAxY1/fP4GYcVfdfxRb+D8btRR2zsRTOXO3JegoX34PdxM+XaGBgAy0Wq1JYYL8+AZjE3rx5tx01jcTjPcSd/KaMkarnJMCCVbxQ= Received: by 10.143.40.12 with SMTP id s12mr64105wfj.1184970335504; Fri, 20 Jul 2007 15:25:35 -0700 (PDT) Received: by 10.143.4.2 with HTTP; Fri, 20 Jul 2007 15:25:35 -0700 (PDT) Message-ID: Date: Fri, 20 Jul 2007 18:25:35 -0400 From: "Ajay H. Daptardar" To: user@cayenne.apache.org Subject: Re: Usage in Axis2 In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <4711027D-3E30-46C0-94A0-DF3CB664A9CD@objectstyle.org> <45C04941-C000-4647-A86F-7173D73D0EB4@objectstyle.org> X-Virus-Checked: Checked by ClamAV on apache.org Hi Andrus, I managed to hack a fix. In the Util class, the getJavaClass method gets the class loader as: ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); if (classLoader == null) { classLoader = Util.class.getClassLoader(); } However (and I did verify this) the class loader is the one that tomcat uses for the Axis2 servlet. Here's how Axis2 uses class loaders Axis2 has the notion of service isolation where each service or module gets its own class loader. Using this class loader you can access any resource that you put into your service archive file. [See http://docs.huihoo.com/apache/axis/axis2-1.0-docs/xdocs/faq.html#b1] The fix was the following: ClassLoader classLoader = null; if (classLoader == null) { classLoader = Util.class.getClassLoader(); } this correctly gets the class loader that Axis2 assigned to the particular WS. Best, - Ajay On 7/20/07, Ajay H. Daptardar wrote: > 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 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/ > > > > > > 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 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 > -- The mind is everything; what you think, you become. -- Buddha