UnsatisfiedLinkError/Error opening socket when starting a OpenJPA-Junit-Test via Ant-Script

StackOverflow https://stackoverflow.com/questions/20352320

  •  07-08-2022
  •  | 
  •  

Pergunta

Hello OpenJpa & DB2 Experts,

I´m getting the folloing error message(stacktrace below). The error appears when the affected Junit test is started from an ant script. Starting the Junit-Test manually in Eclipse works without any problems. Therefore the exception seems to be strange. For any kind of input, which could push the analysis into the right direction I would be grateful.

Further Information :

Drivers:
    db2jcc.jar
    db2jcc_license_cu.jar
    [Version 3.64.82]

OpenJPA Version : 2.1.2

Persistence.xml:

<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.0"
    xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">

    <persistence-unit name="mypersistenceunit" transaction-type="RESOURCE_LOCAL">
    <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
    <class>common.data.domain.MyDomainObjectx</class>
    <class>common.data.domain.MyDomainObjecty</class>

     <properties>
       <property name="openjpa.ReadLockLevel" value="none"/> 
       <property name="openjpa.Log" value="DefaultLevel=TRACE, Runtime=TRACE, Tool=TRACE, SQL=TRACE, Enhance=TRACE"/>
       <property name="openjpa.ConnectionFactoryProperties" value="PrettyPrint=true, PrettyPrintLineLength=72"/>             
<property name="javax.persistence.jdbc.driver" value="com.ibm.db2.jcc.DB2Driver"/>                       
       <property name="javax.persistence.jdbc.url" value="jdbc:db2://xyz:62000/MyDBInstance"/>                                                             
       <property name="javax.persistence.jdbc.user" value="myuser"/>
       <property name="javax.persistence.jdbc.password" value="mypass"/>         
     </properties>

    </persistence-unit>
</persistence>

