Hi my web app use openJPA for database CRUD, i configure like this:

tomee.xml:

<Resource id="MyDataSource" type="DataSource">
  JdbcDriver com.mysql.jdbc.Driver
  JdbcUrl jdbc:mysql://localhost:3306/mydatabase?autoReconnect=true
  UserName myuser
  Password mypass
  JtaManaged true
</Resource>

<Resource id="MyUnmanagedDataSource" type="DataSource">
  JdbcDriver com.mysql.jdbc.Driver
  JdbcUrl jdbc:mysql://localhost:3306/mydatabase?autoReconnect=true
  UserName myuser
  Password mypass
  JtaManaged false
</Resource>


my persistence.xml:

<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence";
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; xsi:schemaLocation="
http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd";>
    <persistence-unit name="testPU" transaction-type="JTA">

<provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
        <jta-data-source>MyDataSource</jta-data-source>
        <non-jta-data-source>MyUnmanagedDataSource</non-jta-data-source>
.
.
.
</persistence>


MyEJB.java

@Stateless
public class MyEJB {

    @PersistenceContext(name="testPU")
    private EntityManager em;

    public void test(){
       .....
       em.createQuery("SELECT o FROM Table o").getResultList();
       ........
    }
}


And all of this works without any trouble.    :)


Now im trying to use DataSourceRealm with the same Datasource (tomee.xml)
but doesnt work

context.xml

<Realm
            className="org.apache.catalina.realm.DataSourceRealm"
            dataSourceName="MyDataSource"
            userTable="userTable"
            userNameCol="user"
            userCredCol="pass"
            userRoleTable="rolTable"
            roleNameCol="rol"/>

I expect the realm take the same DataSource from tomee.xml but this doesnt
happend:

Severe: ........
The MyDataSource name is not associated to this context.


Is there a way to use the same datasource (tomee.xml)

If i use JDBCRealm it works, but i want to reuse the same datasource config.


Any?



-- 
-------------------------------------------------------------------
SCJA. José Luis Cetina
-------------------------------------------------------------------


-- 
-------------------------------------------------------------------
*SCJA. José Luis Cetina*
-------------------------------------------------------------------

Reply via email to