7 Replies Latest reply on Jul 8, 2005 9:16 AM by Steve Rose

    Cannot get a remote context for Session Bean

    Steve Rose Newbie

      Here is my code :
      ...
      public void init() throws ServletException {


      try {
      Hashtable<String,String> env = new Hashtable<String,String>();
      env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
      env.put(Context.PROVIDER_URL, "jnp://192.168.0.5:1099");
      env.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces" );
      Context context = new InitialContext(env);
      roleBean =(AppRoles) context.lookup("com.ejb.test.AppRoles");
      } catch (NamingException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
      }

      // TODO Auto-generated method stub
      }
      ...

      Here is the result:
      java.lang.RuntimeException: javax.naming.NameNotFoundException: Name containers is not bound in this Context
      org.jboss.ejb3.LocalProxy.readObject(LocalProxy.java:54)
      sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
      sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      java.lang.reflect.Method.invoke(Unknown Source)
      java.io.ObjectStreamClass.invokeReadObject(Unknown Source)
      java.io.ObjectInputStream.readSerialData(Unknown Source)
      java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
      java.io.ObjectInputStream.readObject0(Unknown Source)
      java.io.ObjectInputStream.defaultReadFields(Unknown Source)
      java.io.ObjectInputStream.readSerialData(Unknown Source)
      java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
      java.io.ObjectInputStream.readObject0(Unknown Source)
      java.io.ObjectInputStream.readObject(Unknown Source)
      java.rmi.MarshalledObject.get(Unknown Source)
      org.jnp.interfaces.MarshalledValuePair.get(MarshalledValuePair.java:57)
      org.jnp.interfaces.NamingContext.lookup(NamingContext.java:637)
      org.jnp.interfaces.NamingContext.lookup(NamingContext.java:572)
      javax.naming.InitialContext.lookup(Unknown Source)
      com.airit.web.RoleWeb.init(RoleWeb.java:55)
      javax.servlet.GenericServlet.init(GenericServlet.java:211)
      org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
      org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
      org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
      org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
      org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
      org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
      org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
      java.lang.Thread.run(Unknown Source)

      ...

      The Jndi name which i am copying and pasting from the jboss application server log is:

      "2005-07-07 15:15:44,286 INFO [org.jboss.ejb3.ProxyDeployer] default remote binding has jndiName of com.ejb.test.AppRoles"

      I can access my session bean successfully when running on the same jvm as jboss application server. I get this error when running the client in tomcat standalone and trying to access the remote interface from a different machine. The remote interface is running I am positive, I just cant get the context . Please help.

        • 1. Re: Cannot get a remote context for Session Bean
          Steve Rose Newbie

          Ok ...thanks to bill, I figured out part of my problem which was forgeting to delete the @ Local piece in my remote interface. Now I have a different problem. When i try to use the first method in my class , I get a ...

          java.lang.reflect.UndeclaredThrowableException
          at $Proxy0.getAppRoles(Unknown Source)
          at com.airit.web.RoleWeb.showRole(RoleWeb.java:147)
          at com.airit.web.RoleWeb.doPost(RoleWeb.java:88)
          at com.airit.web.RoleWeb.doGet(RoleWeb.java:68)
          at javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
          at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
          at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
          at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
          at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
          at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
          at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
          at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
          at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
          at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
          at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
          at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
          at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
          at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
          at java.lang.Thread.run(Unknown Source)
          Caused by: java.rmi.ConnectException: Failed to communicate. Problem during marshalling/unmarshalling; nested exception is:
          java.io.EOFException
          at org.jboss.remoting.transport.socket.SocketClientInvoker.transport(SocketClientInvoker.java:266)
          at org.jboss.remoting.RemoteClientInvoker.invoke(RemoteClientInvoker.java:117)
          at org.jboss.remoting.Client.invoke(Client.java:201)
          at org.jboss.aspects.remoting.InvokeRemoteInterceptor.invoke(InvokeRemoteInterceptor.java:42)
          at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:90)
          at org.jboss.aspects.tx.ClientTxPropagationInterceptor.invoke(ClientTxPropagationInterceptor.java:44)
          at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:90)
          at org.jboss.aspects.security.SecurityClientInterceptor.invoke(SecurityClientInterceptor.java:38)
          at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:90)
          at org.jboss.aspects.remoting.IsLocalInterceptor.invoke(IsLocalInterceptor.java:32)
          at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:90)
          at org.jboss.ejb3.stateless.StatelessRemoteProxy.invoke(StatelessRemoteProxy.java:79)
          ... 20 more

          Any ideas?

          • 2. Re: Cannot get a remote context for Session Bean
            Steve Rose Newbie

            Forgot to post my interface...

            import java.io.Serializable;
            import java.util.Collection;
            import javax.ejb.Remote;

            @Remote
            public interface AppRolesRemote extends Serializable {

            public Collection getAppRoles();
            public void addAppRole (String rolename, String roledesc);
            public void deleteAppRole(String RoleId);
            public void updateAppRole(String RoleId, String rolename, String roledesc);
            public UserRoleBean getAppRole(String RoleId);

            }

            • 3. Re: Cannot get a remote context for Session Bean
              Bill Burke Master

              what version of JBoss is running your backend? Also, what exact steps did you take to install? I'm trying to determine what version of JBoss Remoting you are using...

              Also, is the stack trace any longer? I need to know where the EOFException is being thrown.

              • 4. Re: Cannot get a remote context for Session Bean
                Steve Rose Newbie

                I am using 4.0.3 RC1. I installed the session bean and the entities beans using an ear file. I have a local interface which runs fine on the jboss application server. I installed a war file in the jboss-tomcat container and used local context look up and it works. This problem is occurring on a remote machine where i have a standalone version of tomcat(5.5.9) using the same war file with only the context lookup altered to use the remote interface. I am not at my office so I cant post the rest of the stack trace but will do so early tommorow. Thanks for all the help so far.

                • 5. Re: Cannot get a remote context for Session Bean
                  Steve Rose Newbie

                  here is the stack trace for the IOException...

                  Caused by: java.io.EOFException
                  at java.io.ObjectInputStream$BlockDataInputStream.peekByte(Unknown Source)
                  at java.io.ObjectInputStream.readObject0(Unknown Source)
                  at java.io.ObjectInputStream.readObject(Unknown Source)
                  at org.jboss.remoting.marshal.serializable.SerializableUnMarshaller.read(SerializableUnMarshaller.java:72)
                  at org.jboss.remoting.transport.socket.SocketClientInvoker.transport(SocketClientInvoker.java:244)

                  • 6. Re: Cannot get a remote context for Session Bean
                    Steve Rose Newbie

                    I also pulled this from the jboss application log file:

                    2005-07-08 09:35:04,542 DEBUG [org.hibernate.jdbc.ConnectionManager] running Session.finalize()
                    2005-07-08 09:35:04,542 DEBUG [org.hibernate.jdbc.ConnectionManager] running Session.finalize()
                    2005-07-08 09:35:59,291 DEBUG [org.jboss.remoting.transport.socket.ServerThread] WAKEUP in SERVER THREAD
                    2005-07-08 09:35:59,291 DEBUG [org.jboss.remoting.transport.socket.ServerThread] beginning dorun
                    2005-07-08 09:35:59,291 DEBUG [org.jboss.ejb3.entity.ManagedEntityManagerFactory] GETTING NEW EntityManager
                    2005-07-08 09:35:59,291 DEBUG [org.jboss.ejb3.entity.ManagedEntityManagerFactory] logLivedSession.get() was NULL
                    2005-07-08 09:35:59,291 DEBUG [org.jboss.ejb3.entity.ManagedEntityManagerFactory] LONG LIVED NOT FOUND
                    2005-07-08 09:35:59,291 DEBUG [org.hibernate.impl.SessionImpl] opened session at timestamp: 4590918694055936
                    2005-07-08 09:35:59,291 DEBUG [org.hibernate.impl.SessionImpl] find: from AppRole r
                    2005-07-08 09:35:59,291 DEBUG [org.hibernate.engine.QueryParameters] named parameters: {}
                    2005-07-08 09:35:59,291 DEBUG [org.hibernate.hql.ast.QueryTranslatorImpl] compile() : The query is already compiled, skipping...
                    2005-07-08 09:35:59,291 DEBUG [org.hibernate.jdbc.AbstractBatcher] about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
                    2005-07-08 09:35:59,301 DEBUG [org.hibernate.jdbc.ConnectionManager] opening JDBC connection
                    2005-07-08 09:35:59,301 DEBUG [org.hibernate.jdbc.JDBCContext] successfully registered Synchronization
                    2005-07-08 09:35:59,301 DEBUG [org.hibernate.SQL] select approle0_.ar_idseq as ar1_, approle0_.ar_rolename as ar2_0_, approle0_.ar_roledesc as ar3_0_ from fidstest.app_role approle0_
                    2005-07-08 09:35:59,301 DEBUG [org.hibernate.jdbc.AbstractBatcher] preparing statement
                    2005-07-08 09:35:59,301 DEBUG [org.hibernate.jdbc.AbstractBatcher] about to open ResultSet (open ResultSets: 0, globally: 0)
                    2005-07-08 09:35:59,301 DEBUG [org.hibernate.loader.Loader] processing result set
                    2005-07-08 09:35:59,301 DEBUG [org.hibernate.loader.Loader] result set row: 0
                    2005-07-08 09:35:59,301 DEBUG [org.hibernate.type.IntegerType] returning '13' as column: ar1_
                    2005-07-08 09:35:59,301 DEBUG [org.hibernate.loader.Loader] result row: EntityKey[com.airit.entities.AppRole#13]
                    2005-07-08 09:35:59,301 DEBUG [org.hibernate.loader.Loader] Initializing object from ResultSet: [com.airit.entities.AppRole#13]
                    2005-07-08 09:35:59,301 DEBUG [org.hibernate.persister.entity.BasicEntityPersister] Hydrating entity: [com.airit.entities.AppRole#13]
                    2005-07-08 09:35:59,301 DEBUG [org.hibernate.type.StringType] returning 'rwd_security' as column: ar2_0_
                    2005-07-08 09:35:59,311 DEBUG [org.hibernate.type.StringType] returning 'read,write,delete Role' as column: ar3_0_
                    2005-07-08 09:35:59,311 DEBUG [org.hibernate.loader.Loader] result set row: 1
                    2005-07-08 09:35:59,311 DEBUG [org.hibernate.type.IntegerType] returning '15' as column: ar1_
                    2005-07-08 09:35:59,311 DEBUG [org.hibernate.loader.Loader] result row: EntityKey[com.airit.entities.AppRole#15]
                    2005-07-08 09:35:59,311 DEBUG [org.hibernate.loader.Loader] Initializing object from ResultSet: [com.airit.entities.AppRole#15]
                    2005-07-08 09:35:59,311 DEBUG [org.hibernate.persister.entity.BasicEntityPersister] Hydrating entity: [com.airit.entities.AppRole#15]
                    2005-07-08 09:35:59,311 DEBUG [org.hibernate.type.StringType] returning 'testprop' as column: ar2_0_
                    2005-07-08 09:35:59,311 DEBUG [org.hibernate.type.StringType] returning 'test xfm' as column: ar3_0_
                    2005-07-08 09:35:59,311 DEBUG [org.hibernate.loader.Loader] result set row: 2
                    2005-07-08 09:35:59,311 DEBUG [org.hibernate.type.IntegerType] returning '8' as column: ar1_
                    2005-07-08 09:35:59,311 DEBUG [org.hibernate.loader.Loader] result row: EntityKey[com.airit.entities.AppRole#8]
                    2005-07-08 09:35:59,311 DEBUG [org.hibernate.loader.Loader] Initializing object from ResultSet: [com.airit.entities.AppRole#8]
                    2005-07-08 09:35:59,311 DEBUG [org.hibernate.persister.entity.BasicEntityPersister] Hydrating entity: [com.airit.entities.AppRole#8]
                    2005-07-08 09:35:59,311 DEBUG [org.hibernate.type.StringType] returning 'role88' as column: ar2_0_
                    2005-07-08 09:35:59,311 DEBUG [org.hibernate.type.StringType] returning 'this is role88' as column: ar3_0_
                    2005-07-08 09:35:59,311 DEBUG [org.hibernate.loader.Loader] result set row: 3
                    2005-07-08 09:35:59,311 DEBUG [org.hibernate.type.IntegerType] returning '12' as column: ar1_
                    2005-07-08 09:35:59,311 DEBUG [org.hibernate.loader.Loader] result row: EntityKey[com.airit.entities.AppRole#12]
                    2005-07-08 09:35:59,311 DEBUG [org.hibernate.loader.Loader] Initializing object from ResultSet: [com.airit.entities.AppRole#12]
                    2005-07-08 09:35:59,311 DEBUG [org.hibernate.persister.entity.BasicEntityPersister] Hydrating entity: [com.airit.entities.AppRole#12]
                    2005-07-08 09:35:59,311 DEBUG [org.hibernate.type.StringType] returning 'admin' as column: ar2_0_
                    2005-07-08 09:35:59,311 DEBUG [org.hibernate.type.StringType] returning 'Administrative Role' as column: ar3_0_
                    2005-07-08 09:35:59,311 DEBUG [org.hibernate.loader.Loader] done processing result set (4 rows)
                    2005-07-08 09:35:59,311 DEBUG [org.hibernate.jdbc.AbstractBatcher] about to close ResultSet (open ResultSets: 1, globally: 1)
                    2005-07-08 09:35:59,311 DEBUG [org.hibernate.jdbc.AbstractBatcher] about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
                    2005-07-08 09:35:59,311 DEBUG [org.hibernate.jdbc.AbstractBatcher] closing statement
                    2005-07-08 09:35:59,311 DEBUG [org.hibernate.jdbc.ConnectionManager] aggressively releasing JDBC connection
                    2005-07-08 09:35:59,311 DEBUG [org.hibernate.jdbc.ConnectionManager] closing JDBC connection [ (open PreparedStatements: 0, globally: 0) (open ResultSets: 0, globally: 0)]
                    2005-07-08 09:35:59,311 DEBUG [org.hibernate.loader.Loader] total objects hydrated: 4
                    2005-07-08 09:35:59,311 DEBUG [org.hibernate.engine.TwoPhaseLoad] resolving associations for [com.airit.entities.AppRole#13]
                    2005-07-08 09:35:59,311 DEBUG [org.hibernate.engine.TwoPhaseLoad] done materializing entity [com.airit.entities.AppRole#13]
                    2005-07-08 09:35:59,311 DEBUG [org.hibernate.engine.TwoPhaseLoad] resolving associations for [com.airit.entities.AppRole#15]
                    2005-07-08 09:35:59,311 DEBUG [org.hibernate.engine.TwoPhaseLoad] done materializing entity [com.airit.entities.AppRole#15]
                    2005-07-08 09:35:59,311 DEBUG [org.hibernate.engine.TwoPhaseLoad] resolving associations for [com.airit.entities.AppRole#8]
                    2005-07-08 09:35:59,311 DEBUG [org.hibernate.engine.TwoPhaseLoad] done materializing entity [com.airit.entities.AppRole#8]
                    2005-07-08 09:35:59,311 DEBUG [org.hibernate.engine.TwoPhaseLoad] resolving associations for [com.airit.entities.AppRole#12]
                    2005-07-08 09:35:59,311 DEBUG [org.hibernate.engine.TwoPhaseLoad] done materializing entity [com.airit.entities.AppRole#12]
                    2005-07-08 09:35:59,311 DEBUG [org.hibernate.engine.StatefulPersistenceContext] initializing non-lazy collections
                    2005-07-08 09:35:59,311 DEBUG [org.jboss.ejb3.entity.ManagedEntityManagerFactory] ************** flushing.....
                    2005-07-08 09:35:59,311 DEBUG [org.hibernate.event.def.AbstractFlushingEventListener] flushing session
                    2005-07-08 09:35:59,311 DEBUG [org.hibernate.event.def.AbstractFlushingEventListener] processing flush-time cascades
                    2005-07-08 09:35:59,311 DEBUG [org.hibernate.event.def.AbstractFlushingEventListener] dirty checking collections
                    2005-07-08 09:35:59,311 DEBUG [org.hibernate.event.def.AbstractFlushingEventListener] Flushing entities and processing referenced collections
                    2005-07-08 09:35:59,311 DEBUG [org.hibernate.event.def.AbstractFlushingEventListener] Processing unreferenced collections
                    2005-07-08 09:35:59,311 DEBUG [org.hibernate.event.def.AbstractFlushingEventListener] Scheduling collection removes/(re)creates/updates
                    2005-07-08 09:35:59,311 DEBUG [org.hibernate.event.def.AbstractFlushingEventListener] Flushed: 0 insertions, 0 updates, 0 deletions to 4 objects
                    2005-07-08 09:35:59,311 DEBUG [org.hibernate.event.def.AbstractFlushingEventListener] Flushed: 0 (re)creations, 0 updates, 0 removals to 0 collections
                    2005-07-08 09:35:59,311 DEBUG [org.hibernate.pretty.Printer] listing entities:
                    2005-07-08 09:35:59,311 DEBUG [org.hibernate.pretty.Printer] com.airit.entities.AppRole{arRoleName=testprop, arRoleDesc=test xfm, arIdSeq=15}
                    2005-07-08 09:35:59,311 DEBUG [org.hibernate.pretty.Printer] com.airit.entities.AppRole{arRoleName=role88, arRoleDesc=this is role88, arIdSeq=8}
                    2005-07-08 09:35:59,311 DEBUG [org.hibernate.pretty.Printer] com.airit.entities.AppRole{arRoleName=rwd_security, arRoleDesc=read,write,delete Role, arIdSeq=13}
                    2005-07-08 09:35:59,311 DEBUG [org.hibernate.pretty.Printer] com.airit.entities.AppRole{arRoleName=admin, arRoleDesc=Administrative Role, arIdSeq=12}
                    2005-07-08 09:35:59,311 DEBUG [org.hibernate.event.def.AbstractFlushingEventListener] executing flush
                    2005-07-08 09:35:59,311 DEBUG [org.hibernate.event.def.AbstractFlushingEventListener] post flush
                    2005-07-08 09:35:59,311 DEBUG [org.hibernate.transaction.CacheSynchronization] transaction before completion callback
                    2005-07-08 09:35:59,311 DEBUG [org.hibernate.jdbc.JDBCContext] before transaction completion
                    2005-07-08 09:35:59,311 DEBUG [org.hibernate.impl.SessionImpl] before transaction completion
                    2005-07-08 09:35:59,311 DEBUG [org.jboss.ejb3.entity.ManagedEntityManagerFactory] ************** closing entity managersession **************
                    2005-07-08 09:35:59,311 DEBUG [org.hibernate.impl.SessionImpl] closing session
                    2005-07-08 09:35:59,311 DEBUG [org.hibernate.transaction.CacheSynchronization] transaction after completion callback, status: 3
                    2005-07-08 09:35:59,311 DEBUG [org.hibernate.jdbc.JDBCContext] after transaction completion
                    2005-07-08 09:35:59,311 DEBUG [org.hibernate.impl.SessionImpl] after transaction completion
                    2005-07-08 09:35:59,321 DEBUG [org.jboss.remoting.transport.socket.ServerThread] failed
                    java.io.EOFException
                    at java.io.ObjectInputStream$BlockDataInputStream.readByte(ObjectInputStream.java:2670)
                    at java.io.ObjectInputStream.readByte(ObjectInputStream.java:864)
                    at org.jboss.remoting.transport.socket.ServerThread.acknowledge(ServerThread.java:192)
                    at org.jboss.remoting.transport.socket.ServerThread.dorun(ServerThread.java:326)
                    at org.jboss.remoting.transport.socket.ServerThread.run(ServerThread.java:147)
                    2005-07-08 09:35:59,321 DEBUG [org.jboss.remoting.transport.socket.ServerThread] begin thread wait
                    2005-07-08 09:36:05,660 DEBUG [org.hibernate.jdbc.ConnectionManager] running Session.finalize()

                    • 7. Re: Cannot get a remote context for Session Bean
                      Steve Rose Newbie

                      I figured it out! One of my objects which i use to copy over data from my entity bean inside my session bean wasnt serializable. I do this to keep my entity bean transparent to my client. Anyways, I made it serializable and it works perfectly.