Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

jboss 4 jms client

Posted on 2004-10-29
12
Medium Priority
?
587 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 5
12 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

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…
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
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…
Simple Linear Regression

604 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