Win a copy of Java Concurrency Live Lessons this week in the Threads forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JMS in Jboss  RSS feed

 
RalphMichelsen Michelsen
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello

I have a problem with a new JMS test app. that I have tried out.

I get a javax.jms.IllegalStateException when I make a call to TopicSubscriber setMessageListener(listener).

Can anyone help me PLEASE??

Source code for the test class:

public class SubscriptionHelper {

private TopicConnection _tc = null;

public SubscriptionHelper(MessageListener listener) throws JMSException {

// Get references to topic connection factory
// and topic.
TopicConnectionFactory tcf = null;
Topic topic = null;

try {
InitialContext initialContext = new InitialContext();
tcf = (TopicConnectionFactory) initialContext.lookup("TopicConnectionFactory");
topic = (Topic)initialContext.lookup ("topic/testTopic");
} catch (NamingException e) {
System.err.println(e.toString());
e.printStackTrace(System.err);
}

try {
// Create a connection and so on
// Subscribe self to topic--messages will be
// delivered to this.onMessage()
_tc = tcf.createTopicConnection();
TopicSession ts = _tc.createTopicSession(
false, Session.AUTO_ACKNOWLEDGE);
TopicSubscriber tsub = ts.createSubscriber(topic);
tsub.setMessageListener(listener);
} catch (JMSException e) {
System.err.println(e.toString());
e.printStackTrace(System.err);
_tc.close();
}
}

}


Here is the stacktrace from jboss:

15:21:58,193 ERROR [STDERR] javax.jms.IllegalStateException: This method is not applicable inside the application server. See the J2EE spec, e.g.
J2EE1.4 Section 6.6
15:21:58,193 ERROR [STDERR] javax.jms.IllegalStateException: This method is not applicable inside the application server. See the J2EE spec, e.g.
J2EE1.4 Section 6.6
15:21:58,193 ERROR [STDERR] at org.jboss.resource.adapter.jms.JmsSession.checkStrict(JmsSession.java:542)
15:21:58,193 ERROR [STDERR] at org.jboss.resource.adapter.jms.JmsMessageConsumer.setMessageListener(JmsMessageConsumer.java:136)
15:21:58,193 ERROR [STDERR] at dk.itu.projekt.jms.SubscriptionHelper.<init>(Unknown Source)
15:21:58,193 ERROR [STDERR] at dk.itu.projekt.jms.MessageReceiver.recieveMessage(Unknown Source)
15:21:58,193 ERROR [STDERR] at dk.itu.projekt.gui.servlets.EmployeeServlet.service(Unknown Source)
15:21:58,193 ERROR [STDERR] at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
15:21:58,193 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
15:21:58,193 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
15:21:58,193 ERROR [STDERR] at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
15:21:58,193 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
15:21:58,193 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
15:21:58,193 ERROR [STDERR] at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
15:21:58,193 ERROR [STDERR] at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
15:21:58,193 ERROR [STDERR] at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:175)
15:21:58,193 ERROR [STDERR] at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
15:21:58,193 ERROR [STDERR] at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
15:21:58,193 ERROR [STDERR] at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
15:21:58,193 ERROR [STDERR] at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
15:21:58,193 ERROR [STDERR] at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
15:21:58,193 ERROR [STDERR] at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
15:21:58,193 ERROR [STDERR] at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:
664)
15:21:58,193 ERROR [STDERR] at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
15:21:58,193 ERROR [STDERR] at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
15:21:58,193 ERROR [STDERR] at java.lang.Thread.run(Thread.java:595)
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!