This week's book giveaway is in the HTML Pages with CSS and JavaScript forum.
We're giving away four copies of Testing JavaScript Applications and have Lucas da Costa on-line!
See this thread for details.
Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Class Caste Exception from client

 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all ,
I am new to ejb 2 entity bean. I am creating a simple application with entity bean and JBoss 4.0.2.As i want want my application to grow further i am maintaining few design patterns like service locator and delegate. I have made two .jar files and one .war file .In one .jar i have all the ejb classes(D_SEjb.jar) and in another(L_simple.jar) service locator and delegate classes. I am putting first .jar along with the .war in deploy folder and the later in lib folder of JBoss.My ejb gets deployed easily and creates the necessary table but when the create method is called from the client to save the data in the database it gives a Class cast exception in the service locator in the PortableRemoteObject.narrow(objref, className) part.
My sevice locator method looks like this:


and in delegate it casted to the Home interface l like this :


My entity bean is:

After running XDoclet my home interface and ejb-jar.xml looks like this

home interface :



part of my ejb-jar.xml looks like this:


and the stack trace is

java.lang.ClassCastException
2009-10-04 11:48:24,119 INFO [STDOUT] at com.sun.corba.se.impl.javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:229)
2009-10-04 11:48:24,119 INFO [STDOUT] at javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:137)
2009-10-04 11:48:24,159 INFO [STDOUT] at com.ejbSimple.serviceLocator.AppServiceLocator.getHome(AppServiceLocator.java:86)
2009-10-04 11:48:24,159 INFO [STDOUT] at com.ejbSimple.delegate.Simpledelegate.<init>(Simpledelegate.java:20)
2009-10-04 11:48:24,159 INFO [STDOUT] at com.ejbSimple.action.simpleAction.execute(simpleAction.java:26)
2009-10-04 11:48:24,159 INFO [STDOUT] at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:421)
2009-10-04 11:48:24,159 INFO [STDOUT] at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:226)
2009-10-04 11:48:24,159 INFO [STDOUT] at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1158)
2009-10-04 11:48:24,209 INFO [STDOUT] at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:397)
2009-10-04 11:48:24,219 INFO [STDOUT] at javax.servlet.http.HttpServlet.service(HttpServlet.java:697)
2009-10-04 11:48:24,219 INFO [STDOUT] at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
2009-10-04 11:48:24,229 INFO [STDOUT] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
2009-10-04 11:48:24,229 INFO [STDOUT] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
2009-10-04 11:48:24,229 INFO [STDOUT] at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:81)
2009-10-04 11:48:24,229 INFO [STDOUT] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
2009-10-04 11:48:24,229 INFO [STDOUT] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
2009-10-04 11:48:24,229 INFO [STDOUT] at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
2009-10-04 11:48:24,289 INFO [STDOUT] at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
2009-10-04 11:48:24,299 INFO [STDOUT] at org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:39)
2009-10-04 11:48:24,299 INFO [STDOUT] at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:153)
2009-10-04 11:48:24,299 INFO [STDOUT] at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:59)
2009-10-04 11:48:24,299 INFO [STDOUT] at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
2009-10-04 11:48:24,299 INFO [STDOUT] at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
2009-10-04 11:48:24,319 INFO [STDOUT] at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
2009-10-04 11:48:24,319 INFO [STDOUT] at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
2009-10-04 11:48:24,319 INFO [STDOUT] at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
2009-10-04 11:48:24,319 INFO [STDOUT] at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
2009-10-04 11:48:24,319 INFO [STDOUT] at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
2009-10-04 11:48:24,329 INFO [STDOUT] at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
2009-10-04 11:48:24,329 INFO [STDOUT] at java.lang.Thread.run(Thread.java:619)
2009-10-04 11:48:24,329 INFO [STDOUT] Caused by: java.lang.ClassCastException: $Proxy53 cannot be cast to org.omg.CORBA.Object
2009-10-04 11:48:24,329 INFO [STDOUT] at com.sun.corba.se.impl.javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:212)
2009-10-04 11:48:24,329 INFO [STDOUT] ... 29 more

I tried by putting L_simple.jar in the deploy but that didn't solve the problem.
Can any body help to figure out where the problem is and what mistake I made.
 
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you are learning EJB then better to go for EJB3.0. I don't know the solution because you are talking about EJB2.0
Presently i think every company working with EJB3.0. So there is no point to spend time on EJB2
Yes there is need of EJB2 if you are using EJB2 & EJB3 both in your project.

 
You guys haven't done this much, have ya? I suggest you study this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic