tomee-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tbbstny <tbbs...@yahoo.com>
Subject Re: Need help getting Derby running in JUnit
Date Tue, 23 Nov 2010 13:41:54 GMT
> If you  want to use a non-portable name, your bean can  lookup

> "openejb:Resource/MYDB".

OK, tried this first, and the lookup worked.


> If you want to do things the portable  way, your bean has to declare a
> reference to the resource via xml or  annotation:
>   http://openejb.apache.org/3.0/resource-ref-for-datasource.html

Following those instructions, I changed the ejb-jar.xml to look like this:
(This appears to look right compared to other snippets I've found in the mail 
list archives too)

<ejb-jar>
    <resource-ref>
        <res-ref-name>MYDB</res-ref-name>
        <res-type>javax.sql.DataSource</res-type>
    </resource-ref>
<ejb-jar/>


Now nothing is loaded, and I am getting this error:

[severity=ERROR,message=unexpected element 
(uri:"http://java.sun.com/xml/ns/javaee", local:"resource-ref"). Expected 
elements are 
<{http://java.sun.com/xml/ns/javaee}assembly-descriptor>,<{http://java.sun.com/xml/ns/javaee}ejb-client-jar>,<{http://java.sun.com/xml/ns/javaee}icon>,<{http://java.sun.com/xml/ns/javaee}display-name>,<{http://java.sun.com/xml/ns/javaee}interceptors>,<{http://java.sun.com/xml/ns/javaee}description>,<{http://java.sun.com/xml/ns/javaee}enterprise-beans>,<{http://java.sun.com/xml/ns/javaee}relationships>,locator=[node=null,object=null,url=null,line=3,col=19,offset=-1]]



> This doc is still a work in progress, but has some info on Java EE and JNDI:
>  http://openejb.apache.org/3.0/basics-getting-things.html

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".

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);

Mime
View raw message