[arquillian-issues] [JBoss JIRA] Issue Comment Edited: (ARQ-593) glassfish-resources.xml (application scoped resources) not loaded with glassfish-remote
Vineet Reynolds (JIRA)
jira-events at lists.jboss.org
Fri Sep 30 15:39:26 EDT 2011
[ https://issues.jboss.org/browse/ARQ-593?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12631595#comment-12631595 ]
Vineet Reynolds edited comment on ARQ-593 at 9/30/11 3:38 PM:
--------------------------------------------------------------
The posted code fails (on both embedded and remote GF), as glassfish-resources.xml is expected to be present in the top-level of the archive. Arquillian eventually creates a WAR file for deployment onto Glassfish, and hence, the glassfish-resources.xml is expected to be present in WEB-INF/glassfish-resources.xml; instead, the posted code places glassfish-resources.xml in WEB-INF/lib/Project-ejb-1.0.0-SNAPSHOT.jar#META-INF/glassfish-resources.xml.
The suggested workaround is to explicitly create a {{WebArchive}} with a {{glassfish-resources.xml}} in the {{WEB-INF}} directory, as shown in the below example:
{code}
@Deployment
public static WebArchive createDeployment()
{
JavaArchive ejbArchive = ShrinkWrap.create(JavaArchive.class, "test-ejb.jar")
.addClasses(GreetingManager.class, GreetingManagerBean.class, User.class)
.addAsResource("META-INF/ejb-jar.xml", "ejb-jar.xml")
.addAsResource("META-INF/persistence-test.xml", "META-INF/persistence.xml");
return ShrinkWrap.create(WebArchive.class, "test.war")
.addAsLibrary(ejbArchive)
.addAsWebInfResource("META-INF/glassfish-resources-test.xml", "glassfish-resources.xml");
}
{code}
To summarize: the WAR archive deployed by Arquillian to Glassfish is a single module (although it contains EJBs). The {{glassfish-resources.xml}} is expected to be present in the top-level archive in the WEB-INF directory for the resources to be application scoped. Also, if module-scoped resources are be used, an {{EnterpriseArchive}} is used for deployment with the {{glassfish-resources.xml}} file present in the EJB jar, as a {{WebArchive}} is treated as a single module (despite the EJB classes in WEB-INF/classes or WEB-INF/lib).
was (Author: vineet.reynolds):
The posted code fails (on both embedded and remote GF), as glassfish-resources.xml is expected to be present in the top-level of the archive. Arquillian eventually creates a WAR file for deployment onto Glassfish, and hence, the glassfish-resources.xml is expected to be present in WEB-INF/glassfish-resources.xml; instead, the posted code places glassfish-resources.xml in WEB-INF/lib/Project-ejb-1.0.0-SNAPSHOT.jar#META-INF/glassfish-resources.xml.
The suggested workaround is to explicitly create a {{WebArchive}} with a {{glassfish-resources.xml}} in the {{WEB-INF}} directory, as shown in the below example:
{code}
@Deployment
public static WebArchive createDeployment()
{
JavaArchive ejbArchive = ShrinkWrap.create(JavaArchive.class, "test-ejb.jar")
.addClasses(GreetingManager.class, GreetingManagerBean.class, User.class)
.addAsResource("META-INF/ejb-jar.xml", "ejb-jar.xml")
.addAsResource("META-INF/persistence-test.xml", "META-INF/persistence.xml");
return ShrinkWrap.create(WebArchive.class, "test.war")
.addAsLibrary(ejbArchive)
.addAsWebInfResource("META-INF/glassfish-resources-test.xml", "glassfish-resources.xml");
}
{code}
> glassfish-resources.xml (application scoped resources) not loaded with glassfish-remote
> ---------------------------------------------------------------------------------------
>
> Key: ARQ-593
> URL: https://issues.jboss.org/browse/ARQ-593
> Project: Arquillian
> Issue Type: Bug
> Security Level: Public(Everyone can see)
> Components: GlassFish Containers
> Affects Versions: 1.0.0.Alpha5
> Environment: MacOSX Lion, Maven 3, arquillian 1.0.0.Alpha5, arquillian-glassfish-remote-3.1 1.0.0.Alpha5, Glassfish 3.1.1, Java 1.6.0_26 64bits
> Reporter: Hugo de Paix de Coeur
> Assignee: Vineet Reynolds
>
> An EJB Jar with an glassfish-resources.xml references an jdbc/rt JNDI resource.
> It's correctly read as java:app/jdbc/rt by the EJB package generated by maven but failed with Arquillian/ShrinkWrap targeting glassfish-remote-3.1
> ShrinkWrap :
> JavaArchive archive =
> ShrinkWrap.create(JavaArchive.class, "Project-ejb-1.0.0-SNAPSHOT.jar")
> .addPackages(true, "com.company.project.ejb.entities")
> .addPackages(true, "com.company.project.ejb.model")
> .addAsManifestResource("META-INF/ejb-jar.xml", ArchivePaths.create("ejb-jar.xml"))
> .addAsManifestResource("META-INF/sun-ejb-jar.xml", ArchivePaths.create("sun-ejb-jar.xml"))
> .addAsManifestResource("META-INF/glassfish-resources-test.xml", ArchivePaths.create("glassfish-resources.xml"))
> .addAsManifestResource("META-INF/persistence-test.xml", ArchivePaths.create("persistence.xml"));
> persistence.xml :
> <?xml version="1.0" encoding="UTF-8"?>
> <persistence version="1.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_1_0.xsd">
> <persistence-unit name="RTUnit" transaction-type="JTA">
> <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
> <jta-data-source>java:app/jdbc/rt</jta-data-source>
> <exclude-unlisted-classes>false</exclude-unlisted-classes>
> </persistence-unit>
>
> </persistence>
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the arquillian-issues
mailing list