tomee-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Blevins <>
Subject Re: Need help getting Derby running in JUnit
Date Tue, 23 Nov 2010 17:00:26 GMT
On Tue, Nov 23, 2010 at 5:41 AM, tbbstny <> wrote:
>> This doc is still a work in progress, but has some info on Java EE and JNDI:
> I've read a few times.  Do I understand correctly that I will not be able to use
> the same JNDI names in OpenEJB inside JUnit that I'm using when deployed to
> JBoss?  For example, my JNDI name for my datasource when deployed would be
> "java:/MYDB", and my EJB might be "java:comp/env/ShortcutFacade".

The "java:comp/env" names used by the EJBs are portable and usable in
JBoss or any application server.  The "java:/MYDB" lookup is JBoss
specific. For all intense purposes imagine it as "jboss:/MYDB"

> Besides the ejb-jar.xml file, I have OpenEJB included as part of my test
> libraries, and my setUpClass method includes this:
>            // Create initial context
>            Properties properties = new Properties();
>            properties.setProperty(Context.INITIAL_CONTEXT_FACTORY,
> "org.apache.openejb.client.LocalInitialContextFactory");
>            properties.put("MYDB", "new://Resource?type=DataSource");
>            properties.put("MYDB.JdbcDriver",
> "org.apache.derby.jdbc.EmbeddedDriver");
>            properties.put("MYDB.JdbcUrl",
> "jdbc:derby:memory:DerbyDB;create=true");
>            properties.put("MYDB.JtaManaged", "false");
>            ic = new InitialContext(properties);

In the testcase itself, I'd simply use the "openejb:Resource/MYDB".
In Java EE 5 there's no way to make a portable test case.

Will try to give more detail in the reply to the other message.


View raw message