Hi David and all,

I got my things to work but I still have a question regarding the
configuration of datasources:

Here's the setup for my datasource:

       properties.put("db2x070", "new://Resource?type=DataSource");
       properties.put("db2x070.JdbcDriver", "com.ibm.db2.jcc.DB2Driver");
       properties.put("db2x070.JdbcUrl",
"jdbc:db2://db2d070n0:50127/db2d070");
       properties.put("db2x070.UserName", "pblais");
       properties.put("db2x070.Password", "xxxxxx");       
       initialContext = new InitialContext(properties);

        }

and here's my test:

        public void testAjouterApplication() throws Exception {
                
                Object object = 
initialContext.lookup("ConsoleGestionServiceImplLocal");
                ConsoleGestionService service = (ConsoleGestionService) object;
                try {
                        Application a = new Application();
                        a.setId(1L);
                        a.setName("fat/ECS1DDD");
                        
                        service.ajouterApplication(a);
                        
                } catch (Exception e) {
                        e.printStackTrace();
                        fail();
                }
        }

My persistence.xml file contains this:
   <persistence-unit name="cgeEntityManagerFactory" transaction-type="JTA">
          <provider>org.hibernate.ejb.HibernatePersistence</provider>
          <jta-data-source>jdbc/db2x070</jta-data-source>
      <properties>
        <property name="hibernate.ejb.cfgfile"
value="com/desj/visa/srv/cge/orm/config/hibernate.cfg.xml"/>
      </properties>
   </persistence-unit>

The Junit works but I can see that there are 2 lines that I cannot explain
in the log :
"Adjusting PersistenceUnit" from "jdbc/db2x070"...

If I understand correctly  <jta-data-source>jdbc/db2x070</jta-data-source> 
corresponds to the jndi name, why does openEJB changes the values? I would
like to setup my datasource name in the persistence.xml file and map the
datasource in my Junit test to that jndi name so that the code in my
existing application and my junit test map to the same thing... 

Is my explanation clear?

INFO - Auto-creating a container for bean ConsoleGestionServiceImpl:
Container(type=STATELESS, id=Default Stateless Container)
INFO - Configuring PersistenceUnit(name=cgeEntityManagerFactory,
provider=org.hibernate.ejb.HibernatePersistence)
INFO - Auto-creating a Resource with id 'db2x070NonJta' of type 'DataSource
for 'cgeEntityManagerFactory'.
INFO - Configuring Service(id=db2x070NonJta, type=Resource,
provider-id=db2x070)
INFO - Adjusting PersistenceUnit cgeEntityManagerFactory <jta-data-source>
to Resource ID 'db2x070' from 'jdbc/db2x070'
INFO - Adjusting PersistenceUnit cgeEntityManagerFactory
<non-jta-data-source> to Resource ID 'db2x070NonJta' from 'null'


Thanks again.

Patrick
-- 
View this message in context: 
http://old.nabble.com/JNDI-lookup...-tp26681793p26681793.html
Sent from the OpenEJB User mailing list archive at Nabble.com.

Reply via email to