
Seam in JBoss Application Server set EJB session bean to Seam component dose not need set any JNDI. Seam can find out EJB’s JNDI.
In Websphere 7 Application Server, Seam cannot find out EJB’s JNDI. Need manual set the EJB’s JNDI (Only set EJB session bean with Seam component).
First, add below setting in web.xml:
<ejb-local-ref> <ejb-ref-name>ejblocal:EjbSynchronizations</ejb-ref-name> <ejb-ref-type>Session</ejb-ref-type> <local-home></local-home> <local>org.jboss.seam.transaction.LocalEjbSynchronizations</local> </ejb-local-ref>
Then, add a seam-jndi.prpperties file in WEB-INF/classes:
com.ibm.websphere.naming.hostname.normalizer=com.ibm.ws.naming.util.DefaultHostnameNormalizer java.naming.factory.initial=com.ibm.websphere.naming.WsnInitialContextFactory com.ibm.websphere.naming.name.syntax=jndi com.ibm.websphere.naming.namespace.connection=lazy com.ibm.ws.naming.ldap.ldapinitctxfactory=com.sun.jndi.ldap.LdapCtxFactory com.ibm.websphere.naming.jndicache.cacheobject=populated com.ibm.websphere.naming.namespaceroot=defaultroot com.ibm.ws.naming.wsn.factory.initial=com.ibm.ws.naming.util.WsnInitCtxFactory com.ibm.websphere.naming.jndicache.maxcachelife=0 com.ibm.websphere.naming.jndicache.maxentrylife=0 com.ibm.websphere.naming.jndicache.cachename=providerURL java.naming.provider.url=corbaloc:rir:/NameServiceServerRoot java.naming.factory.url.pkgs=com.ibm.ws.runtime:com.ibm.ws.naming
Modify components.xml:
<core:init jndi-pattern="ejblocal:#{ejbName}" debug="false" />
Last step is add ibm-ejb-jar-bnd.xml in EJB project’s META-INF:
<?xml version="1.0" encoding="UTF-8"?> <ejb-jar-bnd xmlns="http://websphere.ibm.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://websphere.ibm.com/xml/ns/javaee http://websphere.ibm.com/xml/ns/javaee/ibm-ejb-jar-bnd_1_0.xsd" version="1.0"> <session name="MyBean" simple-binding-name="MyBean" /> </ejb-jar-bnd>
simple-binding-name is a JNDI. Seam will use below JNDI to find out MyBean:
ejblocal:MyBean
If modify jndi-pattern. you must modify simple-binding-name too.
For example:
<core:init jndi-pattern="ejblocal:myModule/#{ejbName}" debug="false" />
simple-binding-name also modify as:
<session name="MyBean" simple-binding-name="myModule/MyBean" />
Tags: Seam