geronimo-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Viet Nguyen" <vhng...@gmail.com>
Subject Re: how to run Ejb program on geronimo
Date Wed, 02 Apr 2008 13:02:13 GMT
Hi Atul,

It looks like you're doing a remote lookup. I think your client code
should look something similar to

My.DemoInter remoteObj =(My.DemoInter)ctx.lookup(<jndi for remote interface>);

Let me know if this works.

Thanks,
Viet


On Wed, Apr 2, 2008 at 4:12 AM, atul12345 <atul.iims@gmail.com> wrote:
>
>
>
>  atul12345 wrote:
>  >
>  >
>  >
>  > Hi Sir,
>  >          Thanks for help. I appreciate your attention. See ya!
>  >       This is my ejb-jar.xml file here i do have  all the classes means
>  > interface name.
>  >
>  > <ejb-jar id="ejb-jar_1" xmlns="http://java.sun.com/xml/ns/j2ee"
>  >        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>  >        xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
>  >        http://java.sun.com/xml/ns/j2ee/ejb-jar_2_1.xsd" version="2.1">
>  >       <description>Example of a session bean</description>
>  >       <display-name>MyTimeBeanEJBName</display-name>
>  >       <enterprise-beans>
>  >               <session id="Session_MyTime">
>  >
>  >                       <ejb-name>My.DemoEJB</ejb-name>
>  >                       <home>My.DemoHome</home>
>  >                       <remote>My.DemoInter</remote>
>  >                       <ejb-class>My.DemoBean</ejb-class>
>  >
>  >                       <session-type>Stateful</session-type>
>  >                       <transaction-type>Container</transaction-type>
>  >               </session>
>  >       </enterprise-beans>
>  > </ejb-jar>
>  >
>  > When I try to execute my client , I receive this error message:
>  > java.lang.ClassCastException.
>  >
>  > java.lang.ClassCastException
>  >         at
>  > com.sun.corba.se.impl.javax.rmi.PortableRemoteObject.narrow(PortableR
>  >         at
>  > javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:137)
>  >         at HelloWorld.main(HelloWorld.java:31)
>  > Caused by: java.lang.ClassCastException: $Proxy0 cannot be cast to
>  > org.omg.CORBA
>  >         at
>  > com.sun.corba.se.impl.javax.rmi.PortableRemoteObject.narrow(PortableR
>  >         ... 2 more
>
>
> >
>  > Could anyone tell me what I'm doing wrong? Thanks a lot. Looking forward
>  > to hearing from you.
>  >
>  >
>  >
>  >
>  > manucet wrote:
>  >>
>  >> Hi Atul,
>  >>             I am not sure but did you specify the home and remote
>  >> interfaces in the ejb-jar.xml file? If yes it will be helpful if you
>  >> can provide a test case.
>  >>
>  >> Regards
>  >> Manu
>  >>
>  >> On Tue, Apr 1, 2008 at 4:33 PM, atul12345 <atul.iims@gmail.com> wrote:
>  >>>
>  >>>  Actually after resolved jndi name problem i get one new error that is
>  >>>
>  >>>  java.lang.ClassCastException: $Proxy0 cannot be cast to My.DemoHome
>  >>>   if anyone have any idea what is this so please give  me suitable
>  >>> soluation
>  >>>  to resolve that problem.........
>  >>>
>  >>>
>  >>>
>  >>>
>  >>>
>  >>>  atul12345 wrote:
>  >>>  >
>  >>>  >  Dear Sir,
>  >>>  >
>  >>>  >               I am new programmer to Geronimo and EJB which are
>  >>> running on
>  >>>  > gentoo. i am createing stateful session bean like that........
>  >>>  > This is remote Interface..........
>  >>>  > package My;
>  >>>  >
>  >>>  > import java.rmi.*;
>  >>>  >
>  >>>  > import javax.ejb.*;
>  >>>  >
>  >>>  > public interface DemoInter extends EJBObject
>  >>>  > {
>  >>>  >            public int add(int a,int b) throws RemoteException;
>  >>>  > }
>  >>>  >
>  >>>  >
>  >>>  > This is Home Interface..........
>  >>>  > package My;
>  >>>  >
>  >>>  > import javax.ejb.*;
>  >>>  > import java.rmi.*;
>  >>>  >
>  >>>  >
>  >>>  >
>  >>>  > public interface DemoHome extends EJBHome
>  >>>  > {
>  >>>  > public DemoInter create() throws CreateException,RemoteException;
>  >>>  > }
>  >>>  >
>  >>>  > This is Bean class............
>  >>>  >
>  >>>  > package My;
>  >>>  >
>  >>>  > import java.rmi.*;
>  >>>  >
>  >>>  > import javax.ejb.*;
>  >>>  >
>  >>>  > public class DemoBean implements SessionBean
>  >>>  > {
>  >>>  >          public DemoBean() {
>  >>>  >                 // TODO Auto-generated constructor stub
>  >>>  >                            }
>  >>>  >         public void ejbCreate()
>  >>>  >         {
>  >>>  >            System.out.println("ejbCreate()");
>  >>>  >         }
>  >>>  >
>  >>>  >         public void ejbRemove()
>  >>>  >         {
>  >>>  >            System.out.println("ejbRemove()");
>  >>>  >         }
>  >>>  >
>  >>>  >
>  >>>  > public void ejbActivate()
>  >>>  > {
>  >>>  >    System.out.println("ejbActivate()");
>  >>>  > }
>  >>>  >
>  >>>  > public void ejbPassivate()
>  >>>  > {
>  >>>  >    System.out.println("ejbPassivate()");
>  >>>  > }
>  >>>  >
>  >>>  >
>  >>>  > public void setSessionContext(SessionContext ctx){}
>  >>>  >
>  >>>  >
>  >>>  > public int add(int a,int b) throws RemoteException
>  >>>  > {
>  >>>  > return (a+b);
>  >>>  > }
>  >>>  >
>  >>>  > }
>  >>>  >
>  >>>  >
>  >>>  > open-ejb.xml is where i specified the jndi name
>  >>>  >
>  >>>  > <openejb-jar xmlns="http://www.openejb.org/xml/ns/openejb-jar-2.1"
>  >>>  >
>  >>> xmlns:naming="http://geronimo.apache.org/xml/ns/naming-1.1"
>  >>>  >
>  >>>  > xmlns:security="http://geronimo.apache.org/xml/ns/security-1.1"
>  >>>  >   xmlns:sys="http://geronimo.apache.org/xml/ns/deployment-1.1">
>  >>>  >
>  >>>  >   <enterprise-beans>
>  >>>  >     <session>
>  >>>  >             <ejb-name>Demo</ejb-name>
>  >>>  >             <jndi-name>org.geronimo.ejbsample.HomeBean</jndi-name>
>  >>>  >     </session>
>  >>>  >   </enterprise-beans>
>  >>>  > </openejb-jar>
>  >>>  >
>  >>>  >
>  >>>  >
>  >>>  >
>  >>>  >
>  >>>  >
>  >>>  >
>  >>>  >
>  >>>  >  and this is my client code...........
>  >>>  >
>  >>>  > import java.util.*;
>  >>>  > import javax.naming.*;
>  >>>  > import javax.rmi.*;
>  >>>  > import My.*;
>  >>>  >
>  >>>  >
>  >>>  > public class Client {
>  >>>  >
>  >>>  >         /**
>  >>>  >          * @param args
>  >>>  >          */
>  >>>  >         public static void main(String[] args) {
>  >>>  >                 // TODO Auto-generated method stub
>  >>>  >                 try {
>  >>>  >
>  >>>  >                         Properties properties=new Properties();
>  >>>  >             properties.setProperty(Context.INITIAL_CONTEXT_FACTORY,
>  >>>  > "org.apache.openejb.client.RemoteInitialContextFactory");
>  >>>  >
>  >>>  >                         properties.setProperty(Context.PROVIDER_URL,
>  >>>  > "ejbd://localhost:4201" );
>  >>>  >
>  >>>  >             Context ctx=new InitialContext(properties);
>  >>>  >
>  >>>  >                  My.DemoHome
>  >>>  > home=(My.DemoHome)ctx.lookup("java:org.geronimo.ejbsample.HomeBean");
>  >>>  >
>  >>>  >   My.DemoInter object =home.create();
>  >>>  >   System.out.println(object.add(12,22));
>  >>>  >
>  >>>  > that is my code, everything is ok means deploy successfully but
>  >>> problem is
>  >>>  > when i execute client program, that time i get error that is
>  >>>  >
>  >>>  > javax.naming.NameNotFoundException: org.geronimo.ejbsample.HomeBean
>  >>> does
>  >>>  > not exist in the system.  Check that the app was successfully
>  >>> deployed.
>  >>>  > So if anybody know how to resolve this problem then please give me
>  >>>  > suitable suggestion to resolve this problem..
>  >>>  >
>  >>>  >
>  >>>
>  >>>  --
>  >>>  View this message in context:
>  >>> http://www.nabble.com/how-to-run--Ejb-program-on-geronimo-tp16392851s134p16417878.html
>  >>>
>  >>>
>  >>> Sent from the Apache Geronimo - Users mailing list archive at
>  >>> Nabble.com.
>  >>>
>  >>>
>  >>
>  >>
>  >
>  >
>
>  --
>  View this message in context: http://www.nabble.com/how-to-run--Ejb-program-on-geronimo-tp16392851s134p16444488.html
>
>
> Sent from the Apache Geronimo - Users mailing list archive at Nabble.com.
>
>

Mime
View raw message