UserTransaction and HttpNamingContextFactory
matthias Oct 20, 2004 5:59 AMHi,
i have a servlet on Server 'A' which communicates with Session-Beans on Server 'B'.
The Servlet starts a Transaction and the Seesion-Bean makes the Database-Actions.
JBoss-Version: jboss-3.0.4_tomcat-4.1.12.
;----------- Servlet-Snipping ---------------------------------------------------
myTrans = (UserTransaction)ctx.lookup( "UserTransaction" );
myTrans.begin();
String updateStmt = "update ..."
try {
mySessBean.doUpdStrbDatabase(updateStmt);
}
lTransaction.commit();
} catch (Exception le) {
lTransaction.rollback();
le.printStackTrace();
}
;----------- Servlet-Snipping ---------------------------------------------------
with standard-Connection the System works fine.
Now i changed the jndi.properties to use HttpNamingContextFactory
because i want to communicate with the JBoss-Server through
a Firewall.
;------jndi.properties----------------------------------------------------
; Standardconnection
;--java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
;--java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
;--java.naming.provider.url=jnp://localhost:11099
java.naming.factory.initial=org.jboss.naming.HttpNamingContextFactory
java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
java.naming.provider.url=http://localhost:8080/invoker/JNDIFactory
;------jndi.properties----------------------------------------------------
the web.xml in http-invoker.sar was customized to solve the external url.
;------- server .../default/deploy/http-invoker.sar/invoker.war/WEB-INF/web.xml
<servlet-name>JNDIFactory</servlet-name>
A servlet that exposes the JBoss JNDI Naming service stub
through http. The return content is a serialized
MarshalledValue containg the org.jnp.interfaces.Naming stub. This
configuration handles requests for the standard JNDI naming service.
<servlet-class>org.jboss.invocation.http.servlet.NamingFactoryServlet</servlet-class>
<init-param>
<param-name>invokerName</param-name>
<param-value>jboss:service=Naming</param-value>
</init-param>
<init-param>
<param-name>externalURL</param-name>
<param-value>http://pcit1052:8080/invoker/JMXInvokerServlet</param-value>
...
</init-param>
<load-on-startup>2</load-on-startup>
;------- server .../default/deploy/http-invoker.sar/invoker.war/WEB-INF/web.xml
The Beans work fine. But when i try to work with a UserTransaction
the System runs into an Exception.
javax.naming.CommunicationException: Failed to connect to server http:1099
[Root exception is javax.naming.ServiceUnavailableException:
Failed to connect to server http:1099
[Root exception is java.net.UnknownHostException: http: http]]
Is there an additional setup necessary ?
I would be glad to get help.
Regards Matthias Lakämper