Piotr Tempes [
http://community.jboss.org/people/carek] created the discussion
"Re: jbpm, process definitions, jboss - looking for knowledge"
To view the discussion, visit:
http://community.jboss.org/message/597342#597342
--------------------------------------------------------------
one hundred thanks for tutorial. Now I am struggling with access to my datasource... My
goal is to reach it from standalone application. Here's what I got when I try to get
through this line of code:
EntityManagerFactory emf =
Persistence.createEntityManagerFactory("org.drools.persistence.jpa");
Exception in thread "main" java.lang.RuntimeException: Could not initialize
stateful knowledge session: [PersistenceUnit: org.drools.persistence.jpa] Unable to build
EntityManagerFactory
at
org.jbpm.integration.console.CommandDelegate.newStatefulKnowledgeSession(CommandDelegate.java:179)
at org.jbpm.integration.console.CommandDelegate.getSession(CommandDelegate.java:187)
at org.jbpm.integration.console.CommandDelegate.<init>(CommandDelegate.java:70)
at org.jbpm.integration.console.CommandDelegate.main(CommandDelegate.java:293)
Caused by: javax.persistence.PersistenceException: [PersistenceUnit:
org.drools.persistence.jpa] Unable to build EntityManagerFactory
at
org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:677)
at
org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:126)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:52)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:34)
at
org.jbpm.integration.console.CommandDelegate.newStatefulKnowledgeSession(CommandDelegate.java:125)
... 3 more
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:137)
at
org.hibernate.ejb.InjectionSettingsFactory.createConnectionProvider(InjectionSettingsFactory.java:29)
at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:89)
at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2101)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1325)
at
org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:867)
at
org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:669)
... 7 more
Caused by: javax.naming.CommunicationException: Receive timed out [Root exception is
java.net.SocketTimeoutException: Receive timed out]
at org.jnp.interfaces.NamingContext.discoverServer(NamingContext.java:1678)
at org.jnp.interfaces.NamingContext.checkRef(NamingContext.java:1795)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:693)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:686)
at javax.naming.InitialContext.lookup(InitialContext.java:409)
at
org.hibernate.connection.DatasourceConnectionProvider.configure(DatasourceConnectionProvider.java:75)
... 14 more
Caused by: java.net.SocketTimeoutException: Receive timed out
at java.net.PlainDatagramSocketImpl.receive0(Native Method)
at
java.net.AbstractPlainDatagramSocketImpl.receive(AbstractPlainDatagramSocketImpl.java:135)
at java.net.DatagramSocket.receive(DatagramSocket.java:729)
at org.jnp.interfaces.NamingContext.discoverServer(NamingContext.java:1647)
... 19 more
My configuration:
persistence.xml in eclipse:
<?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.drools.persistence.jpa"
transaction-type="JTA">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>DefaultDS</jta-data-source>
<!-- <jta-data-source>jdbc:h2:tcp://localhost/~/test</jta-data-source>
-->
<class>org.jbpm.persistence.processinstance.ProcessInstanceInfo</class>
<class>org.drools.persistence.info.SessionInfo</class>
<class>org.drools.persistence.info.WorkItemInfo</class>
<properties>
<property name="hibernate.dialect"
value="org.hibernate.dialect.MySQLDialect"/>
<property name="hibernate.max_fetch_depth" value="3"/>
<property name="hibernate.hbm2ddl.auto" value="update" />
<property name="hibernate.show_sql" value="false" />
<property name="hibernate.transaction.manager_lookup_class"
value="org.hibernate.transaction.JBossTransactionManagerLookup" />
</properties>
</persistence-unit>
</persistence>
and hibernate.cfg.xml:
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
-//Hibernate/Hibernate Configuration DTD 3.0//EN
http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd>
<hibernate-configuration>
<session-factory>
<property
name="connection.driver_class">com.mysql.jdbc.Driver</property>
<property
name="connection.url">jdbc:mysql://localhost:3306/jbossdb</property>
<!--property
name="connection.url">jdbc:h2:file:/NotBackedUp/data/mydb</property-->
<property name="connection.username">root</property>
<property name="connection.password"></property>
<property name="connection.pool_size">1</property>
<property
name="dialect">org.hibernate.dialect.MySQLDialect</property>
<property
name="current_session_context_class">thread</property>
<property
name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>
<property name="show_sql">true</property>
<property name="hbm2ddl.auto">update</property>
<!-- <mapping resource="AuditLog.hbm.xml"/> -->
</session-factory>
</hibernate-configuration>
and mysql-ds.xml
<?xml version="1.0" encoding="UTF-8"?>
<!-- See
http://www.jboss.org/community/wiki/Multiple1PC for information about
local-tx-datasource -->
<!-- $Id: mysql-ds.xml 88948 2009-05-15 14:09:08Z jesper.pedersen $ -->
<!-- Datasource config for MySQL using 3.0.9 available from:
http://www.mysql.com/downloads/api-jdbc-stable.html
-->
<datasources>
<local-tx-datasource>
<jndi-name>DefaultDS</jndi-name>
<use-java-context>false</use-java-context>
<connection-url>jdbc:mysql://localhost:3306/jbossdb</connection-url>
<driver-class>com.mysql.jdbc.Driver</driver-class>
<user-name>root</user-name>
<password></password>
<exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.MySQLExceptionSorter</exception-sorter-class-name>
<!-- should only be used on drivers after 3.22.1 with "ping" support
<valid-connection-checker-class-name>org.jboss.resource.adapter.jdbc.vendor.MySQLValidConnectionChecker</valid-connection-checker-class-name>
-->
<!-- sql to call when connection is created
<new-connection-sql>some arbitrary sql</new-connection-sql>
-->
<!-- sql to call on an existing pooled connection when it is obtained from pool -
MySQLValidConnectionChecker is preferred for newer drivers
<check-valid-connection-sql>some arbitrary
sql</check-valid-connection-sql>
-->
<!-- corresponding type-mapping in the standardjbosscmp-jdbc.xml (optional) -->
<metadata>
<type-mapping>mySQL</type-mapping>
</metadata>
</local-tx-datasource>
</datasources>
jboss starts without errors and exception. In addition I got message:
06:07:44,421 INFO [WrapperDataSourceService] Bound ConnectionManager
'jboss.jca:service=DataSourceBinding,name=DefaultDS' to JNDI name
'DefaultDS'
Any idea why the datasource could not be found?
Thanks in advance
--------------------------------------------------------------
Reply to this message by going to Community
[
http://community.jboss.org/message/597342#597342]
Start a new discussion in jBPM at Community
[
http://community.jboss.org/choose-container!input.jspa?contentType=1&...]