aspose file tools*
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes javax.naming.Reference cannot be cast to org.omg.CORBA.Object Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "javax.naming.Reference cannot be cast to org.omg.CORBA.Object" Watch "javax.naming.Reference cannot be cast to org.omg.CORBA.Object" New topic
Author

javax.naming.Reference cannot be cast to org.omg.CORBA.Object

Marcel Koopman
Greenhorn

Joined: Feb 24, 2009
Posts: 11
Hello, I've got a problem with my test class. I want to get a remote object but get a ClassCastException. (Using jBoss)

Anyone else ever had this problem? Any ideas?





SCJP 5.0 (83%) | SCWCD 5.0 (86%)
Christian Nicoll
Ranch Hand

Joined: Mar 09, 2008
Posts: 106
Hi Marcel,

perhaps there is something wrong with your line 3:

The ClassCastException
Caused by: java.lang.ClassCastException: javax.naming.Reference cannot be cast to org.omg.CORBA.Object

makes me think that there is something wrong with your import-statements. Are you sure that you don't import org.omg.CORBA.Object or org.omg.CORBA.* ? You can also replace line 3 with the following line:

Best regards/Lieben Gruß,
Christian


SCJP 5, SCJD 5, SCWCD 5, SCBCD 5, SCJDWS 5
My SCBCD-Notes - My Hello World Webservice
Marcel Koopman
Greenhorn

Joined: Feb 24, 2009
Posts: 11
These are my import statements:



I also tried your suggestion of:


But still the same exception.

I remember this code was working before, does it have anything to do with the way I run it?
Marcel Koopman
Greenhorn

Joined: Feb 24, 2009
Posts: 11
Also i did a System.out.println of the ref object (System.out.println(modelRemoteRef):
Felipe Cintra
Greenhorn

Joined: Aug 02, 2009
Posts: 1
i have same problem, but solved this replacing some libs in classpath on client side:

using JBoss-5.1.0:
concurrent.jar
ejb3-persistence.jar
jboss-aop.jar
jboss-common-core.jar
jboss-ejb3-common.jar
jboss-ejb3-core.jar
jboss-ejb3-proxy-clustered.jar
jboss-ejb3-proxy-impl.jar
jboss-ejb3-proxy-spi.jar
jboss-ejb3-security.jar
jboss-integration.jar
jboss-javaee.jar
jboss-logging-spi.jar
jboss-remoting-aspects.jar
jboss-remoting.jar
jboss-security-spi.jar
jbosssx.jar
jboss-transaction-aspects.jar
jnpserver.jar

this link help me

http://imasters.uol.com.br/artigo/12975/desenvolvimento/jboss_501ga_ejb3_maven2_e_cargo_juntos_e_na_pratica/

thanks Diego Pacheco, you save my tests

Using glassfish-v2.1:
appserv-admin.jar
appserv-cmp.jar
appserv-deployment-client.jar
appserv-ee.jar
appserv-ext.jar
appserv-jstl.jar
appserv-jwsacc.jar
appserv-launch.jar
appserv-rt.jar
appserv-rt_l10n.jar
appserv-se.jar
appserv-tags.jar
appserv-upgrade.jar
appserv-ws.jar
javaee.jar

all the libs are found in the container (jboss or glassfish) installation directory



www.eco4planet.com/pt/
Mihai Radulescu
Ranch Hand

Joined: Sep 18, 2003
Posts: 918

Hi

Under jBoss the JNDI looks like : "application/BeanName/mode" where the application name is your ear name, the BeanName is the Class name for your beam and the mode is local or remote. By example : "myTestApp/MyBeanImpl/remote", this JNDI lookup search the MyBeanImp remote bean in the myTestApp ear.
Note : this works only for JBoss.

Regards,
Mihai


SCJP, SCJD, SCWCD, OCPJBCD
shiv shetty
Greenhorn

Joined: Oct 09, 2010
Posts: 1
hi below is the solution;

1: make this change in your code

InitialContext context = getInitialContext();
ModelRemote modelRemote = (ModelRemote) context.lookup("ModelBean/remote");


private static InitialContext getInitialContext() throws NamingException
{
Properties properties = new Properties();
properties.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
properties.put(Context.URL_PKG_PREFIXES, "org.jboss.namingrg.jnp.interfaces");
properties.put(Context.PROVIDER_URL, "jnp://localhost:1099");
return new InitialContext(properties);

2. Add jbossall-client.jar to your classpath from jboss/client folder.
Rannye Foster
Greenhorn

Joined: Jul 18, 2013
Posts: 1
Felipe Cintra wrote:i have same problem, but solved this replacing some libs in classpath on client side:

using JBoss-5.1.0:
concurrent.jar
ejb3-persistence.jar
jboss-aop.jar
jboss-common-core.jar
jboss-ejb3-common.jar
jboss-ejb3-core.jar
jboss-ejb3-proxy-clustered.jar
jboss-ejb3-proxy-impl.jar
jboss-ejb3-proxy-spi.jar
jboss-ejb3-security.jar
jboss-integration.jar
jboss-javaee.jar
jboss-logging-spi.jar
jboss-remoting-aspects.jar
jboss-remoting.jar
jboss-security-spi.jar
jbosssx.jar
jboss-transaction-aspects.jar
jnpserver.jar

all the libs are found in the container (jboss or glassfish) installation directory





Thank you Felipe Cintra!
I registered just to thank you for your help.
You saved my day at work today.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: javax.naming.Reference cannot be cast to org.omg.CORBA.Object