• 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
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Error while using lookup

 
Sheriff
Posts: 9708
43
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi! I have a code for an Enterprise application. It contains files for a web application and an ejb mixed. I had to run it. So what I did was that I separated the files of the ejb, web and the enterprise application. Then I created projects using netBeans for all of these three. Then I build the EJB project so it generated a .jar file for the project. Then the web application was using the EJBs so I gave the path of the .jar file of the ejb project i.e. the final distributable file of the ejb project. Then I added these modules into the enterprise application and deployed it.

I gave the above information as there might be a problem in the above process. Now ehen one of the web pages uses InitialContext.lookup, a correct object is being returned i.e. the actual bean object. But when I convert the object to it's interface type, I get a ClassCastException: $Proxy430. This number after Proxy changes whenever I rebuild my project. So basically I think this is related to version of the files. So by the above information, can you figure what I am doing wrong.

I would be really thankful to anyone who could help (I am still thankful to Jaikiran who helped me here)
 
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I guess you are using JBoss

Can you post the entire exception stacktrace and also the output of the JNDI tree? And please also post your code where you are doing the lookup and the cast.
 
Ankit Garg
Sheriff
Posts: 9708
43
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
OK! This is the stack trace



This is the JNDI tree output related to the thing I am looking for

+- ejb (class: org.jnp.interfaces.NamingContext)
| +- AuthenticatorLocal (proxy: $Proxy387 implements interface uk.co.alterhit.cms.ejb.interfaces.AuthenticatorLocal,interface org.jboss.ejb3.JBossProxy,interface javax.ejb.EJBLocalObject)
| +- CmsUserManagerLocal (proxy: $Proxy385 implements interface uk.co.alterhit.cms.ejb.interfaces.CmsUserManagerLocal,interface org.jboss.ejb3.JBossProxy,interface javax.ejb.EJBLocalObject)

I have not used code tags with this as it will disturb the layout. This is the lookup code

AuthenticatorLocal authenticator = (AuthenticatorLocal) ctx.lookup("ejb/AuthenticatorLocal");

The lookup is returning an object of type AuthenticatorBean which implements AuthenticatorLocal...
 
Jaikiran Pai
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This looks like a classloading issue. Are you packaging the EJB interfaces in both the WAR as well as the EJB jar in the EAR? If yes, then remove the EJB interfaces from the WAR. See this for details.
 
Ankit Garg
Sheriff
Posts: 9708
43
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Jaikiran. I don't have the classes and interfaces in my web application. I checked the page that you gave and tried what was told on the page. I am only getting 1 instance of the ejb so that doesn't seem to be the problem. Here is the output of the jmx console when I did what was given on the page that you provided

++++CodeSource: (file:/F:/jboss-4.0.4.GA/server/default/tmp/deploy/tmp54283AlterhitCms.ear-contents/cms-ejb.jar )
Implemented Interfaces:

### Instance0 found in UCL: org.jboss.mx.loading.UnifiedClassLoader3@550344{ url=file:/F:/jboss-4.0.4.GA/server/default/tmp/deploy/tmp54283AlterhitCms.ear ,addedOrder=49}


So as you can see, there is only one instance of the ejb...
 
Ankit Garg
Sheriff
Posts: 9708
43
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I got it solved

It was a matter with another ejb which I was also using. Actually in Netbeans there is an option to add a project (lets say project1) as a library to another project (lets say project2) for compiling the files in the second project (i.e. project2). When I did that my netbeans got hang. So instead of the project, I added the .jar file of the project (i.e. project1) into the second project (i.e. project2). This was creating the problem.

THANK YOU SO MUCH JAIKIRAN. You are my HERO (You would have been more happy if my name was Ankita )
 
Jaikiran Pai
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Do you include any JBoss specific jar files in your application package? Post the output of:

 
Ankit Garg
Sheriff
Posts: 9708
43
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Jaikiran no need for that. I got it working. Looks like you were typing the response when I posted that it is working
 
Jaikiran Pai
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Ankit Garg:
Looks like you were typing the response when I posted that it is working



Yes Good to know it worked!
 
Story like this gets better after being told a few times. Or maybe it's just a tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic