?
Solved

jboss 4 jms client

Posted on 2004-10-29
12
Medium Priority
?
599 Views
Last Modified: 2012-06-27
Hi,

I am using JBoss 4, and I do not know how to write a client to connect to it..

in previous version, 3.2.5, I used this:

"http://localhost:8080/invoker/JNDIFactory"

(also from experts-exchange), but now this does not return the right object.

Thank you.
Mark
0
Comment
Question by:kerzner
  • 6
  • 5
11 Comments
 
LVL 35

Expert Comment

by:TimYates
ID: 12443461
Can you post your connection code?
0
 
LVL 1

Author Comment

by:kerzner
ID: 12444465
Well, here is what I use (did not want to bother you with reading many lines, but you asked).

    public void initJBoss() {
        logger.fine("Preparing to listen for messages on " + JNDIContext.getJBossJmsUrl());
        //  JNDIContext.getJBossJmsUrl()) resolves to "localhost"
        TopicConnectionFactory  topicConnectionFactory = null;
        TopicConnection         topicConnection = null;
        TopicSession            topicSession = null;
        Topic                   topic = null;
        TopicSubscriber         topicSubscriber = null;
        TopicMessageListener    topicListener = null;
       
        try {
            Hashtable <String, String> props = new Hashtable <String, String> ();
            props.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.HttpNamingContextFactory");            
            props.put(Context.PROVIDER_URL, JNDIContext.getJBossJmsUrl());
            props.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
            ctx = new InitialContext(props);        

            topicConnectionFactory =
            (TopicConnectionFactory) ctx.lookup("ConnectionFactory");
            topicConnection = topicConnectionFactory.createTopicConnection();
            topicSession = topicConnection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
            topic = (Topic) ctx.lookup("topic/testTopic");
            topicConnection.start();
           
            topicSubscriber = topicSession.createSubscriber(topic);
            topicListener = new TopicMessageListener();
            topicSubscriber.setMessageListener(topicListener);
            topicConnection.start();
            logger.fine("connected");
        } catch (Exception e) {
            Util.getLogger().fine("Connection problem: " + e.toString());
            e.printStackTrace();
            if (topicConnection != null) {
                try {
                    topicConnection.close();
                } catch (JMSException ee) {}
            }
        }        
    }    
0
 
LVL 35

Accepted Solution

by:
TimYates earned 2000 total points
ID: 12444526
and which line doesn't return the correct object? (ie: throws the exception)

That looks ok at first glance :-)
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
LVL 1

Author Comment

by:kerzner
ID: 12444596
InitialContext gives error

FINE: Connection problem: javax.naming.NamingException: Failed to retrieve Naming interface [Root exception is java.io.FileNotFoundException: http://localhost:8080/invoker/JNDIFactory]
javax.naming.NamingException: Failed to retrieve Naming interface [Root exception is java.io.FileNotFoundException: http://localhost:8080/invoker/JNDIFactory]
        at org.jboss.naming.HttpNamingContextFactory.getInitialContext(HttpNamingContextFactory.java:69)
        at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:667)
        at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:247)
        at javax.naming.InitialContext.init(InitialContext.java:223)
        at javax.naming.InitialContext.<init>(InitialContext.java:197)
        at com.lateral.control.model.TopicMessageListener.initJBoss(TopicMessageListener.java:193)
        at com.lateral.control.model.TopicMessageListener.run(TopicMessageListener.java:82)
Caused by: java.io.FileNotFoundException: http://localhost:8080/invoker/JNDIFactory
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:494)
        at sun.net.www.protocol.http.HttpURLConnection$6.run(HttpURLConnection.java:1111)
        at java.security.AccessController.doPrivileged(Native Method)
        at sun.net.www.protocol.http.HttpURLConnection.getChainedException(HttpURLConnection.java:1105)
        at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:813)
        at org.jboss.naming.HttpNamingContextFactory.getNamingServer(HttpNamingContextFactory.java:117)
        at org.jboss.naming.HttpNamingContextFactory.getInitialContext(HttpNamingContextFactory.java:65)
        ... 6 more
Caused by: java.io.FileNotFoundException: http://localhost:8080/invoker/JNDIFactory
        at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1064)
        at sun.net.www.protocol.http.HttpURLConnection.getHeaderField(HttpURLConnection.java:1773)
        at java.net.URLConnection.getHeaderFieldInt(URLConnection.java:573)
        at java.net.URLConnection.getContentLength(URLConnection.java:468)
        at org.jboss.naming.HttpNamingContextFactory.getNamingServer(HttpNamingContextFactory.java:112)
        ... 7 more
0
 
LVL 35

Expert Comment

by:TimYates
ID: 12444621
What happens if you change:

            props.put(Context.PROVIDER_URL, JNDIContext.getJBossJmsUrl());

to

            props.put(Context.PROVIDER_URL, "jnp://" + JNDIContext.getJBossJmsUrl() + ":1099");
0
 
LVL 1

Author Comment

by:kerzner
ID: 12444771
then I get this,

FINE: Connection problem: javax.naming.NamingException: Failed to retrieve Naming interface [Root exception is java.lang.ClassCastException: java.rmi.MarshalledObject]
javax.naming.NamingException: Failed to retrieve Naming interface [Root exception is java.lang.ClassCastException: java.rmi.MarshalledObject]
        at org.jboss.naming.HttpNamingContextFactory.getInitialContext(HttpNamingContextFactory.java:69)
        at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:667)
        at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:247)
        at javax.naming.InitialContext.init(InitialContext.java:223)
        at javax.naming.InitialContext.<init>(InitialContext.java:197)
        at com.lateral.control.model.TopicMessageListener.initJBoss(TopicMessageListener.java:194)
        at com.lateral.control.model.TopicMessageListener.run(TopicMessageListener.java:82)
Caused by: java.lang.ClassCastException: java.rmi.MarshalledObject
        at org.jboss.naming.HttpNamingContextFactory.getNamingServer(HttpNamingContextFactory.java:119)
        at org.jboss.naming.HttpNamingContextFactory.getInitialContext(HttpNamingContextFactory.java:65)
        ... 6 more
0
 
LVL 35

Expert Comment

by:TimYates
ID: 12444829
And if you change:

    props.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.HttpNamingContextFactory");            

to

    props.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");

?

Hmmm... I will search the web to get a definitive answer...  I think there has been some Jboss refactoring, so classes have changed package...
0
 
LVL 1

Author Comment

by:kerzner
ID: 12444880
I forgot to say, that I really talk to

"http://localhost:8080/invoker/JNDIFactory";

But let me try to see what class I get
0
 
LVL 1

Author Comment

by:kerzner
ID: 12586224
No answer so far, I am back to JBoss 3.5
0
 
LVL 1

Author Comment

by:kerzner
ID: 12833102
Dear Tim:

Thank you, the discussion was helpful. I had to go back to JBoss 3.5, in the rush of the moment, but I will keep these notes.

All the best,
Mark
0
 
LVL 35

Expert Comment

by:TimYates
ID: 12834215
Good luck with it all!  Hope you have more success next try...

I'm on 3.2.5 for pretty much the same reason...I just need a few days open to try out 4...

But there's always work to do :-(

Good luck!

Tim
0

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
Loops Section Overview

589 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question