5 Replies Latest reply on Jul 19, 2012 5:00 AM by mukulgoel

    javax.naming.NameNotFoundException

    mukulgoel

      I am using JBOSS AS7.2 alpha

       

       

      i am getting couldnotfind datasource exception. if any other information is required please letme know

       

       

       

       

       

      following is the stack trace

       

       

      17:46:03,960 ERROR [stderr] (http-localhost/127.0.0.1:8080-4) org.hibernate.HibernateException: Could not find datasource

       

       

      17:46:03,960 ERROR [stderr] (http-localhost/127.0.0.1:8080-4)           at org.hibernate.connection.DatasourceConnectionProvider.configure(DatasourceConnectionProvider.java:79)

       

       

      17:46:03,960 ERROR [stderr] (http-localhost/127.0.0.1:8080-4)           at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:137)

       

       

      17:46:03,960 ERROR [stderr] (http-localhost/127.0.0.1:8080-4)           at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:79)

       

       

      17:46:03,960 ERROR [stderr] (http-localhost/127.0.0.1:8080-4)           at org.hibernate.cfg.SettingsFactory.createConnectionProvider(SettingsFactory.java:448)

       

       

      17:46:03,960 ERROR [stderr] (http-localhost/127.0.0.1:8080-4)           at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:89)

       

       

      17:46:03,960 ERROR [stderr] (http-localhost/127.0.0.1:8080-4)           at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2101)

       

       

      17:46:03,960 ERROR [stderr] (http-localhost/127.0.0.1:8080-4)           at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1325)

       

       

      17:46:03,960 ERROR [stderr] (http-localhost/127.0.0.1:8080-4)           at com.csc.fs.session.hibernate.HibernateUtil.<clinit>(HibernateUtil.java:38)

       

       

      17:46:03,960 ERROR [stderr] (http-localhost/127.0.0.1:8080-4)           at com.csc.fs.session.SessionPersisterHibernate.<clinit>(SessionPersisterHibernate.java:69)

       

       

      17:46:03,960 ERROR [stderr] (http-localhost/127.0.0.1:8080-4)           at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

       

       

      17:46:03,960 ERROR [stderr] (http-localhost/127.0.0.1:8080-4)           at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)

       

       

      17:46:03,960 ERROR [stderr] (http-localhost/127.0.0.1:8080-4)           at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)

       

       

      17:46:03,960 ERROR [stderr] (http-localhost/127.0.0.1:8080-4)           at java.lang.reflect.Constructor.newInstance(Unknown Source)

       

       

      17:46:03,960 ERROR [stderr] (http-localhost/127.0.0.1:8080-4)           at java.lang.Class.newInstance0(Unknown Source)

       

       

      17:46:03,960 ERROR [stderr] (http-localhost/127.0.0.1:8080-4)           at java.lang.Class.newInstance(Unknown Source)

       

       

      17:46:03,960 ERROR [stderr] (http-localhost/127.0.0.1:8080-4)           at com.csc.fs.svcloc.ServiceLocatorConfiguration$Entry.resolveInstance(ServiceLocatorConfiguration.java:448)

       

       

      17:46:03,961 ERROR [stderr] (http-localhost/127.0.0.1:8080-4)           at com.csc.fs.svcloc.Locator$StandardLocationImpl.request(Locator.java:710)

       

       

      17:46:03,961 ERROR [stderr] (http-localhost/127.0.0.1:8080-4)           at com.csc.fs.svcloc.Locator$StandardLocationImpl.lookup(Locator.java:496)

       

       

      17:46:03,961 ERROR [stderr] (http-localhost/127.0.0.1:8080-4)           at com.csc.fs.svcloc.ServiceLocator.lookup(ServiceLocator.java:151)

       

       

      17:46:03,961 ERROR [stderr] (http-localhost/127.0.0.1:8080-4)           at com.csc.fs.session.UserSessionControllerImpl.initializePM(UserSessionControllerImpl.java:655)

       

       

      17:46:03,961 ERROR [stderr] (http-localhost/127.0.0.1:8080-4)           at com.csc.fs.session.UserSessionControllerImpl.create(UserSessionControllerImpl.java:457)

       

       

      17:46:03,961 ERROR [stderr] (http-localhost/127.0.0.1:8080-4)           at com.csc.fs.session.UserSessionControllerFactory.create(UserSessionControllerFactory.java:43)

       

       

      17:46:03,961 ERROR [stderr] (http-localhost/127.0.0.1:8080-4)           at com.csc.fs.service.ServiceControllerAbstract.logon(ServiceControllerAbstract.java:382)

       

       

      17:46:03,961 ERROR [stderr] (http-localhost/127.0.0.1:8080-4)           at com.csc.fs.delegate.DirectServiceController.logon(DirectServiceController.java:132)

       

       

      17:46:03,961 ERROR [stderr] (http-localhost/127.0.0.1:8080-4)           at com.csc.fs.delegate.ServiceDelegateDirect.logon(ServiceDelegateDirect.java:133)

       

       

      17:46:03,961 ERROR [stderr] (http-localhost/127.0.0.1:8080-4)           at com.csc.fs.accel.ui.BaseServiceAction.logon(BaseServiceAction.java:124)

       

       

      17:46:03,961 ERROR [stderr] (http-localhost/127.0.0.1:8080-4)           at com.csc.fs.accel.ui.action.desktop.Logon.perform(Logon.java:47)

       

       

      17:46:03,961 ERROR [stderr] (http-localhost/127.0.0.1:8080-4)           at com.csc.fs.accel.ui.ServiceDelegator.execute(ServiceDelegator.java:506)

       

       

      17:46:03,961 ERROR [stderr] (http-localhost/127.0.0.1:8080-4)           at com.csc.fs.accel.ui.ServiceDelegator.processEvent(ServiceDelegator.java:240)

       

       

      17:46:03,961 ERROR [stderr] (http-localhost/127.0.0.1:8080-4)           at com.csc.fs.accel.ui.BeanBase.executeEvent(BeanBase.java:779)

       

       

      17:46:03,961 ERROR [stderr] (http-localhost/127.0.0.1:8080-4)           at pagecode.authorization.Logon.submit(Logon.java:66)

       

       

      17:46:03,961 ERROR [stderr] (http-localhost/127.0.0.1:8080-4)           at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

       

       

      17:46:03,961 ERROR [stderr] (http-localhost/127.0.0.1:8080-4)           at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

       

       

      17:46:03,962 ERROR [stderr] (http-localhost/127.0.0.1:8080-4)           at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

       

       

      17:46:03,962 ERROR [stderr] (http-localhost/127.0.0.1:8080-4)           at java.lang.reflect.Method.invoke(Unknown Source)

       

       

      17:46:03,962 ERROR [stderr] (http-localhost/127.0.0.1:8080-4)           at org.apache.el.parser.AstValue.invoke(AstValue.java:264)

       

       

      17:46:03,962 ERROR [stderr] (http-localhost/127.0.0.1:8080-4)           at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:278)

       

       

      17:46:03,962 ERROR [stderr] (http-localhost/127.0.0.1:8080-4)           at org.apache.jasper.el.JspMethodExpression.invoke(JspMethodExpression.java:68)

       

       

      17:46:03,962 ERROR [stderr] (http-localhost/127.0.0.1:8080-4)           at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:88)

       

       

      17:46:03,962 ERROR [stderr] (http-localhost/127.0.0.1:8080-4)           at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)

       

       

      17:46:03,962 ERROR [stderr] (http-localhost/127.0.0.1:8080-4)           at javax.faces.component.UICommand.broadcast(UICommand.java:315)

       

       

      17:46:03,962 ERROR [stderr] (http-localhost/127.0.0.1:8080-4)           at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:794)

       

       

      17:46:03,962 ERROR [stderr] (http-localhost/127.0.0.1:8080-4)           at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1259)

       

       

      17:46:03,962 ERROR [stderr] (http-localhost/127.0.0.1:8080-4)           at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81)

       

       

      17:46:03,962 ERROR [stderr] (http-localhost/127.0.0.1:8080-4)           at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)

       

       

      17:46:03,962 ERROR [stderr] (http-localhost/127.0.0.1:8080-4)           at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)

       

       

      17:46:03,962 ERROR [stderr] (http-localhost/127.0.0.1:8080-4)           at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593)

       

       

      17:46:03,962 ERROR [stderr] (http-localhost/127.0.0.1:8080-4)           at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329)

       

       

      17:46:03,962 ERROR [stderr] (http-localhost/127.0.0.1:8080-4)           at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)

       

       

      17:46:03,962 ERROR [stderr] (http-localhost/127.0.0.1:8080-4)           at com.csc.fs.accel.ui.filters.ResponseHeaderFilter.doFilter(ResponseHeaderFilter.java:82)

       

       

      17:46:03,962 ERROR [stderr] (http-localhost/127.0.0.1:8080-4)           at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280)

       

       

      17:46:03,963 ERROR [stderr] (http-localhost/127.0.0.1:8080-4)           at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)

       

       

      17:46:03,963 ERROR [stderr] (http-localhost/127.0.0.1:8080-4)           at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275)

       

       

      17:46:03,963 ERROR [stderr] (http-localhost/127.0.0.1:8080-4)           at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161)

       

       

      17:46:03,963 ERROR [stderr] (http-localhost/127.0.0.1:8080-4)           at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:489)

       

       

      17:46:03,963 ERROR [stderr] (http-localhost/127.0.0.1:8080-4)           at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:153)

       

       

      17:46:03,963 ERROR [stderr] (http-localhost/127.0.0.1:8080-4)           at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155)

       

       

      17:46:03,963 ERROR [stderr] (http-localhost/127.0.0.1:8080-4)           at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)

       

       

      17:46:03,963 ERROR [stderr] (http-localhost/127.0.0.1:8080-4)           at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)

       

       

      17:46:03,963 ERROR [stderr] (http-localhost/127.0.0.1:8080-4)           at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:368)

       

       

      17:46:03,963 ERROR [stderr] (http-localhost/127.0.0.1:8080-4)           at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877)

       

       

      17:46:03,963 ERROR [stderr] (http-localhost/127.0.0.1:8080-4)           at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:679)

       

       

      17:46:03,963 ERROR [stderr] (http-localhost/127.0.0.1:8080-4)           at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:931)

       

       

      17:46:03,963 ERROR [stderr] (http-localhost/127.0.0.1:8080-4)           at java.lang.Thread.run(Unknown Source)

       

       

      17:46:03,963 ERROR [stderr] (http-localhost/127.0.0.1:8080-4) Caused by: javax.naming.NameNotFoundException: datasources/FSCDS -- service jboss.naming.context.java.jboss.datasources.FSCDS

       

       

      17:46:03,963 ERROR [stderr] (http-localhost/127.0.0.1:8080-4)           at org.jboss.as.naming.ServiceBasedNamingStore.lookup(ServiceBasedNamingStore.java:97)

       

       

      17:46:03,963 ERROR [stderr] (http-localhost/127.0.0.1:8080-4)           at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:178)

       

       

      17:46:03,963 ERROR [stderr] (http-localhost/127.0.0.1:8080-4)           at org.jboss.as.naming.InitialContext.lookup(InitialContext.java:129)

       

       

      17:46:03,963 ERROR [stderr] (http-localhost/127.0.0.1:8080-4)           at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:214)

       

       

      17:46:03,963 ERROR [stderr] (http-localhost/127.0.0.1:8080-4)           at javax.naming.InitialContext.lookup(Unknown Source)

       

       

      17:46:03,964 ERROR [stderr] (http-localhost/127.0.0.1:8080-4)           at org.hibernate.connection.DatasourceConnectionProvider.configure(DatasourceConnectionProvider.java:75)

       

       

      17:46:03,964 ERROR [stderr] (http-localhost/127.0.0.1:8080-4)           ... 63 more

       

       

       

       

       

       

       

       

       

      i am attaching my standalone.xml , please assist why is the following error..

        • 1. Re: javax.naming.NameNotFoundException
          mukulgoel

          THE ABOVE TRACE HAPPENS WHEN I DONT HAVE ANYTHING IN  Jboss-web.xml

           

           

          when i write

           

          <resource-ref>

                  <res-ref-name>jdbc/FSCDS</res-ref-name>

                  <res-type>javax.sql.DataSource</res-type>

                  <jndi-name>java:jboss/datasources/FSCDS</jndi-name>

          </resource-ref>

           

           

          in jboss-web.xml.. anduse jdbc/FSCDS inside code. i get following trace with an error

           

          the trace is long so attaching it

          • 2. Re: javax.naming.NameNotFoundException
            sfcoy

            It looks like the configured datasource name in your application is java:jboss/datasources/FSCDS.

             

            Your configuration file contains three data source definitions:

            1. java:jboss/datasources/ExampleDS
            2. java:/ CLIENTDS
            3. java:/ FSCDS

             

            Note the spaces in the second two. I'm not sure that they are even legal JNDI names. Are there any other errors in your server.log?

             

            In any event, none of these three names matches what your code is looking for.

            • 3. Re: javax.naming.NameNotFoundException
              mukulgoel

              hi,

               

              in the standalone.xml , i removed that space between the java:/CLIENTDS. in the application everywhere i am now using java:/CLIENTDS and java:/FSCDS removed everything from JBOSS-web.xml and web.xml regarding the <resource-ref> tags..

               

              but in console i am getting

               

               

              Caused by: org.hibernate.HibernateException: Could not find datasource

               

               

              18:34:29,509 ERROR [stderr] (http-localhost/127.0.0.1:8080-1)           at org.hibernate.connection.DatasourceConnectionProvider.configure(DatasourceConnectionProvider.java:79)

               

               

              18:34:29,510 ERROR [stderr] (http-localhost/127.0.0.1:8080-1)           at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:137)

               

               

              18:34:29,510 ERROR [stderr] (http-localhost/127.0.0.1:8080-1)           at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:79)

               

               

              18:34:29,510 ERROR [stderr] (http-localhost/127.0.0.1:8080-1)           at org.hibernate.cfg.SettingsFactory.createConnectionProvider(SettingsFactory.java:448)

               

               

              18:34:29,510 ERROR [stderr] (http-localhost/127.0.0.1:8080-1)           at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:89)

               

               

              18:34:29,510 ERROR [stderr] (http-localhost/127.0.0.1:8080-1)           at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2101)

               

               

              18:34:29,510 ERROR [stderr] (http-localhost/127.0.0.1:8080-1)           at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1325)

               

               

              18:34:29,510 ERROR [stderr] (http-localhost/127.0.0.1:8080-1)           at com.csc.fs.session.hibernate.HibernateUtil.<clinit>(HibernateUtil.java:38)

               

               

              18:34:29,510 ERROR [stderr] (http-localhost/127.0.0.1:8080-1)           ... 56 more

               

               

              18:34:29,510 ERROR [stderr] (http-localhost/127.0.0.1:8080-1) Caused by: javax.naming.NameNotFoundException: jdbc:/FSCDS -- service jboss.naming.context.java.jdbc:.FSCDS

               

               

              18:34:29,510 ERROR [stderr] (http-localhost/127.0.0.1:8080-1)           at org.jboss.as.naming.ServiceBasedNamingStore.lookup(ServiceBasedNamingStore.java:97)

               

               

              18:34:29,510 ERROR [stderr] (http-localhost/127.0.0.1:8080-1)           at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:178)

               

               

              18:34:29,510 ERROR [stderr] (http-localhost/127.0.0.1:8080-1)           at org.jboss.as.naming.InitialContext.lookup(InitialContext.java:119)

               

               

              18:34:29,510 ERROR [stderr] (http-localhost/127.0.0.1:8080-1)           at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:214)

               

               

              18:34:29,510 ERROR [stderr] (http-localhost/127.0.0.1:8080-1)           at javax.naming.InitialContext.lookup(Unknown Source)

               

               

              18:34:29,510 ERROR [stderr] (http-localhost/127.0.0.1:8080-1)           at org.hibernate.connection.DatasourceConnectionProvider.configure(DatasourceConnectionProvider.java:75)

               

               

              18:34:29,511 ERROR [stderr] (http-localhost/127.0.0.1:8080-1)           ... 63 more

              • 4. Re: javax.naming.NameNotFoundException
                mukulgoel

                i guess this could be some helpful information ..

                 

                 

                this is how i am trying to access the datasource FSCDS

                 

                 

                 

                 

                or.datasource=jdbc:/FSCDS

                or.dbdriver=COM.ibm.db2.jdbc.app.DB2Driver

                or.dburl=jdbc:db2:FSCCSD

                or.dbuserid=

                or.dbpwd=

                attrdef.schema=FSCATTR

                or.contextfactory=org.jnp.interfaces.NamingContextFactory

                or.providerurl=jnp://localhost:1099

                 

                 

                attrdef.datasource=jdbc:/FSCDS

                attrdef.dbdriver=COM.ibm.db2.jdbc.app.DB2Driver

                attrdef.dburl=jdbc:db2:FSCCSD

                attrdef.dbuserid=

                attrdef.dbpwd=

                attrdef.contextfactory=org.jnp.interfaces.NamingContextFactory

                attrdef.providerurl=jnp://localhost:1099

                 

                 

                auditor.datasource=jdbc:/FSCDS

                auditor.dbdriver=COM.ibm.db2.jdbc.app.DB2Driver

                auditor.dburl=jdbc:db2:FSCCSD

                auditor.dbuserid=

                auditor.dbpwd=

                auditor.schema=AUDIT

                auditor.contextfactory=org.jnp.interfaces.NamingContextFactory

                auditor.providerurl=jnp://localhost:1099

                 

                 

                sess.datasource=jdbc:/FSCDS

                sess.dbdriver=COM.ibm.db2.jdbc.app.DB2Driver

                sess.dburl=jdbc:db2:FSCCSD

                sess.dbuserid=

                sess.dbpwd=

                sess.schema=SESSION

                sess.contextfactory=org.jnp.interfaces.NamingContextFactory

                sess.providerurl=jnp://localhost:1099

                • 5. Re: javax.naming.NameNotFoundException
                  mukulgoel

                  hey stephen,

                   

                  thanks for your quick reply on that one.. but i found the error and resolved it.. thanks by the way. .

                   

                  the error was because of incorrect use of JNDI names. thanks for all the help

                   

                   

                  regards

                  mukul

                   

                  Message was edited by: mukul goel