Meaningless Drivel is fun!*
The moose likes EJB and other Java EE Technologies and the fly likes Runtime problem with Session Bean Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Runtime problem with Session Bean" Watch "Runtime problem with Session Bean" New topic
Author

Runtime problem with Session Bean

Arun Prasath
Ranch Hand

Joined: Aug 14, 2006
Posts: 30
I use Sun One Application Server v8.1

I tried the example tutorial providede by sun site to explain how to deploy applications in sun server 8.1

I followed the below site

http://java.sun.com/j2ee/1.4/docs/tutorial-update6/doc/index.html

and the tutorial used in this site atlast i deployed the application and got the client jar

But while i try to run,i get the following error:

Caught an unexpected exception!
java.lang.ClassCastException
at com.sun.corba.ee.impl.javax.rmi.PortableRemoteObject.narrow(PortableR
emoteObject.java:229)
at javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:137)
at ConverterClient.main(ConverterClient.java:44)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at com.sun.enterprise.util.Utility.invokeApplicationMain(Utility.java:23
7)
at com.sun.enterprise.appclient.Main.<init>(Main.java:426)
at com.sun.enterprise.appclient.Main.main(Main.java:97)
Caused by: java.lang.ClassCastException: Object is not of remote type converter.
ConverterHome
at com.sun.corba.ee.impl.javax.rmi.PortableRemoteObject.narrow(PortableR
emoteObject.java:221)
... 9 more


Actually after deployement the client jar is returned to the specific dir and when i verify j2ee compliance for the application the result shows a
result

Error verifying:c:\...\..\ApplicationClient.ear:null

is returned

please help mme use the below site to follow my problem

http://java.sun.com/j2ee/1.4/docs/tutorial-update6/doc/index.html
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10069
    
163

Post the code where you are doing a PortableRemoteObject.narrow. Also, are you sure you are casting to the right type.


[My Blog] [JavaRanch Journal]
Arun Prasath
Ranch Hand

Joined: Aug 14, 2006
Posts: 30
Obtain the environment naming context of the application client.
Context myEnv = (Context)initial.lookup("java:comp/env");

The java:comp/env name is bound to the environment naming context of the ConverterClient component.

Retrieve the object bound to the name ejb/SimpleConverter.
Object objref = myEnv.lookup("ejb/SimpleConverter");

The ejb/SimpleConverter name is bound to an enterprise bean reference, a logical name for the home of an enterprise bean. In this case, the ejb/SimpleConverter name refers to the ConverterHome object. The names of enterprise beans should reside in the java:comp/env/ejb subcontext.

Narrow the reference to a ConverterHome object.
ConverterHome home =
(ConverterHome) PortableRemoteObject.narrow(objref,
ConverterHome.class);

Creating an Enterprise Bean Instance
To create the bean instance, the client invokes the create method on the ConverterHome object. The create method returns an object whose type is Converter. The remote Converter interface defines the business methods of the bean that the client can call. When the client invokes the create method, the EJB container instantiates the bean and then invokes the ConverterBean.ejbCreate method. The client invokes the create method as follows:

Converter currencyConverter = home.create();
Arun Prasath
Ranch Hand

Joined: Aug 14, 2006
Posts: 30
See in Deployment there is no problem but while i run the file i get the above mentioned problem ..This is an example found on Suns Tutorial.....

So there is nothing wrong in the coding and i have followed the step by step process of running the code using the tutorial...

See for your kind information the tutorial is found in the following link


please help me using the link:


http://java.sun.com/j2ee/1.4/docs/tutorial-update6/doc/index.html
Prabhu Venkatachalam
Ranch Hand

Joined: Nov 16, 2005
Posts: 502

Caused by: java.lang.ClassCastException: Object is not of remote type converter.
ConverterHome


This clearly states that Home Type not compatible with Object you got.

So, you can check following things,

1. Check your ejb-jar.xml, that for the name you registered for this particular bean and the name you are using to get matches.

2. Check HOME class name(including package structure) you give for that particular bean type is correct.

If this is also not working, then post ejb-jar.xml.


Prabhu Venkatachalam<br />SCJP 1.4,SCWCD 1.4<br />prabhu.venkatachalam@gmail.com
Arun Prasath
Ranch Hand

Joined: Aug 14, 2006
Posts: 30
<?xml version="1.0" encoding="UTF-8"?>
<ejb-jar xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.1" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/ejb-jar_2_1.xsd">
<display-name>ConverterJAR</display-name>
<enterprise-beans>
<session>
<display-name>ConverterBean</display-name>
<ejb-name>ConverterBean</ejb-name>
<home>converter.ConverterHome</home>
<remote>converter.Converter</remote>
<ejb-class>converter.ConverterBean</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Bean</transaction-type>
<security-identity>
<use-caller-identity/>
</security-identity>
</session>
</enterprise-beans>
</ejb-jar>


See this is the ejb-jar.xml file of me ...

yoou can see the name are all right then pplease anyone tell me why i get the error
Georgy Bolyuba
Ranch Hand

Joined: Feb 18, 2005
Posts: 162
You trying to find "ejb/SimpleConverter":

Object objref = myEnv.lookup("ejb/SimpleConverter");

Just make sure that "ejb/SimpleConverter" is correct name for ConverterHome.

It looks like something else is binded with name "ejb/SimpleConverter".


SCJP 1.4 (100%) Done.<br />SCJD (URLyBird 1.2.3 Started)
 
 
subject: Runtime problem with Session Bean