1

I'm trying to use cayenne within an Axis2 service (compiled as an .aar file).

I was able to make the service locate my cayenne jar but when I try to make a query on the database, it throws the following exception:

2013-01-15 17:52:38,891 [http-8080-Processor25] DEBUG org.apache.axis2.transport.http.AxisServlet - org.apache.axis2.AxisFault: [v.3.0.2 Jun 11 2011 09:52:20] Error during Configuration initialization. [v.3.0.2 Jun 11 2011 09:52:20] [org.apache.cayenne.conf.DefaultConfiguration] : Domain configuration file "cayenne.xml" is not found.

I've been trying to put the cayenne.xml file everywhere (/lib /WEB-INF/lib /WEB-INF/classes though I only had hope for the first one).

Could someone please advise me on how to proceed?

Is it possible to force cayenne to look for the cayenne.xml file in the /lib directory of my .aar ?

Is it possible to print the classpath that is used by the service's classLoader (I understand that each service should have its own classLoader).

laxonline
  • 2,657
  • 1
  • 20
  • 37
ixM
  • 1,244
  • 14
  • 29

1 Answers1

1

While I am no Axis2 expert, from my theoretical understanding of its class loading mechanism, I see two options:

  1. Ensure that cayenne-server.jar and cayenne.xml are loaded by the same ClassLoader (cayenne-server.jar should be in /WEB-INF/lib, while cayenne.xml - in /WEB-INF/classes/),

  2. Set current thread classloader in your Axis code in the place where you bootstrap Cayenne, so that DefaultConfiguration could locate the XML files:

    Thread.currentThread().setContextClassLoader(getClass().getClassLoader());

andrus_a
  • 2,528
  • 1
  • 16
  • 10
  • .aar archives don't have a WEB-INF folder. At their root, you can put a lib folder to put your external jars in but without doing anything else, putting a classes folder doesn't solve the problem. I will try the 2. point and come back with the results. Thanks! – ixM Jan 16 '13 at 07:24
  • I managed to make it work by adding the said line before creating the datacontext and by putting the needed xml files (cayenne.xml, xx.map.xml and xx.driver.xml) at the root of the aar file! Thanks a lot! – ixM Jan 16 '13 at 08:08