Brain Wilson had a question on how to configure remote clients to talk to
EJB beans in Resin.
He sent me some offline email as well posting his question on the Resin mailing list.
I thought I would share the answer with this forum since this is appropiate for people getting started with Resin EE.
1) First I would not hardcode the JNDI properties in your source code. Instead put them in a JNDI properties file called jndi.properties. As long
as this file is on you classpath the JNDI system will find jndi.properties as a class resource and use it as the default properties for the initial
context and provider URL. Then all you need to do is create an InitialContext with no arguments. This is the more portable J2EE way to get
your initial context.
Here is an example properties file for accessing weblogic (resin example
will follow)
Sample Listing....
java.naming.factory.initial=weblogic.jndi.WLInitialContextFactory
java.naming.provider.url=t3://localhost:7001
2) Now the question becomes how do you configure the above for Resin. I think
the answer is here
<a href="http://www.caucho.com/resin-ee/ejb-ref/ejb-jndi.xtp">
http://www.caucho.com/resin-ee/ejb-ref/ejb-jndi.xtp</a>. Although the link does
not specify client access per se or the jndi.properties file.
Try changing the JNDI properties file as follows for hessian...
java.naming.factory.initial=com.caucho.hessian.HessianContextFactory
java.naming.provider.url=http://<yourhostname>/hessian
Try changing the JNDI properties file as follows for burlap...
java.naming.factory.initial=com.caucho.burlap.BurlapContextFactory
java.naming.provider.url=http://<yourhostname>/burlap
I have not tried this with Resin, but I have done similar things when
working with WebLogic and Sun's RI. I've only done local beans for web apps
with Resin EE in production. This should work.
3) You are not done yet. You also have to expose hessian protocol from your
web application that houses your enterprise beans. I found information how
to do this here...
<a href="http://www.caucho.com/resin-ee/ejb-ref/ejb-server.xtp">
http://www.caucho.com/resin-ee/ejb-ref/ejb-server.xtp</a>
Add the following mapping to your web application's deployment descriptor
for burlap.
<!-- Burlap protocol configuration -->
<servlet-mapping>
<url-pattern id='/burlap/*'/>
<servlet-name id='com.caucho.burlap.EJBServlet'/>
</servlet-mapping>
Strangely.... The documentation only explains Burlap instead of Hessian.
Hessian is the preferred way to access the bean remotely (faster, but does
not sneak through firewalls as well as Burlap).
Based on the logical nature of most of the Resin package naming, I make the
following guess on configuring Hessian. (I'll try this when I add this
information to the tutorial I am writing).
<!-- Hessian protocol configuration -->
<servlet-mapping>
<url-pattern id='/hessian/*'/>
<servlet-name id='com.caucho.hessian.EJBServlet'/>
</servlet-mapping>
4) Lastly it seems you are doing this mainly to
test your enterprise beans.
I suggest using Cactus to test local beans. I think there is too much
configuration and runtime overhead to use remote beans just to test beans
that will naturally run locally within the confines of a web application.