1

Problem: I have an ejb-jar-1.jar which defines EJBs and Entities. The project structure is listed below. During deployment all EJBs are successfully bootstraped > started and their JNDI locations are printed in a log file. There's a class in my WAR file which needs to access a NAMED QUERY defined on an Entity which resides inside ejb-jar-1.jar. When this piece of code is run it throws an illegalArgumentException saying NAMED QUERY cannot be found. On a different note I also cannot get reference to SEAM components that were started when ejb-jar1.jar was deployed. I printed the JNDI tree from app-war.war file and it does not have any JNDI resources from ejb-jar-1.jar. So, I believe this is a context issue where JNDI resources available in ejb-jar-1.jar cannot be seen from app-war.war.

Any suggestions on how to access JNDI resources available in ejb-jar-1.jar from app-war.war?

Deployement Info

* JBOSS 7.1.1.FINAL
* Uses seam framework: jboss-seam-2.2.1.CR2.jar
* Uses Hibernate 3.4.0.GA

main-ear.ear

|__META-INF
|   |____jboss-deployment-structure.xml
|   |____application.xml
|   |____jboss-app.xml
|   |____MANIFEST.MF
|__lib
|   |____somejar.jar
|   |____somejar.jar
|__ejb-jar-1.jar
|__ejb-jar-2.jar
|__jboss-seam-2.2.1.CR2.jar
|__commons-lang-2.4.jar
|__commons-codec-1.1.jar
|__jasypt-1.6.jar
|__app-war.war

jboss-deployment-structure.xml

<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.0">
    <ear-subdeployments-isolated>false</ear-subdeployments-isolated>
    <deployment>
        <exclusions>
            <module name="javax.faces.api" slot="1.2"/>
            <module name="com.sun.jsf-impl" slot="1.2"/>
            <module name="org.hibernate" slot="main"/>
            <module name="org.hibernate.validator" slot="main"/>
            <module name="org.apache.commons.lang"/>
            <module name="org.apache.commons.collections"/>
            <module name="org.apache.commons.codec"/>
            <module name="org.picketlink" slot="main"/>
            <module name="org.picketbox" slot="main"/>
            <module name="org.javassist" slot="main"/>
            <module name="org.dom4j" slot="main"/>
        </exclusions>
        <dependencies>
            <module name="javax.faces.api" slot="1.2" export="true"/>
            <module name="com.sun.jsf-impl" slot="1.2" export="true"/>
            <module name="org.javassist" slot="1" export="true"/>
            <module name="org.apache.commons.logging" export="true"/>
        </dependencies>
    </deployment>
    <sub-deployment name="app-war.war">
        <exclusions>
            <module name="javax.faces.api" slot="main"/>
            <module name="com.sun.jsf-impl" slot="main"/>
        </exclusions>
        <dependencies>
            <module name="javax.faces.api" slot="1.2"/>
            <module name="com.sun.jsf-impl" slot="1.2"/>
            <module name="deployment.main-ear.ear.ejb-jar-1.jar" />
            <module name="deployment.main-ear.ear.ejb-jar-2.jar" />
            <module name="deployment.main-ear.ear.jboss-seam-2.2.1.CR2.jar"/>
        </dependencies>
    </sub-deployment>
    <module name="deployment.main-ear.ear.jasypt-1.6.jar" />
    <module name="deployment.main-ear.ear.commons-codec-1.1.jar" />
    <module name="deployment.main-ear.ear.commons-lang-2.4.jar" />
</jboss-deployment-structure>

application.xml

<?xml version="1.0" encoding="UTF-8"?>
<application xmlns="http://java.sun.com/xml/ns/j2ee"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/javaee/application_6.xsd"
             version="6">
    <description>myapp</description>
    <display-name>myapp</display-name>
    <initialize-in-order>true</initialize-in-order>
    <library-directory>lib</library-directory>
    <module>
        <ejb>ejb-jar-1.jar</ejb>
    </module>
    <module>
        <ejb>ejb-jar-2.jar</ejb>
    </module>
    <module>
        <ejb>jboss-seam-2.2.1.CR2.jar</ejb>
    </module>
    <module>
        <web>
            <web-uri>app-war.war</web-uri>
            <context-root>/app</context-root>
        </web>
    </module>
</application>

2 Answers 2

1

Bit late but oh well...for EE6 you need to use JNDI portable syntax, eg. add following annotations to all beans in the secondary module

@JndiName("java:app/NameOfModule/NameOfBean")
1
  • DaveB, thank you - this led me to solve my own similar problem!
    – JGlass
    Aug 29, 2018 at 19:19
0

Think you need seam.properties in your jar in META-INF

1
  • I already have seam.properties in META-INF of the ejb-jar-1.jar
    – ronsi
    Sep 13, 2013 at 13:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.