java - Packaging persistence.xml outside of jar with OpenJPA -
so i'm using jpa (openjpa 2.3.0 implementation) in perhaps rather unconventional way. i'm writing piece of software maintain personnel data , assign work said personnel. type of work assigns undefined - user must extend mapped superclass, add additional mappings class, , software take there. have several systems follow pattern, , wanted write assignment code once. however, there small differences in gets assigned - system assign case, other assign smaller piece of case, others assign based on customer, etc.
to maximum configurability, put metadata persistent entities mapping file instead of using annotations. since programmer using software have extend mapped superclass , add own mapping persistence unit, didn't want package persistence.xml or mapping xml jar i'm creating. figured programmer include files somewhere in ear. wrote entire thing using java se, not ee, i'm creating entitymanagerfactory myself instead of injecting it.
my organization using websphere application server 7.0 implements java ee 5. looking @ documentation jpa in java ee 5, seemed user have package persistence.xml , mapping xml files separate jar placed in ear's library folder. refer jar file in persistence.xml. following (the name of software wam):
<?xml version="1.0" encoding="utf-8"?> <persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"> <persistence-unit name="wam" transaction-type="resource_local"> <mapping-file>wammapping.xml</mapping-file> <jar-file>wam-1.0.0.jar</jar-file> </persistence-unit>
i tried write quick , dirty web service in manner. added persistence.xml file , mapping xml jar called wam-config.jar , stuck in ear library folder. when make web service request, following error back:
javax.persistence.persistenceexception: explicit persistence provider error(s) occurred "wam" after trying following discovered implementations: com.ibm.websphere.persistence.persistenceproviderimpl, org.apache.openjpa.persistence.persistenceproviderimpl, org.apache.openjpa.persistence.persistenceproviderimpl, org.apache.openjpa.persistence.persistenceproviderimpl following failures: com.ibm.websphere.persistence.persistenceproviderimpl returned: java.lang.illegalargumentexception: jar resource "wam-1.0.0.jar" cannot loaded. @ org.apache.openjpa.persistence.persistenceunitinfoimpl.validatejarfilename(persistenceunitinfoimpl.java:277) @ org.apache.openjpa.persistence.persistenceunitinfoimpl.processjarfilenames(persistenceunitinfoimpl.java:239) @ org.apache.openjpa.persistence.persistenceproductderivation.load(persistenceproductderivation.java:538) @ org.apache.openjpa.persistence.persistenceproductderivation.load(persistenceproductderivation.java:335) @ org.apache.openjpa.persistence.persistenceproviderimpl.createentitymanagerfactory(persistenceproviderimpl.java:89) @ com.ibm.websphere.persistence.persistenceproviderimpl.createentitymanagerfactory(persistenceproviderimpl.java:73) @ com.ibm.websphere.persistence.persistenceproviderimpl.createentitymanagerfactory(persistenceproviderimpl.java:43) @ org.apache.openjpa.persistence.persistenceproviderimpl.createentitymanagerfactory(persistenceproviderimpl.java:154) @ org.apache.openjpa.persistence.persistenceproviderimpl.createentitymanagerfactory(persistenceproviderimpl.java:65) @ javax.persistence.persistence.createentitymanagerfactory(persistence.java:150) @ gov.ssa.wam.service.basewamservice.initializeentitymanagerfactory(basewamservice.java:73) @ gov.ssa.wam.service.basewamservice.<init>(basewamservice.java:34) @ gov.ssa.wam.service.wamservicedelegate.getinstance(wamservicedelegate.java:31) @ gov.ssa.earnings.webservice.wamservicebean.<init>(wamservicebean.java:22) @ java.lang.j9vminternals.newinstanceimpl(native method) @ java.lang.class.newinstance(class.java:1474) @ com.ibm.wsspi.injectionengine.injectionutil.createinjectedinstance(injectionutil.java:79) @ com.ibm.ws.websvcs.server.wsserviceinstancefactory.createserviceinstance(wsserviceinstancefactory.java:110) @ org.apache.axis2.jaxws.server.endpointcontroller.handlerequest(endpointcontroller.java:247) @ org.apache.axis2.jaxws.server.endpointcontroller.invoke(endpointcontroller.java:103) @ org.apache.axis2.jaxws.server.jaxwsmessagereceiver.receive(jaxwsmessagereceiver.java:161) @ org.apache.axis2.engine.axisengine.receive(axisengine.java:189) @ org.apache.axis2.transport.http.httptransportutils.processhttppostrequest(httptransportutils.java:275) @ com.ibm.ws.websvcs.transport.http.wasaxis2servlet.dopost(wasaxis2servlet.java:1431) @ javax.servlet.http.httpservlet.service(httpservlet.java:738) @ javax.servlet.http.httpservlet.service(httpservlet.java:831) @ com.ibm.ws.webcontainer.servlet.servletwrapper.service(servletwrapper.java:1663) @ com.ibm.ws.webcontainer.servlet.servletwrapper.handlerequest(servletwrapper.java:939) @ com.ibm.ws.webcontainer.servlet.servletwrapper.handlerequest(servletwrapper.java:502) @ com.ibm.ws.webcontainer.servlet.servletwrapperimpl.handlerequest(servletwrapperimpl.java:181) @ com.ibm.ws.webcontainer.servlet.cacheservletwrapper.handlerequest(cacheservletwrapper.java:91) @ com.ibm.ws.webcontainer.webcontainer.handlerequest(webcontainer.java:864) @ com.ibm.ws.webcontainer.wswebcontainer.handlerequest(wswebcontainer.java:1592) @ com.ibm.ws.webcontainer.channel.wcchannellink.ready(wcchannellink.java:186) @ com.ibm.ws.http.channel.inbound.impl.httpinboundlink.handlediscrimination(httpinboundlink.java:452) @ com.ibm.ws.http.channel.inbound.impl.httpinboundlink.handlenewrequest(httpinboundlink.java:511) @ com.ibm.ws.http.channel.inbound.impl.httpinboundlink.processrequest(httpinboundlink.java:305) @ com.ibm.ws.http.channel.inbound.impl.httpinboundlink.ready(httpinboundlink.java:276) @ com.ibm.ws.tcp.channel.impl.newconnectioninitialreadcallback.sendtodiscriminators(newconnectioninitialreadcallback.java:214) @ com.ibm.ws.tcp.channel.impl.newconnectioninitialreadcallback.complete(newconnectioninitialreadcallback.java:113) @ com.ibm.ws.tcp.channel.impl.aioreadcompletionlistener.futurecompleted(aioreadcompletionlistener.java:165) @ com.ibm.io.async.abstractasyncfuture.invokecallback(abstractasyncfuture.java:217) @ com.ibm.io.async.asyncchannelfuture.firecompletionactions(asyncchannelfuture.java:161) @ com.ibm.io.async.asyncfuture.completed(asyncfuture.java:138) @ com.ibm.io.async.resulthandler.complete(resulthandler.java:204) @ com.ibm.io.async.resulthandler.runeventprocessingloop(resulthandler.java:775) @ com.ibm.io.async.resulthandler$2.run(resulthandler.java:905) @ com.ibm.ws.util.threadpool$worker.run(threadpool.java:1646) org.apache.openjpa.persistence.persistenceproviderimpl returned: java.lang.illegalargumentexception: jar resource "wam-1.0.0.jar" cannot loaded. @ org.apache.openjpa.persistence.persistenceunitinfoimpl.validatejarfilename(persistenceunitinfoimpl.java:277) @ org.apache.openjpa.persistence.persistenceunitinfoimpl.processjarfilenames(persistenceunitinfoimpl.java:239) @ org.apache.openjpa.persistence.persistenceproductderivation.load(persistenceproductderivation.java:538) @ org.apache.openjpa.persistence.persistenceproductderivation.load(persistenceproductderivation.java:335) @ org.apache.openjpa.persistence.persistenceproviderimpl.createentitymanagerfactory(persistenceproviderimpl.java:89) @ org.apache.openjpa.persistence.persistenceproviderimpl.createentitymanagerfactory(persistenceproviderimpl.java:154) @ org.apache.openjpa.persistence.persistenceproviderimpl.createentitymanagerfactory(persistenceproviderimpl.java:65) @ javax.persistence.persistence.createentitymanagerfactory(persistence.java:150) @ gov.ssa.wam.service.basewamservice.initializeentitymanagerfactory(basewamservice.java:73) @ gov.ssa.wam.service.basewamservice.<init>(basewamservice.java:34) @ gov.ssa.wam.service.wamservicedelegate.getinstance(wamservicedelegate.java:31) @ gov.ssa.earnings.webservice.wamservicebean.<init>(wamservicebean.java:22) @ java.lang.j9vminternals.newinstanceimpl(native method) @ java.lang.class.newinstance(class.java:1474) @ com.ibm.wsspi.injectionengine.injectionutil.createinjectedinstance(injectionutil.java:79) @ com.ibm.ws.websvcs.server.wsserviceinstancefactory.createserviceinstance(wsserviceinstancefactory.java:110) @ org.apache.axis2.jaxws.server.endpointcontroller.handlerequest(endpointcontroller.java:247) @ org.apache.axis2.jaxws.server.endpointcontroller.invoke(endpointcontroller.java:103) @ org.apache.axis2.jaxws.server.jaxwsmessagereceiver.receive(jaxwsmessagereceiver.java:161) @ org.apache.axis2.engine.axisengine.receive(axisengine.java:189) @ org.apache.axis2.transport.http.httptransportutils.processhttppostrequest(httptransportutils.java:275) @ com.ibm.ws.websvcs.transport.http.wasaxis2servlet.dopost(wasaxis2servlet.java:1431) @ javax.servlet.http.httpservlet.service(httpservlet.java:738) @ javax.servlet.http.httpservlet.service(httpservlet.java:831) @ com.ibm.ws.webcontainer.servlet.servletwrapper.service(servletwrapper.java:1663) @ com.ibm.ws.webcontainer.servlet.servletwrapper.handlerequest(servletwrapper.java:939) @ com.ibm.ws.webcontainer.servlet.servletwrapper.handlerequest(servletwrapper.java:502) @ com.ibm.ws.webcontainer.servlet.servletwrapperimpl.handlerequest(servletwrapperimpl.java:181) @ com.ibm.ws.webcontainer.servlet.cacheservletwrapper.handlerequest(cacheservletwrapper.java:91) @ com.ibm.ws.webcontainer.webcontainer.handlerequest(webcontainer.java:864) @ com.ibm.ws.webcontainer.wswebcontainer.handlerequest(wswebcontainer.java:1592) @ com.ibm.ws.webcontainer.channel.wcchannellink.ready(wcchannellink.java:186) @ com.ibm.ws.http.channel.inbound.impl.httpinboundlink.handlediscrimination(httpinboundlink.java:452) @ com.ibm.ws.http.channel.inbound.impl.httpinboundlink.handlenewrequest(httpinboundlink.java:511) @ com.ibm.ws.http.channel.inbound.impl.httpinboundlink.processrequest(httpinboundlink.java:305) @ com.ibm.ws.http.channel.inbound.impl.httpinboundlink.ready(httpinboundlink.java:276) @ com.ibm.ws.tcp.channel.impl.newconnectioninitialreadcallback.sendtodiscriminators(newconnectioninitialreadcallback.java:214) @ com.ibm.ws.tcp.channel.impl.newconnectioninitialreadcallback.complete(newconnectioninitialreadcallback.java:113) @ com.ibm.ws.tcp.channel.impl.aioreadcompletionlistener.futurecompleted(aioreadcompletionlistener.java:165) @ com.ibm.io.async.abstractasyncfuture.invokecallback(abstractasyncfuture.java:217) @ com.ibm.io.async.asyncchannelfuture.firecompletionactions(asyncchannelfuture.java:161) @ com.ibm.io.async.asyncfuture.completed(asyncfuture.java:138) @ com.ibm.io.async.resulthandler.complete(resulthandler.java:204) @ com.ibm.io.async.resulthandler.runeventprocessingloop(resulthandler.java:775) @ com.ibm.io.async.resulthandler$2.run(resulthandler.java:905) @ com.ibm.ws.util.threadpool$worker.run(threadpool.java:1646)
the wam-1.0.0.jar file in ear library folder. seems finding persistence.xml in wam-config.jar, can't find (or can't use) wam-1.0.0.jar. have idea i'm going wrong?
edit: posted complete stack trace per request. sorry that!
i figured out. seems couldn't find mapping xml file.
i started experimenting doing things "classic" way - including persistence.xml , mapping xml file in jar persisted entities. wasn't working either. then, changed path mapping file in persistence.xml "meta-inf/wammapping.xml" , things started working! after that, removed persistence.xml , mapping xml jar file , put them in separate jar file inside meta-inf directory. placed in ear library. still working!
i'm having trouble getting additional persistent classes inside war work properly, different problem.
Comments
Post a Comment