WebLogic - 通过JNDI的JDBC数据源导致从weblogic.jdbc.rm.SerialConnection.prepareStatement(String)返回null PreparedStatement

时间:2013-12-02 18:36:18

标签: java oracle jdbc weblogic datasource

您好,感谢您的帮助!

我正在使用Weblogic 10.3.0.0,其JDBC数据源配置为使用oracle.jdbc.OracleDriver中的瘦驱动程序。驱动程序库是ojdbc6.jar,驱动程序版本是11.1.0.6.0-Production。在我的本地客户端,我使用的是11.2.0.3.0版本,但我也尝试了与服务器相同的版本,但无济于事。

问题的症状以两个NullPointerExceptions的形式出现:

java.lang.NullPointerException
at weblogic.utils.wrapper.WrapperFactory.getCachedWrapperClass(WrapperFactory.java:44)
at weblogic.utils.wrapper.WrapperFactory.getWrapperClass(WrapperFactory.java:195)
at weblogic.utils.wrapper.WrapperFactory.getWrapperClass(WrapperFactory.java:183)
at weblogic.utils.wrapper.WrapperFactory.createWrapper(WrapperFactory.java:168)
at weblogic.jdbc.wrapper.JDBCWrapperFactory.getWrapper(JDBCWrapperFactory.java:186)
at weblogic.jdbc.rmi.internal.PreparedStatementStub.readResolve(PreparedStatementStub.java:48)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at java.io.ObjectStreamClass.invokeReadResolve(ObjectStreamClass.java:1104)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1805)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1348)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:370)
at weblogic.utils.io.ChunkedObjectInputStream.readObject(ChunkedObjectInputStream.java:197)
at weblogic.rjvm.MsgAbbrevInputStream.readObject(MsgAbbrevInputStream.java:564)
at weblogic.utils.io.ChunkedObjectInputStream.readObject(ChunkedObjectInputStream.java:193)
at weblogic.rmi.internal.ObjectIO.readObject(ObjectIO.java:62)
at weblogic.rjvm.ResponseImpl.unmarshalReturn(ResponseImpl.java:240)
at weblogic.rmi.internal.BasicRemoteRef.invoke(BasicRemoteRef.java:223)
at weblogic.jdbc.rmi.internal.ConnectionImpl_weblogic_jdbc_wrapper_PoolConnection_oracle_jdbc_driver_T4CConnection_1030_WLStub.prepareStatement(Unknown Source)
at weblogic.jdbc.rmi.SerialConnection.prepareStatement(SerialConnection.java:228)
at org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(AbstractBatcher.java:534)
at org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(AbstractBatcher.java:452)
at org.hibernate.jdbc.AbstractBatcher.prepareQueryStatement(AbstractBatcher.java:161)
at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1573)
at org.hibernate.loader.Loader.doQuery(Loader.java:696)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:259)
at org.hibernate.loader.Loader.doList(Loader.java:2228)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2125)
at org.hibernate.loader.Loader.list(Loader.java:2120)
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:401)
at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:361)
at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:196)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1148)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:102)
at org.hibernate.ejb.QueryImpl.getResultList(QueryImpl.java:67)

java.lang.NullPointerException
at org.hibernate.type.StringType.set(StringType.java:49)
at org.hibernate.type.NullableType.nullSafeSet(NullableType.java:154)
at org.hibernate.type.NullableType.nullSafeSet(NullableType.java:136)
at org.hibernate.param.NamedParameterSpecification.bind(NamedParameterSpecification.java:61)
at org.hibernate.loader.hql.QueryLoader.bindParameterValues(QueryLoader.java:514)
at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1589)
at org.hibernate.loader.Loader.doQuery(Loader.java:696)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:259)
at org.hibernate.loader.Loader.doList(Loader.java:2228)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2125)
at org.hibernate.loader.Loader.list(Loader.java:2120)
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:401)
at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:361)
at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:196)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1148)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:102)
at org.hibernate.ejb.QueryImpl.getResultList(QueryImpl.java:67)

我已经介绍了所有内容,直到weblogic.jdbc.rmi.SerialConnection.prepareStatement,因为该源不是公共的。问题似乎是返回一个空的PreparedStatement,然后传递给那两个抛出NPE的方法。

数据源被声明为Spring bean(为了安全起见,已删除了URL和凭据):

<bean id="datasource" class="org.springframework.jndi.JndiObjectFactoryBean">
    <property name="jndiName">
        <value>jdbc/DS</value>
    </property>
    <property name="resourceRef">
        <value>true</value>
    </property>
    <property name="jndiEnvironment">
        <props>
            <prop key="java.naming.factory.initial">weblogic.jndi.WLInitialContextFactory</prop>
            <prop key="java.naming.provider.url">t3://000.00.00.000:15031/</prop>
            <prop key="java.naming.security.principal">principal</prop>
            <prop key="java.naming.security.credentials">credentials</prop>
        </props>
    </property>
</bean>

我还在本地运行的WebLogic实例的JNDI树中设置了相同的确切数据源,并且没有例外。 (可能需要注意的是,我的本地WebLogic版本是10.3.2):

<bean id="datasource" class="org.springframework.jndi.JndiObjectFactoryBean">
    <property name="jndiName">
        <value>jdbc/DS</value>
    </property>
    <property name="resourceRef">
        <value>true</value>
    </property>
    <property name="jndiEnvironment">
        <props>
            <prop key="java.naming.factory.initial">weblogic.jndi.WLInitialContextFactory</prop>
            <prop key="java.naming.provider.url">t3://localhost:7001/</prop>
            <prop key="java.naming.security.principal">principal</prop>
            <prop key="java.naming.security.credentials">credentials</prop>
        </props>
    </property>
</bean>

最后,通过直接在Spring bean中声明数据源而不引用JNDI,我也让它工作得很好:

<bean id="datasource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
    <property name="driverClassName" value="oracle.jdbc.OracleDriver" />
    <property name="username" value="username" />
    <property name="password" value="password" />
    <property name="url" value="jdbc:oracle:thin:@username.com.com:1530:service_name" />
</bean>

感谢任何帮助,如果有必要,我非常乐意提供更多详细信息。谢谢你的时间!

0 个答案:

没有答案