[junit] at org.apache.openjpa.jdbc.schema.DataSourceFactory.newConnectException(DataSourceFactory.java:261)
[junit] at org.apache.openjpa.jdbc.schema.DataSourceFactory.installDBDictionary(DataSourceFactory.java:247)
[junit] at org.apache.openjpa.jdbc.conf.JDBCConfigurationImpl.getConnectionFactory(JDBCConfigurationImpl.java:733)
[junit] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[junit] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:60)
[junit] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
[junit] at java.lang.reflect.Method.invoke(Method.java:611)
[junit] at org.apache.openjpa.lib.conf.ConfigurationImpl.instantiateAll(ConfigurationImpl.java:295)
[junit] at org.apache.openjpa.conf.OpenJPAConfigurationImpl.instantiateAll(OpenJPAConfigurationImpl.java:1652)
[junit] at org.apache.openjpa.kernel.AbstractBrokerFactory.makeReadOnly(AbstractBrokerFactory.java:645)
[junit] at org.apache.openjpa.kernel.AbstractBrokerFactory.newBroker(AbstractBrokerFactory.java:204)
[junit] at org.apache.openjpa.kernel.DelegatingBrokerFactory.newBroker(DelegatingBrokerFactory.java:156)
[junit] at org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:227)
[junit] at com.ibm.ws.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:50)
[junit] at com.ibm.ws.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:35)
[junit] xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
[junit] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[junit] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:60)
[junit] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
[junit] at java.lang.reflect.Method.invoke(Method.java:611)
[junit] at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)
[junit] at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
[junit] at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)
[junit] at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:27)
[junit] at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:30)
[junit] at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
[junit] at junit.framework.JUnit4TestAdapter.run(JUnit4TestAdapter.java:39)
[junit] at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:420)
[junit] at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.launch(JUnitTestRunner.java:911)
[junit] at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:768)
[junit] Caused by: com.ibm.db2.jcc.am.DisconnectNonTransientConnectionException: [jcc][t4][2043][11550][3.64.82] Exception java.lang.reflect.InvocationTargetException: Error opening socket to server xyz.com/11.11.111.11 on port 62,000 with message: null. ERRORCODE=-4499, SQLSTATE=08001
[junit] at com.ibm.db2.jcc.am.bd.a(bd.java:321)
[junit] at com.ibm.db2.jcc.am.bd.a(bd.java:340)
[junit] at com.ibm.db2.jcc.t4.vb.a(vb.java:436)
[junit] at com.ibm.db2.jcc.t4.vb.<init>(vb.java:93)
[junit] at com.ibm.db2.jcc.t4.a.b(a.java:355)
[junit] at com.ibm.db2.jcc.t4.b.newAgent_(b.java:2026)
[junit] at com.ibm.db2.jcc.am.Connection.initConnection(Connection.java:718)
[junit] at com.ibm.db2.jcc.am.Connection.<init>(Connection.java:667)
[junit] at com.ibm.db2.jcc.t4.b.<init>(b.java:332)
[junit] at com.ibm.db2.jcc.DB2SimpleDataSource.getConnection(DB2SimpleDataSource.java:232)
[junit] at com.ibm.db2.jcc.DB2SimpleDataSource.getConnection(DB2SimpleDataSource.java:198)
[junit] at com.ibm.db2.jcc.DB2Driver.connect(DB2Driver.java:475)
[junit] at com.ibm.db2.jcc.DB2Driver.connect(DB2Driver.java:116)
[junit] at org.apache.openjpa.jdbc.schema.SimpleDriverDataSource.getSimpleConnection(SimpleDriverDataSource.java:96)
[junit] at org.apache.openjpa.jdbc.schema.SimpleDriverDataSource.getConnection(SimpleDriverDataSource.java:92)
[junit] at org.apache.openjpa.jdbc.schema.SimpleDriverDataSource.getConnection(SimpleDriverDataSource.java:88)
[junit] at org.apache.openjpa.lib.jdbc.DelegatingDataSource.getConnection(DelegatingDataSource.java:139)
[junit] at org.apache.openjpa.lib.jdbc.DecoratingDataSource.getConnection(DecoratingDataSource.java:112)
[junit] at org.apache.openjpa.jdbc.schema.DataSourceFactory.installDBDictionary(DataSourceFactory.java:239)
[junit] ... 28 more
[junit] Caused by: java.lang.reflect.InvocationTargetException
[junit] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[junit] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:60)
[junit] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
[junit] at java.lang.reflect.Method.invoke(Method.java:611)
[junit] at com.ibm.db2.jcc.t4.v.run(v.java:69)
[junit] at java.security.AccessController.doPrivileged(AccessController.java:251)
[junit] at com.ibm.db2.jcc.t4.vb.a(vb.java:422)
[junit] ... 44 more
[junit] Caused by: java.lang.UnsatisfiedLinkError: com/ibm/net/SocketUtils.configureKeepAlive(JIII)V
[junit] at com.ibm.net.SocketUtils.configureKeepAlive(SocketUtils.java:233)
[junit] ... 51 more
[junit] )
[junit] class load: org.apache.tools.ant.taskdefs.optional.junit.JUnitTaskMirrorImpl$VmExitErrorTest from: file:/C:/IBM/Ressource/SDP/plugins/org.apache.ant_1.7.1.v20100518-1145/lib/ant-junit.jar
[junit] class load: java/util/Collections$1
[junit] class load: org/w3c/dom/CDATASection
[junit] class load: org/apache/xerces/dom/CDATASectionImpl
[junit] Tests run: 0, Failures: 0, Errors: 1, Time elapsed: 3.391 sec
[junit] class load: sun/nio/cs/UTF8_Encoder
[junit] class load: sun/nio/cs/UTF_8$Encoder
[junit] class load: org.apache.tools.ant.util.DOMElementWriter from: file:/C:/IBM/Ressource/SDP/plugins/org.apache.ant_1.7.1.v20100518-1145/lib/ant.jar
[junit] class load: org.apache.tools.ant.util.DOMElementWriter$XmlNamespacePolicy from: file:/C:/IBM/Ressource/SDP/plugins/org.apache.ant_1.7.1.v20100518-1145/lib/ant.jar
[junit] class load: java/util/IdentityHashMap$1
[junit] class load: java/util/IdentityHashMap$IdentityHashMapIterator
[junit] class load: java/util/IdentityHashMap$1$1
[junit] class load: java/util/IdentityHashMap$IdentityHashMapEntry
[junit] class load: com/ibm/tools/attach/javaSE/AttachHandler$1
[junit] class load: java/lang/Thread$State
[junit] class load: java/io/DeleteOnExitHook 

Nenhuma solução correta

Outras dicas

You should check that there are not connectivity problems from the client to the server before testing the connection via OpenJPA.

First, you should check the database name. You wrote 'MyDBInstance' and it has more that 8 characters, and DB2 databases have a max of 8. I hope this is not the problem.

I could see that the driver is refusing the connection:

Caused by: com.ibm.db2.jcc.am.DisconnectNonTransientConnectionException: 
[jcc][t4][2043][11550][3.64.82] Exception java.lang.reflect.InvocationTargetException:
Error opening socket to server xyz.com/11.11.111.11 on port 62,000 with message: null.
ERRORCODE=-4499, SQLSTATE=08001

From Java, the connection problems are not very clear to detect. This error message says nothing. You should check that there are not firewall issues. For example test the port via:

telnet xyz.com 62000

or

telnet 11.11.111.11 62000

Once you can verify the port is open, you can use the DB2 driver directly to check the connection to the database with the Java driver

${DB2_DIR}/java/jdk64/bin/java -cp ${DB2_DIR}/java/db2jcc4.jar:${DB2_DIR}/java/db2jcc_license_cu.jar com.ibm.db2.jcc.DB2Jcc -url jdbc:db2://xyz.com:62000/MyDBInst -user myuser -password mypass

For more information about using the driver to test the connection: http://pic.dhe.ibm.com/infocenter/db2luw/v10r5/topic/com.ibm.db2.luw.apdv.java.doc/src/tpc/imjcc_rjv00004.html

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top