I am trying to run a [Java DB Web Starter][1] created in [IBM Bluemix][2] in my local [Websphere Liberty][3] server, but it keeps giving the below error
[ERROR ] CWWJP0029E: The server cannot find the openjpa-todo persistence unit in the liberty-IRDS.war module and the JavaDBApp application. [ERROR ] CWNEN0035E: The java:comp/env/openjpa-todo/entitymanager reference of type javax.persistence.EntityManager for the null component in the liberty-IRDS.war module of the JavaDBApp application cannot be resolved. [err] javax.naming.NamingException: CWNEN1001E: The object referenced by the java:comp/env/openjpa-todo/entitymanager JNDI name could not be instantiated. If the reference name maps to a JNDI name in the deployment descriptor bindings for the application performing the JNDI lookup, make sure that the JNDI name mapping in the deployment descriptor binding is correct. If the JNDI name mapping is correct, make sure the target resource can be resolved with the specified name relative to the default initial context. [Root exception is com.ibm.wsspi.injectionengine.InjectionException: The java:comp/env/openjpa-todo/entitymanager reference of type javax.persistence.EntityManager for the null component in the liberty-IRDS.war module of the JavaDBApp application cannot be resolved.] [err] at com.ibm.ws.injectionengine.osgi.internal.naming.InjectionJavaColonHelper.newCannotInstantiateObjectException(InjectionJavaColonHelper.java:183) [err] at [internal classes] [err] at javax.naming.InitialContext.lookup(Unknown Source) [err] at example.jpa.TODOListResource.getEm(TODOListResource.java:184) [err] at example.jpa.TODOListResource.(TODOListResource.java:35)
Steps done:
- Create Java DB Web Starter in Bluemix
- Download Code
Modify server.xml as suggested - Tried with both Connecting to Local Db and Database hosted as a part of Web Starter app-
--Deployed application
The
Server.xml
<!-- Enable features --> <featureManager> <feature>webProfile-7.0</feature> <feature>localConnector-1.0</feature> </featureManager> <!-- To access this server from a remote client add a host attribute to the following element, e.g. host="*" --> <httpEndpoint httpPort="9080" httpsPort="9443" id="defaultHttpEndpoint"/> <!-- Automatically expand WAR files and EAR files --> <applicationManager autoExpand="true"/> <applicationMonitor updateTrigger="mbean"/>
<library id="MySQLLib"> <fileset dir="${server.config.dir}/lib" id="mysql-connector-jar" includes="mysql-connector-java-*.jar"/> </library> <webApplication id="JavaDBApp" location="liberty-IRDS.war" name="JavaDBApp"/> </server>
Also Tried :To connect to DB in Java DB Web starter
<server description="new server"> <!-- Enable features --> <featureManager> <feature>webProfile-7.0</feature> <feature>localConnector-1.0</feature> </featureManager> <!-- To access this server from a remote client add a host attribute to the following element, e.g. host="*" --> <httpEndpoint httpPort="9080" httpsPort="9443" id="defaultHttpEndpoint"/> <!-- Automatically expand WAR files and EAR files --> <applicationManager autoExpand="true"/> <applicationMonitor updateTrigger="mbean"/> <dataSource id="mydbdatasource" jndiName="jdbc/mydbdatasource"> <jdbcDriver libraryRef="MySQLLib"/> <properties url="db2://user13711:[email protected]:50000/SQLDB" user="user13711" password="****"/> </dataSource> <library id="MySQLLib"> <fileset dir="${server.config.dir}/lib" id="mysql-connector-jar" includes="mysql-connector-java-*.jar"/> </library> <webApplication id="JavaDBApp" location="liberty-IRDS.war" name="JavaDBApp"/> </server>