6 Replies Latest reply on Aug 12, 2006 2:31 PM by one_special_user

    Error accessing EJB within Servlet

    one_special_user Newbie

      Error accessing EJB within Servlet



      Hello, I've created an IIOP Stateless SessionBean bound to "vfmcontroller/VFMController", which i can access from
      my C#-Client (via IIOP.Net), all works fine and JBoss doesn't list any error during startup.

      But if I want to access the SessionBean from within a Servlet, I get an Error.
      I do not include the EJB - JARFile where my SessionBean resides (have read that this might cause errors due to ClassLoaders)
      Servlet-Code:

      protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
       response.setContentType("text/plain;charset=UTF-8");
       PrintWriter out = response.getWriter();
       try {
       Context ctx = new InitialContext();
       Object obj_ref = ctx.lookup( "vfmcontroller/VFMController" );
       VFMControllerHome home = (VFMControllerHome)PortableRemoteObject.narrow( obj_ref, VFMControllerHome.class );
       VFMController controller = home.create();
       String time = controller.getTime();
       out.println( "TIME = " + time );
       } catch (Throwable error) {
       error.printStackTrace( out );
       }
       out.close();
      }


      And this is the Error I caught and print out to the Browser:
      ERROR:
      java.lang.Error: POA: not configured!
       at org.jacorb.poa.POA._getChildPOA(POA.java:314)
       at org.jacorb.orb.ORB.findPOA(ORB.java:494)
       at org.jacorb.orb.Delegate.resolvePOA(Delegate.java:781)
       at org.jacorb.orb.Delegate.is_really_local(Delegate.java:1326)
       at org.jacorb.orb.Delegate.is_a(Delegate.java:1177)
       at org.omg.CORBA.portable.ObjectImpl._is_a(ObjectImpl.java:112)
       at com.sun.corba.se.impl.javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:218)
       at javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:137)
       at org.jboss.proxy.ejb.IIOPHomeFactory.getObjectInstance(IIOPHomeFactory.java:70)
       at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:304)
       at org.jnp.interfaces.NamingContext.getObjectInstance(NamingContext.java:1125)
       at org.jnp.interfaces.NamingContext.getObjectInstanceWrapFailure(NamingContext.java:1142)
       at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:705)
       at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:587)
       at javax.naming.InitialContext.lookup(InitialContext.java:351)
       at servlet.Test.processRequest(Test.java:27)
       at servlet.Test.doGet(Test.java:57)
       at javax.servlet.http.HttpServlet.service(HttpServlet.java:697)
       at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
       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.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:175)
       at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
       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:869)
       at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
       at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
       at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
       at java.lang.Thread.run(Thread.java:595)




      And JBoss' Logging tells me the following:
      16:19:51,384 INFO [Server] JBoss (MX MicroKernel) [4.0.4.GA (build: CVSTag=JBoss_4_0_4_GA date=200605151000)] Started in 40s:488ms
      
      //
      // COMMENT: JBoss started without any Error-Messages,
      // but as soon as I first access the Servlet,
      // I get the following Log-Output:
      //
      
      16:19:54,919 WARN [listener] Address already in use: JVM_Bind
      16:19:54,919 WARN [ORBFactory] Unable to activate POA
      org.omg.CORBA.INITIALIZE: Could not create server socket vmcid: 0x0 minor code: 0 completed: No
       at org.jacorb.orb.iiop.IIOPListener$Acceptor.createServerSocket(IIOPListener.java:466)
       at org.jacorb.orb.iiop.IIOPListener$Acceptor.init(IIOPListener.java:378)
       at org.jacorb.orb.iiop.IIOPListener.configure(IIOPListener.java:166)
       at org.jacorb.orb.etf.FactoriesBase.create_listener(FactoriesBase.java:101)
       at org.jacorb.orb.BasicAdapter.configure(BasicAdapter.java:147)
       at org.jacorb.orb.ORB.getRootPOA(ORB.java:885)
       at org.jacorb.orb.ORB.resolve_initial_references(ORB.java:1167)
       at org.jboss.corba.ORBFactory.getORB(ORBFactory.java:82)
       at org.jboss.iiop.CorbaORB.getInstance(CorbaORB.java:87)
       at org.jboss.proxy.ejb.IIOPHomeFactory.getObjectInstance(IIOPHomeFactory.java:69)
       at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:304)
       at org.jnp.interfaces.NamingContext.getObjectInstance(NamingContext.java:1125)
       at org.jnp.interfaces.NamingContext.getObjectInstanceWrapFailure(NamingContext.java:1142)
       at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:705)
       at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:587)
       at javax.naming.InitialContext.lookup(InitialContext.java:351)
       at servlet.Test.processRequest(Test.java:27)
       at servlet.Test.doGet(Test.java:57)
       at javax.servlet.http.HttpServlet.service(HttpServlet.java:697)
       at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
       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.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:175)
       at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
       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:869)
       at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
       at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
       at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
       at java.lang.Thread.run(Thread.java:595)




      I've been tracking down the Sources for at org.jacorb.orb.iiop.IIOPListener.createServerSocket()
      and found out that this Method in turn calls private int getConfiguredPort(), which returns oaport
      being initially set by the Property "OAPort".
      The "Address already in use: JVM_Bind" brought me to the idea of changing this Property in jacorb.properties,
      but nothing happened.

      The Log-Output "Unable to activate POA" form ORBFactory is thrown when it tires to retrieve
      the initial reference:
      public static ORB getORB()
       {
       synchronized (ORBFactory.class)
       {
       if (orb == null)
       {
       Properties properties;
       try
       {
       properties = (Properties) AccessController.doPrivileged(new PrivilegedAction()
       {
       public Object run()
       {
       return System.getProperties();
       }
       });
       }
       catch (SecurityException ignored)
       {
       log.trace("Unable to retrieve system properties", ignored);
       properties = null;
       }
      
       // Create the singleton ORB
       orb = ORB.init(new String[0], properties);
      
       // Activate the root POA
       try
       {
       POA rootPOA = (POA) orb.resolve_initial_references("RootPOA");
       rootPOA.the_POAManager().activate();
       }
       catch (Throwable t)
       {
       ///////////////////////
       // HERE WE ARE ..
       ///////////////////////
       log.warn("Unable to activate POA", t);
       }
       }
       return orb;
       }
       }




      JBoss 4.0.4 GA
      Java 1.5.0
      Windows XP SP2


      On a similar Problem I've read that JBoss might have problems if not being connected to a network
      (Clustering etc.), but I do have a network connection.

      Any Ideas what's going on!?

      Have no clue how this problem arises and can be fixed :-/