NotSerializableException when Lookup DataSource in AS 7.1.1 Final
zllj_qn Aug 31, 2012 3:43 AMThis is the first time I use JBoss AS. The version I using now is AS 7.1.1 Final.
What I want to do is create a simple test on using JBoss DataSource to connect Oracle 10g.
The root exception I got is:
Root exception is java.io.NotSerializableException: org.jboss.jca.core.connectionmanager.pool.strategy.OnePool
Below is what I configure the DataSource, and success pass the testing from AS Admin Console:
<datasource jta="true" jndi-name="java:jboss/exported/ds/test" pool-name="TEST_DB" enabled="true" use-ccm="false">
<connection-url>jdbc:oracle:thin:@localhost:1521:test</connection-url>
<driver-class>oracle.jdbc.OracleDriver</driver-class>
<driver>oracle</driver>
<pool>
<min-pool-size>0</min-pool-size>
<max-pool-size>500</max-pool-size>
<prefill>false</prefill>
</pool>
<security>
<user-name>test_admin</user-name>
<password>******</password>
</security>
<validation>
<validate-on-match>false</validate-on-match>
<background-validation>false</background-validation>
</validation>
<statement>
<share-prepared-statements>false</share-prepared-statements>
</statement>
</datasource>
Below is the Java code I used to get the DataSource:
public static void main(String[] args) {
try {
Properties props = new Properties();
props.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");
props.setProperty(Context.PROVIDER_URL, "remote://localhost:4447");
props.setProperty(Context.SECURITY_PRINCIPAL, "test");
props.setProperty(Context.SECURITY_CREDENTIALS, "******");
Context context = new InitialContext(props);
context.lookup("ds/test");
} catch(Exception e) {
e.printStackTrace();
}
}
Below is the exception printed in the Eclipse console:
Aug 31, 2012 3:14:33 PM org.xnio.Xnio <clinit>
INFO: XNIO Version 3.0.3.GA
Aug 31, 2012 3:14:33 PM org.xnio.nio.NioXnio <clinit>
INFO: XNIO NIO Implementation Version 3.0.3.GA
Aug 31, 2012 3:14:33 PM org.jboss.remoting3.EndpointImpl <clinit>
INFO: JBoss Remoting version 3.2.3.GA
Aug 31, 2012 3:14:35 PM org.jboss.naming.remote.protocol.v1.RemoteNamingStoreV1$MessageReceiver handleMessage
ERROR: java.io.EOFException
javax.naming.NamingException: Failed to lookup [Root exception is java.io.NotSerializableException: org.jboss.jca.core.connectionmanager.pool.strategy.OnePool]
at org.jboss.naming.remote.client.ClientUtil.namingException(ClientUtil.java:36)
at org.jboss.naming.remote.protocol.v1.Protocol$1.execute(Protocol.java:104)
at org.jboss.naming.remote.protocol.v1.RemoteNamingStoreV1.lookup(RemoteNamingStoreV1.java:79)
at org.jboss.naming.remote.client.RemoteContext.lookup(RemoteContext.java:79)
at org.jboss.naming.remote.client.RemoteContext.lookup(RemoteContext.java:83)
at javax.naming.InitialContext.lookup(InitialContext.java:392)
at com.toc.dbc.junit.Test.main(Test.java:23)
Caused by: java.io.NotSerializableException: org.jboss.jca.core.connectionmanager.pool.strategy.OnePool
at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:891)
at org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1063)
at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1019)
at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:998)
at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:885)
at org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1063)
at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1019)
at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:885)
at org.jboss.marshalling.AbstractObjectOutput.writeObject(AbstractObjectOutput.java:62)
at org.jboss.marshalling.AbstractMarshaller.writeObject(AbstractMarshaller.java:119)
at org.jboss.naming.remote.protocol.v1.Protocol$1$2.write(Protocol.java:138)
at org.jboss.naming.remote.protocol.v1.WriteUtil.write(WriteUtil.java:61)
at org.jboss.naming.remote.protocol.v1.Protocol$1.handleServerMessage(Protocol.java:128)
at org.jboss.naming.remote.protocol.v1.RemoteNamingServerV1$MessageReciever$1.run(RemoteNamingServerV1.java:73)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:619)
Caused by: an exception which occurred:
in field pool
in field cm
in object org.jboss.jca.adapters.jdbc.WrapperDataSource@383efa