1
votes

I have a openJPA based project that I need to deploy it in format of aar into the following folder under Tomcat.

tomcat\webapps\axis2\WEB-INF\services

But it seems that the service cannot load the persistence.xml file in the META-INF folder within the aar file. I found a solution to rename the aar file into jar, like DummySerivce.aar -> DummySerivce.jar and then put the DummySerivce.jar into the lib folder, to be exactly

tomcat\webapps\axis2\WEB-INF\lib

This time, the persistence.xml could be loaded and the service worked well. But this unnecessarily imported a jar file which was not included in the specification.

So my question is, is there any way to load the persistence.xml from a aar file? is it possible to overload the path of persistence.xml file in code?

btw, only entity information are left in the persistence.xml, database connection parameters are already define in code, and I'm using Axis2.

Thanks!

1

1 Answers

4
votes

I have found a solution.

By adding the following line into the services.xml, persistence.xml packed in aar file could be successfully loaded.

<parameter name="ServiceTCCL">composite</parameter>

for detailed info. please refer to http://wso2.org/node/1131

Now checking if there's any side effect.

TCCL - Thread context class loader

  • default - Status quo, normal behavior
  • composite - TCCL contains all jars from environment (say webapp) and those specified in the
  • service archive (aar) file under /lib service - TCCL contains all jars from service archive (aar)