File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes EJB and other Java EE Technologies and the fly likes Cant get reference to Queue Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Cant get reference to Queue" Watch "Cant get reference to Queue" New topic
Author

Cant get reference to Queue

John R Roberts
Ranch Hand

Joined: Dec 27, 2006
Posts: 36
Hi, when the following code executes



i get an exception.
queue = (Queue) ctx.lookup("queue/MyTestQueue");

why is this?
I am using JBoss and have defined the Queue.
John R Roberts
Ranch Hand

Joined: Dec 27, 2006
Posts: 36
oops...
i get an exception.
queue = (Queue) ctx.lookup("queue/MyTestQueue");


the exception is
java.lang.ClassCastException: javax.naming.Reference
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10289
    
168

Post the exception stacktrace that you are seeing and also how have you defined the queue?


[My Blog] [JavaRanch Journal]
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10289
    
168

I see you posted that exception stacktrace just when i asked for it From where are you looking up this queue? Is it a standalone java class or is it some servlet/jsp?
John R Roberts
Ranch Hand

Joined: Dec 27, 2006
Posts: 36
I want to send the message from a simple standalone java class.
I defined the queue in
jboss-4.0.3SP1\server\default\deploy\jms\jbossmq-destinations-service.xml

as
<mbean code="org.jboss.mq.server.jmx.Queue"
name="jboss.mq.destination:service=Queue,name=MyTestQueue">
<depends optional-attribute-name="DestinationManager">jboss.mq:service=DestinationManager</depends>
</mbean>
which is a copy and paste from the examples already there.

anything else you need to know?
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10289
    
168

Have you made sure that the client jars from JBoss, especially the jbossall-client.jar, is present in the standalone client's classpath? You can find the client jar(s) in %JBOSS_HOME%/client folder
[ March 03, 2007: Message edited by: Jaikiran Pai ]
John R Roberts
Ranch Hand

Joined: Dec 27, 2006
Posts: 36
to be sure I left nothing out I have just added all the jars in that folder to my classpath and still I get the same result
I was hoping it was a classpath issue
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10289
    
168

I have just added all the jars in that folder to my classpath


Just to be completely sure that they are in the classpath, can you tell me how did you add them to the classpath? Can you post the %classpath% value?
John R Roberts
Ranch Hand

Joined: Dec 27, 2006
Posts: 36
I am using Eclipse and added them to the classpath. I am running the app using eclipse too.

here is my code also
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10289
    
168

Strange. I have an exactly similar sample application in Eclipse which is meant to do the same.



However in my classpath i have placed ONLY the following jars:

jboss-client.jar, jboss-common-client.jar, jboss-j2ee.jar, jbossmq-client.jar, jboss-system.jar, jnp-client.jar, log4j.jar, concurrent.jar

Additionally, can you follow these steps to check the JNDI tree in JBoss:

- Go to http://localhost:8080/jmx-console
- Click on service=JNDIView
- On the page that comes up click on the Invoke button beside the list() method
- This will show up the JNDI contents in JBoss.

Post the contents here.
[ March 03, 2007: Message edited by: Jaikiran Pai ]
John R Roberts
Ranch Hand

Joined: Dec 27, 2006
Posts: 36
I just removed everything and readded them and it worked.
how frustrating...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Cant get reference to Queue