您好OpenJpa& DB2专家,
我收到了以下错误消息(下面的stacktrace)。出现错误 受影响的Junit测试是从ant脚本开始的。启动Junit-Test 在Eclipse中手动运行没有任何问题。因此似乎有例外 很奇怪对于任何可以将分析推向正确方向的输入,我将不胜感激。
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
答案 0 :(得分:1)
在通过OpenJPA测试连接之前,您应该检查从客户端到服务器没有连接问题。
首先,您应该检查数据库名称。您编写了“MyDBInstance”,它有8个以上的字符,DB2数据库的最大值为8.我希望这不是问题所在。
我可以看到驱动程序拒绝连接:
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
从Java中,连接问题检测不是很清楚。此错误消息没有任何说明。您应该检查是否存在防火墙问题。例如,通过以下方式测试端口:
telnet xyz.com 62000
或
telnet 11.11.111.11 62000
一旦您可以验证端口是否已打开,您可以直接使用DB2驱动程序检查与Java驱动程序的数据库连接
${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
有关使用驱动程序测试连接的更多信息:http://pic.dhe.ibm.com/infocenter/db2luw/v10r5/topic/com.ibm.db2.luw.apdv.java.doc/src/tpc/imjcc_rjv00004.html