5 Replies Latest reply on Feb 13, 2003 1:14 PM by Stephanie Levesque

    EJB showstopper - javax.ejb.EJBException: Deprecated

    Phil Duckworth Newbie

      Hi - usual story, new to this etc. - just trying to get a simple session bean example up and running. Works fine up to calling the remote bean method (which just returns a String).
      The returned errors are extremely ambiguous - see below.
      Cheers.

      From the client:
      Name = Demo
      Got initial context
      Got reference.
      Got Bean's Home interface reference.
      java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:
      java.rmi.ServerException: Bean exception. Notify the application administrator; nested exception is:
      javax.ejb.EJBException: Deprecated

      From the console:
      16:05:35,789 INFO [STDOUT] setSessionContext called
      16:05:35,789 ERROR [LogInterceptor] EJBException:
      javax.ejb.EJBException: Deprecated
      at org.jboss.ejb.EnterpriseContext$EJBContextImpl.getEnvironment(EnterpriseContext.java:307)

      at ejb.demo.DemoBean.setSessionContext(DemoBean.java:52)
      at org.jboss.ejb.StatelessSessionEnterpriseContext.(StatelessSessionEnterpriseContext.
      java:47)
      at org.jboss.ejb.plugins.StatelessSessionInstancePool.create(StatelessSessionInstancePool.ja
      va:61)
      at org.jboss.ejb.plugins.AbstractInstancePool.get(AbstractInstancePool.java:208)
      at org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invoke(StatelessSessionInstance
      Interceptor.java:63)
      at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:129)
      at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:166)
      at org.jboss.ejb.StatelessSessionContainer.invoke(StatelessSessionContainer.java:313)
      at org.jboss.ejb.Container.invoke(Container.java:705)
      at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:491)
      at org.jboss.invocation.jrmp.server.JRMPInvoker.invoke(JRMPInvoker.java:362)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:324)
      at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:261)
      at sun.rmi.transport.Transport$1.run(Transport.java:148)
      at java.security.AccessController.doPrivileged(Native Method)
      at sun.rmi.transport.Transport.serviceCall(Transport.java:144)
      at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)
      at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
      at java.lang.Thread.run(Thread.java:536)

        • 1. Re: EJB showstopper - javax.ejb.EJBException: Deprecated
          Adrian Brock Master

          As the javadocs say, use

          new InitialContext().lookup("java:comp/env");

          Regards,
          Adrian

          • 2. Re: EJB showstopper - javax.ejb.EJBException: Deprecated
            Phil Duckworth Newbie

            Many thanks for the reply - I've now read the errata to the EJB 1.1 but I'm still struggling - my client is:

            package ejb.demo;
            import javax.naming.Context;
            import javax.naming.InitialContext;
            import ejb.demo.Demo;
            import ejb.demo.DemoHome;

            public class DemoClient
            {
            public static void main(String[] args)
            {
            try
            {
            Context initContext = new InitialContext();
            Context ctx = (Context)initContext.lookup("java:comp/env");
            DemoHome dHome = (DemoHome) ctx.lookup( "ejb/demo/Demo" );
            Demo lDemo = dHome.create();
            // Do anything with the Demo Entity
            int lId = lDemo.hashCode();
            System.out.println( "Hashcode is: " + lId );
            lDemo.remove();
            }
            catch ( Exception e )
            {
            e.printStackTrace();
            }
            }
            }

            ...but it fails on the "java:comp/env" lookup, the error is shown below - Do I need some extra configuration to ejb-jar.xml to fix this ?
            Many thanks for your help !

            My ejb-jar.xml:
            <?xml version="1.0" encoding="UTF-8"?>

            <ejb-jar>
            JBoss Demo Application
            <display-name>Demo EJB</display-name>
            <enterprise-beans>

            <ejb-name>ejb/demo/Demo</ejb-name>
            ejb.demo.DemoHome
            ejb.demo.Demo
            <ejb-class>ejb.demo.DemoBean</ejb-class>
            <session-type>Stateless</session-type>
            <transaction-type>Bean</transaction-type>

            </enterprise-beans>
            </ejb-jar>

            (Error from DemoClient below):

            javax.naming.NameNotFoundException: comp not bound

            at org.jnp.server.NamingServer.getBinding(NamingServer.java:495)

            at org.jnp.server.NamingServer.getBinding(NamingServer.java:503)

            at org.jnp.server.NamingServer.getObject(NamingServer.java:509)

            at org.jnp.server.NamingServer.lookup(NamingServer.java:253)

            at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:445)

            at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:429)

            at javax.naming.InitialContext.lookup(InitialContext.java:350)

            at ejb.demo.DemoClient.main(DemoClient.java:14)

            • 3. Re: EJB showstopper - javax.ejb.EJBException: Deprecated
              Adrian Brock Master

              The java:comp/env namespace is for use inside the bean.

              You cannot access it from a client.

              Regards,
              Adrian

              • 4. Re: EJB showstopper - javax.ejb.EJBException: Deprecated
                Michel Teunissen Newbie

                Hi,

                Have a look at the free 'getting started' PDF which will give you examples of clients outside the Jboss JVM doing a JNDI lookup:

                http://prdownloads.sourceforge.net/jboss/JBoss.3.0QuickStart.Draft3.pdf

                Michel

                • 5. Re: EJB showstopper - javax.ejb.EJBException: Deprecated
                  Stephanie Levesque Newbie

                  I also got this error with Sun EJB tutorial. I fixed it by making this code in comment in DemoBean.java:

                  public void setSessionContext(SessionContext ctx) {
                  /*if (verbose)
                  System.out.println("setSessionContext called");
                  this.ctx = ctx;
                  props = ctx.getEnvironment();*/
                  }