0 Replies Latest reply on Feb 17, 2012 8:48 AM by David C

    Persistence for jbpm5 in Tomcat 7 problem

    David C Newbie

      Hi

       

      I've previously managed to setup jbpm 5 with persistence in a J2SE application but I'm now trying to convert and deploy my app as a servlet on a tomcat. I'm using Eclipse dynamic web project to create the servlet.

       

      My problem is that tomcat can't seem to find my "datasource: jdbc/testDS1". I've followed the user guide's instruction on persistence.xml etc (works in J2SE mode). I'm suspecting that I've misconfigured Tomcat somewhere.

       

      This is the error I get:

       

      2012-02-17 13:40:48,914 57220 [http-bio-8080-exec-3] ERROR org.hibernate.connection.DatasourceConnectionProvider  - Could not find datasource: jdbc/testDS1
      javax.naming.NameNotFoundException: Name jdbc is not bound in this Context
                at org.apache.naming.NamingContext.lookup(NamingContext.java:820)
                at org.apache.naming.NamingContext.lookup(NamingContext.java:168)
                at org.apache.naming.SelectorContext.lookup(SelectorContext.java:158)
                at javax.naming.InitialContext.lookup(InitialContext.java:392)
                at org.hibernate.connection.DatasourceConnectionProvider.configure(DatasourceConnectionProvider.java:75)
                at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:143)
                at org.hibernate.ejb.InjectionSettingsFactory.createConnectionProvider(InjectionSettingsFactory.java:51)
                at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:90)
                at org.hibernate.cfg.Configuration.buildSettingsInternal(Configuration.java:2863)
                at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2859)
                at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1870)
                at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:906)
                at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:57)
                at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:48)
                at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:32)
                at ac.uk.ucl.css.AHECore.Workflow.WorkflowAPI.createKnowledgeSession(WorkflowAPI.java:523)
                at ac.uk.ucl.css.AHECore.Workflow.WorkflowAPI.getKnowledgeSession(WorkflowAPI.java:613)
                at ac.uk.ucl.css.AHECore.Workflow.WorkflowAPI.createWorkflow(WorkflowAPI.java:425)
                at ac.uk.ucl.css.AHECore.Engine.AHEEngine.startWorkflow(AHEEngine.java:903)
                at ac.uk.ucl.css.AHECore.API.AHE_API.Prepare(AHE_API.java:151)
                at ac.uk.ucl.css.AHECore.API.Rest.UserCommandResource.PrepareCommands(UserCommandResource.java:534)
                at ac.uk.ucl.css.AHECore.API.Rest.UserCommandResource.post_FORM_PrepareCommands(UserCommandResource.java:488)
                at ac.uk.ucl.css.AHECore.API.Rest.UserCommandResource.post_FORM_Parser(UserCommandResource.java:156)
                at ac.uk.ucl.css.AHECore.API.Rest.UserCommandResource.postResource(UserCommandResource.java:1122)
                at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                at java.lang.reflect.Method.invoke(Method.java:597)
                at org.restlet.resource.ServerResource.doHandle(ServerResource.java:446)
                at org.restlet.resource.ServerResource.post(ServerResource.java:1111)
                at org.restlet.resource.ServerResource.doHandle(ServerResource.java:530)
                at org.restlet.resource.ServerResource.doNegotiatedHandle(ServerResource.java:587)
                at org.restlet.resource.ServerResource.doConditionalHandle(ServerResource.java:299)
                at org.restlet.resource.ServerResource.handle(ServerResource.java:846)
                at org.restlet.resource.Finder.handle(Finder.java:510)
                at org.restlet.routing.Filter.doHandle(Filter.java:156)
                at org.restlet.routing.Filter.handle(Filter.java:203)
                at org.restlet.routing.Router.doHandle(Router.java:497)
                at org.restlet.routing.Router.handle(Router.java:737)
                at org.restlet.routing.Filter.doHandle(Filter.java:156)
                at org.restlet.routing.Filter.handle(Filter.java:203)
                at org.restlet.routing.Filter.doHandle(Filter.java:156)
                at org.restlet.routing.Filter.handle(Filter.java:203)
                at org.restlet.routing.Filter.doHandle(Filter.java:156)
                at org.restlet.routing.Filter.handle(Filter.java:203)
                at org.restlet.routing.Filter.doHandle(Filter.java:156)
                at org.restlet.engine.application.StatusFilter.doHandle(StatusFilter.java:151)
                at org.restlet.routing.Filter.handle(Filter.java:203)
                at org.restlet.routing.Filter.doHandle(Filter.java:156)
                at org.restlet.routing.Filter.handle(Filter.java:203)
                at org.restlet.engine.ChainHelper.handle(ChainHelper.java:111)
                at org.restlet.engine.application.ApplicationHelper.handle(ApplicationHelper.java:72)
                at org.restlet.Application.handle(Application.java:388)
                at org.restlet.routing.Filter.doHandle(Filter.java:156)
                at org.restlet.routing.Filter.handle(Filter.java:203)
                at org.restlet.routing.Router.doHandle(Router.java:497)
                at org.restlet.routing.Router.handle(Router.java:737)
                at org.restlet.routing.Filter.doHandle(Filter.java:156)
                at org.restlet.routing.Filter.handle(Filter.java:203)
                at org.restlet.routing.Router.doHandle(Router.java:497)
                at org.restlet.routing.Router.handle(Router.java:737)
                at org.restlet.routing.Filter.doHandle(Filter.java:156)
                at org.restlet.routing.Filter.handle(Filter.java:203)
                at org.restlet.engine.ChainHelper.handle(ChainHelper.java:111)
                at org.restlet.Component.handle(Component.java:388)
                at org.restlet.Server.handle(Server.java:488)
                at org.restlet.engine.ServerHelper.handle(ServerHelper.java:71)
                at org.restlet.engine.http.HttpServerHelper.handle(HttpServerHelper.java:150)
                at org.restlet.ext.servlet.ServerServlet.service(ServerServlet.java:1037)
                at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
                at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
                at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
                at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:224)
                at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169)
                at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
                at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
                at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
                at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:928)
                at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
                at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
                at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:987)
                at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:539)
                at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:298)
                at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
                at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
                at java.lang.Thread.run(Thread.java:662)
      javax.persistence.PersistenceException: [PersistenceUnit: org.jbpm.persistence.jpa] Unable to build EntityManagerFactory
                at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:915)
                at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:57)
                at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:48)
                at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:32)
                at ac.uk.ucl.css.AHECore.Workflow.WorkflowAPI.createKnowledgeSession(WorkflowAPI.java:523)
                at ac.uk.ucl.css.AHECore.Workflow.WorkflowAPI.getKnowledgeSession(WorkflowAPI.java:613)
                at ac.uk.ucl.css.AHECore.Workflow.WorkflowAPI.createWorkflow(WorkflowAPI.java:425)
                at ac.uk.ucl.css.AHECore.Engine.AHEEngine.startWorkflow(AHEEngine.java:903)
                at ac.uk.ucl.css.AHECore.API.AHE_API.Prepare(AHE_API.java:151)
                at ac.uk.ucl.css.AHECore.API.Rest.UserCommandResource.PrepareCommands(UserCommandResource.java:534)
                at ac.uk.ucl.css.AHECore.API.Rest.UserCommandResource.post_FORM_PrepareCommands(UserCommandResource.java:488)
                at ac.uk.ucl.css.AHECore.API.Rest.UserCommandResource.post_FORM_Parser(UserCommandResource.java:156)
                at ac.uk.ucl.css.AHECore.API.Rest.UserCommandResource.postResource(UserCommandResource.java:1122)
                at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                at java.lang.reflect.Method.invoke(Method.java:597)
                at org.restlet.resource.ServerResource.doHandle(ServerResource.java:446)
                at org.restlet.resource.ServerResource.post(ServerResource.java:1111)
                at org.restlet.resource.ServerResource.doHandle(ServerResource.java:530)
                at org.restlet.resource.ServerResource.doNegotiatedHandle(ServerResource.java:587)
                at org.restlet.resource.ServerResource.doConditionalHandle(ServerResource.java:299)
                at org.restlet.resource.ServerResource.handle(ServerResource.java:846)
                at org.restlet.resource.Finder.handle(Finder.java:510)
                at org.restlet.routing.Filter.doHandle(Filter.java:156)
                at org.restlet.routing.Filter.handle(Filter.java:203)
                at org.restlet.routing.Router.doHandle(Router.java:497)
                at org.restlet.routing.Router.handle(Router.java:737)
                at org.restlet.routing.Filter.doHandle(Filter.java:156)
                at org.restlet.routing.Filter.handle(Filter.java:203)
                at org.restlet.routing.Filter.doHandle(Filter.java:156)
                at org.restlet.routing.Filter.handle(Filter.java:203)
                at org.restlet.routing.Filter.doHandle(Filter.java:156)
                at org.restlet.routing.Filter.handle(Filter.java:203)
                at org.restlet.routing.Filter.doHandle(Filter.java:156)
                at org.restlet.engine.application.StatusFilter.doHandle(StatusFilter.java:151)
                at org.restlet.routing.Filter.handle(Filter.java:203)
                at org.restlet.routing.Filter.doHandle(Filter.java:156)
                at org.restlet.routing.Filter.handle(Filter.java:203)
                at org.restlet.engine.ChainHelper.handle(ChainHelper.java:111)
                at org.restlet.engine.application.ApplicationHelper.handle(ApplicationHelper.java:72)
                at org.restlet.Application.handle(Application.java:388)
                at org.restlet.routing.Filter.doHandle(Filter.java:156)
                at org.restlet.routing.Filter.handle(Filter.java:203)
                at org.restlet.routing.Router.doHandle(Router.java:497)
                at org.restlet.routing.Router.handle(Router.java:737)
                at org.restlet.routing.Filter.doHandle(Filter.java:156)
                at org.restlet.routing.Filter.handle(Filter.java:203)
                at org.restlet.routing.Router.doHandle(Router.java:497)
                at org.restlet.routing.Router.handle(Router.java:737)
                at org.restlet.routing.Filter.doHandle(Filter.java:156)
                at org.restlet.routing.Filter.handle(Filter.java:203)
                at org.restlet.engine.ChainHelper.handle(ChainHelper.java:111)
                at org.restlet.Component.handle(Component.java:388)
                at org.restlet.Server.handle(Server.java:488)
                at org.restlet.engine.ServerHelper.handle(ServerHelper.java:71)
                at org.restlet.engine.http.HttpServerHelper.handle(HttpServerHelper.java:150)
                at org.restlet.ext.servlet.ServerServlet.service(ServerServlet.java:1037)
                at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
                at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
                at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
                at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:224)
                at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169)
                at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
                at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
                at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
                at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:928)
                at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
                at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
                at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:987)
                at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:539)
                at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:298)
                at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
                at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
                at java.lang.Thread.run(Thread.java:662)
      Caused by: org.hibernate.HibernateException: Could not find datasource
                at org.hibernate.connection.DatasourceConnectionProvider.configure(DatasourceConnectionProvider.java:79)
                at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:143)
                at org.hibernate.ejb.InjectionSettingsFactory.createConnectionProvider(InjectionSettingsFactory.java:51)
                at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:90)
                at org.hibernate.cfg.Configuration.buildSettingsInternal(Configuration.java:2863)
                at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2859)
                at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1870)
                at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:906)
                ... 74 more
      Caused by: javax.naming.NameNotFoundException: Name jdbc is not bound in this Context
                at org.apache.naming.NamingContext.lookup(NamingContext.java:820)
                at org.apache.naming.NamingContext.lookup(NamingContext.java:168)
                at org.apache.naming.SelectorContext.lookup(SelectorContext.java:158)
                at javax.naming.InitialContext.lookup(InitialContext.java:392)
                at org.hibernate.connection.DatasourceConnectionProvider.configure(DatasourceConnectionProvider.java:75)
                ... 81 more
      

       

      This is my persistence.xml

       

      <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
      <persistence version="1.0" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd
      http://java.sun.com/xml/ns/persistence/orm http://java.sun.com/xml/ns/persistence/orm_1_0.xsd" xmlns:orm="http://java.sun.com/xml/ns/persistence/orm" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/persistence">
          <persistence-unit name="org.jbpm.persistence.jpa" transaction-type="JTA">
      
      
              <provider>org.hibernate.ejb.HibernatePersistence</provider>
      
      
      
              <jta-data-source>jdbc/testDS1</jta-data-source>
                          <mapping-file>META-INF/orm.xml</mapping-file>
              <class>org.drools.persistence.info.SessionInfo</class>
              <class>org.jbpm.persistence.processinstance.ProcessInstanceInfo</class>
              <class>org.jbpm.persistence.processinstance.ProcessInstanceEventInfo</class>
              <class>org.drools.persistence.info.WorkItemInfo</class>
              <class>org.jbpm.process.audit.ProcessInstanceLog</class>
              <class>org.jbpm.process.audit.NodeInstanceLog</class>
              <class>org.jbpm.process.audit.VariableInstanceLog</class>       
      
              <class>org.jbpm.task.Task</class>
                          <class>org.jbpm.task.Comment</class>
                          <class>org.jbpm.task.Attachment</class>
                          <class>org.jbpm.task.I18NText</class>
                          <class>org.jbpm.task.SubTasksStrategy</class>
                          <class>org.jbpm.task.Deadline</class>
                          <class>org.jbpm.task.Escalation</class>
                          <class>org.jbpm.task.Reassignment</class>
                          <class>org.jbpm.task.Notification</class>
                          <class>org.jbpm.task.BooleanExpression</class>
                          <class>org.jbpm.task.User</class>
                          <class>org.jbpm.task.PeopleAssignments</class>
              <properties>
      
      
      
                  <property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5InnoDBDialect"/>
                  <property name="hibernate.connection.autocommit" value="false"/>
                  <property name="hibernate.max_fetch_depth" value="3"/>
      
      
                  <property name="hibernate.hbm2ddl.auto" value="update" />
                  <property name="hibernate.show_sql" value="true" />
                  <property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.BTMTransactionManagerLookup"/>
      
      
              </properties>
      
      
          </persistence-unit>
          <persistence-unit name="org.jbpm.task">
              <provider>org.hibernate.ejb.HibernatePersistence</provider>
      
              <class>org.jbpm.task.Attachment</class>
              <class>org.jbpm.task.Content</class>
              <class>org.jbpm.task.BooleanExpression</class>
              <class>org.jbpm.task.Comment</class>
              <class>org.jbpm.task.Deadline</class>
              <class>org.jbpm.task.Comment</class>
              <class>org.jbpm.task.Deadline</class>
              <class>org.jbpm.task.Delegation</class>
              <class>org.jbpm.task.Escalation</class>
              <class>org.jbpm.task.Group</class>
              <class>org.jbpm.task.I18NText</class>
              <class>org.jbpm.task.Notification</class>
              <class>org.jbpm.task.EmailNotification</class>
              <class>org.jbpm.task.EmailNotificationHeader</class>
              <class>org.jbpm.task.PeopleAssignments</class>
              <class>org.jbpm.task.Reassignment</class>
              <class>org.jbpm.task.Status</class>
              <class>org.jbpm.task.Task</class>
              <class>org.jbpm.task.TaskData</class>
              <class>org.jbpm.task.SubTasksStrategy</class>
              <class>org.jbpm.task.OnParentAbortAllSubTasksEndStrategy</class>
              <class>org.jbpm.task.OnAllSubTasksEndParentEndStrategy</class>
      
      
              <class>org.jbpm.task.User</class>
      
      
              <class>org.drools.persistence.info.SessionInfo</class>
              <class>org.jbpm.persistence.processinstance.ProcessInstanceInfo</class>
              <class>org.jbpm.persistence.processinstance.ProcessInstanceEventInfo</class>
              <class>org.drools.persistence.info.WorkItemInfo</class>
      
      
      
              <properties>
                   <!-- sample MySQL configuration  -->
      
                  <property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5InnoDBDialect"/>
                  <property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver"/>
                  <property name="hibernate.connection.url" value="jdbc:mysql://localhost:3306/jbpm5db" />
                  <property name="hibernate.connection.username" value="user"/>
                  <property name="hibernate.connection.password" value="testtest"/>
      
      
      
      
                  <property name="hibernate.connection.autocommit" value="false" />
                  <property name="hibernate.max_fetch_depth" value="3"/>
                  <property name="hibernate.hbm2ddl.auto" value="update" />
                  <property name="hibernate.show_sql" value="true" />
              </properties>
          </persistence-unit>
      
      </persistence>
      

       

      My web.xml

       

      <?xml version="1.0" encoding="UTF-8"?>  
      <web-app id="WebApp_ID" version="2.4"  
                  xmlns="http://java.sun.com/xml/ns/j2ee"  
                  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
                  xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee  
                       http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">  
         <display-name>first steps servlet</display-name>  
         <!-- Application class name -->  
         <context-param>  
            <param-name>org.restlet.application</param-name>  
            <param-value>  
               ac.uk.ucl.css.AHECore.API.Rest.AHERestletApplication  
            </param-value>  
         </context-param>  
      
         <!-- Restlet adapter -->  
         <servlet>  
            <servlet-name>RestletServlet</servlet-name>  
            <servlet-class>  
               org.restlet.ext.servlet.ServerServlet  
            </servlet-class>  
         </servlet>  
      
         <!-- Catch all requests -->  
         <servlet-mapping>  
            <servlet-name>RestletServlet</servlet-name>  
            <url-pattern>/*</url-pattern>  
         </servlet-mapping>
         <resource-ref>
                          <description>My datasource</description>
                          <res-ref-name>jdbc/testDS1</res-ref-name>
                          <res-type>javax.sql.DataSource</res-type>
                          <res-auth>Container</res-auth>
                </resource-ref>  
      </web-app>