• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Junilu Lacar
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Piet Souris
  • Carey Brown
  • Stephan van Hulst
Bartenders:
  • Frits Walraven
  • fred rosenberger
  • salvin francis

JMS in Jboss

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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)
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic