Question

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).

Était-ce utile?

La solution

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());

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top