• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

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

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?



 
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Also i did a System.out.println of the ref object (System.out.println(modelRemoteRef):
 
Greenhorn
Posts: 1
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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


 
Ranch Hand
Posts: 918
IntelliJ IDE Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.naming:org.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.
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
[Thumbnail for Capture.JPG]
Adding Jar to Java Application Client
 
What I don't understand is how they changed the earth's orbit to fit the metric calendar. Tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic