jpa - Can Web sphere Liberty manage multiple JTA sources? -
when add more 1 jta-data-source in persistence.xml run runtime exception
[error ] cwwjp0012e: persistence unit name not specified , unique persistence unit not found in coplinkrestservice application , coplinkrestservice.war module. [error ] cwwjp0029e: server cannot find persistence unit in coplinkrestservice.war module , coplinkrestservice application. [error ] cwnen0035e: java:comp/env/cldb reference of type javax.persistence.entitymanager null component in coplinkrestservice.war module of coplinkrestservice application cannot resolved. [error ] cntr0019e: ejb threw unexpected (non-declared) exception during invocation of method "getpersondetails". exception data: javax.ejb.ejbexception: java:comp/env/cldb reference of type javax.persistence.entitymanager null component in coplinkrestservice.war module of coplinkrestservice application cannot resolved. @ com.ibm.wsspi.injectionengine.injectionbinding.getinjectionobject(injectionbinding.java:1494) @ [internal classes] @ com.ibm.coplink.enterprise.details.person.ejslocalnslpersondetailsejb_df3bc29f.getpersondetails(ejslocalnslpersondetailsejb_df3bc29f.java) @ com.ibm.coplink.enterprise.details.detailshandlerejb$$lambda$8.000000001a297440.apply(unknown source) @ com.ibm.coplink.enterprise.details.detailshandlerejb.getdetails(detailshandlerejb.java:45) @ sun.reflect.nativemethodaccessorimpl.invoke0(native method) @ sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:95) @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:55) @ java.lang.reflect.method.invoke(method.java:495) @ com.ibm.ejs.container.ejscontainer.invokeproceed(ejscontainer.java:5323) @ [internal classes] @ com.ibm.coplink.enterprise.details.ejslocalnsldetailshandlerejb_c56b7144.getdetails(ejslocalnsldetailshandlerejb_c56b7144.java) @ com.ibm.coplink.service.coplinkrestserviceimpl.deleteme(coplinkrestserviceimpl.java:74) @ sun.reflect.nativemethodaccessorimpl.invoke0(native method) @ sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:95) @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:55) @ java.lang.reflect.method.invoke(method.java:495) @ com.ibm.ws.jaxrs20.server.libertyjaxrsserverfactorybean.performinvocation(libertyjaxrsserverfactorybean.java:607) @ [internal classes] [error ] cntr0020e: ejb threw unexpected (non-declared) exception during invocation of method "getdetails" on bean "beanid(coplinkrestservice#coplinkrestservice.war#detailshandlerejb, null)". exception data: javax.ejb.ejbtransactionrolledbackexception: nested exception is: javax.ejb.ejbexception: java:comp/env/cldb reference of type javax.persistence.entitymanager null component in coplinkrestservice.war module of coplinkrestservice application cannot resolved. @ com.ibm.ejs.container.businessexceptionmappingstrategy.mapcsiexception(businessexceptionmappingstrategy.java:127) @ [internal classes] @ com.ibm.coplink.enterprise.details.person.ejslocalnslpersondetailsejb_df3bc29f.getpersondetails(ejslocalnslpersondetailsejb_df3bc29f.java) @ com.ibm.coplink.enterprise.details.detailshandlerejb$$lambda$8.000000001a297440.apply(unknown source) @ com.ibm.coplink.enterprise.details.detailshandlerejb.getdetails(detailshandlerejb.java:45) @ sun.reflect.nativemethodaccessorimpl.invoke0(native method) @ sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:95) @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:55) @ java.lang.reflect.method.invoke(method.java:495) @ com.ibm.ejs.container.ejscontainer.invokeproceed(ejscontainer.java:5323) @ [internal classes] @ com.ibm.coplink.enterprise.details.ejslocalnsldetailshandlerejb_c56b7144.getdetails(ejslocalnsldetailshandlerejb_c56b7144.java) @ com.ibm.coplink.service.coplinkrestserviceimpl.deleteme(coplinkrestserviceimpl.java:74) @ sun.reflect.nativemethodaccessorimpl.invoke0(native method) @ sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:95) @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:55) @ java.lang.reflect.method.invoke(method.java:495) @ com.ibm.ws.jaxrs20.server.libertyjaxrsserverfactorybean.performinvocation(libertyjaxrsserverfactorybean.java:607) @ [internal classes] caused by: javax.ejb.ejbexception: java:comp/env/cldb reference of type javax.persistence.entitymanager null component in coplinkrestservice.war module of coplinkrestservice application cannot resolved. @ com.ibm.wsspi.injectionengine.injectionbinding.getinjectionobject(injectionbinding.java:1494) ... 18 more [warning ] application {http://service.coplink.ibm.com/}coplinkrestserviceimpl has thrown exception, unwinding nested exception is: javax.ejb.ejbexception: java:comp/env/cldb reference of type javax.persistence.entitymanager null component in coplinkrestservice.war module of coplinkrestservice application cannot resolved. [warning ] exception in handlefault on interceptor org.apache.cxf.jaxrs.interceptor.jaxrsdefaultfaultoutinterceptor@8ca66b2 nested exception is: javax.ejb.ejbexception: java:comp/env/cldb reference of type javax.persistence.entitymanager null component in coplinkrestservice.war module of coplinkrestservice application cannot resolved. [error ] error occurred during error handling, give up! nested exception is: javax.ejb.ejbexception: java:comp/env/cldb reference of type javax.persistence.entitymanager null component in coplinkrestservice.war module of coplinkrestservice application cannot resolved. [error ] srve0777e: exception thrown application class 'org.apache.cxf.interceptor.abstractfaultchaininitiatorobserver.onmessage:116' java.lang.runtimeexception: org.apache.cxf.interceptor.fault: nested exception is: javax.ejb.ejbexception: java:comp/env/cldb reference of type javax.persistence.entitymanager null component in coplinkrestservice.war module of coplinkrestservice application cannot resolved. @ org.apache.cxf.interceptor.abstractfaultchaininitiatorobserver.onmessage(abstractfaultchaininitiatorobserver.java:116) @ [internal classes] caused by: org.apache.cxf.interceptor.fault: nested exception is: javax.ejb.ejbexception: java:comp/env/cldb reference of type javax.persistence.entitymanager null component in coplinkrestservice.war module of coplinkrestservice application cannot resolved. @ org.apache.cxf.service.invoker.abstractinvoker.createfault(abstractinvoker.java:163) ... 1 more caused by: javax.ejb.ejbtransactionrolledbackexception: nested exception is: javax.ejb.ejbexception: java:comp/env/cldb reference of type javax.persistence.entitymanager null component in coplinkrestservice.war module of coplinkrestservice application cannot resolved. @ com.ibm.ejs.container.businessexceptionmappingstrategy.mapcsiexception(businessexceptionmappingstrategy.java:127) @ [internal classes] @ com.ibm.coplink.enterprise.details.person.ejslocalnslpersondetailsejb_df3bc29f.getpersondetails(ejslocalnslpersondetailsejb_df3bc29f.java) @ com.ibm.coplink.enterprise.details.detailshandlerejb$$lambda$8.000000001a297440.apply(unknown source) @ com.ibm.coplink.enterprise.details.detailshandlerejb.getdetails(detailshandlerejb.java:45) @ sun.reflect.nativemethodaccessorimpl.invoke0(native method) @ sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:95) @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:55) @ java.lang.reflect.method.invoke(method.java:495) @ com.ibm.ejs.container.ejscontainer.invokeproceed(ejscontainer.java:5323) @ [internal classes] @ com.ibm.coplink.enterprise.details.ejslocalnsldetailshandlerejb_c56b7144.getdetails(ejslocalnsldetailshandlerejb_c56b7144.java) @ com.ibm.coplink.service.coplinkrestserviceimpl.deleteme(coplinkrestserviceimpl.java:74) @ sun.reflect.nativemethodaccessorimpl.invoke0(native method) @ sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:95) @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:55) @ java.lang.reflect.method.invoke(method.java:495) @ com.ibm.ws.jaxrs20.server.libertyjaxrsserverfactorybean.performinvocation(libertyjaxrsserverfactorybean.java:607) ... 1 more caused by: javax.ejb.ejbexception: java:comp/env/cldb reference of type javax.persistence.entitymanager null component in coplinkrestservice.war module of coplinkrestservice application cannot resolved. @ com.ibm.wsspi.injectionengine.injectionbinding.getinjectionobject(injectionbinding.java:1494) ... 18 more
my persistence.xml entries :
<?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="cldb"> <jta-data-source>coplink-database</jta-data-source> <properties> <property name="eclipselink.logging.level" value="all"/> <property name="eclipselink.logging.parameters" value="true"/> </properties> </persistence-unit> <persistence-unit name="cl_admin"> <jta-data-source>coplink-admin-database</jta-data-source> <properties> <property name="eclipselink.logging.level" value="all"/> <property name="eclipselink.logging.parameters" value="true"/> </properties> </persistence-unit> </persistence>
my server.xml entries :
<datasource id="coplink-database" jndiname="coplink-database" statementcachesize="20" type="javax.sql.connectionpooldatasource"> <properties.microsoft.sqlserver databasename="coplink_democldb_4.8.1.0" password="cldb_password" portnumber="1433" user="cldb_user"/> <connectionmanager agedtimeout="-1" connectiontimeout="30s" maxidletime="30m" maxpoolsize="100" minpoolsize="10" reaptime="15m"/> <jdbcdriver> <library description="sqlserverdriver" name="sqlserverdriver"> <!-- relative path jdbc driver. eg. wlp/usr/servers/coplinksearchapiandui/resources/sqljdbc41.jar --> <file name="resources/sqljdbc41.jar"/> </library> </jdbcdriver> </datasource> <datasource id="coplink-admin-database" jndiname="coplink-admin-database" statementcachesize="20" type="javax.sql.connectionpooldatasource"> <properties.microsoft.sqlserver databasename="coplink_demoadmin_4.8.1.0" password="cldb_password" portnumber="1433" user="cldb_user"/> <connectionmanager agedtimeout="-1" connectiontimeout="30s" maxidletime="30m" maxpoolsize="100" minpoolsize="10" reaptime="15m"/> <jdbcdriver> <library description="sqlserverdriver" name="sqlserverdriver"> <!-- relative path jdbc driver. eg. wlp/usr/servers/coplinksearchapiandui/resources/sqljdbc41.jar --> <file name="resources/sqljdbc41.jar"/> </library> </jdbcdriver> </datasource>
my java reference :
@persistencecontext(name = "cldb") private entitymanager cldbmanager;
you should using @persistencecontext(unitname="cldb")
. name
used control java:comp/env/
name. unitname
optional until have second <persistence-unit>
, , need specify unit want.
(the cwwjp0029e
message seems poor serviceability since shows the persistence unit
2 spaces, means the "" persistence unit
. should reported ibm either fix or remove error message in case.)
Comments
Post a Comment