Hello,
I'm getting an exception in a sample JMS app I wrote:
package com.localmatters;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.annotation.Resource;
import javax.ejb.Stateless;
import javax.jms.Connection;
import javax.jms.ConnectionFactory;
import javax.jms.Message;
import javax.jms.MessageProducer;
import javax.jms.Session;
import javax.jms.Topic;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebService;
@Stateless()
@WebService()
public class SampleWSBean {
@Resource(mappedName="jms/ConnectionFactory")
private ConnectionFactory connectionFactory;
@Resource(mappedName="jms/InitialDestination")
private Topic initialDestination;
private Connection connection;
private Session session;
private MessageProducer producer;
public SampleWSBean() {
System.out.println("Constructor: Connection Factory: \n" +
connectionFactory);
System.out.println("Constructor: InitialDestination: \n" +
initialDestination);
}
@PostConstruct()
private void init() {
System.out.println("Init: Connection Factory: \n" +
connectionFactory);
System.out.println("Init: InitialDestination: \n" +
initialDestination);
try {
connection = connectionFactory.createConnection("guest",
"guest");
} catch (Throwable ex) {
ex.printStackTrace();
}
}
@PreDestroy()
private void release() {
System.out.println("Release: Connection Factory: \n" +
connectionFactory);
System.out.println("Release: InitialDestination: \n" +
initialDestination);
try {
connection.close();
} catch (Throwable ex) {
ex.printStackTrace();
}
}
@WebMethod()
public void send(@WebParam(name="msg") String message) {
System.out.println("Message: " + message);
System.out.println("Send: Connection Factory: \n" +
connectionFactory);
System.out.println("Send: InitialDestination: \n" +
initialDestination);
try {
session = connection.createSession(true, -1);
producer = session.createProducer(initialDestination);
Message msg = session.createTextMessage(message);
connection.start();
producer.send(msg);
connection.stop();
session.close();
} catch (Throwable ex) {
ex.printStackTrace();
}
}
}
com.sun.messaging.jms.JMSException: MQRA:CA:Unsupported-stop()
at com.sun.messaging.jms.ra.ConnectionAdapter.stop(
ConnectionAdapter.java:198)
at com.localmatters.SampleWSBean.send(SampleWSBean.java:81)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(
NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(
DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at
com.sun.enterprise.security.application.EJBSecurityManager.runMethod(
EJBSecurityManager.java:1051)
at com.sun.enterprise.security.SecurityUtil.invoke(SecurityUtil.java
:165)
at com.sun.ejb.containers.BaseContainer.invokeTargetBeanMethod(
BaseContainer.java:2846)
at com.sun.ejb.containers.BaseContainer.intercept(BaseContainer.java
:3930)
at com.sun.ejb.containers.WebServiceInvocationHandler.invoke(
WebServiceInvocationHandler.java:176)
at $Proxy93.send(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(
NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(
DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at com.sun.enterprise.webservice.InvokerImpl.invoke(InvokerImpl.java
:68)
at com.sun.enterprise.webservice.EjbInvokerImpl.invoke(
EjbInvokerImpl.java:75)
at com.sun.xml.ws.server.InvokerTube$2.invoke(InvokerTube.java:132)
at com.sun.xml.ws.server.sei.EndpointMethodHandler.invoke(
EndpointMethodHandler.java:241)
at com.sun.xml.ws.server.sei.SEIInvokerTube.processRequest(
SEIInvokerTube.java:75)
at com.sun.xml.ws.api.pipe.Fiber.__doRun(Fiber.java:559)
at com.sun.xml.ws.api.pipe.Fiber._doRun(Fiber.java:518)
at com.sun.xml.ws.api.pipe.Fiber.doRun(Fiber.java:503)
at com.sun.xml.ws.api.pipe.Fiber.runSync(Fiber.java:400)
at com.sun.xml.ws.api.pipe.helper.AbstractTubeImpl.process(
AbstractTubeImpl.java:70)
at com.sun.enterprise.webservice.MonitoringPipe.process(
MonitoringPipe.java:133)
at com.sun.xml.ws.api.pipe.helper.PipeAdapter.processRequest(
PipeAdapter.java:79)
at com.sun.xml.ws.api.pipe.Fiber.__doRun(Fiber.java:559)
at com.sun.xml.ws.api.pipe.Fiber._doRun(Fiber.java:518)
at com.sun.xml.ws.api.pipe.Fiber.doRun(Fiber.java:503)
at com.sun.xml.ws.api.pipe.Fiber.runSync(Fiber.java:400)
at com.sun.xml.ws.api.pipe.helper.AbstractTubeImpl.process(
AbstractTubeImpl.java:70)
at com.sun.xml.ws.mex.server.MetadataServerPipe.process(
MetadataServerPipe.java:97)
at
com.sun.enterprise.webservice.CommonServerSecurityPipe.processRequest(
CommonServerSecurityPipe.java:191)
at com.sun.enterprise.webservice.CommonServerSecurityPipe.process(
CommonServerSecurityPipe.java:113)
at com.sun.xml.ws.api.pipe.helper.PipeAdapter.processRequest(
PipeAdapter.java:79)
at com.sun.xml.ws.api.pipe.Fiber.__doRun(Fiber.java:559)
at com.sun.xml.ws.api.pipe.Fiber._doRun(Fiber.java:518)
at com.sun.xml.ws.api.pipe.Fiber.doRun(Fiber.java:503)
at com.sun.xml.ws.api.pipe.Fiber.runSync(Fiber.java:400)
at com.sun.xml.ws.server.WSEndpointImpl$2.process(
WSEndpointImpl.java:208)
at com.sun.xml.ws.transport.http.HttpAdapter$HttpToolkit.handle(
HttpAdapter.java:374)
at com.sun.xml.ws.transport.http.HttpAdapter.handle(HttpAdapter.java
:175)
at com.sun.xml.ws.transport.http.servlet.ServletAdapter.handle(
ServletAdapter.java:134)
at com.sun.enterprise.webservice.Ejb3MessageDispatcher.handlePost(
Ejb3MessageDispatcher.java:100)
at com.sun.enterprise.webservice.Ejb3MessageDispatcher.invoke(
Ejb3MessageDispatcher.java:74)
at
com.sun.enterprise.webservice.EjbWebServiceServlet.dispatchToEjbEndpoint(
EjbWebServiceServlet.java:187)
at com.sun.enterprise.webservice.EjbWebServiceServlet.service(
EjbWebServiceServlet.java:116)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
at com.sun.enterprise.web.AdHocContextValve.invoke(
AdHocContextValve.java:101)
at org.apache.catalina.core.StandardPipeline.doInvoke(
StandardPipeline.java:611)
at org.apache.catalina.core.StandardPipeline.doInvoke(
StandardPipeline.java:564)
at org.apache.catalina.core.StandardPipeline.invoke(
StandardPipeline.java:558)
at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:74)
at org.apache.catalina.core.StandardHostValve.invoke(
StandardHostValve.java:207)
at org.apache.catalina.core.StandardPipeline.doInvoke(
StandardPipeline.java:611)
at org.apache.catalina.core.StandardPipeline.doInvoke(
StandardPipeline.java:564)
at org.apache.catalina.core.StandardPipeline.invoke(
StandardPipeline.java:558)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java
:1067)
at org.apache.catalina.core.StandardEngineValve.invoke(
StandardEngineValve.java:137)
at org.apache.catalina.core.StandardPipeline.doInvoke(
StandardPipeline.java:611)
at org.apache.catalina.core.StandardPipeline.doInvoke(
StandardPipeline.java:564)
at org.apache.catalina.core.StandardPipeline.invoke(
StandardPipeline.java:558)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java
:1067)
at org.apache.coyote.tomcat5.CoyoteAdapter.service(
CoyoteAdapter.java:249)
at
com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.invokeAdapter(
DefaultProcessorTask.java:618)
at
com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.doProcess(
DefaultProcessorTask.java:549)
at
com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.process(
DefaultProcessorTask.java:790)
at
com.sun.enterprise.web.connector.grizzly.DefaultReadTask.executeProcessorTask
(DefaultReadTask.java:326)
at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(
DefaultReadTask.java:248)
at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(
DefaultReadTask.java:199)
at
com.sun.enterprise.web.portunif.PortUnificationPipeline$PUTask.doTask(
PortUnificationPipeline.java:328)
at com.sun.enterprise.web.connector.grizzly.TaskBase.run(
TaskBase.java:252)
at com.sun.enterprise.web.connector.grizzly.ssl.SSLWorkerThread.run(
SSLWorkerThread.java:93)
I thought what I was doing was right.
The managed objects are perfectly created in the AS.
Furthermore, I had initially declared initialDestination as private
Destination initialDestination (w/ the resource injection annotation of
course), but when I try to deploy the bean, the AS complains:
: UnExpected error occured while creating ejb container
javax.naming.InvalidNameException: JMS Destination Reference Type Mismatch :
`com.localmatters.SampleWSBean/initialDestination` does not refer to a
destination of type `javax.jms.Destination`
at com.sun.enterprise.naming.NamingManagerImpl.bindObjects(
NamingManagerImpl.java:404)
at com.sun.ejb.containers.BaseContainer.setupEnvironment(
BaseContainer.java:2705)
at com.sun.ejb.containers.BaseContainer.<init>(BaseContainer.java
:632)
at com.sun.ejb.containers.StatelessSessionContainer.<init>(
StatelessSessionContainer.java:160)
at com.sun.ejb.containers.ContainerFactoryImpl.createContainer(
ContainerFactoryImpl.java:255)
at com.sun.enterprise.server.AbstractLoader.loadEjbs(
AbstractLoader.java:484)
at com.sun.enterprise.server.EJBModuleLoader.load(
EJBModuleLoader.java:158)
at
com.sun.enterprise.server.StandAloneEJBModulesManager.moduleDeployed(
StandAloneEJBModulesManager.java:219)
at
com.sun.enterprise.server.StandAloneEJBModulesManager.moduleDeployed(
StandAloneEJBModulesManager.java:174)
at
com.sun.enterprise.server.StandAloneEJBModulesManager.moduleDeployed(
StandAloneEJBModulesManager.java:406)
at
com.sun.enterprise.server.StandAloneEJBModulesManager.moduleEnabled(
StandAloneEJBModulesManager.java:500)
at
com.sun.enterprise.admin.event.AdminEventMulticaster.invokeModuleDeployEventListener
(AdminEventMulticaster.java:957)
at
com.sun.enterprise.admin.event.AdminEventMulticaster.handleModuleDeployEvent
(AdminEventMulticaster.java:938)
at com.sun.enterprise.admin.event.AdminEventMulticaster.processEvent
(AdminEventMulticaster.java:448)
at
com.sun.enterprise.admin.event.AdminEventMulticaster.multicastEvent(
AdminEventMulticaster.java:160)
at
com.sun.enterprise.admin.mbeans.ApplicationsConfigMBean.sendEnableConfigChangeEventExplicitly
(ApplicationsConfigMBean.java:1824)
at com.sun.enterprise.admin.mbeans.ApplicationsConfigMBean.enable(
ApplicationsConfigMBean.java:1892)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(
NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(
DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at com.sun.enterprise.admin.MBeanHelper.invokeOperationInBean(
MBeanHelper.java:353)
at com.sun.enterprise.admin.MBeanHelper.invokeOperationInBean(
MBeanHelper.java:336)
at com.sun.enterprise.admin.config.BaseConfigMBean.invoke(
BaseConfigMBean.java:448)
at com.sun.jmx.mbeanserver.DynamicMetaDataImpl.invoke(
DynamicMetaDataImpl.java:213)
at com.sun.jmx.mbeanserver.MetaDataImpl.invoke(MetaDataImpl.java
:220)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(
DefaultMBeanServerInterceptor.java:815)
at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java
:784)
at sun.reflect.GeneratedMethodAccessor19.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(
DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at com.sun.enterprise.admin.util.proxy.ProxyClass.invoke(
ProxyClass.java:77)
at $Proxy1.invoke(Unknown Source)
at com.sun.enterprise.admin.server.core.jmx.SunoneInterceptor.invoke
(SunoneInterceptor.java:297)
at
com.sun.enterprise.admin.jmx.remote.server.callers.InvokeCaller.call(
InvokeCaller.java:56)
at
com.sun.enterprise.admin.jmx.remote.server.MBeanServerRequestHandler.handle(
MBeanServerRequestHandler.java:142)
at
com.sun.enterprise.admin.jmx.remote.server.servlet.RemoteJmxConnectorServlet.processRequest
(RemoteJmxConnectorServlet.java:109)
at
com.sun.enterprise.admin.jmx.remote.server.servlet.RemoteJmxConnectorServlet.doPost
(RemoteJmxConnectorServlet.java:180)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
at org.apache.catalina.core.ApplicationFilterChain.servletService(
ApplicationFilterChain.java:398)
at org.apache.catalina.core.StandardWrapperValve.invoke(
StandardWrapperValve.java:277)
at org.apache.catalina.core.StandardContextValve.invokeInternal(
StandardContextValve.java:255)
at org.apache.catalina.core.StandardContextValve.invoke(
StandardContextValve.java:188)
at org.apache.catalina.core.StandardPipeline.doInvoke(
StandardPipeline.java:611)
at org.apache.catalina.core.StandardPipeline.doInvoke(
StandardPipeline.java:564)
at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:81)
at org.apache.catalina.core.StandardHostValve.invoke(
StandardHostValve.java:207)
at org.apache.catalina.core.StandardPipeline.doInvoke(
StandardPipeline.java:611)
at org.apache.catalina.core.StandardPipeline.doInvoke(
StandardPipeline.java:564)
at org.apache.catalina.core.StandardPipeline.invoke(
StandardPipeline.java:558)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java
:1067)
at org.apache.catalina.core.StandardEngineValve.invoke(
StandardEngineValve.java:137)
at org.apache.catalina.core.StandardPipeline.doInvoke(
StandardPipeline.java:611)
at org.apache.catalina.core.StandardPipeline.doInvoke(
StandardPipeline.java:564)
at org.apache.catalina.core.StandardPipeline.invoke(
StandardPipeline.java:558)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java
:1067)
at org.apache.coyote.tomcat5.CoyoteAdapter.service(
CoyoteAdapter.java:249)
at
com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.invokeAdapter(
DefaultProcessorTask.java:618)
at
com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.doProcess(
DefaultProcessorTask.java:549)
at
com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.process(
DefaultProcessorTask.java:790)
at
com.sun.enterprise.web.connector.grizzly.DefaultReadTask.executeProcessorTask
(DefaultReadTask.java:326)
at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(
DefaultReadTask.java:248)
at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(
DefaultReadTask.java:199)
at com.sun.enterprise.web.connector.grizzly.TaskBase.run(
TaskBase.java:252)
at com.sun.enterprise.web.connector.grizzly.WorkerThreadImpl.run(
WorkerThreadImpl.java:103)
Could someone give some pointers?
thanks,
Daniel