hi gustavo,<span id="result_box" class="short_text"><span style="" title=""><br><br>has a big </span></span><span id="result_box" class="short_text"><span style="" title="">different between tomcat5.5 and tomcat6? </span></span>According to your guide,i cannot bind JNDI,<span id="result_box" class="short_text"><span style="" title="">maybe i must set resource in tomcat </span></span>conf/context.xml<span id="result_box" class="short_text"><span style="" title="">, i am confusing&hellip;&hellip;</span></span><span id="result_box" class="short_text"><span style="" title="">can you&nbsp; send a example to me</span></span>?THS<br>
<br><div class="gmail_quote">在 2010年9月3日 下午11:49,Gustavo Tenrreiro <span dir="ltr">&lt;<a href="mailto:gustavo@tenrreiro.com">gustavo@tenrreiro.com</a>&gt;</span>写道:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
If it helps at all; I spent almost a full week trying to get JPA &nbsp;to<br>
work with Tomcat 5.5 + Hibernate + Bitronix and this is what I found.<br>
<br>
The instructions for Bitronix in<br>
<a href="http://docs.codehaus.org/display/BTM/Tomcat13" target="_blank">http://docs.codehaus.org/display/BTM/Tomcat13</a> did not help me much.<br>
The datasource that gets created via the resource.properties could<br>
never be found.<br>
<br>
- So to get it to work, do deploy the Bitronix jar files into your<br>
server / context<br>
<br>
- In the Tomcat conf/context.xml I do have &quot;&lt;Transaction<br>
factory=&quot;bitronix.tm.BitronixUserTransactionObjectFactory&quot; /&gt;&quot; but I<br>
am not sure if it is required ( haven&#39;t tested removing it ).<br>
<br>
- In the web.xml I do have:<br>
<br>
 &nbsp;&lt;resource-env-ref&gt;<br>
 &nbsp; &nbsp;&lt;resource-env-ref-name&gt;java:comp/env/jdbc/processInstanceDS&lt;/resource-env-ref-name&gt;<br>
 &nbsp; &nbsp;&lt;resource-env-ref-type&gt;javax.sql.DataSource&lt;/resource-env-ref-type&gt;<br>
 &nbsp;&lt;/resource-env-ref&gt;<br>
<br>
where jdbc/processInstanceDS is your jdbc/mysql<br>
<br>
- In the Hibernate persistence.xml I do have:<br>
<div class="im"><br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;property name=&quot;hibernate.transaction.manager_lookup_class&quot;<br>
value=&quot;org.hibernate.transaction.BTMTransactionManagerLookup&quot; /&gt;<br>
</div> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;property name=&quot;hibernate.jndi.class&quot;<br>
value=&quot;bitronix.tm.jndi.BitronixInitialContextFactory&quot; /&gt;<br>
<br>
although I don&#39;t think it is using the jndi.class specified there, so<br>
the second line might be redundant.<br>
<br>
Then in my code I create the datasource by hand ( in a ServletContextListener ):<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;PoolingDataSource ds = new PoolingDataSource();<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ds.setUniqueName( &quot;jdbc/processInstanceDS&quot; );<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ds.setClassName( &quot;bitronix.tm.resource.jdbc.lrc.LrcXADataSource&quot;);<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ds.setMaxPoolSize( 3 );<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ds.setAllowLocalTransactions( true );<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ds.getDriverProperties().put(&quot;driverClassName&quot;,&quot;com.microsoft.sqlserver.jdbc.SQLServerDriver&quot;);<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ds.getDriverProperties().put( &quot;user&quot;, &quot;xxxxxxx&quot; );<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ds.getDriverProperties().put( &quot;password&quot;, &quot;xxxxxxxx&quot; );<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ds.getDriverProperties().put( &quot;url&quot;, &quot;mySqlServerUrl...&quot; );<br>
<br>
replace the driverClassName, user, password, and url for your setup. I<br>
am using SQLServer, but I guess you are on MySql.<br>
<br>
After that the JPA stuff works, and persistence works as advertised.<br>
This is the only setup that worked for me. I tried creating the<br>
datasource from Spring but that didn&#39;t work either.<br>
<br>
Please let me know what you find out.<br>
<br>
Thanks<br>
<br>
<br>
2010/9/3 Pablo Nussembaum &lt;<a href="mailto:baunax@gmail.com">baunax@gmail.com</a>&gt;:<br>
<div><div></div><div class="h5">&gt; You need to configure bitronix[0] to provide JTA. Or use drools-spring that<br>
&gt; allows you to use drools-persisntece-jpa without JTA.<br>
&gt;<br>
&gt; [0] <a href="http://docs.codehaus.org/display/BTM/Tomcat13" target="_blank">http://docs.codehaus.org/display/BTM/Tomcat13</a><br>
&gt; On 09/03/2010 08:53 AM, liang wrote:<br>
&gt;<br>
&gt; i found that tomcat 6 have not JTA,which server is able to persistence?<br>
&gt;<br>
&gt; 在 2010年9月3日 下午12:02,liang &lt;<a href="mailto:zhuyx808@gmail.com">zhuyx808@gmail.com</a>&gt;写道:<br>
&gt;&gt;<br>
&gt;&gt; THS,Esteban,I found it which is resin&#39;s problem, so i replaced it to<br>
&gt;&gt; tomcat6, i got other questions:<br>
&gt;&gt;<br>
&gt;&gt; &nbsp;in my webapp webroot/meta-inf/content.xml:<br>
&gt;&gt; &lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;<br>
&gt;&gt; &lt;Context&gt;<br>
&gt;&gt; &nbsp; &lt;Resource name=&quot;jdbc/mysql&quot; auth=&quot;Container&quot; type=&quot;javax.sql.DataSource&quot;<br>
&gt;&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;maxActive=&quot;10&quot; maxIdle=&quot;2&quot; maxWait=&quot;10000&quot;<br>
&gt;&gt; logAbandoned=&quot;true&quot;<br>
&gt;&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;username=&quot;root&quot; password=&quot;111111&quot;<br>
&gt;&gt; driverClassName=&quot;com.mysql.jdbc.Driver&quot;<br>
&gt;&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;url=&quot;jdbc:mysql://localhost:3306/test&quot;/&gt;<br>
&gt;&gt; &lt;/Context&gt;<br>
&gt;&gt;<br>
&gt;&gt; webroot/web-inf/web.xml:<br>
&gt;&gt;<br>
&gt;&gt; &nbsp;&lt;resource-ref&gt;<br>
&gt;&gt; &nbsp; &nbsp; &nbsp; &lt;description&gt;DB Connection&lt;/description&gt;<br>
&gt;&gt; &nbsp; &nbsp; &nbsp; &lt;res-ref-name&gt;jdbc/mysql&lt;/res-ref-name&gt;<br>
&gt;&gt; &nbsp; &nbsp; &nbsp; &lt;res-type&gt;javax.sql.DataSource&lt;/res-type&gt;<br>
&gt;&gt; &nbsp; &nbsp; &nbsp; &lt;res-auth&gt;Container&lt;/res-auth&gt;<br>
&gt;&gt; &lt;/resource-ref&gt;<br>
&gt;&gt;<br>
&gt;&gt; webroot/meta-inf/persistence.xml:<br>
&gt;&gt;<br>
&gt;&gt; &lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;yes&quot;?&gt;<br>
&gt;&gt; &lt;persistence<br>
&gt;&gt; &nbsp; &nbsp; version=&quot;1.0&quot;<br>
&gt;&gt; &nbsp; &nbsp; xsi:schemaLocation=<br>
&gt;&gt; &nbsp; &nbsp; &nbsp; &nbsp; &quot;<a href="http://java.sun.com/xml/ns/persistence" target="_blank">http://java.sun.com/xml/ns/persistence</a><br>
&gt;&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<a href="http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd" target="_blank">http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd</a><br>
&gt;&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<a href="http://java.sun.com/xml/ns/persistence/orm" target="_blank">http://java.sun.com/xml/ns/persistence/orm</a><br>
&gt;&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<a href="http://java.sun.com/xml/ns/persistence/orm_1_0.xsd" target="_blank">http://java.sun.com/xml/ns/persistence/orm_1_0.xsd</a>&quot;<br>
&gt;&gt; &nbsp; &nbsp; xmlns:orm=&quot;<a href="http://java.sun.com/xml/ns/persistence/orm" target="_blank">http://java.sun.com/xml/ns/persistence/orm</a>&quot;<br>
&gt;&gt; &nbsp; &nbsp; xmlns:xsi=&quot;<a href="http://www.w3.org/2001/XMLSchema-instance" target="_blank">http://www.w3.org/2001/XMLSchema-instance</a>&quot;<br>
&gt;&gt; &nbsp; &nbsp; xmlns=&quot;<a href="http://java.sun.com/xml/ns/persistence" target="_blank">http://java.sun.com/xml/ns/persistence</a>&quot;&gt;<br>
&gt;&gt;<br>
&gt;&gt; &nbsp;&lt;!--persistence-unit name=&quot;ProcessService&quot;&gt;<br>
&gt;&gt; &nbsp; &lt;jta-data-source&gt;java:/DefaultDS&lt;/jta-data-source&gt;<br>
&gt;&gt; &nbsp; &lt;properties&gt;<br>
&gt;&gt; &nbsp; &nbsp;&lt;property name=&quot;hibernate.hbm2ddl.auto&quot; value=&quot;create-drop&quot;/&gt;<br>
&gt;&gt; &nbsp; &lt;/properties&gt;<br>
&gt;&gt; &nbsp;&lt;/persistence-unit--&gt;<br>
&gt;&gt;<br>
&gt;&gt; &nbsp; &nbsp; &lt;persistence-unit name=&quot;org.drools.persistence.jpa&quot;<br>
&gt;&gt; transaction-type=&quot;JTA&quot;&gt;<br>
&gt;&gt; &nbsp; &nbsp; &nbsp; &nbsp; &lt;provider&gt;org.hibernate.ejb.HibernatePersistence&lt;/provider&gt;<br>
&gt;&gt; &nbsp; &nbsp; &nbsp; &nbsp; &lt;jta-data-source&gt;java:comp/env/jdbc/mysql&lt;/jta-data-source&gt;<br>
&gt;&gt; &nbsp; &nbsp; &lt;class&gt;org.drools.persistence.session.SessionInfo&lt;/class&gt;<br>
&gt;&gt; &nbsp;&lt;class&gt;org.drools.persistence.processinstance.ProcessInstanceInfo&lt;/class&gt;<br>
&gt;&gt;<br>
&gt;&gt; &lt;class&gt;org.drools.persistence.processinstance.ProcessInstanceEventInfo&lt;/class&gt;<br>
&gt;&gt; &nbsp; &nbsp; &lt;class&gt;org.drools.persistence.processinstance.WorkItemInfo&lt;/class&gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; &nbsp; &nbsp; &nbsp; &nbsp; &lt;properties&gt;<br>
&gt;&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;property name=&quot;hibernate.dialect&quot;<br>
&gt;&gt; value=&quot;org.hibernate.dialect.MySQLDialect&quot;/&gt;<br>
&gt;&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;property name=&quot;hibernate.max_fetch_depth&quot; value=&quot;3&quot;/&gt;<br>
&gt;&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;property name=&quot;hibernate.hbm2ddl.auto&quot; value=&quot;create&quot; /&gt;<br>
&gt;&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;property name=&quot;hibernate.show_sql&quot; value=&quot;true&quot; /&gt;<br>
&gt;&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;property name=&quot;hibernate.transaction.manager_lookup_class&quot;<br>
&gt;&gt; value=&quot;org.hibernate.transaction.BTMTransactionManagerLookup&quot; /&gt;<br>
&gt;&gt; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/properties&gt;<br>
&gt;&gt; &nbsp; &nbsp; &lt;/persistence-unit&gt;<br>
&gt;&gt;<br>
&gt;&gt; &lt;/persistence&gt;<br>
&gt;&gt;<br>
&gt;&gt; webroot/testJNDI.jsp:<br>
&gt;&gt;<br>
&gt;&gt; &lt;%@ page import=&#39;java.sql.*, javax.sql.*, javax.naming.*&#39; %&gt;<br>
&gt;&gt; &lt;%<br>
&gt;&gt; Context ic = new InitialContext();<br>
&gt;&gt; DataSource ds = (DataSource) ic.lookup(&quot;java:comp/env/jdbc/mysql&quot;);<br>
&gt;&gt;<br>
&gt;&gt; Connection conn = ds.getConnection();<br>
&gt;&gt;<br>
&gt;&gt; try {<br>
&gt;&gt; &nbsp; Statement stmt = conn.createStatement();<br>
&gt;&gt; &nbsp; ResultSet rs = stmt.executeQuery(&quot;select * from test&quot;);<br>
&gt;&gt; &nbsp; while (rs.next()) { %&gt;<br>
&gt;&gt; &lt;%= rs.getString(1) %&gt; &lt;%= rs.getString(2) %&gt;&lt;br&gt;&lt;%<br>
&gt;&gt; &nbsp; }<br>
&gt;&gt; } finally {<br>
&gt;&gt; &nbsp; conn.close();<br>
&gt;&gt; }<br>
&gt;&gt; %&gt;<br>
&gt;&gt;<br>
&gt;&gt; webroot/testDroolsFlow.jsp:<br>
&gt;&gt;<br>
&gt;&gt; &lt;%@ page import=&#39;java.sql.*, javax.sql.*, javax.naming.*,com.abc.*&#39; %&gt;<br>
&gt;&gt; &lt;%<br>
&gt;&gt; VdcService.exec();<br>
&gt;&gt; %&gt;<br>
&gt;&gt;<br>
&gt;&gt; run the testJNDI.jsp,its OK.when i run testDroolsFlow.jsp, appears this<br>
&gt;&gt; exception:<br>
&gt;&gt;<br>
&gt;&gt; java.lang.RuntimeException: Could not commit session<br>
&gt;&gt; &nbsp; &nbsp; at<br>
&gt;&gt; org.drools.persistence.session.SingleSessionCommandService.&lt;init&gt;(SingleSessionCommandService.java:119)<br>
&gt;&gt; &nbsp; &nbsp; at<br>
&gt;&gt; org.drools.persistence.jpa.impl.JPAKnowledgeServiceProviderImpl.newStatefulKnowledgeSession(JPAKnowledgeServiceProviderImpl.java:44)<br>
&gt;&gt; &nbsp; &nbsp; at<br>
&gt;&gt; org.drools.persistence.jpa.JPAKnowledgeService.newStatefulKnowledgeSession(JPAKnowledgeService.java:93)<br>
&gt;&gt; &nbsp; &nbsp; at com.abc.VdcService.exec(VdcService.java:39)<br>
&gt;&gt; &nbsp; &nbsp; at<br>
&gt;&gt; org.apache.jsp._testDroolsFlow_jsp._jspService(_testDroolsFlow_jsp.java:60)<br>
&gt;&gt; &nbsp; &nbsp; at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)<br>
&gt;&gt; &nbsp; &nbsp; at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)<br>
&gt;&gt; &nbsp; &nbsp; at<br>
&gt;&gt; org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:377)<br>
&gt;&gt; &nbsp; &nbsp; at<br>
&gt;&gt; org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)<br>
&gt;&gt; &nbsp; &nbsp; at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)<br>
&gt;&gt; &nbsp; &nbsp; at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)<br>
&gt;&gt; &nbsp; &nbsp; at<br>
&gt;&gt; org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)<br>
&gt;&gt; &nbsp; &nbsp; at<br>
&gt;&gt; org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)<br>
&gt;&gt; &nbsp; &nbsp; at<br>
&gt;&gt; org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)<br>
&gt;&gt; &nbsp; &nbsp; at<br>
&gt;&gt; org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)<br>
&gt;&gt; &nbsp; &nbsp; at<br>
&gt;&gt; org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)<br>
&gt;&gt; &nbsp; &nbsp; at<br>
&gt;&gt; org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)<br>
&gt;&gt; &nbsp; &nbsp; at<br>
&gt;&gt; org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)<br>
&gt;&gt; &nbsp; &nbsp; at<br>
&gt;&gt; org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)<br>
&gt;&gt; &nbsp; &nbsp; at<br>
&gt;&gt; org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:859)<br>
&gt;&gt; &nbsp; &nbsp; at<br>
&gt;&gt; org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:579)<br>
&gt;&gt; &nbsp; &nbsp; at<br>
&gt;&gt; org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1555)<br>
&gt;&gt; &nbsp; &nbsp; at java.lang.Thread.run(Thread.java:619)<br>
&gt;&gt; Caused by: javax.naming.NamingException: Cannot create resource instance<br>
&gt;&gt; &nbsp; &nbsp; at<br>
&gt;&gt; org.apache.naming.factory.TransactionFactory.getObjectInstance(TransactionFactory.java:113)<br>
&gt;&gt; &nbsp; &nbsp; at<br>
&gt;&gt; javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:304)<br>
&gt;&gt; &nbsp; &nbsp; at org.apache.naming.NamingContext.lookup(NamingContext.java:793)<br>
&gt;&gt; &nbsp; &nbsp; at org.apache.naming.NamingContext.lookup(NamingContext.java:140)<br>
&gt;&gt; &nbsp; &nbsp; at org.apache.naming.NamingContext.lookup(NamingContext.java:781)<br>
&gt;&gt; &nbsp; &nbsp; at org.apache.naming.NamingContext.lookup(NamingContext.java:153)<br>
&gt;&gt; &nbsp; &nbsp; at org.apache.naming.SelectorContext.lookup(SelectorContext.java:152)<br>
&gt;&gt; &nbsp; &nbsp; at javax.naming.InitialContext.lookup(InitialContext.java:392)<br>
&gt;&gt; &nbsp; &nbsp; at<br>
&gt;&gt; org.drools.persistence.session.SingleSessionCommandService.&lt;init&gt;(SingleSessionCommandService.java:102)<br>
&gt;&gt; &nbsp; &nbsp; ... 22 more<br>
&gt;&gt;<br>
&gt;&gt; JNDI is OK,so i guess the question is in drools side,is right of my guess?<br>
&gt;&gt; the exception is here:<br>
&gt;&gt; 38 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;StatefulKnowledgeSession ksession =<br>
&gt;&gt; 39 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;JPAKnowledgeService.newStatefulKnowledgeSession(<br>
&gt;&gt; kbase, null, env );<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; PS:<br>
&gt;&gt;<br>
&gt;&gt; i write the webapp &nbsp;is want to know:<br>
&gt;&gt;<br>
&gt;&gt; 1. &nbsp; &nbsp; &nbsp; How to save drools into database<br>
&gt;&gt;<br>
&gt;&gt; 2. &nbsp; &nbsp; &nbsp; What data is saved in the tables; are all the instances of a<br>
&gt;&gt; process stored?<br>
&gt;&gt;<br>
&gt;&gt; 3. &nbsp; &nbsp; &nbsp; Are all nodes in a ruleflow saved?<br>
&gt;&gt;<br>
&gt;&gt; 4. &nbsp; &nbsp; &nbsp; Are there any nodes which are not running saved in the tables?<br>
&gt;&gt;<br>
&gt;&gt; 5. &nbsp; &nbsp; &nbsp; What status are running and non-running nodes in the tables?<br>
&gt;&gt;<br>
&gt;&gt; 2010/9/1 Esteban Aliverti &lt;<a href="mailto:esteban.aliverti@gmail.com">esteban.aliverti@gmail.com</a>&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; As far as I can see, this has nothing to do with drools. You can&#39;t even<br>
&gt;&gt;&gt; create the EntityManagerFactory. Try to set a finest log level<br>
&gt;&gt;&gt; for com.caucho.amber.* and org.hibernate.* to see why it is throwing a NPE.<br>
&gt;&gt;&gt; Best,<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Esteban Aliverti<br>
&gt;&gt;&gt; - Developer @ <a href="http://www.plugtree.com" target="_blank">http://www.plugtree.com</a><br>
&gt;&gt;&gt; - Blog @ <a href="http://ilesteban.wordpress.com" target="_blank">http://ilesteban.wordpress.com</a><br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; 2010/9/1 亮亮 &lt;<a href="mailto:zhuyx808@gmail.com">zhuyx808@gmail.com</a>&gt;<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; hi:<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; in my webapp, I use JPA to store the runtime state,i use this code in<br>
&gt;&gt;&gt;&gt; VdcService.java which is a sample &nbsp;java class:<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; EntityManagerFactory emf =Persistence.createEntityManagerFactory(<br>
&gt;&gt;&gt;&gt; &quot;org.drools.persistence.jpa&quot; );<br>
&gt;&gt;&gt;&gt; Environment env = KnowledgeBaseFactory.newEnvironment();<br>
&gt;&gt;&gt;&gt; env.set( EnvironmentName.ENTITY_MANAGER_FACTORY, emf );<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; &nbsp;// create a new knowledge session that uses JPA to store the runtime<br>
&gt;&gt;&gt;&gt; state<br>
&gt;&gt;&gt;&gt; StatefulKnowledgeSession ksession =<br>
&gt;&gt;&gt;&gt; JPAKnowledgeService.newStatefulKnowledgeSession( kbase, null, env );<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; I put persistence.xml to webRoot/META-INF/ &nbsp;, persistence.xml:<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; &lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;yes&quot;?&gt;<br>
&gt;&gt;&gt;&gt; &lt;persistence<br>
&gt;&gt;&gt;&gt; &nbsp; &nbsp; version=&quot;1.0&quot;<br>
&gt;&gt;&gt;&gt; &nbsp; &nbsp; xsi:schemaLocation=<br>
&gt;&gt;&gt;&gt; &nbsp; &nbsp; &nbsp; &nbsp; &quot;<a href="http://java.sun.com/xml/ns/persistence" target="_blank">http://java.sun.com/xml/ns/persistence</a><br>
&gt;&gt;&gt;&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<a href="http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd" target="_blank">http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd</a><br>
&gt;&gt;&gt;&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<a href="http://java.sun.com/xml/ns/persistence/orm" target="_blank">http://java.sun.com/xml/ns/persistence/orm</a><br>
&gt;&gt;&gt;&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<a href="http://java.sun.com/xml/ns/persistence/orm_1_0.xsd" target="_blank">http://java.sun.com/xml/ns/persistence/orm_1_0.xsd</a>&quot;<br>
&gt;&gt;&gt;&gt; &nbsp; &nbsp; xmlns:orm=&quot;<a href="http://java.sun.com/xml/ns/persistence/orm" target="_blank">http://java.sun.com/xml/ns/persistence/orm</a>&quot;<br>
&gt;&gt;&gt;&gt; &nbsp; &nbsp; xmlns:xsi=&quot;<a href="http://www.w3.org/2001/XMLSchema-instance" target="_blank">http://www.w3.org/2001/XMLSchema-instance</a>&quot;<br>
&gt;&gt;&gt;&gt; &nbsp; &nbsp; xmlns=&quot;<a href="http://java.sun.com/xml/ns/persistence" target="_blank">http://java.sun.com/xml/ns/persistence</a>&quot;&gt;<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; &nbsp; &nbsp; &lt;persistence-unit name=&quot;org.drools.persistence.jpa&quot;<br>
&gt;&gt;&gt;&gt; transaction-type=&quot;JTA&quot;&gt;<br>
&gt;&gt;&gt;&gt; &nbsp; &nbsp; &nbsp; &nbsp; &lt;provider&gt;org.hibernate.ejb.HibernatePersistence&lt;/provider&gt;<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; &lt;jta-data-source&gt;java:comp/env/jdbc/mysql&lt;/jta-data-source&gt;<br>
&gt;&gt;&gt;&gt; &nbsp; &nbsp; &lt;class&gt;org.drools.persistence.session.SessionInfo&lt;/class&gt;<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; &nbsp;&lt;class&gt;org.drools.persistence.processinstance.ProcessInstanceInfo&lt;/class&gt;<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; &lt;class&gt;org.drools.persistence.processinstance.ProcessInstanceEventInfo&lt;/class&gt;<br>
&gt;&gt;&gt;&gt; &nbsp; &nbsp; &lt;class&gt;org.drools.persistence.processinstance.WorkItemInfo&lt;/class&gt;<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; &nbsp; &nbsp; &nbsp; &nbsp; &lt;properties&gt;<br>
&gt;&gt;&gt;&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;property name=&quot;hibernate.dialect&quot;<br>
&gt;&gt;&gt;&gt; value=&quot;org.hibernate.dialect.MySQLDialect&quot;/&gt;<br>
&gt;&gt;&gt;&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;property name=&quot;hibernate.max_fetch_depth&quot; value=&quot;3&quot;/&gt;<br>
&gt;&gt;&gt;&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;property name=&quot;hibernate.hbm2ddl.auto&quot; value=&quot;create&quot; /&gt;<br>
&gt;&gt;&gt;&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;property name=&quot;hibernate.show_sql&quot; value=&quot;true&quot; /&gt;<br>
&gt;&gt;&gt;&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;property name=&quot;hibernate.transaction.manager_lookup_class&quot;<br>
&gt;&gt;&gt;&gt; value=&quot;org.hibernate.transaction.BTMTransactionManagerLookup&quot; /&gt;<br>
&gt;&gt;&gt;&gt; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/properties&gt;<br>
&gt;&gt;&gt;&gt; &nbsp; &nbsp; &lt;/persistence-unit&gt;<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; &lt;/persistence&gt;<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; I use resin 3.1.10, &nbsp;$resin-home/conf/resin.conf:<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;database&gt;<br>
&gt;&gt;&gt;&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;jndi-name&gt;jdbc/mysql&lt;/jndi-name&gt;<br>
&gt;&gt;&gt;&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;driver type=&quot;org.gjt.mm.mysql.Driver&quot;&gt;<br>
&gt;&gt;&gt;&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;url&gt;jdbc:mysql://<a href="http://127.0.0.1:3306/test" target="_blank">127.0.0.1:3306/test</a>&lt;/url&gt;<br>
&gt;&gt;&gt;&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;user&gt;root&lt;/user&gt;<br>
&gt;&gt;&gt;&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;password&gt;&lt;/password&gt;<br>
&gt;&gt;&gt;&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/driver&gt;<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; &lt;prepared-statement-cache-size&gt;8&lt;/prepared-statement-cache-size&gt;<br>
&gt;&gt;&gt;&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;max-connections&gt;20&lt;/max-connections&gt;<br>
&gt;&gt;&gt;&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;max-idle-time&gt;30s&lt;/max-idle-time&gt;<br>
&gt;&gt;&gt;&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/database&gt;<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; when i run this webapp , i got this exception:<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; java.lang.NullPointerException<br>
&gt;&gt;&gt;&gt; &nbsp; &nbsp; at<br>
&gt;&gt;&gt;&gt; com.caucho.amber.manager.AmberPersistenceProvider.createEntityManagerFactory(AmberPersistenceProvider.java:65)<br>
&gt;&gt;&gt;&gt; &nbsp; &nbsp; at<br>
&gt;&gt;&gt;&gt; javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:69)<br>
&gt;&gt;&gt;&gt; &nbsp; &nbsp; at com.abc.abc.service.VdcService.exec(VdcService.java:32)<br>
&gt;&gt;&gt;&gt; &nbsp; &nbsp; at com.abc.abc.resources.Apply.apply(Apply.java:55)<br>
&gt;&gt;&gt;&gt; &nbsp; &nbsp; at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)<br>
&gt;&gt;&gt;&gt; &nbsp; &nbsp; at<br>
&gt;&gt;&gt;&gt; sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)<br>
&gt;&gt;&gt;&gt; &nbsp; &nbsp; at<br>
&gt;&gt;&gt;&gt; sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)<br>
&gt;&gt;&gt;&gt; &nbsp; &nbsp; at java.lang.reflect.Method.invoke(Method.java:597)<br>
&gt;&gt;&gt;&gt; &nbsp; &nbsp; at<br>
&gt;&gt;&gt;&gt; com.sun.jersey.server.impl.model.method.dispatch.AbstractResourceMethodDispatchProvider$TypeOutInvoker._dispatch(AbstractResourceMethodDispatchProvider.java:156)<br>
&gt;&gt;&gt;&gt; &nbsp; &nbsp; at<br>
&gt;&gt;&gt;&gt; com.sun.jersey.server.impl.model.method.dispatch.ResourceJavaMethodDispatcher.dispatch(ResourceJavaMethodDispatcher.java:67)<br>
&gt;&gt;&gt;&gt; &nbsp; &nbsp; at<br>
&gt;&gt;&gt;&gt; com.sun.jersey.server.impl.uri.rules.HttpMethodRule.accept(HttpMethodRule.java:208)<br>
&gt;&gt;&gt;&gt; &nbsp; &nbsp; at<br>
&gt;&gt;&gt;&gt; com.sun.jersey.server.impl.uri.rules.ResourceClassRule.accept(ResourceClassRule.java:75)<br>
&gt;&gt;&gt;&gt; &nbsp; &nbsp; at<br>
&gt;&gt;&gt;&gt; com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:115)<br>
&gt;&gt;&gt;&gt; &nbsp; &nbsp; at<br>
&gt;&gt;&gt;&gt; com.sun.jersey.server.impl.uri.rules.RootResourceClassesRule.accept(RootResourceClassesRule.java:67)<br>
&gt;&gt;&gt;&gt; &nbsp; &nbsp; at<br>
&gt;&gt;&gt;&gt; com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:724)<br>
&gt;&gt;&gt;&gt; &nbsp; &nbsp; at<br>
&gt;&gt;&gt;&gt; com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:689)<br>
&gt;&gt;&gt;&gt; &nbsp; &nbsp; at<br>
&gt;&gt;&gt;&gt; com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:680)<br>
&gt;&gt;&gt;&gt; &nbsp; &nbsp; at<br>
&gt;&gt;&gt;&gt; com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:324)<br>
&gt;&gt;&gt;&gt; &nbsp; &nbsp; at<br>
&gt;&gt;&gt;&gt; com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:425)<br>
&gt;&gt;&gt;&gt; &nbsp; &nbsp; at<br>
&gt;&gt;&gt;&gt; com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:604)<br>
&gt;&gt;&gt;&gt; &nbsp; &nbsp; at javax.servlet.http.HttpServlet.service(HttpServlet.java:91)<br>
&gt;&gt;&gt;&gt; &nbsp; &nbsp; at<br>
&gt;&gt;&gt;&gt; com.caucho.server.dispatch.ServletFilterChain.doFilter(ServletFilterChain.java:103)<br>
&gt;&gt;&gt;&gt; &nbsp; &nbsp; at<br>
&gt;&gt;&gt;&gt; org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:416)<br>
&gt;&gt;&gt;&gt; &nbsp; &nbsp; at<br>
&gt;&gt;&gt;&gt; com.caucho.server.dispatch.FilterFilterChain.doFilter(FilterFilterChain.java:87)<br>
&gt;&gt;&gt;&gt; &nbsp; &nbsp; at<br>
&gt;&gt;&gt;&gt; org.apache.struts2.dispatcher.ActionContextCleanUp.doFilter(ActionContextCleanUp.java:99)<br>
&gt;&gt;&gt;&gt; &nbsp; &nbsp; at<br>
&gt;&gt;&gt;&gt; com.caucho.server.dispatch.FilterFilterChain.doFilter(FilterFilterChain.java:87)<br>
&gt;&gt;&gt;&gt; &nbsp; &nbsp; at<br>
&gt;&gt;&gt;&gt; com.caucho.server.webapp.WebAppFilterChain.doFilter(WebAppFilterChain.java:187)<br>
&gt;&gt;&gt;&gt; &nbsp; &nbsp; at<br>
&gt;&gt;&gt;&gt; com.caucho.server.dispatch.ServletInvocation.service(ServletInvocation.java:265)<br>
&gt;&gt;&gt;&gt; &nbsp; &nbsp; at<br>
&gt;&gt;&gt;&gt; com.caucho.server.http.HttpRequest.handleRequest(HttpRequest.java:273)<br>
&gt;&gt;&gt;&gt; &nbsp; &nbsp; at com.caucho.server.port.TcpConnection.run(TcpConnection.java:682)<br>
&gt;&gt;&gt;&gt; &nbsp; &nbsp; at com.caucho.util.ThreadPool$Item.runTasks(ThreadPool.java:743)<br>
&gt;&gt;&gt;&gt; &nbsp; &nbsp; at com.caucho.util.ThreadPool$Item.run(ThreadPool.java:662)<br>
&gt;&gt;&gt;&gt; &nbsp; &nbsp; at java.lang.Thread.run(Thread.java:619)<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; i can&#39;t solve it.How to solve it?help me ,THS<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; _______________________________________________<br>
&gt;&gt;&gt;&gt; rules-users mailing list<br>
&gt;&gt;&gt;&gt; <a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
&gt;&gt;&gt;&gt; <a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; _______________________________________________<br>
&gt;&gt;&gt; rules-users mailing list<br>
&gt;&gt;&gt; <a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
&gt;&gt;&gt; <a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
&gt;&gt;&gt;<br>
&gt;&gt;<br>
&gt;<br>
&gt;<br>
&gt; _______________________________________________<br>
&gt; rules-users mailing list<br>
&gt; <a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
&gt; <a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
&gt;<br>
&gt;<br>
&gt; _______________________________________________<br>
&gt; rules-users mailing list<br>
&gt; <a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
&gt; <a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
&gt;<br>
&gt;<br>
<br>
_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
</div></div></blockquote></div><br>