Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Marcel Koopman
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?



 
Christian Nicoll
Ranch Hand
Posts: 106
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Marcel Koopman
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also i did a System.out.println of the ref object (System.out.println(modelRemoteRef):
 
Felipe Cintra
Greenhorn
Posts: 1
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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


 
Mihai Radulescu
Ranch Hand
Posts: 918
IntelliJ IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
shiv shetty
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Vin Vikram
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We can use "jboss-as-client" instead.

For me it worked by adding this dependency in ejb client:

<dependency>
<groupId>org.jboss.jbossas</groupId>
<artifactId>jboss-as-client</artifactId>
<version>5.1.0.GA</version>
<type>pom</type>
</dependency>

Thanks,
Vin
 
Vin Vikram
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We can use "D:\AppServer\jboss-as-distribution-6.1.0.Final\jboss-6.1.0.Final\client\jbossall-client.jar" in our ejb client to fix javax.naming.Reference issue.
Capture.JPG
Adding Jar to Java Application Client
[Thumbnail for Capture.JPG]
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic