Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Problem Accessing EJB on Websphere from JSP on Tomcat

 
venkat paruchuri
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have an EJB running on Websphere application. I have written a sample client which is as JSP file running on Tomcat. I am able to connect to Websphere from Tomcat and lookup the EJB registered with JNDI server of Websphere as below.

Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.ibm.websphere.naming.WsnInitialContextFactory");

1. InitialContext initContext = new InitialContext(env);
2. System.out.println("Before looking up HelloJavaHome.");
3. Object obj = initContext.lookup("ejb/HelloJavaHome");
4. System.out.println("After lookup javahome.");
5. HelloJavaHome home = (HelloJavaHome);
6. javax.rmi.PortableRemoteObject.narrow(obj, HelloJavaHome.class);
7.System.out.println("After narrowing home object");
8. HelloJava remote = home.create();
9. String greeting = remote.getGreeting("John Smith");
10. System.out.println("Greeting :" + greeting);

I am getting the following exception after printing the statement at line 7.


java.lang.ClassCastException
at com.sun.corba.se.internal.iiop.ShutdownUtilDelegate.isLocal(ShutdownUtilDelegate.java:39)
at javax.rmi.CORBA.Util.isLocal(Util.java:262)
at com.mycompany._HelloJavaHome_Stub.create(_HelloJavaHome_Stub.java:202)
at com.mycompany.client.RemoteConn.connect(RemoteConn.java:62)
at com.mycompany.client.Greeting.getGreeting(Greeting.java:130)
at com.mycompany.Wsconnect.getGreeting(Wsconnect.java:11)
at org.apache.jsp.index_jsp._jspService(index_jsp.java:63)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:137)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:210)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:256)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2422)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:171)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:163)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:199)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:828)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:700)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:584)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
at java.lang.Thread.run(Thread.java:534)

I have set the client jar file of EJB application (which includes META-INF and application-client.xml and ibm-application-client-bind.xml files) in class path of the webapplication in Tomcat. Also I added the following lines in the web.xml file of the webapplication in Tomcat.

<ejb-ref>
<ejb-ref-name>ejb/HelloJava</ejb-ref-name>
<ejb-ref-type>Session</ejb-ref-type>
<home>com.deque.HelloJavaHome</home>
<remote>com.deque.HelloJava</remote>
<ejb-link>HelloJava</ejb-link>
</ejb-ref>


Has anybody experienced this problem? Can anybody help me why I am getting ClassCastException? The same program ran successfully from command line without any problem. I greatly appreciate if somebody could help me ASAP.
Thanks in advance
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!