Hi Anotonio,
We have a dev test that exercise similar combination and it is passing.
The only difference being the dev test does not use CDI. Can you try
putting the @DSD annnotation on your @Stateless bean to see if this works.
Thanks,
Mitesh
On 1/5/2012 7:08 AM, Antonio Goncalves wrote:
> BTW, same thing happens with 3.1.2-b14 : works within GlassFish,
> doesn't work in embedded mode
>
> Antonio
>
> 2012/1/5 Antonio Goncalves <antonio.mailing_at_gmail.com
> <mailto:antonio.mailing_at_gmail.com>>
>
> Hi,
>
> I'm using @DataSourceDefinition to define a datasource. This works
> fine when I run it with GlassFish 3.1.1-b12 but doesn't when I run
> a test using the embedded mode (with EJBContainer). These are my
> classes :
>
> *DatabaseResource *defines a Derby in memory datasource and
> produces an EntityManager
>
> @DataSourceDefinition(name = "java:app/jdbc/sampleArquilianWytiwyrDS",
> className = "org.apache.derby.jdbc.EmbeddedDriver",
> url =
> "jdbc:derby:memory:sampleArquilianWytiwyrDB;create=true;user=app;password=app"
> )
> public class DatabaseResource {
>
> @Produces
> @PersistenceContext(unitName = "sampleArquilianWytiwyrPU")
> private EntityManager em;
> }
>
> The *persistence.xml* uses this datasource :
>
> <persistence 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"
> version="2.0">
> <persistence-unit name="sampleArquilianWytiwyrPU"
> transaction-type="JTA">
> <jta-data-source>java:app/jdbc/sampleArquilianWytiwyrDS</jta-data-source>
> <class>org.agoncal.sample.arquilian.wytiwyr.Book</class>
> <properties>
> <property name="eclipselink.target-database" value="DERBY"/>
> <property name="eclipselink.ddl-generation" value="create-tables"/>
> <property name="eclipselink.logging.level" value="INFO"/>
> </properties>
> </persistence-unit>
> </persistence>
>
> And my *ItemEJB *just injects the EntityManager :
>
> @Stateless
> @Path("/items")
> public class ItemEJB {
>
> @Inject
> private EntityManager em;
>
> public Book createBook(Book book) {
> em.persist(book);
> return book;
> }
> }
>
> As I said, this works fine when deployed to GlassFish, but not in
> embedded more (using glassfish-embedded-all). I've seen several
> JIRAs on this (http://java.net/jira/browse/EMBEDDED_GLASSFISH-121,
> http://java.net/jira/browse/GLASSFISH-13672,
> http://java.net/jira/browse/GLASSFISH-15430) but because I use
> @DataSourceDefinition it's not related with any xml configuration
>
> Any idea ?
>
> Thanks,
> Antonio
>
> Stacktrace :
>
> GRAVE: Exception while preparing the app
> 5 janv. 2012 14:29:30
> com.sun.enterprise.v3.server.ApplicationLifecycle deploy
> GRAVE: Invalid resource : { ResourceInfo :
> (jndiName=java:app/jdbc/sampleArquilianWytiwyrDS__pm),
> (applicationName=classes) }
> java.lang.RuntimeException: Invalid resource : { ResourceInfo :
> (jndiName=java:app/jdbc/sampleArquilianWytiwyrDS__pm),
> (applicationName=classes) }
> at
> com.sun.enterprise.connectors.ConnectorRuntime.lookupDataSourceInDAS(ConnectorRuntime.java:540)
> at
> com.sun.enterprise.connectors.ConnectorRuntime.lookupPMResource(ConnectorRuntime.java:469)
> at
> org.glassfish.persistence.common.PersistenceHelper.lookupPMResource(PersistenceHelper.java:63)
> at
> org.glassfish.persistence.jpa.ProviderContainerContractInfoBase.lookupDataSource(ProviderContainerContractInfoBase.java:71)
> at
> org.glassfish.persistence.jpa.PersistenceUnitInfoImpl.<init>(PersistenceUnitInfoImpl.java:108)
> at
> org.glassfish.persistence.jpa.PersistenceUnitLoader.loadPU(PersistenceUnitLoader.java:154)
> at
> org.glassfish.persistence.jpa.PersistenceUnitLoader.<init>(PersistenceUnitLoader.java:119)
> at
> org.glassfish.persistence.jpa.JPADeployer$1.visitPUD(JPADeployer.java:214)
> at
> org.glassfish.persistence.jpa.JPADeployer$PersistenceUnitDescriptorIterator.iteratePUDs(JPADeployer.java:483)
> at
> org.glassfish.persistence.jpa.JPADeployer.createEMFs(JPADeployer.java:221)
> at
> org.glassfish.persistence.jpa.JPADeployer.prepare(JPADeployer.java:167)
> at
> com.sun.enterprise.v3.server.ApplicationLifecycle.prepareModule(ApplicationLifecycle.java:872)
> at
> com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:410)
> at
> com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:240)
> at
> org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:382)
> at
> com.sun.enterprise.v3.admin.CommandRunnerImpl$1.execute(CommandRunnerImpl.java:355)
> at
> com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:370)
> at
> com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1064)
> at
> com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1200(CommandRunnerImpl.java:96)
> at
> com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1244)
> at
> com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1232)
> at
> com.sun.enterprise.admin.cli.embeddable.CommandExecutorImpl.executeCommand(CommandExecutorImpl.java:147)
> at
> com.sun.enterprise.admin.cli.embeddable.DeployerImpl.deploy(DeployerImpl.java:99)
> at
> org.glassfish.ejb.embedded.EJBContainerImpl.deploy(EJBContainerImpl.java:142)
> at
> org.glassfish.ejb.embedded.EJBContainerProviderImpl.createEJBContainer(EJBContainerProviderImpl.java:134)
> at
> javax.ejb.embeddable.EJBContainer.createEJBContainer(EJBContainer.java:127)
> at
> org.agoncal.sample.arquilian.wytiwyr.ItemEJBWithoutArquillianIT.initContainer(ItemEJBWithoutArquillianIT.java:41)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> at java.lang.reflect.Method.invoke(Method.java:597)
> at
> org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
> at
> org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
> at
> org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
> at
> org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:27)
> at
> org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
> at org.junit.runners.ParentRunner.run(ParentRunner.java:292)
> at org.junit.runner.JUnitCore.run(JUnitCore.java:157)
> at
> com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:71)
> at
> com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:199)
> at
> com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:62)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> at java.lang.reflect.Method.invoke(Method.java:597)
> at
> com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
> Caused by:
> com.sun.appserv.connectors.internal.api.ConnectorRuntimeException:
> Invalid resource : { ResourceInfo :
> (jndiName=java:app/jdbc/sampleArquilianWytiwyrDS__pm),
> (applicationName=classes) }
> at
> com.sun.enterprise.connectors.service.ConnectorResourceAdminServiceImpl$MyDataSource.validateResource(ConnectorResourceAdminServiceImpl.java:274)
> at
> com.sun.enterprise.connectors.service.ConnectorResourceAdminServiceImpl$MyDataSource.setResourceInfo(ConnectorResourceAdminServiceImpl.java:255)
> at
> com.sun.enterprise.connectors.service.ConnectorResourceAdminServiceImpl.lookupDataSourceInDAS(ConnectorResourceAdminServiceImpl.java:245)
> at
> com.sun.enterprise.connectors.ConnectorRuntime.lookupDataSourceInDAS(ConnectorRuntime.java:538)
> ... 45 more
> 5 janv. 2012 14:29:30 org.glassfish.deployment.admin.DeployCommand
> execute
> GRAVE: Exception while preparing the app : Invalid resource : {
> ResourceInfo :
> (jndiName=java:app/jdbc/sampleArquilianWytiwyrDS__pm),
> (applicationName=classes) }
> com.sun.appserv.connectors.internal.api.ConnectorRuntimeException:
> Invalid resource : { ResourceInfo :
> (jndiName=java:app/jdbc/sampleArquilianWytiwyrDS__pm),
> (applicationName=classes) }
> at
> com.sun.enterprise.connectors.service.ConnectorResourceAdminServiceImpl$MyDataSource.validateResource(ConnectorResourceAdminServiceImpl.java:274)
> at
> com.sun.enterprise.connectors.service.ConnectorResourceAdminServiceImpl$MyDataSource.setResourceInfo(ConnectorResourceAdminServiceImpl.java:255)
> at
> com.sun.enterprise.connectors.service.ConnectorResourceAdminServiceImpl.lookupDataSourceInDAS(ConnectorResourceAdminServiceImpl.java:245)
> at
> com.sun.enterprise.connectors.ConnectorRuntime.lookupDataSourceInDAS(ConnectorRuntime.java:538)
> at
> com.sun.enterprise.connectors.ConnectorRuntime.lookupPMResource(ConnectorRuntime.java:469)
> at
> org.glassfish.persistence.common.PersistenceHelper.lookupPMResource(PersistenceHelper.java:63)
> at
> org.glassfish.persistence.jpa.ProviderContainerContractInfoBase.lookupDataSource(ProviderContainerContractInfoBase.java:71)
> at
> org.glassfish.persistence.jpa.PersistenceUnitInfoImpl.<init>(PersistenceUnitInfoImpl.java:108)
> at
> org.glassfish.persistence.jpa.PersistenceUnitLoader.loadPU(PersistenceUnitLoader.java:154)
> at
> org.glassfish.persistence.jpa.PersistenceUnitLoader.<init>(PersistenceUnitLoader.java:119)
> at
> org.glassfish.persistence.jpa.JPADeployer$1.visitPUD(JPADeployer.java:214)
> at
> org.glassfish.persistence.jpa.JPADeployer$PersistenceUnitDescriptorIterator.iteratePUDs(JPADeployer.java:483)
> at
> org.glassfish.persistence.jpa.JPADeployer.createEMFs(JPADeployer.java:221)
> at
> org.glassfish.persistence.jpa.JPADeployer.prepare(JPADeployer.java:167)
> at
> com.sun.enterprise.v3.server.ApplicationLifecycle.prepareModule(ApplicationLifecycle.java:872)
> at
> com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:410)
> at
> com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:240)
> at
> org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:382)
> at
> com.sun.enterprise.v3.admin.CommandRunnerImpl$1.execute(CommandRunnerImpl.java:355)
> at
> com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:370)
> at
> com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1064)
> at
> com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1200(CommandRunnerImpl.java:96)
> at
> com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1244)
> at
> com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1232)
> at
> com.sun.enterprise.admin.cli.embeddable.CommandExecutorImpl.executeCommand(CommandExecutorImpl.java:147)
> at
> com.sun.enterprise.admin.cli.embeddable.DeployerImpl.deploy(DeployerImpl.java:99)
> at
> org.glassfish.ejb.embedded.EJBContainerImpl.deploy(EJBContainerImpl.java:142)
> at
> org.glassfish.ejb.embedded.EJBContainerProviderImpl.createEJBContainer(EJBContainerProviderImpl.java:134)
> at
> javax.ejb.embeddable.EJBContainer.createEJBContainer(EJBContainer.java:127)
> at
> org.agoncal.sample.arquilian.wytiwyr.ItemEJBWithoutArquillianIT.initContainer(ItemEJBWithoutArquillianIT.java:41)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> at java.lang.reflect.Method.invoke(Method.java:597)
> at
> org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
> at
> org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
> at
> org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
> at
> org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:27)
> at
> org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
> at org.junit.runners.ParentRunner.run(ParentRunner.java:292)
> at org.junit.runner.JUnitCore.run(JUnitCore.java:157)
> at
> com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:71)
> at
> com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:199)
> at
> com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:62)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> at java.lang.reflect.Method.invoke(Method.java:597)
> at
> com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
> PlainTextActionReporterFAILUREDescription: deploy
> AdminCommandError occurred during deployment: Exception while
> preparing the app : Invalid resource : { ResourceInfo :
> (jndiName=java:app/jdbc/sampleArquilianWytiwyrDS__pm),
> (applicationName=classes) }. Please see server.log for more details.
> [name=classes
> 5 janv. 2012 14:29:30
> org.glassfish.ejb.embedded.EJBContainerProviderImpl createEJBContainer
>
>
>
>
> --
> --
> Antonio Goncalves (antonio.goncalves_at_gmail.com
> <mailto:antonio.goncalves_at_gmail.com>)
> Software architect
>
> Web site : www.antoniogoncalves.org <http://www.antoniogoncalves.org>
> Blog: agoncal.wordpress.com <http://agoncal.wordpress.com>
> Feed: feeds2.feedburner.com/AntonioGoncalves
> <http://feeds2.feedburner.com/AntonioGoncalves>
> Paris JUG leader : www.parisjug.org <http://www.parisjug.org>
> LinkedIn: www.linkedin.com/in/agoncal <http://www.linkedin.com/in/agoncal>