5 Replies Latest reply on Apr 13, 2011 10:38 AM by wdfink

    1 datasource, 1 persistence unit, 2 war's

    carek

      Hi. I've got problem with JBoss 5 AS. I am trying to deploy two apps. Jbpm-console and my own application. What I am trying to achieve is to make those two web apps to be using one datasource, but I don't know how to do that. I tried two things:

       

      - using the same persistence.xml and mysql-ds.xml in both of them

      - using the same mysql-ds.xml and changing persistence-unit name in one of persistence.xml

       

      but both of those paths led me to exceptions. What is the proper way to follow in order to do that?

       

      Thanks for help in advance

        • 1. 1 datasource, 1 persistence unit, 2 war's
          wdfink

          Two persistenceunits and one mysql-ds.xml should be ok.

          Could you attach the configuration files and the server.log?

          • 2. Re: 1 datasource, 1 persistence unit, 2 war's
            carek

            sure.

             

            Here they are:

            persistences:

             

            <?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="console" transaction-type="JTA">
                    <jta-data-source>java:/DefaultDS</jta-data-source>
                        <class>org.jbpm.persistence.processinstance.ProcessInstanceInfo</class>
                        <class>org.drools.persistence.info.SessionInfo</class>
                        <class>org.drools.persistence.info.WorkItemInfo</class>
            
                </persistence-unit>
            
            </persistence>
            
            

             

            <?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="pl.edu.agh.iosr.agent" transaction-type="JTA">
                    <jta-data-source>java:/DefaultDS</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="jboss.entity.manager.factory.jndi.name" value="java:/EntityManagerFactory"/> 
                    </properties>
                </persistence-unit>
            
            </persistence>
            

             

            hibernate:

             

            <?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.username">root</property>
                    <property name="connection.password"></property>
                    <property name="connection.pool_size">1</property>
                    <property name="current_session_context_class">thread</property>
                    <property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>
                    <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
                    <property name="hibernate.hbm2ddl.auto">update</property>
                    <property name="hibernate.show_sql">true</property>
                </session-factory>
            </hibernate-configuration>
            

             

            datasource:

             

            <?xml version="1.0" encoding="UTF-8"?>
            
            <datasources>
              <local-tx-datasource>
                <jndi-name>DefaultDS</jndi-name>
                <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>
                <metadata>
                   <type-mapping>mySQL</type-mapping>
                </metadata>
              </local-tx-datasource>
            </datasources>
            

             

            I am afraid that there's third persistence.xml or rather I woud say lack of it... After searching through code of jbpm console I saw a line:

             

            EntityManagerFactory emf = Persistence.createEntityManagerFactory("org.drools.persistence.jpa);
            

             

            but I can't see any persistence.xml inside it's war... In addition processes are read from hardcoded path on disk... well I guess the only thing I can do is to modify jbpm console source code and recompile it

            • 3. 1 datasource, 1 persistence unit, 2 war's
              wdfink

              You should not deploy a hibernate configuration if you use persistence.xml (I've never done in that way)

              • 4. Re: 1 datasource, 1 persistence unit, 2 war's
                carek

                ok. Thanks for the advice

                • 5. 1 datasource, 1 persistence unit, 2 war's
                  wdfink

                  Oooh,

                  please, please edit your post and attach the log as file,

                  the thread and the log is mor or less unreadable.