-
1. Re: jboss-remote-naming-1.0.2.Final.jar is not in the class path.
jaikiran Apr 12, 2012 1:38 AM (in response to enakai00)Where does it throw the ClassNotFoundException? Can you post the entire exception stacktrace?
-
2. Re: jboss-remote-naming-1.0.2.Final.jar is not in the class path.
enakai00 Apr 12, 2012 5:15 AM (in response to jaikiran)I'm trying to connect to a remote JMS provider from a servlet.
-------------------------------
@Override
protected void doGet(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
(snip)
try {
Properties props = new Properties();
props.put(Context.INITIAL_CONTEXT_FACTORY, org.jboss.naming.remote.client.InitialContextFactory.class.getName()); // throws an Exception
props.put(Context.PROVIDER_URL, "remote://node02:4447");
Context ic = new InitialContext(props);ConnectionFactory cf = (ConnectionFactory) ic.lookup("java:/RemoteConnectionFactory");
Queue queue = (Queue) ic.lookup(destinationName);
Connection connection = cf.createConnection(JMS_USER, JMS_PASS);
Session session = connection.createSession(false,
Session.AUTO_ACKNOWLEDGE);
MessageProducer publisher = session.createProducer(queue);connection.start();
TextMessage tmessage = session.createTextMessage(message);
publisher.send(tmessage);
connection.close();
} catch (final Exception e) {
e.printStackTrace();
}-------------------------------
Eclipse complains that org.jboss.naming cannot be resolved. And when deployed on a server, the following "java.lang.NoClassDefFoundError" occures.
-------------------------------
[Server:host01_server01] 15:25:56,142 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/HelloWorld].[web.HelloWorldServlet]] (http--0.0.0.0-8080-1) Servlet.service() for servlet web.HelloWorldServlet threw exception: java.lang.NoClassDefFoundError: org/jboss/naming/remote/client/InitialContextFactory
[Server:host01_server01] at web.HelloWorldServlet.doGet(HelloWorldServlet.java:78) [classes:]
[Server:host01_server01] at javax.servlet.http.HttpServlet.service(HttpServlet.java:734) [jboss-servlet-api_3.0_spec-1.0.0.Final.jar:1.0.0.Final]
[Server:host01_server01] at javax.servlet.http.HttpServlet.service(HttpServlet.java:847) [jboss-servlet-api_3.0_spec-1.0.0.Final.jar:1.0.0.Final]
[Server:host01_server01] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329) [jbossweb-7.0.13.Final.jar:]
[Server:host01_server01] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.13.Final.jar:]
[Server:host01_server01] at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275) [jbossweb-7.0.13.Final.jar:]
[Server:host01_server01] at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161) [jbossweb-7.0.13.Final.jar:]
[Server:host01_server01] at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:153) [jboss-as-web-7.1.1.Final.jar:7.1.1.Final]
[Server:host01_server01] at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155) [jbossweb-7.0.13.Final.jar:]
[Server:host01_server01] at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [jbossweb-7.0.13.Final.jar:]
[Server:host01_server01] at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [jbossweb-7.0.13.Final.jar:]
[Server:host01_server01] at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:368) [jbossweb-7.0.13.Final.jar:]
[Server:host01_server01] at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877) [jbossweb-7.0.13.Final.jar:]
[Server:host01_server01] at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:671) [jbossweb-7.0.13.Final.jar:]
[Server:host01_server01] at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:930) [jbossweb-7.0.13.Final.jar:]
[Server:host01_server01] at java.lang.Thread.run(Thread.java:679) [rt.jar:1.6.0_22]
[Server:host01_server01]
-------------------------------
If I modify:
props.put(Context.INITIAL_CONTEXT_FACTORY, org.jboss.naming.remote.client.InitialContextFactory.class.getName());
to
props.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");
The following error occures.
-------------------------------
[Server:host01_server01] 17:08:04,651 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/HelloWorld].[web.HelloWorldServlet]] (http--0.0.0.0-8080-1) Servlet.service() for servlet web.HelloWorldServlet threw exception: java.lang.Error: Unresolved compilation problem
[Server:host01_server01] org.jboss.naming cannot be resolved to a type
[Server:host01_server01]
[Server:host01_server01] at web.HelloWorldServlet.doGet(HelloWorldServlet.java:78) [classes:]
[Server:host01_server01] at javax.servlet.http.HttpServlet.service(HttpServlet.java:734) [jboss-servlet-api_3.0_spec-1.0.0.Final.jar:1.0.0.Final]
[Server:host01_server01] at javax.servlet.http.HttpServlet.service(HttpServlet.java:847) [jboss-servlet-api_3.0_spec-1.0.0.Final.jar:1.0.0.Final]
[Server:host01_server01] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329) [jbossweb-7.0.13.Final.jar:]
[Server:host01_server01] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.13.Final.jar:]
[Server:host01_server01] at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275) [jbossweb-7.0.13.Final.jar:]
[Server:host01_server01] at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161) [jbossweb-7.0.13.Final.jar:]
[Server:host01_server01] at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:153) [jboss-as-web-7.1.1.Final.jar:7.1.1.Final]
[Server:host01_server01] at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155) [jbossweb-7.0.13.Final.jar:]
[Server:host01_server01] at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [jbossweb-7.0.13.Final.jar:]
[Server:host01_server01] at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [jbossweb-7.0.13.Final.jar:]
[Server:host01_server01] at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:368) [jbossweb-7.0.13.Final.jar:]
[Server:host01_server01] at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877) [jbossweb-7.0.13.Final.jar:]
[Server:host01_server01] at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:671) [jbossweb-7.0.13.Final.jar:]
[Server:host01_server01] at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:930) [jbossweb-7.0.13.Final.jar:]
[Server:host01_server01] at java.lang.Thread.run(Thread.java:679) [rt.jar:1.6.0_22]
[Server:host01_server01]
-------------------------------