简体   繁体   中英

Load persistence.xml from aar in tomcat

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!

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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM