• 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

Client to invoke a deployed EJB

 
Ranch Hand
Posts: 202
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When I try to invoke a deployed EJB using a client with the following code I get a ClassCastException. What can be problem.

The EJB has been successfully deployed. The process continues up to narrowing the homeobject. System.out.println("5"); gets executes and then the program throws the ClassCast Exception
The error is as follows :

------------------
Suneel

[This message has been edited by Suneel Setlur (edited February 06, 2001).]
[This message has been edited by Suneel Setlur (edited February 06, 2001).]
[This message has been edited by Rahul Mahindrakar (edited May 07, 2001).]
 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Suneel
I have got the same problem, i could not able to fix it but my suggestion for this one is , if you are using package try putting the package name along with class name. for example.
demo.CartHome home = (CartHome) PortableRemoteObject.narrow(homeObject, demo.CartHome.class);
Or try this
demo.CartHome home = (CartHome) PortableRemoteObject.narrow((org.omg.CORBA.Object)homeObject, demo.CartHome.class);
Thanks
Konda
[This message has been edited by Konda Balabbigari (edited February 06, 2001).]
 
Suneel Setlur
Ranch Hand
Posts: 202
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Konda
Thanks for your reply !
After both cases mentioned by you, the exception still existed.
However, not setting classpath explicitly to the jar file deployed was the only reason for the classcast exception.
Its been solved and the EJB has been invoked successfully.
Regards
Suneel
[This message has been edited by Suneel Setlur (edited February 06, 2001).]
 
Konda Balabbigari
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Suneel
Setting the class path means, just put the deployed .jar file in the class path or anything else.
Thanks
Konda
 
Suneel Setlur
Ranch Hand
Posts: 202
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Konda
Like this !!
java -cp %classpath%;c:\websphere\appserver\deployedEJBs\Deployedjet_out.jar carter.CartClient
Regards
Suneel
 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Suneel Setlur:
Hi Konda
Like this !!
java -cp %classpath%;c:\websphere\appserver\deployedEJBs\Deployedjet_out.jar carter.CartClient
Regards
Suneel


Can you please tell me what Deployedjet_out.jar is? Is it the jar file created from the deployment tool?
 
Suneel Setlur
Ranch Hand
Posts: 202
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
Yes thats the deployed jar file from the deployment tool when you dont change the default name.
Suneel
 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Suneel,
Although unrelated to your original question or your topic even, could you please help me? I noticed that in your code where you get an Initial Context, you specify the property InitialContextFactory, But you are not specifying Provider_url. Does this work? If yes how? I know that in weblogic, when a client accesses an EJB or any other JNDI resourse, the client specifies both the InitialContextFactory, and the Provider_url. I am confused about why we don't need to do the same with WebSphere.
Do you know why?
 
Anupama Dhir
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have successfully deployed a bean using the example from Chapter 4 of Oreilly's book on EJB. I am running j2ee server. However, when I try to run my client application, I get the following error:
java.lang.ClassCastException
at com.sun.corba.ee.internal.javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:296)
at javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:137)
at com.titan.cabin.Client_1.main(Client_1.java:19)
I have changed my cpath to add the Cabin.jar file created by the deployment tool(This is not the client .jar file which appears to be optional)
Please give me some suggestions 'coz I've been stuck with this problem for almost a week now.
Thanks for your help.
Exception in thread main

Originally posted by Suneel Setlur:
Hi
Yes thats the deployed jar file from the deployment tool when you dont change the default name.
Suneel


 
Suneel Setlur
Ranch Hand
Posts: 202
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
There might be a difficulty in the hierarchy...while casting.
Secondly you might have classpath problem. I hope all paths and classpaths have been set.
May be you can post the code too.
Suneel
 
Anupama Dhir
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I was able to run the application by using the following link: www.techquestion.net/ejbs/cabintutorial.html. It gives a step by step approach.
Rgds,
Anupama

Originally posted by Suneel Setlur:
Hi
There might be a difficulty in the hierarchy...while casting.
Secondly you might have classpath problem. I hope all paths and classpaths have been set.
May be you can post the code too.
Suneel


 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
if ur using IBM Websphere then u must change ur code a little.
The following code has been complied and run successfully..
import java.util.*;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.rmi.PortableRemoteObject;
public class CartClient {

public static void main(String[] args) {

try {

Hashtable ht = new Hashtable();
ht.put(javax.naming.Context.PROVIDER_URL, "iiop://localhost:900/");
ht.put(javax.naming.Context.INITIAL_CONTEXT_FACTORY,"com.ibm.ejs.ns.jndi.CNInitialContextFactory");

InitialContext ctx = new InitialContext(ht);
java.lang.Object objref = ctx.lookup("com/ejb/cart/Cart");

CartHome home =
(CartHome)PortableRemoteObject.narrow(objref,
CartHome.class);
Cart shoppingCart = home.create("Duke DeEarl","123");
shoppingCart.addBook("The Martian Chronicles");
shoppingCart.addBook("2001 A Space Odyssey");
shoppingCart.addBook("The Left Hand of Darkness");
shoppingCart.addBook("Gone with the Wind");
Vector bookList = new Vector();
bookList = shoppingCart.getContents();
Enumeration enumer = bookList.elements();
while (enumer.hasMoreElements()) {
String title = (String) enumer.nextElement();
System.out.println(title);
}
shoppingCart.removeBook("Alice in Wonderland");
shoppingCart.remove();
} catch (BookException ex) {
System.err.println("Caught a BookException: " + ex.getMessage());
} catch (Exception ex) {
System.err.println("Caught an unexpected exception!");
ex.printStackTrace();
}
}
public CartClient() {
super();
}
}

Kavitha
 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello All,
