I'm not seeing that javax.annotation.sql.DataSourceDefinition is working when I do EJBContainer#createEJBContainer().
I've placed this annotation on my (now, finally) discovered EJB (which otherwise loads fine). It looks like this:
[code]
@javax.annotation.sql.DataSourceDefinition(
name = "java:global/env/H2Test",
url = "jdbc:h2:mem:test;DB_CLOSE_DELAY=-1",
className = "org.h2.Driver",
user = "sa",
password = ""
)
@Stateless
public class FooBean implements Foo {
//...
}
[/code]
And my persistence.xml refers to it like this:
[code]
<?xml version="1.0" encoding="UTF-8"?>
<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="test" transaction-type="JTA">
<jta-data-source>java:global/env/H2Test</jta-data-source>
</persistence-unit>
</persistence>
[/code]
(Obviously I have much to add here; I'm just trying to see if this might be a way to define a data source quickly and easily in embedded testing. So far no luck.)
The container bombs out with a NamingException saying that "env", actually, can't be found:
[code]
Caused by: javax.naming.NameNotFoundException: env
at com.sun.enterprise.naming.impl.TransientContext.resolveContext(TransientContext.java:252)
at com.sun.enterprise.naming.impl.TransientContext.lookup(TransientContext.java:171)
at com.sun.enterprise.naming.impl.TransientContext.lookup(TransientContext.java:172)
at com.sun.enterprise.naming.impl.SerialContextProviderImpl.lookup(SerialContextProviderImpl.java:58)
at com.sun.enterprise.naming.impl.LocalSerialContextProviderImpl.lookup(LocalSerialContextProviderImpl.java:101)
at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:430)
[/code]
To be clear, I'm running this in "unsanctioned" mode :-). I don't have a preexisting Glassfish installation; I'm relying on a transitive Maven download of org.glassfish.extras:glassfish-embedded-all:3.0.1-b02.
Is this a known problem?
Best,
Laird
[Message sent by forum member 'ljnelson']
http://forums.java.net/jive/thread.jspa?messageID=396015