7 Replies Latest reply on Apr 28, 2008 3:28 AM by frankthetank

    JDNI Lookup - Naming Not Found with JBOSS 4.2.2

    senthilrajan.nitt

      Hi,

      I am trying to set my local environment in JBOSS 4.2.2 server for my project.

      I have configured the Datasource to point to my local oracle instance. The JBOSS log shows up as follows.


      19:29:13,031 INFO [ConnectionFactoryBindingService] Bound ConnectionManager 'jb
      oss.jca:service=DataSourceBinding,name=DefaultDS' to JNDI name 'java:DefaultDS'
      19:29:13,984 INFO [A] Bound to JNDI name: queue/A
      19:29:13,984 INFO [B] Bound to JNDI name: queue/B
      19:29:14,000 INFO [C] Bound to JNDI name: queue/C
      19:29:14,000 INFO [D] Bound to JNDI name: queue/D
      19:29:14,000 INFO [ex] Bound to JNDI name: queue/ex
      19:29:14,031 INFO [testTopic] Bound to JNDI name: topic/testTopic
      19:29:14,031 INFO [securedTopic] Bound to JNDI name: topic/securedTopic
      19:29:14,046 INFO [testDurableTopic] Bound to JNDI name: topic/testDurableTopic

      19:29:14,046 INFO [testQueue] Bound to JNDI name: queue/testQueue
      19:29:14,140 INFO [UILServerILService] JBossMQ UIL service available at : /127.
      0.0.1:8093
      19:29:14,203 INFO [DLQ] Bound to JNDI name: queue/DLQ
      19:29:14,703 INFO [ConnectionFactoryBindingService] Bound ConnectionManager 'jb
      oss.jca:service=ConnectionFactoryBinding,name=JmsXA' to JNDI name 'java:JmsXA'
      19:29:14,937 INFO [ConnectionFactoryBindingService] Bound ConnectionManager 'jb
      oss.jca:service=DataSourceBinding,name=OracleDS' to JNDI name 'java:OracleDS'

      When i try to lookup for my Datasource i got NamenotFound Exception.


      Context ctx = new InitialContext();
      Object ds = ctx.lookup("java:OracleDS");
      System.out.println("Got the object : "+ds)

      But when i look the object by name : topic/testTopic i got the object.

      Context ctx = new InitialContext();
      Object ds = ctx.lookup("topic/testTopic");
      System.out.println("Got the object : "+ds)

      Could anybody please help me what i have to do to work properly?

      Thanks,
      Senthil

        • 1. Re: JDNI Lookup - Naming Not Found with JBOSS 4.2.2
          jaikiran

          Where are you doing this lookup from? Is it a standalone java client? If yes, then the java: namespace wont be available for the standalone client.

          • 2. Re: JDNI Lookup - Naming Not Found with JBOSS 4.2.2
            senthilrajan.nitt

            Hi,

            Thanks for your quick response.

            I am doing lookup in my servlet and its being deployed on the JBOSS server.

            Could you please help me on the same?

            Thanks,
            Senthil

            • 3. Re: JDNI Lookup - Naming Not Found with JBOSS 4.2.2
              jaikiran

              Please post the entire exception stacktrace, the code where you doing the lookup and also the JNDI tree contents. For displaying the contents of the jndi tree, read this http://wiki.jboss.org/wiki/en/DisplayTheJNDITreeWithTheJMXConsole.

              While posting the logs or code or xml content, remember to wrap it in a code block using the Code button in the message editor window and please hit the Preview button to make sure your post is correctly formatted

              • 4. Re: JDNI Lookup - Naming Not Found with JBOSS 4.2.2
                senthilrajan.nitt

                Hi,

                My JMX Console output for JNDI Service :


                java: Namespace
                +- XAConnectionFactory (class: org.jboss.mq.SpyXAConnectionFactory)
                +- DefaultDS (class: org.jboss.resource.adapter.jdbc.WrapperDataSource)
                +- SecurityProxyFactory (class: org.jboss.security.SubjectSecurityProxyFactory)
                +- OracleDS (class: org.jboss.resource.adapter.jdbc.WrapperDataSource)
                +- DefaultJMSProvider (class: org.jboss.jms.jndi.JNDIProviderAdapter)
                +- comp (class: javax.naming.Context)
                +- JmsXA (class: org.jboss.resource.adapter.jms.JmsConnectionFactoryImpl)
                +- ConnectionFactory (class: org.jboss.mq.SpyConnectionFactory)
                +- jaas (class: javax.naming.Context)
                | +- HsqlDbRealm (class: org.jboss.security.plugins.SecurityDomainContext)
                | +- jbossmq (class: org.jboss.security.plugins.SecurityDomainContext)
                | +- JmsXARealm (class: org.jboss.security.plugins.SecurityDomainContext)
                +- comp.original (class: javax.namingMain.Context)
                +- timedCacheFactory (class: javax.naming.Context)
                Failed to lookup: timedCacheFactory, errmsg=org.jboss.util.TimedCachePolicy
                +- TransactionPropagationContextExporter (class: com.arjuna.ats.internal.jbossatx.jta.PropagationContextManager)
                +- StdJMSPool (class: org.jboss.jms.asf.StdServerSessionPoolFactory)
                +- Mail (class: javax.mail.Session)
                +- comp.ejb3 (class: javax.naming.Context)
                | NonContext: null
                +- TransactionPropagationContextImporter (class: com.arjuna.ats.internal.jbossatx.jta.PropagationContextManager)
                +- TransactionManager (class: com.arjuna.ats.jbossatx.jta.TransactionManagerDelegate)

                I am looking for the object as follows,

                public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response)
                 throws ServletException, IOException {
                
                 logger.info("SpringappController - returning hello view");
                
                 String now = (new java.util.Date()).toString();
                 logger.info("senthil:returning hello view with " + now);
                 Connection con =null;
                 try {
                
                 Context ctx = new InitialContext();
                 Object ds = ctx.lookup("java:OracleDS");
                 System.out.println("Got the object : "+ds);
                
                 //System.out.println("got the data source :"+ds.getClass());
                
                 // con = ds.getConnection();
                
                 if(con!=null){
                 System.out.println("Connected to saba5");
                 }
                
                 } catch (NamingException e) {
                 // TODO Auto-generated catch block
                 //e.printStackTrace();
                 System.out.println(e.getMessage());
                 }finally{
                 if(con!=null){
                 try {
                 con.close();
                 } catch (SQLException e) {
                 // TODO Auto-generated catch block
                 e.printStackTrace();
                 }
                 }
                 }
                
                 Map myModel = new HashMap();
                 myModel.put("now", now);
                 myModel.put("products", getProductManager().getProducts());
                
                 return new ModelAndView("hello", "model", myModel);
                 }
                


                The error that i am getting

                19:36:34,031 ERROR [STDERR] javax.naming.NameNotFoundException: OracleDS not bound
                19:36:34,031 ERROR [STDERR] at org.jnp.server.NamingServer.getBinding(NamingServer.java:529)
                19:36:34,031 ERROR [STDERR] at org.jnp.server.NamingServer.getBinding(NamingServer.java:537)
                19:36:34,031 ERROR [STDERR] at org.jnp.server.NamingServer.getObject(NamingServer.java:543)
                19:36:34,031 ERROR [STDERR] at org.jnp.server.NamingServer.lookup(NamingServer.java:296)
                19:36:34,031 ERROR [STDERR] at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:667)
                19:36:34,031 ERROR [STDERR] at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:627)
                19:36:34,046 ERROR [STDERR] at javax.naming.InitialContext.lookup(InitialContext.java:351)
                19:36:34,046 ERROR [STDERR] at com.pk.controller.SpringappController.handleRequest(SpringappController.java:55)
                19:36:34,046 ERROR [STDERR] at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:48)
                19:36:34,046 ERROR [STDERR] at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:875)
                19:36:34,046 ERROR [STDERR] at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:809)
                19:36:34,046 ERROR [STDERR] at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:523)
                19:36:34,046 ERROR [STDERR] at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:453)
                19:36:34,046 ERROR [STDERR] at javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
                19:36:34,046 ERROR [STDERR] at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
                19:36:34,046 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
                19:36:34,046 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
                19:36:34,046 ERROR [STDERR] at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
                19:36:34,046 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
                19:36:34,046 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
                19:36:34,046 ERROR [STDERR] at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
                19:36:34,046 ERROR [STDERR] at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
                19:36:34,046 ERROR [STDERR] at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
                19:36:34,046 ERROR [STDERR] at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
                19:36:34,046 ERROR [STDERR] at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
                19:36:34,046 ERROR [STDERR] at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
                19:36:34,046 ERROR [STDERR] at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
                19:36:34,046 ERROR [STDERR] at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
                19:36:34,046 ERROR [STDERR] at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
                19:36:34,046 ERROR [STDERR] at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
                19:36:34,046 ERROR [STDERR] at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
                19:36:34,046 ERROR [STDERR] at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
                19:36:34,046 ERROR [STDERR] at java.lang.Thread.run(Thread.java:595)


                Please give your suggestions.
                Thanks,
                Senthil



                • 5. Re: JDNI Lookup - Naming Not Found with JBOSS 4.2.2
                  jaikiran

                  Senthil,

                  Based on the JNDI tree contents and the the jndi-name you are using, i don't see a reason why it should throw a NameNotFoundException. How are you starting JBoss? Do you use the -b option (if yes, what value do you pass)? And is the servlet deployed on the same server as the datasource?

                  • 6. Re: JDNI Lookup - Naming Not Found with JBOSS 4.2.2
                    senthilrajan.nitt

                    Thanks for your reply.

                    I also wondering why it didnt work.

                    To start the jboss server i am just running run.bat & not using any -b option.

                    Yep, the servlet is deployed on server as DS.

                    Let me try once again.

                    Thanks,
                    Senthil

                    • 7. Re: JDNI Lookup - Naming Not Found with JBOSS 4.2.2
                      frankthetank

                      pls try

                      java:/OracleDS
                      


                      That is the way I have it in the jta-data-source tag of my persistence.xml.