Skip to Main Content

Database Software

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Produce Message to AQ Queue using standalone Java client in Oracle 11g FMW

738358Mar 17 2010 — edited Mar 16 2011
I have a Java client that creates a TextMessage and tries to post it to AQ queue using the server context. Please find the sample code below:

QueueSession jmsSession = null;
QueueConnection queueConnection = null;
try {
Properties parm = new Properties();
parm.setProperty("java.naming.factory.initial","weblogic.jndi.WLInitialContextFactory");
parm.setProperty("java.naming.provider.url","t3://10.209.125.23:8001");
parm.setProperty("java.naming.security.principal","weblogic");
parm.setProperty("java.naming.security.credentials","weblogic1");
Context ctx = new InitialContext(parm);

System.out.println("Weblogic Initial Context obtained : " + ctx);
//DataSource ds = (DataSource)ctx.lookup(datasourceJNDI);

QueueConnectionFactory queueConnfactory = (QueueConnectionFactory)ctx.lookup(QCF) ;
System.out.println("QueueConnectionFactory from QCF jndi lookup : " + queueConnfactory);

queueConnection = queueConnfactory.createQueueConnection();
System.out.println("QueueConnection obtained : " + queueConnection);

//Make QueueSession
jmsSession = queueConnection.createQueueSession(true, Session.AUTO_ACKNOWLEDGE);
System.out.println("QueueSession obtained : " + jmsSession);

//Start QueueConnection else no messages will be delivered
queueConnection.start();

Queue aqQueue = (Queue)ctx.lookup(QUEUE_JNDI);
System.out.println("Queue obtained from lookup: " + aqQueue);

QueueSender sender = ((AQjmsSession)jmsSession).createSender(aqQueue);
System.out.println("QueueSender obtained: " + sender);

File file = new File("C:\\Documents and Settings\\Apara\\Desktop\\EH_Mig\\development\\Resub.xml");
XmlObject object = XmlObject.Factory.parse(file);
String payloadString = object.toString();
System.out.println("Message to be sent : " + payloadString);

Message message = jmsSession.createTextMessage(payloadString);
sender.send(message);
jmsSession.commit();

System.out.println("Message sent : " + message.toString());
}
catch(Exception ex) {
ex.printStackTrace();
}
finally {
if (jmsSession != null)
jmsSession.close();

if (queueConnection != null)
queueConnection.stop();
queueConnection.close();
}


The code gives a runtime exception when it reaches the statement sender.send() as below :
weblogic.rmi.extensions.RemoteRuntimeException: Unexpected Exception
at weblogic.jdbc.rmi.internal.ConnectionImpl_weblogic_jdbc_wrapper_JTAConnection_weblogic_jdbc_wrapper_XAConnection_oracle_jdbc_driver_LogicalConnection_1032_WLStub.physicalConnectionWithin(Unknown Source)
at weblogic.jdbc.rmi.SerialConnection_weblogic_jdbc_rmi_internal_ConnectionImpl_weblogic_jdbc_wrapper_JTAConnection_weblogic_jdbc_wrapper_XAConnection_oracle_jdbc_driver_LogicalConnection_1032_WLStub.physicalConnectionWithin(Unknown Source)
at oracle.sql.TypeDescriptor.setPhysicalConnectionOf(TypeDescriptor.java:817)
at oracle.sql.TypeDescriptor.<init>(TypeDescriptor.java:622)
at oracle.sql.StructDescriptor.<init>(StructDescriptor.java:317)
at oracle.sql.StructDescriptor.createDescriptor(StructDescriptor.java:200)
at oracle.sql.StructDescriptor.createDescriptor(StructDescriptor.java:168)
at oracle.sql.StructDescriptor.createDescriptor(StructDescriptor.java:137)
at oracle.jpub.runtime.MutableStruct.toDatum(MutableStruct.java:113)
at oracle.jms.AQjmsGenMessage_C.toDatum(AQjmsGenMessage_C.java:46)
at oracle.jms.AQjmsProducer.jdbcEnqueue(AQjmsProducer.java:1027)
at oracle.jms.AQjmsProducer.send(AQjmsProducer.java:747)
at oracle.jms.AQjmsProducer.send(AQjmsProducer.java:517)
at co.uk.morrisons.errorhospital.util.QueueTest.sendMessageUsingServerContextAndQCF(QueueTest.java:245)
at co.uk.morrisons.errorhospital.util.QueueTest.main(QueueTest.java:293)
Caused by: java.rmi.MarshalException: error marshalling return; nested exception is:
java.io.NotSerializableException: oracle.jdbc.driver.T4CConnection
at weblogic.rjvm.ResponseImpl.unmarshalReturn(ResponseImpl.java:234)
at weblogic.rmi.internal.BasicRemoteRef.invoke(BasicRemoteRef.java:223)
... 15 more
Caused by: java.io.NotSerializableException: oracle.jdbc.driver.T4CConnection
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1156)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:326)
at weblogic.rjvm.MsgAbbrevOutputStream.writeObject(MsgAbbrevOutputStream.java:618)
at weblogic.utils.io.ChunkedObjectOutputStream.writeObject(ChunkedObjectOutputStream.java:63)
at weblogic.jdbc.rmi.internal.ConnectionImpl_weblogic_jdbc_wrapper_JTAConnection_weblogic_jdbc_wrapper_XAConnection_oracle_jdbc_driver_LogicalConnection_WLSkel.internalInvoke2(Unknown Source)
at weblogic.jdbc.rmi.internal.ConnectionImpl_weblogic_jdbc_wrapper_JTAConnection_weblogic_jdbc_wrapper_XAConnection_oracle_jdbc_driver_LogicalConnection_WLSkel.internalInvoke1(Unknown Source)
at weblogic.jdbc.rmi.internal.ConnectionImpl_weblogic_jdbc_wrapper_JTAConnection_weblogic_jdbc_wrapper_XAConnection_oracle_jdbc_driver_LogicalConnection_WLSkel.invoke(Unknown Source)
at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:589)
at weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:477)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:363)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:147)
at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:473)
at weblogic.rmi.internal.wls.WLSExecuteRequest.run(WLSExecuteRequest.java:118)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)


I am using a ForeignServer configuration which is targeted to a JMS Server. This a Weblogic 10.3 feature. Please see if you can help me to enqueue my message.


Thanks,
Aparajeeta
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 13 2011
Added on Mar 17 2010
3 comments
3,412 views