Stack Exchange
ClassNotFoundException referencing hornetq specific stuff in JBoss AS 7
I am trying to use JMS in a JBoss AS 7 application.  Publishing normal messages seems to work OK, however when I try to use hornetq specific features (to exclude duplicate messages), an exception is thrown.
This is the code:
om.setStringProperty(org.hornetq.api.core.Message.HDR_DUPLICATE_DETECTION_ID.toString(), application+rs.getString("stream")+ rs.getInt("site"));

And here is the stack trace:
java.lang.ClassNotFoundException: org.hornetq.api.core.Message from [Module "deployment.TestRestEasy.war:main" from Service Module Loader]
org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:191)
org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:361)
org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:333)
org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:310)
org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:103)
sample.Processor.processStreamSite(Processor.java:82)
sample.Processor.processSitesForStream(Processor.java:63)
sample.Processor.process(Processor.java:55)
sample.HelloWorld.process(HelloWorld.java:31)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:597)
org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:140)
org.jboss.resteasy.core.ResourceMethod.invokeOnTarget(ResourceMethod.java:255)
org.jboss.resteasy.core.ResourceMethod.invoke(ResourceMethod.java:220)
org.jboss.resteasy.core.ResourceMethod.invoke(ResourceMethod.java:209)
org.jboss.resteasy.core.SynchronousDispatcher.getResponse(SynchronousDispatcher.java:519)
org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:496)
org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:119)
org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:208)
org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:55)
org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:50)
javax.servlet.http.HttpServlet.service(HttpServlet.java:847)

I believe I have configured the standalone.xml configuration file correctly, as the standard JMS code works.  Is there anything special I need to do to access HornetQ specific features?
Update:
Was worried was related to RestEasy stuff I was using, so moved into standalone Servlet, but still had same issue.  Code and exception below
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
   try {
    Context ic = new InitialContext();

  QueueConnectionFactory qcf = (QueueConnectionFactory) ic.lookup("java:/ConnectionFactory");
  Queue q = (Queue) ic.lookup("queue/test");

  QueueConnection qc = qcf.createQueueConnection();
  QueueSession qsess = qc.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
  QueueSender qsend = qsess.createSender(q);

  ObjectMessage om = qsess.createObjectMessage();
  om.setObject((Serializable)new InboundDirectory("X", "Y", 9));
  om.setStringProperty(org.hornetq.api.core.Message.HDR_DUPLICATE_DETECTION_ID.toString(), "X");
  qsend.send(om);
  System.out.println("X");
  }
  catch (Exception e) {
     e.printStackTrace();
  }
}

And here is the exception:
java.lang.ClassNotFoundException: org.hornetq.api.core.Message from [Module "deployment.TestRestEasy.war:main" from Service Module Loader]
org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:191)
org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:361)
org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:333)
org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:310)
org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:103)
TestServlet.doPost(TestServlet.java:65)
TestServlet.doGet(TestServlet.java:46)
javax.servlet.http.HttpServlet.service(HttpServlet.java:734)
javax.servlet.http.HttpServlet.service(HttpServlet.java:847)

Further update:
Got it working by using the String value instead, but I don't think that is ideal, the property key is not guaranteed that string forever.
om.setStringProperty("_HQ_DUPL_ID", "X:Y:9");

Any idea the proper way to do it?
Update:  Thanks @Vadzim for pointing me in the right direction.  For anybody else struggling with this specific problem I updated the Manifest.MF as follows:
Manifest-Version: 1.0
Class-Path: 
Dependencies: org.hornetq

Note, (as I struggled with this for a while), the parsing of this file is very 'fragile'.  The Space after the 'Class-Path:' entry line is essential.

Classloading model changed in JBoss 7. It hides much stuff that's not explicitly declared.
You have to get familar with these links:
https://docs.jboss.org/author/display/AS7/Developer+Guide#DeveloperGuide-HowtoresolveClassNotFoundExceptionsandNoCLassDefFoundErrors
https://docs.jboss.org/author/display/AS7/Class+Loading+in+AS7

Awesome answer, thanks.  Pointed me in the right direction, but still left me a bit of work to do.

You are welcome. Those links provide much useful info to help you with migration. It's worth reading anyway. Quick answer could prevent you from doing it. :)

I believe the hornetq-client should be exposed to the HOrnetQ module.
Maybe you should talk to AS7 guys through their forum.. or maybe raise an issue on jira.jboss.org for the AS7 project.. but I believe you are required to talk on the forums first.
