[Beginners Corner] - javax.naming.NameNotFoundException: ConnectionFactory not bo
by donald.x.szeto
Hi,
I'm new to JBoss and am trying to setup sample code to use the JBoss messaging service.
I'm trying to use the included TopicSendRecvClient.java test class to access the following default JNDI objects to send/receive JMS Text messages.
TopicConnectionFactory
topic/testTopic
Problem:
In Setup 1 (Local Workstation Environment listed below), I can retrieve and use the objects normally.
In Setup 2, I have installed the same version server on a remote linux server. My problem is that when I try to retrieve the same objects through JNDI, I have an exception saying that the objects are not bound. This doesn't seem to be the case though since I can see the objects through the JMXConsole JNDIView.list() method on the same remote Linux server.
JMXConsole JNDIView.list(): On Remote Linux Server
Global JNDI Namespace
+- TopicConnectionFactory (class: org.jboss.naming.LinkRefPair)
+- UIL2ConnectionFactory[link -> ConnectionFactory] (class: javax.naming.LinkRef)
+- UserTransactionSessionFactory (proxy: $Proxy12 implements interface org.jboss.tm.usertx.interfaces.UserTransactionSessionFactory)
+- console (class: org.jnp.interfaces.NamingContext)
| +- PluginManager (proxy: $Proxy43 implements interface org.jboss.console.manager.PluginManagerMBean)
+- UIL2XAConnectionFactory[link -> XAConnectionFactory] (class: javax.naming.LinkRef)
+- UUIDKeyGeneratorFactory (class: org.jboss.ejb.plugins.keygenerator.uuid.UUIDKeyGeneratorFactory)
+- QueueConnectionFactory (class: org.jboss.naming.LinkRefPair)
+- UserTransaction (class: org.jboss.tm.usertx.client.ClientUserTransaction)
+- jmx (class: org.jnp.interfaces.NamingContext)
| +- invoker (class: org.jnp.interfaces.NamingContext)
| | +- RMIAdaptor (proxy: $Proxy42 implements interface org.jboss.jmx.adaptor.rmi.RMIAdaptor,interface org.jboss.jmx.adaptor.rmi.RMIAdaptorExt)
| +- rmi (class: org.jnp.interfaces.NamingContext)
| | +- RMIAdaptor[link -> jmx/invoker/RMIAdaptor] (class: javax.naming.LinkRef)
+- UILXAConnectionFactory[link -> XAConnectionFactory] (class: javax.naming.LinkRef)
+- UILConnectionFactory[link -> ConnectionFactory] (class: javax.naming.LinkRef)
Client Exception:
javax.naming.NameNotFoundException: ConnectionFactory not bound
at org.jnp.server.NamingServer.getBinding(NamingServer.java:529)
at org.jnp.server.NamingServer.getBinding(NamingServer.java:537)
at org.jnp.server.NamingServer.getObject(NamingServer.java:543)
at org.jnp.server.NamingServer.lookup(NamingServer.java:296)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:294)
at sun.rmi.transport.Transport$1.run(Transport.java:153)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:149)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:466)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:707)
at java.lang.Thread.run(Thread.java:595)
at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:247)
at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:223)
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:126)
at org.jnp.server.NamingServer_Stub.lookup(Unknown Source)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:625)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:587)
at javax.naming.InitialContext.lookup(InitialContext.java:351)
at org.jboss.naming.LinkRefPairObjectFactory.getObjectInstance(LinkRefPairObjectFactory.java:85)
at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:304)
at org.jnp.interfaces.NamingContext.getObjectInstance(NamingContext.java:1125)
at org.jnp.interfaces.NamingContext.getObjectInstanceWrapFailure(NamingContext.java:1142)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:705)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:587)
at javax.naming.InitialContext.lookup(InitialContext.java:351)
at TopicSendRecvClient.setupPubSub(TopicSendRecvClient.java:49)
at TopicSendRecvClient.sendRecvAsync(TopicSendRecvClient.java:71)
at TopicSendRecvClient.main(TopicSendRecvClient.java:94)
Exception in thread "main" javax.naming.NameNotFoundException: ConnectionFactory not bound
at org.jnp.server.NamingServer.getBinding(NamingServer.java:529)
at org.jnp.server.NamingServer.getBinding(NamingServer.java:537)
at org.jnp.server.NamingServer.getObject(NamingServer.java:543)
at org.jnp.server.NamingServer.lookup(NamingServer.java:296)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:294)
at sun.rmi.transport.Transport$1.run(Transport.java:153)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:149)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:466)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:707)
at java.lang.Thread.run(Thread.java:595)
at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:247)
at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:223)
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:126)
at org.jnp.server.NamingServer_Stub.lookup(Unknown Source)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:625)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:587)
at javax.naming.InitialContext.lookup(InitialContext.java:351)
at org.jboss.naming.LinkRefPairObjectFactory.getObjectInstance(LinkRefPairObjectFactory.java:85)
at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:304)
at org.jnp.interfaces.NamingContext.getObjectInstance(NamingContext.java:1125)
at org.jnp.interfaces.NamingContext.getObjectInstanceWrapFailure(NamingContext.java:1142)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:705)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:587)
at javax.naming.InitialContext.lookup(InitialContext.java:351)
at TopicSendRecvClient.setupPubSub(TopicSendRecvClient.java:49)
at TopicSendRecvClient.sendRecvAsync(TopicSendRecvClient.java:71)
at TopicSendRecvClient.main(TopicSendRecvClient.java:94)
Client Code:
import java.io.IOException;
import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageListener;
import javax.jms.Topic;
import javax.jms.TopicConnection;
import javax.jms.TopicConnectionFactory;
import javax.jms.TopicPublisher;
import javax.jms.TopicSubscriber;
import javax.jms.TopicSession;
import javax.jms.TextMessage;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import EDU.oswego.cs.dl.util.concurrent.CountDown;
/**
* A complete JMS client example program that sends a TextMessage to a Topic and
* asynchronously receives the message from the same Topic.
*
* @author Scott.Stark(a)jboss.org
* @version $Revision: 1.10 $
*/
public class TopicSendRecvClient {
static CountDown done = new CountDown(1);
TopicConnection conn = null;
TopicSession session = null;
Topic topic = null;
public static class ExListener implements MessageListener {
public void onMessage(Message msg) {
done.release();
TextMessage tm = (TextMessage) msg;
try {
System.out.println("onMessage, recv text=" + tm.getText());
} catch (Throwable t) {
t.printStackTrace();
}
}
}
public void setupPubSub() throws JMSException, NamingException, IOException {
try{
InitialContext iniCtx = new InitialContext();
Object tmp = iniCtx.lookup("TopicConnectionFactory");
TopicConnectionFactory tcf = (TopicConnectionFactory) tmp;
conn = tcf.createTopicConnection();
topic = (Topic) iniCtx.lookup("topic/testTopic");
session = conn.createTopicSession(false, TopicSession.AUTO_ACKNOWLEDGE);
conn.start();
}
catch(NamingException e){
e.printStackTrace();
throw e;
}
catch(JMSException e){
e.printStackTrace();
throw e;
}
}
public void sendRecvAsync(String text) throws JMSException, NamingException, IOException {
System.out.println("Begin sendRecvAsync");
// Setup the PubSub connection, session
setupPubSub();
// Set the async listener
TopicSubscriber recv = session.createSubscriber(topic);
recv.setMessageListener(new ExListener());
// Send a text msg
TopicPublisher send = session.createPublisher(topic);
TextMessage tm = session.createTextMessage(text);
send.publish(tm);
System.out.println("sendRecvAsync, sent text=" + tm.getText());
send.close();
System.out.println("End sendRecvAsync");
}
public void stop() throws JMSException {
conn.stop();
session.close();
conn.close();
}
public static void main(String args[]) throws Exception {
System.out.println("Begin TopicSendRecvClient, now="
+ System.currentTimeMillis());
TopicSendRecvClient client = new TopicSendRecvClient();
client.sendRecvAsync("A text msg, now=" + System.currentTimeMillis());
client.done.acquire();
client.stop();
System.out.println("End TopicSendRecvClient");
System.exit(0);
}
}
Setup 1:
Environment: Windows XP Pro (Local Workstation)
JBoss: 4.0.5 Installed via jems-installer-1.2.0.GA.jar
The server here started correctly.
Setup 2:
Envrionment: Linux Server (Remote)
JBoss: 4.0.5 Installed via jboss-4.0.5.GA.zip.
The server here experienced startup errors from a fresh install. I don't know if this is a red herring relating to my problem but I'll list them anyways.
Startup Errors:
18:52:15,974 WARN [ServiceController] Problem starting service jboss:service=Hypersonic,database=localDB
java.sql.SQLException: The database is already in use by another process: org.hsqldb.persist.NIOLockFile@96f0a4c6[file =/home/coms/jboss1/jboss-4.0.5.GA/server/default/data/hypersonic/localDB.lck, exists=true, locked=false, valid=false, fl =null]:
at org.hsqldb.jdbc.Util.sqlException(Unknown Source)
at org.hsqldb.jdbc.jdbcConnection.(Unknown Source)
at org.hsqldb.jdbcDriver.getConnection(Unknown Source)
at org.hsqldb.jdbcDriver.connect(Unknown Source)
at java.sql.DriverManager.getConnection(DriverManager.java:525)
at java.sql.DriverManager.getConnection(DriverManager.java:171)
at org.jboss.jdbc.HypersonicDatabase.getConnection(HypersonicDatabase.java:761)
at org.jboss.jdbc.HypersonicDatabase.startStandaloneDatabase(HypersonicDatabase.java:611)
at org.jboss.jdbc.HypersonicDatabase.startService(HypersonicDatabase.java:557)
at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:289)
at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:245)
at sun.reflect.GeneratedMethodAccessor2.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
...
Any help would be greatly appreciated to help me figure out why I can't connect to my TopicConnectionFactory object via JNDI on the remote linux server.
thanks!
Don
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4029546#4029546
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4029546
19Â years, 1Â month
[JBoss Seam] - Re: BUG: #{redirect.returnToCapturedView} does not work with
by fhh
Still no luck... This seems to be a bug! I switched to page params but still the parameter is nul,l after a returning to the captured view.
I ran this through the debugger and traced the bug down to org.jboss.seam.core.Pages.getViewRootValues(FacesContext facesContext). Things go wrong when retriving the page parameters:
| for ( Param pageParameter: page.getParameters() )
| {
| Object object = Contexts.getPageContext().get( pageParameter.getName() );
| if (object!=null)
| {
| parameters.put( pageParameter.getName(), object );
| }
| }
|
It loops correctly over my parameters but it fails to retrieve them: pageParamter.getName() delivers the correct string but Contexts.getPageContext().get() returned null. So nothing is ever put into the parameters map.
I tried to trace it any further but it was beyond my knowledge of JSF to get to the bottom of the problem. If you need more info please let me know.
Regards
Felix
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4029544#4029544
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4029544
19Â years, 1Â month
[JBoss Seam] - how best to workaround lack of ServletContext at Startup
by charles.crouchï¼ jboss.com
So I just wanted to get suggestions for how I can workaround not having access to the ServletContext during the phase when components tagged with @Startup and @Application get created.
Here's my use case:
I've got a component,which needs some one-off, time consuming initialization to be run before it can be used. The component is currently a static singleton.
In order to initialize the component I need to grab a resource using ServletContext.getResource(..). This resource is not available on the classpath.
I'm currently using a servlet to do the initialization and making sure it runs early by putting <load-on-startup>1</load-on-startup> in the web.xml
This all works however I would like to move away from using the static singleton approach and have the singleton component injected into my other Seam components which need it.
The approach I've seen discussed before of just removing the @Startup annotation and have the component created lazily won't work here, since I don't want the first request being held up by the time consuming initialization that the component requires.
Any other ideas?
Cheers
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4029540#4029540
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4029540
19Â years, 1Â month
[EJB 3.0] - [Bug?] @EJB versus JNDI lookup problems within SLSBs
by asack
I have 4.0.4.GA isolation/call by value on.
Let me start simple, I have an EAR with a simple servlet WAR and a JAR containing one SLSB and its local implementation. The SLSB is bound to some place in JNDI space:
@Stateless
@LocalBinding ( jndiBinding="blah")
public class HelpMe implements IHelpMe {
...
}
Can someone please tell me why the JNDI viewer off the JMX console claims that they are NO CLASSLOADERS for this bean? It seems like within my EAR, the deployer should certainly pick up my local interface classfile? What's even more distrubing is that now if I try to INJECT this bean via @EJB in another bean (within the same JAR file within the same EAR) I get a runtime exception claiming that it can't find the interface (which is again all in the same JAR file in the same package). However, if I look it up via a context lookup, no problem (in fact I lookup this interface via the WAR file to get access to it with no issue).
What the heck is going on here? I don't understand why the local client interface that a bean implements has to be outside the EAR for injection to occur. This seems like a bug to me.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4029534#4029534
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4029534
19Â years, 1Â month