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.
I tried it. It works almost exactly like I said it would. One thing I left out, is the web application name in the provider url.
Also although the jndi.properties is the most portable way to create the web app. There are issues of other jndi.properties file being first on the classpath. Be careful. If you have problems print out the getEnvironment from the initial context to see if it is setup correctly. Or if you are still having classpath/jndi.properties issues you can hard code the , i.e.,
I tried the tutorial in objectlearn. http://www.objectlearn.com/support/docs/introduction.jsp I used the Lomboz + Eclipse + Resin. When I tried to do the client testing, I got an error which is "no /hessian/ found" . If I removed the "/hessian/" from the url provider. It throw an exception and stop the process. The exception is unknow code:m.
Any one has tried that tutorial before, and completed it. Or anyone has any idea. I would appreciate that.
Thanks a lot.
SCJP 1.4, SCWCD, SCBCD,<br />SCDJWS (preparing)
subject: Step by Step how to configure remote clients with Resin