3 Replies Latest reply on Jan 9, 2008 6:12 PM by Sara Rodríguez Dorrego

    Could not find datasource: java:/JbpmDS

    Sara Rodríguez Dorrego Novice

      Hello!!!

      I've configuring jbpm to works with mySQL following the steps http://wiki.jboss.org/wiki/Wiki.jsp?page=SetUpMysqlAsDefaultDS


      The configuration was right, but I think the problem is in hibernate.cfg. I changed this file to works with my BD:

      <!-- hibernate dialect -->
       <property name="hibernate.dialect">org.hibernate.dialect.MySQLInnoDBDialect</property>
      
       <property name="hibernate.connection.datasource">java:/JbpmDS</property>
      
       <property name="hibernate.cache.provider_class">org.hibernate.cache.HashtableCacheProvider</property>
       <property name="hibernate.show_sql">true</property>
       <property name="hibernate.format_sql">true</property>
       <property name="hibernate.use_sql_comments">true</property>
      


      But this doesn't work because it's thrown this exception:
      11:34:48,093 [main] INFO NamingHelper : JNDI InitialContext properties:{}
      11:34:48,140 [main] FATAL DatasourceConnectionProvider : Could not find datasource: java:/JbpmDS
      javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
       at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
       at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
       at javax.naming.InitialContext.getURLOrDefaultInitCtx(Unknown Source)
       at javax.naming.InitialContext.lookup(Unknown Source)
       at org.hibernate.connection.DatasourceConnectionProvider.configure(DatasourceConnectionProvider.java:52)
       at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:124)
       at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:56)
       at org.hibernate.cfg.SettingsFactory.createConnectionProvider(SettingsFactory.java:410)
       at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:62)
       at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2009)
       at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1292)
       at org.jbpm.persistence.db.DbPersistenceServiceFactory.getSessionFactory(DbPersistenceServiceFactory.java:91)
       at org.jbpm.persistence.db.DbPersistenceService.getSessionFactory(DbPersistenceService.java:95)
       at org.jbpm.JbpmContext.getSessionFactory(JbpmContext.java:486)
       at org.jbpm.context.exe.matcher.HibernateLongIdMatcher.matches(HibernateLongIdMatcher.java:47)
       at org.jbpm.context.exe.JbpmType.matches(JbpmType.java:53)
       at org.jbpm.context.exe.VariableInstance.createVariableInstance(VariableInstance.java:86)
       at org.jbpm.context.exe.VariableInstance.create(VariableInstance.java:65)
       at org.jbpm.context.exe.VariableContainer.setVariableLocally(VariableContainer.java:173)
       at org.jbpm.context.exe.VariableContainer.setVariable(VariableContainer.java:45)
       at org.jbpm.context.exe.ContextInstance.setVariable(ContextInstance.java:212)
       at org.jbpm.context.exe.ContextInstance.setVariable(ContextInstance.java:202)
       at com.Ejemplo1.action.ExActionHandler.execute(ExActionHandler.java:17)
       at org.jbpm.graph.def.Action.execute(Action.java:122)
       at org.jbpm.graph.def.GraphElement.executeAction(GraphElement.java:264)
       at org.jbpm.graph.def.GraphElement.executeActions(GraphElement.java:220)
       at org.jbpm.graph.def.GraphElement.fireAndPropagateEvent(GraphElement.java:190)
       at org.jbpm.graph.def.GraphElement.fireEvent(GraphElement.java:174)
       at org.jbpm.graph.def.Transition.take(Transition.java:138)
       at org.jbpm.graph.def.Node.leave(Node.java:394)
       at org.jbpm.graph.node.StartState.leave(StartState.java:70)
       at org.jbpm.graph.exe.Token.signal(Token.java:195)
       at org.jbpm.graph.exe.Token.signal(Token.java:140)
       at org.jbpm.graph.exe.ProcessInstance.signal(ProcessInstance.java:271)
       at com.Ejemplo1.Test2.testEjemplo1Process(Test2.java:96)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
       at java.lang.reflect.Method.invoke(Unknown Source)
       at junit.framework.TestCase.runTest(TestCase.java:154)
       at junit.framework.TestCase.runBare(TestCase.java:127)
       at junit.framework.TestResult$1.protect(TestResult.java:106)
       at junit.framework.TestResult.runProtected(TestResult.java:124)
       at junit.framework.TestResult.run(TestResult.java:109)
       at junit.framework.TestCase.run(TestCase.java:118)
       at junit.framework.TestSuite.runTest(TestSuite.java:208)
       at junit.framework.TestSuite.run(TestSuite.java:203)
       at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
       at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
       at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
       at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
       at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
       at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
      11:34:48,140 [main] DEBUG Token : token[0] is unlocked by token[0]
      11:34:48,140 [main] ERROR GraphElement : action threw exception: Could not find datasource
      org.hibernate.HibernateException: Could not find datasource
       at org.hibernate.connection.DatasourceConnectionProvider.configure(DatasourceConnectionProvider.java:56)
       at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:124)
       at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:56)
       at org.hibernate.cfg.SettingsFactory.createConnectionProvider(SettingsFactory.java:410)
       at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:62)
       at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2009)
       at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1292)
       at org.jbpm.persistence.db.DbPersistenceServiceFactory.getSessionFactory(DbPersistenceServiceFactory.java:91)
       at org.jbpm.persistence.db.DbPersistenceService.getSessionFactory(DbPersistenceService.java:95)
       at org.jbpm.JbpmContext.getSessionFactory(JbpmContext.java:486)
       at org.jbpm.context.exe.matcher.HibernateLongIdMatcher.matches(HibernateLongIdMatcher.java:47)
       at org.jbpm.context.exe.JbpmType.matches(JbpmType.java:53)
       at org.jbpm.context.exe.VariableInstance.createVariableInstance(VariableInstance.java:86)
       at org.jbpm.context.exe.VariableInstance.create(VariableInstance.java:65)
       at org.jbpm.context.exe.VariableContainer.setVariableLocally(VariableContainer.java:173)
       at org.jbpm.context.exe.VariableContainer.setVariable(VariableContainer.java:45)
       at org.jbpm.context.exe.ContextInstance.setVariable(ContextInstance.java:212)
       at org.jbpm.context.exe.ContextInstance.setVariable(ContextInstance.java:202)
       at com.Ejemplo1.action.ExActionHandler.execute(ExActionHandler.java:17)
       at org.jbpm.graph.def.Action.execute(Action.java:122)
       at org.jbpm.graph.def.GraphElement.executeAction(GraphElement.java:264)
       at org.jbpm.graph.def.GraphElement.executeActions(GraphElement.java:220)
       at org.jbpm.graph.def.GraphElement.fireAndPropagateEvent(GraphElement.java:190)
       at org.jbpm.graph.def.GraphElement.fireEvent(GraphElement.java:174)
       at org.jbpm.graph.def.Transition.take(Transition.java:138)
       at org.jbpm.graph.def.Node.leave(Node.java:394)
       at org.jbpm.graph.node.StartState.leave(StartState.java:70)
       at org.jbpm.graph.exe.Token.signal(Token.java:195)
       at org.jbpm.graph.exe.Token.signal(Token.java:140)
       at org.jbpm.graph.exe.ProcessInstance.signal(ProcessInstance.java:271)
       at com.Ejemplo1.Test2.testEjemplo1Process(Test2.java:96)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
       at java.lang.reflect.Method.invoke(Unknown Source)
       at junit.framework.TestCase.runTest(TestCase.java:154)
       at junit.framework.TestCase.runBare(TestCase.java:127)
       at junit.framework.TestResult$1.protect(TestResult.java:106)
       at junit.framework.TestResult.runProtected(TestResult.java:124)
       at junit.framework.TestResult.run(TestResult.java:109)
       at junit.framework.TestCase.run(TestCase.java:118)
       at junit.framework.TestSuite.runTest(TestSuite.java:208)
       at junit.framework.TestSuite.run(TestSuite.java:203)
       at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
       at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
       at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
       at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
       at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
       at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
      Caused by: javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
       at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
       at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
       at javax.naming.InitialContext.getURLOrDefaultInitCtx(Unknown Source)
       at javax.naming.InitialContext.lookup(Unknown Source)
       at org.hibernate.connection.DatasourceConnectionProvider.configure(DatasourceConnectionProvider.java:52)
       ... 48 more
      



      I have the jbpm-ds in the deploy directory. Any ideas to solucionate this?

      Thank you in advance,

      Regards

        • 1. Re: Could not find datasource: java:/JbpmDS
          Ronald van Kuijk Master

          look at the last 'caused by' and also look in the jndi tree to see if the ds is realy there and under which name

          • 2. Re: Could not find datasource: java:/JbpmDS
            Sara Rodríguez Dorrego Novice

            Sorry! How can I do that?

             Context ctx = new InitialContext();
            
             Hashtable<String, String> env;
             env = new Hashtable<String, String>();
             env.put("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
             env.put("java.naming.factory.url.pkgs","org.jboss.naming:org.jn.interfaces");
             env.put("java.naming.provider.url","jnp://localhost:1099");
             ctx = new InitialContext(env);
            
             NamingEnumeration list = ctx.list("");
            
             while (list.hasMore()) {
             NameClassPair nc = (NameClassPair) list.next();
            
             System.out.println(nc);


            And the result of that is:
            TopicConnectionFactory: org.jboss.naming.LinkRefPair
            jmx: org.jnp.interfaces.NamingContext
            HTTPXAConnectionFactory: org.jboss.mq.SpyXAConnectionFactory
            ConnectionFactory: org.jboss.mq.SpyConnectionFactory
            UserTransactionSessionFactory: $Proxy12
            HTTPConnectionFactory: org.jboss.mq.SpyConnectionFactory
            XAConnectionFactory: org.jboss.mq.SpyXAConnectionFactory
            UserTransaction: org.jboss.tm.usertx.client.ClientUserTransaction
            UILXAConnectionFactory: javax.naming.LinkRef
            UIL2XAConnectionFactory: javax.naming.LinkRef
            queue: org.jnp.interfaces.NamingContext
            console: org.jnp.interfaces.NamingContext
            UIL2ConnectionFactory: javax.naming.LinkRef
            HiLoKeyGeneratorFactory: org.jboss.ejb.plugins.keygenerator.hilo.HiLoKeyGeneratorFactory
            UILConnectionFactory: javax.naming.LinkRef
            EventDispatcher: org.jboss.ws.eventing.mgmt.DispatcherDelegate
            QueueConnectionFactory: org.jboss.naming.LinkRefPair


            But ... I don't know exacty do what you are telling me. Could you tell me how I could do that?

            Thanks a lot!

            • 3. Re: Could not find datasource: java:/JbpmDS
              Sara Rodríguez Dorrego Novice

              It's solucionated!

              The problem was that I was modifying the wrong hibernate.cfg file. I changed the one which is inside jbpm-console.war and the problem disappeared ;)