Hi
I've been informed by a helpful forum member that sun-ejb-jar.xml is required in order to lookup local/remote stateless session beans in GlassFish v2.
So as an academic exercise, I've been trying to get my own "example" enterprise project to work by using the proprietary sun-ejb-jar.xml configuration file....
QUESTION: how do I configure the sun-ejb-jar.xml file so that I may access the stateless session bean (EJB2.1) using BOTH remote and local interfaces?
NOTE: I've read the GlassFish EJB FAQ several times
(i.e.,
https://glassfish.dev.java.net/javaee5/ejb/EJB_FAQ.html)
But it is still not clear -- to me -- how I should proceed when the stateless session bean should be accessible via **both** the remote AND local interfaces...
The examples I've seen are for either local or remote....not both... and the following is typical of the examples in the EJB FAQ:
[code]
<sun-ejb-jar>
<enterprise-beans>
<ejb>
<ejb-name>FooBean</ejb-name>
<jndi-name>FooEJB</jndi-name>
</ejb>
</enterprise-beans>
</sun-ejb-jar>
[/code]
So, anyway, I have an "example" session bean that has both a remote AND local interface.... And, I have not been able to successfully configure the "sun-ejb-jar.xml" to allow a successful lookup on the local interface.
My most recent attempt to get this to work looks like this....(any helpful direction/corrections appreciated!)
[u][b]*** sun-ejb-jar.xml ***[/b][/u]
[code]
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sun-ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Application Server 9.0 EJB 3.0//EN" "
http://www.sun.com/software/appserver/dtds/sun-ejb-jar_3_0-0.dtd">
<sun-ejb-jar>
<enterprise-beans>
<ejb>
<ejb-name>DddEJBBean</ejb-name>
<ejb-ref>
<ejb-ref-name>DddEJBRemoteHome</ejb-ref-name>
<jndi-name>ejb/DddEJBRemoteHome</jndi-name>
</ejb-ref>
<ejb-ref>
<ejb-ref-name>DddEJBLocalHome</ejb-ref-name>
<jndi-name>ejb/DddEJBLocalHome</jndi-name>
</ejb-ref>
</ejb>
</enterprise-beans>
</sun-ejb-jar>
[/code]
[b]The ejb-jar.xml is configured like this[/b]
[u][b]*** ejb-jar.xml ***[/b][/u]
[code]
<?xml version="1.0" encoding="UTF-8"?>
<ejb-jar version="2.1" 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/j2ee/ejb-jar_2_1.xsd">
<enterprise-beans>
<session>
<display-name>DddEJBSB</display-name>
<ejb-name>DddEJBBean</ejb-name>
<home>ddd.ejb.DddEJBRemoteHome</home>
<remote>ddd.ejb.DddEJBRemote</remote>
<local-home>ddd.ejb.DddEJBLocalHome</local-home>
<local>ddd.ejb.DddEJBLocal</local>
<ejb-class>ddd.ejb.DddEJBBean</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
<ejb-ref>
<ejb-ref-name>DddEJBRemoteHome</ejb-ref-name>
<ejb-ref-type>Session</ejb-ref-type>
<home>ddd.ejb.DddEJBRemoteHome</home>
<remote>ddd.ejb.DddEJBRemote</remote>
<ejb-link>dddEAR-ejb.jar#DddEJBBean</ejb-link>
</ejb-ref>
<ejb-local-ref>
<ejb-ref-name>DddEJBLocalHome</ejb-ref-name>
<ejb-ref-type>Session</ejb-ref-type>
<local-home>ddd.ejb.DddEJBLocalHome</local-home>
<local>ddd.ejb.DddEJBLocal</local>
<ejb-link>dddEAR-ejb.jar#DddEJBBean</ejb-link>
</ejb-local-ref>
</session>
</enterprise-beans>
<assembly-descriptor>
<container-transaction>
<method>
<ejb-name>DddEJBBean</ejb-name>
<method-name>*</method-name>
</method>
<trans-attribute>Required</trans-attribute>
</container-transaction>
</assembly-descriptor>
</ejb-jar>
[/code]
[b]The code that performs the lookup looks like this[/b]
[u][b]*** lookup code ***[/b][/u]
[code]
private DddEJBLocal lookupDddEJBBean() {
try {
Context c = new InitialContext();
DddEJBLocalHome rv = (DddEJBLocalHome) c.lookup("ejb/DddEJBLocalHome");
return rv.create();
} catch (NamingException ne) {
java.util.logging.Logger.getLogger(getClass().getName()).log(java.util.logging.Level.SEVERE, "exception caught", ne);
throw new RuntimeException(ne);
} catch (CreateException ce) {
java.util.logging.Logger.getLogger(getClass().getName()).log(java.util.logging.Level.SEVERE, "exception caught", ce);
throw new RuntimeException(ce);
}
}
[/code]
[u][b]My environment is a follows[/b][/u]
Windows XP
NetBeans 6.0
GlassFish v2 (bundled with NetBeans 6.0)[/b]
(i am using EJB2.1)
NOTE AGAIN: I have tried myriad combinations of JNDI names with the above "lookup" code, but, nothing has worked. I listed the InitialContext and got the following
- UserTransaction: com.sun.enterprise.distributedtx.UserTransactionImpl
- jdbc: com.sun.enterprise.naming.TransientContext
- __SYSTEM: com.sun.enterprise.naming.TransientContext
- ejb: com.sun.enterprise.naming.TransientContext
- ddd.ejb.DddEJBRemoteHome: javax.naming.Reference
it doesn't appear --- to my untrained eye -- that the local reference is registered
--Thanks again for any help -sd
[Message sent by forum member 'sairndain' (sairndain)]
http://forums.java.net/jive/thread.jspa?messageID=253490