7 Replies Latest reply: May 30, 2012 6:07 AM by Laura delli Paoli RSS

Creating initial Context in JBoss AS 7.1.1

Laura delli Paoli Apprentice

Hello Everybody,

I'm new to JBoss and I'm trying to run a simple helloWorld JMS application.

when I run:

 

            env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");

            env.put(Context.PROVIDER_URL, System.getProperty(Context.PROVIDER_URL, "remote://localhost:4447"));

            env.put(Context.SECURITY_PRINCIPAL, System.getProperty("username", DEFAULT_USERNAME));

            env.put(Context.SECURITY_CREDENTIALS, System.getProperty("password", DEFAULT_PASSWORD));

            context = new InitialContext(env);

 

I get the following error: GRAVE: Cannot instantiate class: org.jboss.naming.remote.client.InitialContextFactory

 

Can anyone help me?

 

thanks

Laura

  • 1. Re: Creating initial Context in JBoss AS 7.1.1
    Wolf-Dieter Fink Master

    Do you have the JBOSS/bin/client/jboss-client.jar in your classpath?

    Also add env.put("jboss.naming.client.ejb.context", true) to your environment.

  • 2. Re: Creating initial Context in JBoss AS 7.1.1
    Laura delli Paoli Apprentice

    Thanks,

    How can I add "env.put("jboss.naming.client.ejb.context", true)" to my environment.

     

    Laura

  • 3. Re: Creating initial Context in JBoss AS 7.1.1
    Wolf-Dieter Fink Master

    add that simple to your code snipped above before new InitialContext(env)

  • 4. Re: Creating initial Context in JBoss AS 7.1.1
    Laura delli Paoli Apprentice

    It still doesn't work!

    Is there any ather way to send a message to a queue?

     

    Thanks

    Laura

  • 5. Re: Creating initial Context in JBoss AS 7.1.1
    jaikiran pai Master

    You'll have to post the entire exception stacktrace you are seeing. And what client jar(s) do you have on your classpath?

  • 6. Re: Creating initial Context in JBoss AS 7.1.1
    Laura delli Paoli Apprentice

    I added jboss-clieny.jar as a library in Eclipse and I a different exception (see below)

    Note that I used the same credential I use to open JBoss Administration Console.

     

    30-mag-2012 9.59.07 org.xnio.Xnio <clinit>

    INFO: XNIO Version 3.0.3.GA

    30-mag-2012 9.59.07 org.xnio.nio.NioXnio <clinit>

    INFO: XNIO NIO Implementation Version 3.0.3.GA

    30-mag-2012 9.59.07 org.jboss.remoting3.EndpointImpl <clinit>

    INFO: JBoss Remoting version 3.2.3.GA

    30-mag-2012 9.59.07 org.jboss.remoting3.remote.RemoteConnection handleException

    ERROR: JBREM000200: Remote connection failed: javax.security.sasl.SaslException: Authentication failed: all available authentication mechanisms failed

    javax.naming.NamingException: Failed to create remoting connection [Root exception is java.lang.RuntimeException: javax.security.sasl.SaslException: Authentication failed: all available authentication mechanisms failed]

              at org.jboss.naming.remote.client.ClientUtil.namingException(ClientUtil.java:36)

              at org.jboss.naming.remote.client.InitialContextFactory.getInitialContext(InitialContextFactory.java:121)

              at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)

              at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)

              at javax.naming.InitialContext.init(Unknown Source)

              at javax.naming.InitialContext.<init>(Unknown Source)

              at SimpleSender.getInitialContext(SimpleSender.java:87)

              at run.main(run.java:23)

    Caused by: java.lang.RuntimeException: javax.security.sasl.SaslException: Authentication failed: all available authentication mechanisms failed

              at org.jboss.naming.remote.protocol.IoFutureHelper.get(IoFutureHelper.java:87)

              at org.jboss.naming.remote.client.NamingStoreCache.getRemoteNamingStore(NamingStoreCache.java:56)

              at org.jboss.naming.remote.client.InitialContextFactory.getOrCreateCachedNamingStore(InitialContextFactory.java:166)

              at org.jboss.naming.remote.client.InitialContextFactory.getOrCreateNamingStore(InitialContextFactory.java:139)

              at org.jboss.naming.remote.client.InitialContextFactory.getInitialContext(InitialContextFactory.java:104)

              ... 6 more

    Caused by: javax.security.sasl.SaslException: Authentication failed: all available authentication mechanisms failed

              at org.jboss.remoting3.remote.ClientConnectionOpenListener$Capabilities.handleEvent(ClientConnectionOpenListener.java:365)

              at org.jboss.remoting3.remote.ClientConnectionOpenListener$Capabilities.handleEvent(ClientConnectionOpenListener.java:214)

              at org.xnio.ChannelListeners.invokeChannelListener(ChannelListeners.java:72)

              at org.xnio.channels.TranslatingSuspendableChannel.handleReadable(TranslatingSuspendableChannel.java:189)

              at org.xnio.channels.TranslatingSuspendableChannel$1.handleEvent(TranslatingSuspendableChannel.java:103)

              at org.xnio.ChannelListeners.invokeChannelListener(ChannelListeners.java:72)

              at org.xnio.nio.NioHandle.run(NioHandle.java:90)

              at org.xnio.nio.WorkerThread.run(WorkerThread.java:184)

              at ...asynchronous invocation...(Unknown Source)

              at org.jboss.remoting3.EndpointImpl.doConnect(EndpointImpl.java:270)

              at org.jboss.remoting3.EndpointImpl.doConnect(EndpointImpl.java:251)

              at org.jboss.remoting3.EndpointImpl.connect(EndpointImpl.java:349)

              at org.jboss.remoting3.EndpointImpl.connect(EndpointImpl.java:333)

              at org.jboss.naming.remote.client.EndpointCache$EndpointWrapper.connect(EndpointCache.java:105)

              at org.jboss.naming.remote.client.NamingStoreCache.getRemoteNamingStore(NamingStoreCache.java:55)

  • 7. Re: Creating initial Context in JBoss AS 7.1.1
    Laura delli Paoli Apprentice

    Hi,

    I avoided this error by disabling security.  (I removed the "security-realm" from the "remoting-connector" <connector>).

    Now I get an erron when I lookup the "ConnectionFactory" queue:

     

    public void init(Context ctx, String queueName)throws NamingException, JMSException {

                        qconFactory = (QueueConnectionFactory) ctx.lookup("/ConnectionFactory");

                        qcon = qconFactory.createQueueConnection();

                        qsession = qcon.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);

                        queue = (Queue) ctx.lookup(queueName);

                        qsender = qsession.createSender(queue);

                        msg = qsession.createTextMessage();

                        qcon.start();

              }

     

    the trace is:

     

    30-mag-2012 11.53.24 org.xnio.Xnio <clinit>

    INFO: XNIO Version 3.0.3.GA

    30-mag-2012 11.53.24 org.xnio.nio.NioXnio <clinit>

    INFO: XNIO NIO Implementation Version 3.0.3.GA

    30-mag-2012 11.53.24 org.jboss.remoting3.EndpointImpl <clinit>

    INFO: JBoss Remoting version 3.2.3.GA

    30-mag-2012 11.53.25 org.jboss.ejb.client.remoting.VersionReceiver handleMessage

    INFO: Received server version 1 and marshalling strategies [river]

    30-mag-2012 11.53.25 org.jboss.ejb.client.remoting.RemotingConnectionEJBReceiver associate

    INFO: Successful version handshake completed for receiver context EJBReceiverContext{clientContext=org.jboss.ejb.client.EJBClientContext@7e717d91, receiver=Remoting connection EJB receiver [connection=Remoting connection <5f18223d>,channel=jboss.ejb,nodename=dellipaoli]} on channel Channel ID e776d2fb (outbound) of Remoting connection 10ed32c4 to localhost/127.0.0.1:4447

    30-mag-2012 11.53.25 org.jboss.ejb.client.remoting.ChannelAssociation$ResponseReceiver handleMessage

    WARN: Unsupported message received with header 0xffffffff

    javax.naming.NameNotFoundException: ConnectionFactory -- service jboss.naming.context.java.jboss.exported.ConnectionFactory

              at org.jboss.as.naming.ServiceBasedNamingStore.lookup(ServiceBasedNamingStore.java:97)

              at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:178)

              at org.jboss.naming.remote.protocol.v1.Protocol$1.handleServerMessage(Protocol.java:127)

              at org.jboss.naming.remote.protocol.v1.RemoteNamingServerV1$MessageReciever$1.run(RemoteNamingServerV1.java:73)

              at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)

              at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)

              at java.lang.Thread.run(Unknown Source)