Update 04-dec-2004:
This document has been deprecated. Check this basic example on how you can call a bean remotely through HTTP. Tested with JBoss 3.2.6. You can download it here (source).
Follow this steps:
- modify build.properties with you jboss path and src/httpTest/remote/jndi.properties with your hostname
- copy jboss-common.jar, jboss-transaction.jar, jnpserver.jar, jboss-j2ee.jar, jboss.jar to the lib directory
- run ant deploy (will deploy the ear to you jboss)
- run ant test (requires jboss running)
- inspect the code, enjoy.
JNDI and RMI over HTTP (part I – general)
Created: 20 Nov 2003
1.Change the jndi.properties from:
java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
java.naming.provider.url=[internal machine address]
to:
java.naming.factory.initial=org.jboss.naming.HttpNamingContextFactory
java.naming.provider.url=http://[external machine address]:[port]/invoker/JNDIFactory
2. Modify the jboss subtask in ejbdoclet
<jboss version=”${jboss.version}”
xmlencoding=”UTF-8″
typemapping=”${type.mapping}”
datasource=”${datasource.name}”
destdir=”${build.dir}/META-INF”
mergedir=”${src.resources.dir}”
validateXml=”false”
/>
and copy the jboss-container.xml file in the ${src.resources.dir}:
<container-configurations>
<container-configuration extends=”Standard Stateful SessionBean”>
<container-name>HTTP Session</container-name>
<home-invoker>jboss:service=invoker,type=http</home-invoker>
<bean-invoker>jboss:service=invoker,type=http</bean-invoker>
</container-configuration>
</container-configurations>
This file will be merged into the jboss.xml file
3. Add a new xdoclet line to the stateful beans:
@jboss.container-configuration name=”HTTP Session”
4. !!!! for some reason all naming lookups have to be changed from
lContext.lookup(“java:pilot/X”)
to
lContext.lookup(“pilot/X”)
otherwise the following exception will occur: javax.naming.CommunicationException: Failed to connect to server http:1099.
*. Tested with jboss 3.0.6