I'm using Websphere Application Server 3.5.4. My EJB Client throws ClassCastException. I have tried all the available options that you people have mentioned above. I have tried setting the classpath to Deployed jar file too. Still No LUCK. I think Konda and Suneel can really help me.
Please.. Please help me in this regard.
Thanking u all in anticipation,
- Bharani
[This message has been edited by Bharani Marepalli (edited September 27, 2001).]
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
May be you included deployed jar file generated by jatace into classpath, but not one generated by administration console. If so - you need to include jar generated by admin console, that can be found for ex.: d:\WAS_HOME\deployedEJBs\DeployedYourEJB.jar
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Guys,
I found this site very interesting. I'hv one quetsion reg the VAJ. I'm running the sample commerce Infashion store in VAJ using WTE. I'm getting the following error.
I appreciate your great help.
regards
Madhu
Note : storename - madhuStore
Error
==================
Unhandled error! You might want to consider having an error page to report such errors more gracefully
com.sun.jsp.JspException: C:\VAJava\ide\project_resources\IBM WebSphere Test Environment\temp\JSP1_0\default_app\MadhuStore\_StoreCatalogDisplay_xjsp_jspsrc_1715270079.java:20: Package com.ibm.commerce.server not found in import.
import com.ibm.commerce.server.*;
^
C:\VAJava\ide\project_resources\IBM WebSphere Test Environment\temp\JSP1_0\default_app\MadhuStore\_StoreCatalogDisplay_xjsp_jspsrc_1715270079.java:21: Package com.ibm.commerce.command not found in import.
import com.ibm.commerce.command.*;
^
C:\VAJava\ide\project_resources\IBM WebSphere Test Environment\temp\JSP1_0\default_app\MadhuStore\_StoreCatalogDisplay_xjsp_jspsrc_1715270079.java:22: Package com.ibm.commerce.catalog.beans not found in import.
import com.ibm.commerce.catalog.beans.*;
^
C:\VAJava\ide\project_resources\IBM WebSphere Test Environment\temp\JSP1_0\default_app\MadhuStore\_StoreCatalogDisplay_xjsp_jspsrc_1715270079.java:23: Package com.ibm.commerce.catalog.objects not found in import.
import com.ibm.commerce.catalog.objects.*;
^
C:\VAJava\ide\project_resources\IBM WebSphere Test Environment\temp\JSP1_0\default_app\MadhuStore\_StoreCatalogDisplay_xjsp_jspsrc_1715270079.java:24: Package com.ibm.commerce.beans not found in import.
import com.ibm.commerce.beans.*;
^
C:\VAJava\ide\project_resources\IBM WebSphere Test Environment\temp\JSP1_0\default_app\MadhuStore\_StoreCatalogDisplay_xjsp_jspsrc_1715270079.java:25: Package com.ibm.commerce.common.beans not found in import.
import com.ibm.commerce.common.beans.*;
^
6 errors
java.lang.Throwable(java.lang.String)
java.lang.Exception(java.lang.String)
javax.servlet.ServletException(java.lang.String)
com.sun.jsp.JspException(java.lang.String)
boolean com.ibm.ivj.jsp.compiler.JspDebugPageCompiler.javaToClass(java.lang.String, java.lang.String, java.lang.String)
void com.sun.jsp.compiler.Main.compile(java.lang.ClassLoader, javax.servlet.ServletContext, java.lang.String, com.sun.jsp.compiler.Main$ClassFileData, java.lang.String, boolean, boolean, java.lang.String)
void com.ibm.ivj.jsp.runtime.JspDebugLoader.compile(java.lang.String, com.sun.jsp.compiler.Main$ClassFileData, java.lang.String, boolean, java.lang.String)
boolean com.ibm.ivj.jsp.runtime.JspDebugLoader.loadJSP(java.lang.String, boolean, java.lang.String)
void com.sun.jsp.runtime.JspServlet$JspServletWrapper.loadIfNecessary(java.lang.String)
void com.sun.jsp.runtime.JspServlet$JspServletWrapper.service(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
void com.ibm.ivj.jsp.runtime.JspDebugServlet.serviceJspFile(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, java.lang.String, java.lang.Throwable)
void com.sun.jsp.runtime.JspServlet.service(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
void javax.servlet.http.HttpServlet.service(javax.servlet.ServletRequest, javax.servlet.ServletResponse)
void com.ibm.servlet.engine.webapp.StrictServletInstance.doService(javax.servlet.ServletRequest, javax.servlet.ServletResponse)
void com.ibm.servlet.engine.webapp.StrictLifecycleServlet._service(javax.servlet.ServletRequest, javax.servlet.ServletResponse)
void com.ibm.servlet.engine.webapp.IdleServletState.service(com.ibm.servlet.engine.webapp.StrictLifecycleServlet, javax.servlet.ServletRequest, javax.servlet.ServletResponse)
void com.ibm.servlet.engine.webapp.StrictLifecycleServlet.service(javax.servlet.ServletRequest, javax.servlet.ServletResponse)
void com.ibm.servlet.engine.webapp.ServletInstance.service(javax.servlet.ServletRequest, javax.servlet.ServletResponse, com.ibm.servlet.engine.webapp.WebAppServletInvocationEvent)
void com.ibm.servlet.engine.webapp.ValidServletReferenceState.dispatch(com.ibm.servlet.engine.webapp.ServletInstanceReference, javax.servlet.ServletRequest, javax.servlet.ServletResponse, com.ibm.servlet.engine.webapp.WebAppServletInvocationEvent)
void com.ibm.servlet.engine.webapp.ServletInstanceReference.dispatch(javax.servlet.ServletRequest, javax.servlet.ServletResponse, com.ibm.servlet.engine.webapp.WebAppServletInvocationEvent)
void com.ibm.servlet.engine.webapp.WebAppRequestDispatcher.handleWebAppDispatch(com.ibm.servlet.engine.webapp.WebAppRequest, com.ibm.servlet.engine.webapp.WebAppResponse, boolean)
void com.ibm.servlet.engine.webapp.WebAppRequestDispatcher.dispatch(javax.servlet.ServletRequest, javax.servlet.ServletResponse, boolean)
void com.ibm.servlet.engine.webapp.WebAppRequestDispatcher.forward(javax.servlet.ServletRequest, javax.servlet.ServletResponse)
void com.ibm.commerce.command.HttpForwardViewCommandImpl.forwardDocument(java.lang.String)
void com.ibm.commerce.command.HttpForwardViewCommandImpl.performExecute()
void com.ibm.commerce.command.ECCommandImpl.execute()
void com.ibm.commerce.webcontroller.ViewCmdExecUnit.execute()
void com.ibm.commerce.webcontroller.WebController.executeTransaction(com.ibm.commerce.webcontroller.ExecutableUnit, com.ibm.commerce.adapter.SessionContext)
void com.ibm.commerce.webcontroller.WebController.processRequest(com.ibm.commerce.webcontroller.ControllerRequestObject, java.lang.Object)
void com.ibm.commerce.adapter.HttpAdapterImpl.processRequest(javax.servlet.ServletContext, java.lang.String)
void com.ibm.commerce.server.RequestServlet.service(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
void javax.servlet.http.HttpServlet.service(javax.servlet.ServletRequest, javax.servlet.ServletResponse)
void com.ibm.servlet.engine.webapp.StrictServletInstance.doService(javax.servlet.ServletRequest, javax.servlet.ServletResponse)
void com.ibm.servlet.engine.webapp.StrictLifecycleServlet._service(javax.servlet.ServletRequest, javax.servlet.ServletResponse)
void com.ibm.servlet.engine.webapp.IdleServletState.service(com.ibm.servlet.engine.webapp.StrictLifecycleServlet, javax.servlet.ServletRequest, javax.servlet.ServletResponse)
void com.ibm.servlet.engine.webapp.StrictLifecycleServlet.service(javax.servlet.ServletRequest, javax.servlet.ServletResponse)
void com.ibm.servlet.engine.webapp.ServletInstance.service(javax.servlet.ServletRequest, javax.servlet.ServletResponse, com.ibm.servlet.engine.webapp.WebAppServletInvocationEvent)
void com.ibm.servlet.engine.webapp.ValidServletReferenceState.dispatch(com.ibm.servlet.engine.webapp.ServletInstanceReference, javax.servlet.ServletRequest, javax.servlet.ServletResponse, com.ibm.servlet.engine.webapp.WebAppServletInvocationEvent)
void com.ibm.servlet.engine.webapp.ServletInstanceReference.dispatch(javax.servlet.ServletRequest, javax.servlet.ServletResponse, com.ibm.servlet.engine.webapp.WebAppServletInvocationEvent)
void com.ibm.servlet.engine.webapp.WebAppRequestDispatcher.handleWebAppDispatch(com.ibm.servlet.engine.webapp.WebAppRequest, com.ibm.servlet.engine.webapp.WebAppResponse, boolean)
void com.ibm.servlet.engine.webapp.WebAppRequestDispatcher.dispatch(javax.servlet.ServletRequest, javax.servlet.ServletResponse, boolean)
void com.ibm.servlet.engine.webapp.WebAppRequestDispatcher.forward(javax.servlet.ServletRequest, javax.servlet.ServletResponse)
void com.ibm.servlet.engine.srt.WebAppInvoker.handleInvocationHook(java.lang.Object)
void com.ibm.servlet.engine.invocation.CachedInvocation.handleInvocation(java.lang.Object)
void com.ibm.servlet.engine.srp.ServletRequestProcessor.dispatchByURI(java.lang.String, com.ibm.servlet.engine.srp.ISRPConnection)
void com.ibm.servlet.engine.oselistener.OSEListenerDispatcher.service(com.ibm.servlet.engine.oselistener.api.IOSEConnection)
void com.ibm.servlet.engine.http_transport.HttpTransportHandler.handleConnection(java.net.Socket)
void com.ibm.servlet.engine.http_transport.HttpTransportHandler.run()
void java.lang.Thread.run()
 
Madhuri Neerukonda
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
my email id id :
chinna_sri@msn.com
thanks
Madhu
 
Whoever got anywhere by being normal? Just ask this exceptional tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic