• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Runtime problem with Session Bean

 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
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
Post the code where you are doing a PortableRemoteObject.narrow. Also, are you sure you are casting to the right type.
 
Arun Prasath
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 502
jQuery Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
Arun Prasath
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
<?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
 
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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".
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic