RMI ClassCastException
Hello, world!
My problem is the following: I'm developping a peer-to-peer application based on RMI. This application includes applets -called peerlets- that can be exposed to and used by other peers. Hence I have two remote interfaces:
public interface Peerlet extends Remote {
// stuff that throws RemoteException
public interface Peer extends Remote {
public Peerlet getPeerlet(/*some Peerlet ID here*/) throws RemoteException;
}As you can see Peer is the broker that passes references on local peerlets to remote peers. There are many possible peerlets, such as:
public interface APeerlet extends Peerlet {
// stuff that throws RemoteException
}Creating a Peer instance, retrieve it from another remote Peer instance via RMI is fine. My problem occurs when I try to get references on remote peerlets. Concretely the situation is the following:
- peerA and peerB are two running Peer instances, they have a reference on each other; peerA hosts a APeerlet.
- if peerB tries the following:
Peerlet p = (APeerlet) peerA.getPeerlet(/*appropriate ID to get the desired APeerlet*/);
//...everything goes fine, peerB can use p normaly. But this is not what I want, since this piece of code needs to have APeerlet defined. If I try to get simply a Peerlet - that would be used latter by another piece of code who knows what to do with a APeerlet - ie:
Peerlet p = (Peerlet) peerA.getPeerlet(/*...*/);
//...I get a
java.lang.ClassCastException: $Proxy3 cannot be cast to ....PeerletI guess it's a class loading issue, but I can't figure out why the cast to Peerlet fails whereas a cast to APeerlet does not. I have found interesting behaviour with this two variations in peerB's code:
import ....APeerlet;
Class<? extends Peerlet> clazz = APeerlet.class;
Peerlet p = clazz.cast(peerA.getPeerlet(/*...*/););
// no import ....APeerlet;
Class<? extends Peerlet> clazz = /*something that returns me APeerlet.class*/;
Peerlet p = clazz.cast(peerA.getPeerlet(/*...*/););The first version is still not what I want since it needs a definition of APeerlet, but it works. The second one throws ClassCastException... I have hidden many details, such as the http server I use for dynamic class loading; it does not receive the same queries when the ClassCastException is thrown. Could it be the source of my trouble?
S
Edited by: sylf on Aug 14, 2010 3:09 PM
I see your point. Only Peer should be in the codebase, since it is the only class bound to the RMIRegistry, Peerlet and APeerlet should NOT be in the codebase but only in the classpath of both peers.
However, if Peerlet is not in the codebase, I get a ClassNotFoundException : Peerlet at startup, since the Peer interface uses Peerlet as a return type of Peer.getPeerlet(...). So I had no choice but to keep Peerlet in the codebase, and now peerB gets a ClassNotFoundException : APeerlet when trying to get a APeerlet from peerA...
java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:
java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is:
java.lang.ClassNotFoundException: ....APeerlet
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:336)
at sun.rmi.transport.Transport$1.run(Transport.java:159)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:155)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:535)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:790)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:649)
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)
at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:273)
at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:251)
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:160)
at java.rmi.server.RemoteObjectInvocationHandler.invokeRemoteMethod(RemoteObjectInvocationHandler.java:194)
at java.rmi.server.RemoteObjectInvocationHandler.invoke(RemoteObjectInvocationHandler.java:148)
at $Proxy0.getPeerlet(Unknown Source)
at ...Peer.getPeerlet(Peer.java:112)
at //...
Caused by: java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is:
java.lang.ClassNotFoundException: ...APeerlet
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:296)
at sun.rmi.transport.Transport$1.run(Transport.java:159)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:155)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:535)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:790)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:649)
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: java.lang.ClassNotFoundException: ...APeerlet
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:247)
at sun.rmi.server.LoaderHandler.loadClass(LoaderHandler.java:434)
at sun.rmi.server.LoaderHandler.loadClass(LoaderHandler.java:165)
at java.rmi.server.RMIClassLoader$2.loadClass(RMIClassLoader.java:620)
at java.rmi.server.RMIClassLoader.loadClass(RMIClassLoader.java:247)
at sun.rmi.server.MarshalInputStream.resolveClass(MarshalInputStream.java:197)
at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1575)
at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1496)
at java.io.ObjectInputStream.readClass(ObjectInputStream.java:1462)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1312)
at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1947)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1871)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351)
at sun.rmi.server.UnicastRef.unmarshalValue(UnicastRef.java:306)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:290)
... 9 moreIt looks like it's the RMIServer who can't find APeerlet... but why?
I get the same Exception after having changed the return type of Peer.getPeerlet() to Remote so that Peerlet has not to be in the codebase anymore.
S
Similar Messages
-
Applets, RMI & ClassCastException
I'm developing my first RMI application and I'm getting a ClassCastException upon Naming.lookup(...) on the client:
java.lang.ClassCastException: com.alcatel.applet.FileUploaderRemote_Stub
at com.alcatel.applet.FileUploader$UploadThread.run(FileUploader.java:184)
I'm pretty sure I've got my interfaces, etc. setup correctly and I'm not sure what the problem is. The client has a signed .jar which contains the same stub/skel as the server:
jar tvf FileUploader.jar
846 Tue Apr 16 09:01:10 PDT 2002 META-INF/MANIFEST.MF
899 Tue Apr 16 09:01:14 PDT 2002 META-INF/mycompany.SF
960 Tue Apr 16 09:01:14 PDT 2002 META-INF/mycompany.DSA
0 Tue Apr 16 09:01:08 PDT 2002 META-INF/
5012 Fri Apr 12 13:28:52 PDT 2002 com/mycompany/applet/FileUploader$$3.class
3624 Tue Apr 16 09:01:14 PDT 2002 com/mycompany/applet/FileUploader$UploadThread.class
5134 Tue Apr 16 09:01:14 PDT 2002 com/mycompany/applet/FileUploader.class
1447 Tue Apr 16 09:01:14 PDT 2002 com/mycompany/applet/FileUploaderRemote.class
340 Mon Apr 15 16:17:36 PDT 2002 com/mycompany/applet/FileUploaderRemoteInterface.class
2216 Tue Apr 16 09:01:32 PDT 2002 com/mycompany/applet/FileUploaderRemote_Skel.class
4126 Tue Apr 16 09:01:30 PDT 2002 com/mycompany/applet/FileUploaderRemote_Stub.class
Here's my implementation... maybe something is wrong here.. Anyone got any ideas where I'm going wrong?
FileUploaderRemoteInterface.java
package com.mycompany.applet;
import java.rmi.*;
public interface FileUploaderRemoteInterface extends Remote {
FileUploaderRemote.java:
package com.mycompany.applet;
import java.rmi.*;
import java.rmi.server.*;
public class FileUploaderRemote extends UnicastRemoteObject
implements FileUploaderRemoteInterface {
public static void main(String args[]) {
try {
FileUploaderRemote fur = new FileUploaderRemote();
Naming.rebind("FileUploader", fur);
catch(Exception e) {
e.printStackTrace();
System.exit(1);
FileUploader.java:
package com.mycompany.applet;
import javax.swing.*;
import javax.swing.event.*;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import java.io.*;
import java.text.*;
import java.rmi.*;
public class FileUploader extends JApplet implements ActionListener {
FileUploaderRemote remote = null;
try {
remote = (FileUploaderRemote)Naming.lookup("rmi://myserver/FileUploader");
catch(Exception e) {
e.printStackTrace();You must cast your remote reference to the interface that the RMIServer implements.
So remote should be FileUploaderRemoteInterface and the getting the reference should look like this:
FileUploaderRemoteInterface remote = null;
try {
remote = (FileUploaderRemoteInterface)Naming.lookup("rmi://myserver/FileUploader");
} catch(Exception e) {
e.printStackTrace();
...That is because Naming.lookup(...) actually returns the stub object which is obviously not the server object itself. It just implements the remote interfaces that the server object does...
Hope it helps,
Sany -
ClassCastException: weblogic.jdbc.rmi.SerialResultSet
HI,
I am using WebLogic 6.0 SP2 connection pooling to get CLOB data from Oracle database.
It is working fine to get the connection and get non-CLOB data like string, but
when I retrieve the CLOB column in my program such as, theClob = ((oracle.jdbc.OracleResultSet)
rs).getCLOB(1),
Weblogic throws ClassCastException: weblogic.jdbc.rmi.SerialResultSet, does anybody
experience the same problem ? How can I get around this problem ?
Thanks
JohnHi,
I've got the same error. The only diference is that I read BLOBs out of the table
((oracle.jdbc.OracleResultSet)rset).getBLOB(1) from oracle.jdbc.OracleResultSet).
Best regards,
Kai
"John Chen" <[email protected]> wrote:
>
HI,
I am using WebLogic 6.0 SP2 connection pooling to get CLOB data from
Oracle database.
It is working fine to get the connection and get non-CLOB data like string,
but
when I retrieve the CLOB column in my program such as, theClob = ((oracle.jdbc.OracleResultSet)
rs).getCLOB(1),
Weblogic throws ClassCastException: weblogic.jdbc.rmi.SerialResultSet,
does anybody
experience the same problem ? How can I get around this problem ?
Thanks
John -
ClassCastException: com.evermind.server.rmi.OrionRemoteException
We have resently tried to move our application from OC4J 9.0.3 to the OC4J 9.0.4 preview.
However when autogenerating data we get the following exception:
com.evermind.server.rmi.OrionRemoteException: java.lang.ClassCastException: com.evermind.server.rmi.OrionRemoteException
at com.evermind.server.ejb.EJBUtils.getUserException(EJBUtils.java:275)
at InstallSession_StatelessSessionBeanWrapper2717.createItemBatchBaseData(InstallSession_StatelessSessionBeanWrapper2717.java:268)
at java.lang.reflect.Method.invoke(Native Method)
at com.evermind.server.rmi.RMICallHandler.run(RMICallHandler.java:124)
at com.evermind.server.rmi.RMICallHandler.run(RMICallHandler.java:48)
at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:192)
at java.lang.Thread.run(Thread.java:479)
at connection to wmsserver/192.168.1.95 as admin
at com.evermind.server.rmi.RMIConnection.EXCEPTION_ORIGINATES_FROM_THE_REMOTE_SERVER(RMIConnection.java:1499)
at com.evermind.server.rmi.RMIConnection.invokeMethod(RMIConnection.java:1452)
at com.evermind.server.rmi.RemoteInvocationHandler.invoke(RemoteInvocationHandler.java:55)
at com.evermind.server.rmi.RecoverableRemoteInvocationHandler.invoke(RecoverableRemoteInvocationHandler.java:22)
at com.evermind.server.ejb.StatelessSessionRemoteInvocationHandler.invoke(StatelessSessionRemoteInvocationHandler.java:50)
at __Proxy1.createItemBatchBaseData(Unknown Source)
at Sampleinstall.InstallSessionClient2.main(InstallSessionClient2.java:28)
Nested exception is:
java.lang.ClassCastException: com.evermind.server.rmi.OrionRemoteException
at ItemBatchLocalHome_EntityHomeWrapper343.create(ItemBatchLocalHome_EntityHomeWrapper343.java:1063)
at install.impl.InstallSessionBean.createItemBatchBaseData(InstallSessionBean.java:120)
at InstallSession_StatelessSessionBeanWrapper2717.createItemBatchBaseData(InstallSession_StatelessSessionBeanWrapper2717.java:254)
at java.lang.reflect.Method.invoke(Native Method)
at com.evermind.server.rmi.RMICallHandler.run(RMICallHandler.java:124)
at com.evermind.server.rmi.RMICallHandler.run(RMICallHandler.java:48)
at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:192)
at java.lang.Thread.run(Thread.java:479)
at connection to wmsserver/192.168.1.95
at com.evermind.server.rmi.OrionRemoteException.receive(OrionRemoteException.java:130)
at com.evermind.server.rmi.RMIConnection.handleMethodInvocationResponse(RMIConnection.java:1622)
at com.evermind.server.rmi.RMIConnection.run(RMIConnection.java:406)
at com.evermind.server.rmi.RMIConnection.run(RMIConnection.java:286)
at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:186)
at java.lang.Thread.run(Thread.java:536)
Process exited with exit code 0.
The method which fails is the following method, which is located in an orinary stateless session bean:
public void createItemBatchBaseData() {
try{
ItemBatchLocalHome itemBatchHome = getItemBatchLocalHome();
ItemLocalHome itemHome = getItemLocalHome(); ItemLocal item = itemHome.findByPrimaryKey("5501");
System.out.println("Før create "+item);
ItemBatchLocal itemBatch = itemBatchHome.create(item,
"B05501-1",
new Long(System.currentTimeMillis()),
new Boolean(false),new Double(0),new Double(0),
new Double(0),new Double(0),new Double(0),new Double(0),
new Double(0),new Double(0),new Double(0),
new Double(0),new Double(0),new Double(0),
new Long(System.currentTimeMillis()),
new Long(System.currentTimeMillis()),
new Long(System.currentTimeMillis()),
new Integer(0));
System.err.println("Efter create");
item = itemHome.findByPrimaryKey("5502");
/* FAILS HERE >> */ itemBatch = itemBatchHome.create(item,
("B05502-1"),
new Long(System.currentTimeMillis()),
new Boolean(false),new Double(0),new Double(0),
new Double(0),new Double(0),new Double(0),new Double(0),
new Double(0),new Double(0),new Double(0),
new Double(0),new Double(0),new Double(0),
new Long(System.currentTimeMillis()),
new Long(System.currentTimeMillis()),
new Long(System.currentTimeMillis()),
new Integer(0));
catch (CreateException e) {
System.err.println("Et eller flere batchnumre er oprettet i forvejen \n");
e.printStackTrace();
catch (FinderException f){
System.err.println("Ved oprettelse af batchnummer manglede relateret vare \n");
f.printStackTrace();
catch (NamingException e) {
System.err.println("Naming");
e.printStackTrace();
itemBatch is a CMP entity bean, with nothing but the field getters and setters, so it should be quite basic.
It worked without problems in 9.0.3, so we are wondering what we might have missed when changing to 9.0.4.
mvh
NHBWe have resently tried to move our application from OC4J 9.0.3 to the OC4J 9.0.4 preview.
However when autogenerating data we get the following exception:
com.evermind.server.rmi.OrionRemoteException: java.lang.ClassCastException: com.evermind.server.rmi.OrionRemoteException
at com.evermind.server.ejb.EJBUtils.getUserException(EJBUtils.java:275)
at InstallSession_StatelessSessionBeanWrapper2717.createItemBatchBaseData(InstallSession_StatelessSessionBeanWrapper2717.java:268)
at java.lang.reflect.Method.invoke(Native Method)
at com.evermind.server.rmi.RMICallHandler.run(RMICallHandler.java:124)
at com.evermind.server.rmi.RMICallHandler.run(RMICallHandler.java:48)
at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:192)
at java.lang.Thread.run(Thread.java:479)
at connection to wmsserver/192.168.1.95 as admin
at com.evermind.server.rmi.RMIConnection.EXCEPTION_ORIGINATES_FROM_THE_REMOTE_SERVER(RMIConnection.java:1499)
at com.evermind.server.rmi.RMIConnection.invokeMethod(RMIConnection.java:1452)
at com.evermind.server.rmi.RemoteInvocationHandler.invoke(RemoteInvocationHandler.java:55)
at com.evermind.server.rmi.RecoverableRemoteInvocationHandler.invoke(RecoverableRemoteInvocationHandler.java:22)
at com.evermind.server.ejb.StatelessSessionRemoteInvocationHandler.invoke(StatelessSessionRemoteInvocationHandler.java:50)
at __Proxy1.createItemBatchBaseData(Unknown Source)
at Sampleinstall.InstallSessionClient2.main(InstallSessionClient2.java:28)
Nested exception is:
java.lang.ClassCastException: com.evermind.server.rmi.OrionRemoteException
at ItemBatchLocalHome_EntityHomeWrapper343.create(ItemBatchLocalHome_EntityHomeWrapper343.java:1063)
at install.impl.InstallSessionBean.createItemBatchBaseData(InstallSessionBean.java:120)
at InstallSession_StatelessSessionBeanWrapper2717.createItemBatchBaseData(InstallSession_StatelessSessionBeanWrapper2717.java:254)
at java.lang.reflect.Method.invoke(Native Method)
at com.evermind.server.rmi.RMICallHandler.run(RMICallHandler.java:124)
at com.evermind.server.rmi.RMICallHandler.run(RMICallHandler.java:48)
at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:192)
at java.lang.Thread.run(Thread.java:479)
at connection to wmsserver/192.168.1.95
at com.evermind.server.rmi.OrionRemoteException.receive(OrionRemoteException.java:130)
at com.evermind.server.rmi.RMIConnection.handleMethodInvocationResponse(RMIConnection.java:1622)
at com.evermind.server.rmi.RMIConnection.run(RMIConnection.java:406)
at com.evermind.server.rmi.RMIConnection.run(RMIConnection.java:286)
at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:186)
at java.lang.Thread.run(Thread.java:536)
Process exited with exit code 0.
The method which fails is the following method, which is located in an orinary stateless session bean:
public void createItemBatchBaseData() {
try{
ItemBatchLocalHome itemBatchHome = getItemBatchLocalHome();
ItemLocalHome itemHome = getItemLocalHome(); ItemLocal item = itemHome.findByPrimaryKey("5501");
System.out.println("Før create "+item);
ItemBatchLocal itemBatch = itemBatchHome.create(item,
"B05501-1",
new Long(System.currentTimeMillis()),
new Boolean(false),new Double(0),new Double(0),
new Double(0),new Double(0),new Double(0),new Double(0),
new Double(0),new Double(0),new Double(0),
new Double(0),new Double(0),new Double(0),
new Long(System.currentTimeMillis()),
new Long(System.currentTimeMillis()),
new Long(System.currentTimeMillis()),
new Integer(0));
System.err.println("Efter create");
item = itemHome.findByPrimaryKey("5502");
/* FAILS HERE >> */ itemBatch = itemBatchHome.create(item,
("B05502-1"),
new Long(System.currentTimeMillis()),
new Boolean(false),new Double(0),new Double(0),
new Double(0),new Double(0),new Double(0),new Double(0),
new Double(0),new Double(0),new Double(0),
new Double(0),new Double(0),new Double(0),
new Long(System.currentTimeMillis()),
new Long(System.currentTimeMillis()),
new Long(System.currentTimeMillis()),
new Integer(0));
catch (CreateException e) {
System.err.println("Et eller flere batchnumre er oprettet i forvejen \n");
e.printStackTrace();
catch (FinderException f){
System.err.println("Ved oprettelse af batchnummer manglede relateret vare \n");
f.printStackTrace();
catch (NamingException e) {
System.err.println("Naming");
e.printStackTrace();
itemBatch is a CMP entity bean, with nothing but the field getters and setters, so it should be quite basic.
It worked without problems in 9.0.3, so we are wondering what we might have missed when changing to 9.0.4.
mvh
NHB -
Hi Guys,
This is my First post, I am in a deep trouble with the following exception. Initially I was getting
javax.naming.NoInitialContextException:
Need to specify class name in
environment or system property, or as an applet parameter
I added few lines of code in the .java file. and set the classpath to j2ee.jar
Hashtable env = new Hashtable();
env.putContext.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.cosnaming.CNCtxFactory");
env.put(Context.PROVIDER_URL, "iiop://localhost:3700");
Context initctx = new InitialContext(env);
I was able to get through that error. But then now i am stuck up with the new runtime error .
java.lang.ClassCastException
at com.sun.corba.se.internal.javax.rmi.PortableRemoteObject.narrow(Unknown Source)
at javax.rmi.PortableRemoteObject.narrow(Unknown Source)
at AdviceClient.go(AdviceClient.java:24)
at AdviceClient.main(AdviceClient.java:11)
I have tried to figure out myself but with little vain. I am using
Sun One App Server( j2sdkee 1.4 ) with Windows XP.
I am waiting for a positive response.
I am pasting the code of my Client
AdviceClient.java
import javax.naming.* ;
import java.rmi.* ;
import javax.rmi.* ;
import HeadFirst.* ;
import javax.ejb.* ;
public class AdviceClient {
public static void main( String[] args ) {
new AdviceClient( ).go( ) ;
public void go( ) {
try {
Hashtable env = new Hashtable();
env.putContext.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.cosnaming.CNCtxFactory");
env.put(Context.PROVIDER_URL, "iiop://localhost:3700");
Context initctx = new InitialContext(env);
Object o = ic.lookup("Advisor") ;
AdviceHome home = ( AdviceHome ) javax.rmi.PortableRemoteObject.narrow( o, HeadFirst.AdviceHome.class ) ;
Advice advisor = (Advice )home.create( ) ;
System.out.println(advisor.getTheMessage( ) ) ;
} catch( Exception ex ) {
ex.printStackTrace( );
I am starting the default server and deploying the session Stateless beans.Hi Shivakanth,
Please follow the guidelines in our EJB FAQ for writing a stand-alone java cilent that accesses ejbs :
https://glassfish.dev.java.net/javaee5/ejb/EJB_FAQ.html
--ken -
ClassCastException while looking up RMI objects bound to weblogic.JNDI under WLS 6.1
We deploy a servlet (in a single .war archive) establishing a RMI connection to
an external Java object bound into weblogic JNDI (WLS 6.1).
We get a ClassCastException on invoking JNDI lookup:
Servlet failed with Exception>
java.lang.ClassCastException: $Proxy67
at com.thyssenkrupp.tks.tnt.admin.rmi.ClientServlet.init(ClientServlet.java:81)
at weblogic.servlet.internal.ServletStubImpl.createServlet(ServletStubImpl.java:698)
at weblogic.servlet.internal.ServletStubImpl.createInstances(ServletStubImpl.java:641)
at weblogic.servlet.internal.ServletStubImpl.prepareServlet(ServletStubImpl.java:586)
at weblogic.servlet.internal.ServletStubImpl.getServlet(ServletStubImpl.java:366)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:240)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:200)
at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:2390)
at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:1959)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:137)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)
Curiously we don't observe these problems when we include all the classes of the
remote application in the classpath of the WebLogic Server. Actually we want to
avoid including external classes in weblogic.classpath for (hot) deployment reasons.
It also seems that problems don't occur when accessing the remote object from
an independent client application.
We expect this to be a classloader conflict within WLS 6.1
Does anybody know a solution to our problems?
Thanks for suggestions
Andreas KoernerThere was a similar bug that was supposedly fixed in WL 6.1 SP 2. I had
filed a bug on this myself, and was given a patch for SP1, you should be
able to ask for the patch for CR060416.
Peter Mularien
Deploy Solutions, Inc.
Andreas Koerner wrote:
>
We deploy a servlet (in a single .war archive) establishing a RMI connection to
an external Java object bound into weblogic JNDI (WLS 6.1).
We get a ClassCastException on invoking JNDI lookup:
Servlet failed with Exception>
java.lang.ClassCastException: $Proxy67
at com.thyssenkrupp.tks.tnt.admin.rmi.ClientServlet.init(ClientServlet.java:81)
at weblogic.servlet.internal.ServletStubImpl.createServlet(ServletStubImpl.java:698)
at weblogic.servlet.internal.ServletStubImpl.createInstances(ServletStubImpl.java:641)
at weblogic.servlet.internal.ServletStubImpl.prepareServlet(ServletStubImpl.java:586)
at weblogic.servlet.internal.ServletStubImpl.getServlet(ServletStubImpl.java:366)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:240)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:200)
at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:2390)
at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:1959)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:137)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)
Curiously we don't observe these problems when we include all the classes of the
remote application in the classpath of the WebLogic Server. Actually we want to
avoid including external classes in weblogic.classpath for (hot) deployment reasons.
It also seems that problems don't occur when accessing the remote object from
an independent client application.
We expect this to be a classloader conflict within WLS 6.1
Does anybody know a solution to our problems?
Thanks for suggestions
Andreas Koerner -
Classcastexception with rmi-iiop
Hi,
I try the rmi-iiop example in examples/rmi_iiop/hello using Sun's JDK 1.3rc1 on Linux. I use weblogic.rmic to generate an IDL file from HelloImpl.class. Next, I use idlj (comes with the JDK) to generate those help .java files from IDL. Then, I compile these files and HelloClient.java. I start Weblogic(SP6) and launch HelloClient using the command,
java examples.rmi_iiop.hello.HelloClient {long IOR number string}
Weblogic server throws this exception when the client make a contact,
Sun Dec 17 16:52:33 GMT+08:00 2000:<I> <WebLogicServer> WebLogic Server started
Sun Dec 17 16:52:40 GMT+08:00 2000:<I> <ListenThread> Adding address: localhost/127.0.0.1 to licensed client list
Sun Dec 17 16:52:40 GMT+08:00 2000:<E> <Adapter> Exception thrown by rmi server: [-8596339638698095515S127.0.0.1:[7001,7001,7002,7002,7001,-1]/8]
java.lang.ClassCastException: examples.rmi_iiop.hello.HelloImpl
at weblogic.cos.naming.NamingContextImpl.resolve(NamingContextImpl.java:138)
at weblogic.cos.naming.NamingContext_WLSkel.invoke(NamingContext_WLSkel.java:53)
at weblogic.rmi.extensions.BasicServerObjectAdapter.invoke(BasicServerObjectAdapter.java:347)
at weblogic.rmi.extensions.BasicRequestHandler.handleRequest(BasicRequestHandler.java:69)
at weblogic.rmi.internal.BasicExecuteRequest.execute(BasicExecuteRequest.java:15)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:135)
Why there is a ClassCastException? If there a compatiblity problem with idlj that comes with the JDK? Please advise.Generally, this is a classpath problem. You must ensure that the classes that are produced by jidl are not in the WLS classpath; similarly, the RMI interfaces must not be visible to the java CORBA client.
IMO, a java CORBA client is not a viable development platform.
TH Lim wrote:
Hi,
I try the rmi-iiop example in examples/rmi_iiop/hello using Sun's JDK 1.3rc1 on Linux. I use weblogic.rmic to generate an IDL file from HelloImpl.class. Next, I use idlj (comes with the JDK) to generate those help .java files from IDL. Then, I compile these files and HelloClient.java. I start Weblogic(SP6) and launch HelloClient using the command,
java examples.rmi_iiop.hello.HelloClient {long IOR number string}
Weblogic server throws this exception when the client make a contact,
Sun Dec 17 16:52:33 GMT+08:00 2000:<I> <WebLogicServer> WebLogic Server started
Sun Dec 17 16:52:40 GMT+08:00 2000:<I> <ListenThread> Adding address: localhost/127.0.0.1 to licensed client list
Sun Dec 17 16:52:40 GMT+08:00 2000:<E> <Adapter> Exception thrown by rmi server: [-8596339638698095515S127.0.0.1:[7001,7001,7002,7002,7001,-1]/8]
java.lang.ClassCastException: examples.rmi_iiop.hello.HelloImpl
at weblogic.cos.naming.NamingContextImpl.resolve(NamingContextImpl.java:138)
at weblogic.cos.naming.NamingContext_WLSkel.invoke(NamingContext_WLSkel.java:53)
at weblogic.rmi.extensions.BasicServerObjectAdapter.invoke(BasicServerObjectAdapter.java:347)
at weblogic.rmi.extensions.BasicRequestHandler.handleRequest(BasicRequestHandler.java:69)
at weblogic.rmi.internal.BasicExecuteRequest.execute(BasicExecuteRequest.java:15)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:135)
Why there is a ClassCastException? If there a compatiblity problem with idlj that comes with the JDK? Please advise. -
ClassCastException when RMI callback via HTTP tunneling
Hello,
I have a typical stock quote type of weblogic RMI application running WLS
6.0. If I use T3 for client to register its stub on the server side, the
server callback works fine. I use standard jndi lookup to find the server,
if I simply switch the provider_url form:
env.put(Context.PROVIDER_URL, "t3://192.168.1.5:7001");
to
env.put(Context.PROVIDER_URL, "http://192.168.1.5:7001");
the client can still connect to server and register itself, but server
callback fails:
this client method: qClient.setFreshData(vList) generates the following
error:
java.lang.ClassCastException: ocsmon.wServerThread
at weblogic.servlet.logging.CLFLogger.log(CLFLogger.java:65)
at
weblogic.servlet.logging.LogManagerHttp.log(LogManagerHttp.java:293)
at weblogic.servlet.internal.HttpServer.log(HttpServer.java:670)
at
weblogic.servlet.internal.ServletResponseImpl.send(ServletResponseImpl.java:
851)
at
weblogic.rjvm.http.HTTPServerJVMConnection.sendMsg(HTTPServerJVMConnection.j
ava:361)
at
weblogic.rjvm.MsgAbbrevJVMConnection.sendOutMsg(MsgAbbrevJVMConnection.java:
367)
at
weblogic.rjvm.MsgAbbrevJVMConnection.sendMsg(MsgAbbrevJVMConnection.java:173
at
weblogic.rjvm.ConnectionManager.sendMsg(ConnectionManager.java:482)
at weblogic.rjvm.RJVMImpl.send(RJVMImpl.java:419)
at
weblogic.rjvm.MsgAbbrevOutputStream.flushAndSendRaw(MsgAbbrevOutputStream.ja
va:114)
at
weblogic.rjvm.MsgAbbrevOutputStream.flushAndSend(MsgAbbrevOutputStream.java:
122)
at
weblogic.rjvm.MsgAbbrevOutputStream.sendRecv(MsgAbbrevOutputStream.java:144)
at
weblogic.rmi.internal.AbstractOutboundRequest.sendReceive(AbstractOutboundRe
quest.java
:84)
at
ocsmon.QuoteClientInterface_WLStub.setFreshData(QuoteClientInterface_WLStub.
java:218)
at ocsmon.wServerThread.run(wQuoteServer.java:350)
ocsmon.wServerThread is the thread spawned on the server side that obtains
the qClient stub from the server's registry and calls the refreshQuotes
method on it. 'vList' is a Vector of Strings containing the quotes.
What went wrong?
thanks
-AlanHello,
I have a typical stock quote type of weblogic RMI application running WLS
6.0. If I use T3 for client to register its stub on the server side, the
server callback works fine. I use standard jndi lookup to find the server,
if I simply switch the provider_url form:
env.put(Context.PROVIDER_URL, "t3://192.168.1.5:7001");
to
env.put(Context.PROVIDER_URL, "http://192.168.1.5:7001");
the client can still connect to server and register itself, but server
callback fails:
this client method: qClient.setFreshData(vList) generates the following
error:
java.lang.ClassCastException: ocsmon.wServerThread
at weblogic.servlet.logging.CLFLogger.log(CLFLogger.java:65)
at
weblogic.servlet.logging.LogManagerHttp.log(LogManagerHttp.java:293)
at weblogic.servlet.internal.HttpServer.log(HttpServer.java:670)
at
weblogic.servlet.internal.ServletResponseImpl.send(ServletResponseImpl.java:
851)
at
weblogic.rjvm.http.HTTPServerJVMConnection.sendMsg(HTTPServerJVMConnection.j
ava:361)
at
weblogic.rjvm.MsgAbbrevJVMConnection.sendOutMsg(MsgAbbrevJVMConnection.java:
367)
at
weblogic.rjvm.MsgAbbrevJVMConnection.sendMsg(MsgAbbrevJVMConnection.java:173
at
weblogic.rjvm.ConnectionManager.sendMsg(ConnectionManager.java:482)
at weblogic.rjvm.RJVMImpl.send(RJVMImpl.java:419)
at
weblogic.rjvm.MsgAbbrevOutputStream.flushAndSendRaw(MsgAbbrevOutputStream.ja
va:114)
at
weblogic.rjvm.MsgAbbrevOutputStream.flushAndSend(MsgAbbrevOutputStream.java:
122)
at
weblogic.rjvm.MsgAbbrevOutputStream.sendRecv(MsgAbbrevOutputStream.java:144)
at
weblogic.rmi.internal.AbstractOutboundRequest.sendReceive(AbstractOutboundRe
quest.java
:84)
at
ocsmon.QuoteClientInterface_WLStub.setFreshData(QuoteClientInterface_WLStub.
java:218)
at ocsmon.wServerThread.run(wQuoteServer.java:350)
ocsmon.wServerThread is the thread spawned on the server side that obtains
the qClient stub from the server's registry and calls the refreshQuotes
method on it. 'vList' is a Vector of Strings containing the quotes.
What went wrong?
thanks
-Alan -
Hi,
I am trying to deploy ejb3.0 on weblogic 10 server. I am able to find the JNDI name of the stateless session bean correctly, but getting an exception while narrowing it down. My ejb3.0 client is a standalone java client. I am trying to access the stateless session ejb3.0 bean.Please help me. i have been trying it for many days.
thanks in advance,
Sanjeev
[sanpraka@localhost certEjb]$ java -cp ./:/usr/weblogic/bea/wlserver_10.0/server/lib/weblogic.jar:/usr/weblogic/bea/wlserver_10.0/server/lib/wlclient.jar com.titan.clients.Client
Object is weblogic.rmi.internal.BasicRemoteRef - hostID: '5337880647112897730S:127.0.0.1:[7001,7001,-1,-1,-1,-1,-1]:wl_server:examplesServer', oid: '302', channel: 'null'
java.lang.ClassCastException: Cannot narrow remote object weblogic.rmi.internal.BasicRemoteRef - hostID: '5337880647112897730S:127.0.0.1:[7001,7001,-1,-1,-1,-1,-1]:wl_server:examplesServer', oid: '302', channel: 'null' to com.titan.travelagent.TravelAgentRemote
at weblogic.corba.server.naming.ReferenceHelperImpl.narrow(ReferenceHelperImpl.java:206)
at weblogic.rmi.extensions.PortableRemoteObject.narrow(PortableRemoteObject.java:88)
at weblogic.iiop.PortableRemoteObjectDelegateImpl.narrow(PortableRemoteObjectDelegateImpl.java:32)
at javax.rmi.PortableRemoteObject.narrow(Unknown Source)
at com.titan.clients.Client.main(Client.java:24)
[sanpraka@localhost certEjb]$We have a similar problem. We have a web application (on server A) that invokes an EJB on a remote server (server B). This works fine, until we deploy another web application to server A at which point the existing web application starts to throw java.lang.ClassCastException when narrowing the remote EJB interface. The exception starts to be thrown at the moment the latter web application is deployed - start is not required.
The latter web application contains (actually in APP-INF/lib) the old version of the EJB remote interface, that somehow gets to be loaded into the classpath of the existing web application. The solution is to delete the old version of the EJB remote interface from APP-INF/lib of the latter web application (we didn't need it anyway), but it would be interesting to know in which circumstances classes can get mixed between enterprise applications.
I failed to reproduce the error in simple scenario, so this does not happen always. -
ClassCastException while narrow an EJV using RMI-IIOP
Hi,
I'm trying to deploy an EJB on weblogic 6.1 SP4 on an AIX system, and a client
(JSP) running on weblogic 6.1 SP4 on a SUN system. And, the dialog between EJB
and servlet has to use RMI-IIOP (due to exploitation constraints).
I receive this exception when getting the reference of the EJB's home :
java.lang.ClassCastException: Cannot narrow remote object to ejbMweb.TstEjbMwebHome
at weblogic.iiop.PortableRemoteObjectDelegateImpl.narrow(PortableRemoteObjectDelegateImpl.java:124)
at javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:132)
at cliEjbMweb.cliTstMweb.narrow(cliTstMweb.java:133)
at cliEjbMweb.cliTstMweb.getHome(cliTstMweb.java:31)
at cliEjbMweb.cliTstMweb.testBean1(cliTstMweb.java:53)
at jsp_servlet.__index._jspService(__index.java:91)
at weblogic.servlet.jsp.JspBase.service(JspBase.java:27)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:262)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:321)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:198)
at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:2637)
at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2359)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:139)
The same test using t3 is running OK (there is no problem of classpath).
Can you hel me ?
Thank you !
Marc"Marc" <[email protected]> writes:
It can't download the stub, you need to set an appropriate security
manager for the RMIClassLoader to work, or make sure the stubs are on
the client.
andy
Hi,
I'm trying to deploy an EJB on weblogic 6.1 SP4 on an AIX system, and a client
(JSP) running on weblogic 6.1 SP4 on a SUN system. And, the dialog between EJB
and servlet has to use RMI-IIOP (due to exploitation constraints).
I receive this exception when getting the reference of the EJB's home :
java.lang.ClassCastException: Cannot narrow remote object to ejbMweb.TstEjbMwebHome
at weblogic.iiop.PortableRemoteObjectDelegateImpl.narrow(PortableRemoteObjectDelegateImpl.java:124)
at javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:132)
at cliEjbMweb.cliTstMweb.narrow(cliTstMweb.java:133)
at cliEjbMweb.cliTstMweb.getHome(cliTstMweb.java:31)
at cliEjbMweb.cliTstMweb.testBean1(cliTstMweb.java:53)
at jsp_servlet.__index._jspService(__index.java:91)
at weblogic.servlet.jsp.JspBase.service(JspBase.java:27)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:262)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:321)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:198)
at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:2637)
at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2359)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:139)
The same test using t3 is running OK (there is no problem of classpath).
Can you hel me ?
Thank you !
Marc -
Hi I am getting the following exception:
java.lang.ClassCastException: weblogic.rmi.internal.MethodDescriptor
at weblogic.rjvm.MsgAbbrevInputStream.readClassDescriptor(MsgAbbrevInputStream.java:186)
at weblogic.common.internal.ChunkedObjectInputStream$NestedObjectInputStream.readClassDescriptor(ChunkedObjectInputStream.java:300)
at java.io.ObjectInputStream.inputClassDescriptor(ObjectInputStream.java:901)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:361)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:231)
at java.io.ObjectInputStream.inputObject(ObjectInputStream.java:1181)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:381)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:231)
at weblogic.common.internal.ChunkedObjectInputStream.readObject(ChunkedObjectInputStream.java:110)
at weblogic.common.internal.ChunkedObjectInputStream.readObject(ChunkedObjectInputStream.java:123)
at weblogic.jndi.internal.RootNamingNode_WLSkel.invoke(Unknown Source)
at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:298)
at weblogic.rmi.cluster.ReplicaAwareServerRef.invoke(ReplicaAwareServerRef.java:93)
at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:267)
at weblogic.rmi.internal.BasicExecuteRequest.execute(BasicExecuteRequest.java:22)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:139)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)
can any body explain the Cause for this exception and what will be the impact on the server.
but if i restart the server the error is not comingHi I am getting the following exception:
java.lang.ClassCastException: weblogic.rmi.internal.MethodDescriptor
at weblogic.rjvm.MsgAbbrevInputStream.readClassDescriptor(MsgAbbrevInputStream.java:186)
at weblogic.common.internal.ChunkedObjectInputStream$NestedObjectInputStream.readClassDescriptor(ChunkedObjectInputStream.java:300)
at java.io.ObjectInputStream.inputClassDescriptor(ObjectInputStream.java:901)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:361)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:231)
at java.io.ObjectInputStream.inputObject(ObjectInputStream.java:1181)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:381)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:231)
at weblogic.common.internal.ChunkedObjectInputStream.readObject(ChunkedObjectInputStream.java:110)
at weblogic.common.internal.ChunkedObjectInputStream.readObject(ChunkedObjectInputStream.java:123)
at weblogic.jndi.internal.RootNamingNode_WLSkel.invoke(Unknown Source)
at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:298)
at weblogic.rmi.cluster.ReplicaAwareServerRef.invoke(ReplicaAwareServerRef.java:93)
at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:267)
at weblogic.rmi.internal.BasicExecuteRequest.execute(BasicExecuteRequest.java:22)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:139)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)
can any body explain the Cause for this exception and what will be the impact on the server.
but if i restart the server the error is not coming -
ClassCastException for RMI-IIOP client hitting CORBA server
I am writing a RMI-IIOP client to connect to an existing CORBA C++ server. I started out with writing a RMI Interface mimicking the IDL and then converting into a stub using rmic -iiop option. I then use COSNaming to connect to the server. When I narrow the reference using PortableRemoteObject.narrow(), I get a ClassCastException. Probably because the object that I get from naming service will be a CORBA object which cannot be casted to RMI Interface object.
Exception in thread "main" java.lang.ClassCastException
at com.sun.corba.se.impl.javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:229)
at javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:137)
at com.att.cswd.poc.RMIIIOPClient.IMSConnect(RMIIIOPClient.java:46)
at com.att.cswd.poc.RMIIIOPClient.main(RMIIIOPClient.java:27)
Caused by: java.lang.ClassCastException: Object is not of remote type com.att.cswd.poc.CORBAInterface
at com.sun.corba.se.impl.javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:221)
... 3 more
Code
CORBAInterface ims;
String tranCode="CRTUN130";
byte[][] input_segs = null;
try {
Hashtable hm = new Hashtable();
hm.put("java.naming.factory.initial", "com.sun.jndi.cosnaming.CNCtxFactory");
hm.put("java.naming.provider.url", "corbaloc:iiop:BSYS.MVS.SC.COM:14050/NameService");
Context initialNamingContext = new InitialContext(hm);
Object objref = initialNamingContext.lookup("O2K/AdapterInterface");
ims = (CORBAInterface) PortableRemoteObject.narrow(objref, CORBAInterface.class);
byte output_segs[][] = ims.run_transaction_binary(tranCode, input_segs);
System.out.println ("Response is " + output_segs);
} catch (NamingException e) {
e.printStackTrace();
} catch (RemoteException e) {
e.printStackTrace();
}I am writing a RMI-IIOP client to connect to an existing CORBA C++ serverAs it says in [the Javadoc|http://java.sun.com/j2se/1.5.0/docs/guide/rmi-iiop/rmiiiopUsing.html#when], you can't do that. For RMI/IIOP you have to start with a PortableRemoteObject and rmic -iiop. You can use a C++ client to that but you can't use an RMI/IIOP client to a C++ server.
Use IDLJ. -
ClassCastException: weblogic.jdbc.rmi.SerialPreparedStatement
I am attempting to retrieve CLOBs and XMLTypes in a servelet from a 9i release
2 database. Using sampe code from oracle, I am getting ClassCastException when
I attempt to cast ...
oracle.jdbc.OraclePreparedStatement stmt =
(oracle.jdbc.OraclePreparedStatement) conn.prepareStatement( sql );
The connection pool sets up fine, no errors. I am getting the connection in the
servlet through the JNDI lookup ... (see code)
From the config.xml, the jdbc setup ...
<JDBCConnectionPool DriverName="oracle.jdbc.driver.OracleDriver"
InitialCapacity="3" MaxCapacity="10" Name="9iR2Pool"
Properties="user=kr;password=*****;dll=ocijdbc9;protocol=oci8"
Targets="myserver" URL="jdbc:oracle:oci8:@ora9i"/>
Has anyone done this before? Is there another way? Does bea have 9i release
2 jdbc drivers?
[huh.java]Hi Rick,
JDBC objects obtained via a connection pool
can not be cast to anything oracle.jdbc.*.
In order to use oracle-specific functions of
prepared statements you need to use oracle
extensions provided by weblogic. Documentation
and examples can be found here:
http://e-docs.bea.com/wls/docs61/jdbc/thirdparty.html#1043705
Regards,
Slava Imeshev
"Rick Bradshaw" <[email protected]> wrote in message
news:3d6cfa2c$[email protected]..
>
I am attempting to retrieve CLOBs and XMLTypes in a servelet from a 9irelease
2 database. Using sampe code from oracle, I am getting ClassCastExceptionwhen
I attempt to cast ...
oracle.jdbc.OraclePreparedStatement stmt =
(oracle.jdbc.OraclePreparedStatement) conn.prepareStatement( sql );
The connection pool sets up fine, no errors. I am getting the connectionin the
servlet through the JNDI lookup ... (see code)
From the config.xml, the jdbc setup ...
<JDBCConnectionPool DriverName="oracle.jdbc.driver.OracleDriver"
InitialCapacity="3" MaxCapacity="10" Name="9iR2Pool"
Properties="user=kr;password=*****;dll=ocijdbc9;protocol=oci8"
Targets="myserver" URL="jdbc:oracle:oci8:@ora9i"/>
Has anyone done this before? Is there another way? Does bea have 9irelease
2 jdbc drivers? -
You can try this as a work around :
// CLOB clob = ((OracleResultSet) rs).getCLOB (2); this causes the exception
// this is the work around (assuming thin drivers)
java.sql.Clob clobFromDB = (java.sql.Clob) rs.getObject("MYCLOBCOL");
int len = (int) clobFromDB.length();
String str = clobFromDB.getSubString (Long.parseLong("1"), len );hi, all.
I also encounter this problem.but I can't see your message body on this subject. can you help me to resolve this problem? Please send to me by email. Thanks! -
Remote object trying to return another remote object and a ClassCastExcepti
I have a server running with a TreeModel (the tree model implements Remote). I also have the the TreeNodes all linked together on the server. Now, I can get to the TreeModel on the server and the root node of the remote tree model.
treeModelStub = (treeModelIface)Naming.lookup(url+"remoteTM"); //works
rootStub = (remoteTreeNodeIface)treeModelStub.getRoot(); //works. The call to getRoot returns Object
But when I call
remoteTreeNodeIface aChild = (remoteTreeNodeIface)rootStub.getChildAt(index) //Does not work. "Exception in thread "main" java.lang.ClassCastException
at remoteTreeNode_Stub.getChildAt(Unknown Source)
The remote tree node method getChildAt returns TreeNode because the class implements TreeNode:
public class remoteTreeNode extends UnicastRemoteObject implements rdcaDataIface, Comparable, TreeNode {
public TreeNode getChildAt(int idx) {
System.out.println("DEBUG: class is "+this.getClass()); // class is remoteTreeNode
return (remoteTreeNode)children.get(idx);
The remote interface is defined as:
public interface rdcaDataIface extends java.rmi.Remote {
public TreeNode getChildAt(int idx) throws RemoteException;
Any ideas why this does not work. Why can a remote object of type Object be returned just fine, but a TreeNode not be returned?
Thank you for your help,
BrentI have a server running with a TreeModel (the tree
model implements Remote). I also have the the
TreeNodes all linked together on the server. Now, I
can get to the TreeModel on the server and the root
node of the remote tree model.
treeModelStub =
(treeModelIface)Naming.lookup(url+"remoteTM");
//works
rootStub =
(remoteTreeNodeIface)treeModelStub.getRoot();
//works. The call to getRoot returns Object
But when I call
remoteTreeNodeIface aChild =
(remoteTreeNodeIface)rootStub.getChildAt(index)******************************************
can only be casted to rdcaDataIface. The returned object is an instanceof the rdcaDataIface_stub, which have nothing to do with TreeNode.
//Does not work. "Exception in thread "main"
java.lang.ClassCastException
at remoteTreeNode_Stub.getChildAt(Unknown
t(Unknown Source)
The remote tree node method getChildAt returns
TreeNode because the class implements TreeNode:
public class remoteTreeNode extends
UnicastRemoteObject implements rdcaDataIface,
Comparable, TreeNode {
public TreeNode getChildAt(int idx) {
System.out.println("DEBUG: class is
lass is "+this.getClass()); // class is
remoteTreeNode
return (remoteTreeNode)children.get(idx);
The remote interface is defined as:
public interface rdcaDataIface extends java.rmi.Remote
public TreeNode getChildAt(int idx) throws
ows RemoteException;
Any ideas why this does not work. Why can a remote
object of type Object be returned just fine, but a
TreeNode not be returned?
Thank you for your help,
Brent
Maybe you are looking for
-
I cannot get updates for IPhoto on the latest OS on my MacBook air when using my Itunes password. I just loaded a OS update with no problem using my password but it will not upgrade IPhoto. I have photos on my 5s that I want to get on my MacBook Air
-
Error While testing SAP Webservice build by RFC enabled function Module
Hi All, Iam getting an error " You are not authorized to view the requested resource"., while Iam testing SAP Webservice using transaction WSADMIN or SOAMANAGER.I have succesfully tested for WSDL and done with required configurations and settings. Ca
-
Exporting Versions without Version # included in name
Hi all, I am trialing 1.5 and would like to upload lores Jpegs of a single version of each of my master files to Photoshelter. Everything works well except that I don't want to include the version # in the file name. I have renamed the files from the
-
Copy control from Invoice to Credit Memo request
Hii All We have a requirement where when we create an credit memo request with reference to the invoice we want that PO number in the invoice should be copied to the credit memo request. Can this be done through copy control or some user exit needs t
-
How do I clone an OS 8.6 disk when it is the only disk in a G3?
I purchased a G3 with OS 8.6 and other special software preinstalled. The software will not run on any other OS, there is only one disk in the G3, and I do not have any installer disks for the OS or the special software. I would like to clone a few b