Skip to main content

[JMS] MDB problem - cannot make this work

8 replies [Last post]
Anonymous

Hi.
I wanted to take a look at JMS with Glassfish. The idea is simple - a servlet has the Notifier bean injected, calls the doNotify() method on it, which sends a message via JMS, which is handled by the MDB, and printed to standard output.
I logged into the admin console and created two resources:
1. Resources -> JMS Resources -> Connection Factories: I created it with a name "jms/topicFactory" and type "javax.jms.TopicConnectionFactory", deleted the properties "UserName" and "Password"
2. Resources -> JMS Resources -> Destination Resources: mine is called "jms/testDestination" and is of type "javax.jms.Topic", it has a "Name" property with "Destination" as the value - this was created by default, there is a message at the top of the page that the Name property specifies some physical destination (?)
The interface / bean producing the messages look like this:

<br />
package ejb;</p>
<p>import javax.ejb.Remote;</p>
<p>@Remote<br />
public interface Notifier {</p>
<p>    void doNotify(String notification);</p>
<p>}</p>
<p>package ejb;</p>
<p>import javax.annotation.PostConstruct;<br />
import javax.annotation.PreDestroy;<br />
import javax.annotation.Resource;<br />
import javax.ejb.Stateless;<br />
import javax.jms.JMSException;<br />
import javax.jms.MessageProducer;<br />
import javax.jms.Session;<br />
import javax.jms.TextMessage;<br />
import javax.jms.Topic;<br />
import javax.jms.TopicConnection;<br />
import javax.jms.TopicConnectionFactory;</p>
<p>@Stateless<br />
public class JMSNotifierBean implements Notifier {</p>
<p>    @Resource(mappedName = "jms/topicFactory")<br />
    private TopicConnectionFactory connectionFactory;</p>
<p>    @Resource(mappedName = "jms/testDestination")<br />
    private Topic topic;</p>
<p>    private TopicConnection connection;</p>
<p>    @Override<br />
    public void doNotify(String notification) {<br />
        try {<br />
            Session s = connection.createSession(true, Session.AUTO_ACKNOWLEDGE);<br />
            MessageProducer p = s.createProducer(topic);<br />
            TextMessage tm = s.createTextMessage("<<< " + notification + " >>>");<br />
            p.send(tm);<br />
            p.close();<br />
            s.close();<br />
        } catch (JMSException exc) {<br />
            exc.printStackTrace();<br />
        }<br />
    }</p>
<p>    @PostConstruct<br />
    public void initialize() {<br />
        try {<br />
            connection = connectionFactory.createTopicConnection();<br />
        } catch (JMSException exc) {<br />
            exc.printStackTrace();<br />
        }<br />
    }</p>
<p>    @PreDestroy<br />
    public void destroy() {<br />
        try {<br />
            connection.close();<br />
        } catch (JMSException exc) {<br />
            exc.printStackTrace();<br />
        }<br />
    }</p>
<p>}<br />

And the Message Driven Bean:

<br />
package ejb;</p>
<p>import javax.ejb.ActivationConfigProperty;<br />
import javax.ejb.MessageDriven;<br />
import javax.jms.Message;<br />
import javax.jms.MessageListener;</p>
<p>@MessageDriven(activationConfig = {<br />
        @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Topic"),<br />
        @ActivationConfigProperty(propertyName = "destinationName", propertyValue = "jms/testDestination")<br />
})<br />
public class NotificationListenerBean implements MessageListener {</p>
<p>    @Override<br />
    public void onMessage(Message msg) {<br />
        System.out.println(msg);<br />
    }<br />
}<br />

However, this doesn't work - when deploying this application (in Eclipse, I get this exception):

<br />
[#|2008-11-10T23:47:50.682+0100|SEVERE|sun-appserver9.1|javax.enterprise.system.container.ejb.mdb|_ThreadID=17;<br />
_ThreadName=httpWorkerThread-4848-0;_RequestID=0d22116a-556e-4705-97ce-bcf58a27c639;|com.sun.enterprise.connectors.ConnectorRuntimeException<br />
com.sun.enterprise.connectors.ConnectorRuntimeException: JMS resource not created :<br />
	at com.sun.enterprise.connectors.system.ActiveJmsResourceAdapter.getPhysicalDestinationFromConfiguration(ActiveJmsResourceAdapter.java:1546)<br />
	at com.sun.enterprise.connectors.system.ActiveJmsResourceAdapter.updateMDBRuntimeInfo(ActiveJmsResourceAdapter.java:1380)<br />
	at com.sun.enterprise.connectors.inflow.ConnectorMessageBeanClient.setup(ConnectorMessageBeanClient.java:170)<br />
	at com.sun.ejb.containers.MessageBeanContainer.(MessageBeanContainer.java:209)<br />
	at com.sun.ejb.containers.ContainerFactoryImpl.createContainer(ContainerFactoryImpl.java:280)<br />
	at com.sun.enterprise.server.AbstractLoader.loadEjbs(AbstractLoader.java:536)<br />
	at com.sun.enterprise.server.ApplicationLoader.doLoad(ApplicationLoader.java:188)<br />
	at com.sun.enterprise.server.TomcatApplicationLoader.doLoad(TomcatApplicationLoader.java:126)<br />
	at com.sun.enterprise.server.AbstractLoader.load(AbstractLoader.java:244)<br />
	at com.sun.enterprise.server.ApplicationManager.applicationDeployed(ApplicationManager.java:336)<br />
	at com.sun.enterprise.server.ApplicationManager.applicationDeployed(ApplicationManager.java:210)<br />
	at com.sun.enterprise.server.ApplicationManager.applicationDeployed(ApplicationManager.java:645)<br />
	at com.sun.enterprise.admin.event.AdminEventMulticaster.invokeApplicationDeployEventListener(AdminEventMulticaster.java:928)<br />
	at com.sun.enterprise.admin.event.AdminEventMulticaster.handleApplicationDeployEvent(AdminEventMulticaster.java:912)<br />
	at com.sun.enterprise.admin.event.AdminEventMulticaster.processEvent(AdminEventMulticaster.java:461)<br />
	at com.sun.enterprise.admin.event.AdminEventMulticaster.multicastEvent(AdminEventMulticaster.java:176)<br />
	at com.sun.enterprise.admin.server.core.DeploymentNotificationHelper.multicastEvent(DeploymentNotificationHelper.java:308)<br />
	at com.sun.enterprise.deployment.phasing.DeploymentServiceUtils.multicastEvent(DeploymentServiceUtils.java:226)<br />
	at com.sun.enterprise.deployment.phasing.ServerDeploymentTarget.sendStartEvent(ServerDeploymentTarget.java:298)<br />
	at com.sun.enterprise.deployment.phasing.ApplicationStartPhase.runPhase(ApplicationStartPhase.java:132)<br />
	at com.sun.enterprise.deployment.phasing.DeploymentPhase.executePhase(DeploymentPhase.java:108)<br />
	at com.sun.enterprise.deployment.phasing.PEDeploymentService.executePhases(PEDeploymentService.java:919)<br />
	at com.sun.enterprise.deployment.phasing.PEDeploymentService.start(PEDeploymentService.java:591)<br />
	at com.sun.enterprise.deployment.phasing.PEDeploymentService.start(PEDeploymentService.java:635)<br />
	at com.sun.enterprise.admin.mbeans.ApplicationsConfigMBean.start(ApplicationsConfigMBean.java:744)<br />
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)<br />
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)<br />
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)<br />
	at java.lang.reflect.Method.invoke(Method.java:597)<br />
	at com.sun.enterprise.admin.MBeanHelper.invokeOperationInBean(MBeanHelper.java:375)<br />
	at com.sun.enterprise.admin.MBeanHelper.invokeOperationInBean(MBeanHelper.java:358)<br />
	at com.sun.enterprise.admin.config.BaseConfigMBean.invoke(BaseConfigMBean.java:464)<br />
	at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:836)<br />
	at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:761)<br />
	at sun.reflect.GeneratedMethodAccessor13.invoke(Unknown Source)<br />
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)<br />
	at java.lang.reflect.Method.invoke(Method.java:597)<br />
	at com.sun.enterprise.admin.util.proxy.ProxyClass.invoke(ProxyClass.java:90)<br />
	at $Proxy1.invoke(Unknown Source)<br />
	at com.sun.enterprise.admin.server.core.jmx.SunoneInterceptor.invoke(SunoneInterceptor.java:304)<br />
	at com.sun.enterprise.interceptor.DynamicInterceptor.invoke(DynamicInterceptor.java:174)<br />
	at com.sun.enterprise.admin.jmx.remote.server.callers.InvokeCaller.call(InvokeCaller.java:69)<br />
	at com.sun.enterprise.admin.jmx.remote.server.MBeanServerRequestHandler.handle(MBeanServerRequestHandler.java:155)<br />
	at com.sun.enterprise.admin.jmx.remote.server.servlet.RemoteJmxConnectorServlet.processRequest(RemoteJmxConnectorServlet.java:122)<br />
	at com.sun.enterprise.admin.jmx.remote.server.servlet.RemoteJmxConnectorServlet.doPost(RemoteJmxConnectorServlet.java:193)<br />
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:738)<br />
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:831)<br />
	at org.apache.catalina.core.ApplicationFilterChain.servletService(ApplicationFilterChain.java:411)<br />
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:290)<br />
	at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:271)<br />
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:202)<br />
	at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:632)<br />
	at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:577)<br />
	at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:94)<br />
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:206)<br />
	at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:632)<br />
	at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:577)<br />
	at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:571)<br />
	at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1080)<br />
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:150)<br />
	at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:632)<br />
	at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:577)<br />
	at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:571)<br />
	at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1080)<br />
	at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:272)<br />
	at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.invokeAdapter(DefaultProcessorTask.java:637)<br />
	at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.doProcess(DefaultProcessorTask.java:568)<br />
	at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.process(DefaultProcessorTask.java:813)<br />
	at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.executeProcessorTask(DefaultReadTask.java:341)<br />
	at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadTask.java:263)<br />
	at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadTask.java:214)<br />
	at com.sun.enterprise.web.connector.grizzly.TaskBase.run(TaskBase.java:265)<br />
	at com.sun.enterprise.web.connector.grizzly.WorkerThreadImpl.run(WorkerThreadImpl.java:116)<br />
|#]<br />

The official Java EE 5 tutorial states:
"In the Application Server implementation of JMS, each destination resource refers to a physical
destination. You can create a physical destination explicitly, but if you do not, the Application
Server creates it when it is needed and deletes it when you delete the destination resource." (page 902, the very last paragraph)
This doesn't work for me. The only physical destination in Configuration -> Java Message Service is mq.sys.dmq, which is always there. I tried to create a physical destination named "Destination" (to reflect the Name property of the destination resource I created), but no change in behaviour.
Could someone please help me out and tell me what is wrong here?
Thanks.

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Wim Verreycken

And jms/ testDestination should have been :
jms/testDestination.

Sorry about that.
wim
-----Original Message-----
From: Wim Verreycken [mailto:wim@pizzastop.be]
Sent: dinsdag 11 november 2008 12:38
To: users@glassfish.dev.java.net
Subject: RE: [JMS] MDB problem - cannot make this work

Hi,

>I tried to create a physical destination named "Destination"
According to your code it should be called "testDestination".
You also seem to miss "mappedName" from the @MessageDriven Annotation.
Below is an example that works for me.

Hope it helps.

good luck!
wim

@MessageDriven(mappedName = "jms/ testDestination", activationConfig = {
@ActivationConfigProperty(propertyName = "acknowledgeMode",
propertyValue = "Auto-acknowledge"),
@ActivationConfigProperty(propertyName = "destinationType",
propertyValue = "javax.jms.Topic"),
@ActivationConfigProperty(propertyName = "subscriptionDurability",
propertyValue = "Durable"),
@ActivationConfigProperty(propertyName = "clientId", propertyValue =
" NotificationListenerBean"),
@ActivationConfigProperty(propertyName = "subscriptionName",
propertyValue = " NotificationListenerBean")
})

public class NotificationListenerBean implements MessageListener {

@Resource
private MessageDrivenContext mdc;

public void onMessage(Message inMessage) {
...
}
}

-----Original Message-----
From: glassfish@javadesktop.org [mailto:glassfish@javadesktop.org]
Sent: dinsdag 11 november 2008 0:24
To: users@glassfish.dev.java.net
Subject: [JMS] MDB problem - cannot make this work

Hi.
I wanted to take a look at JMS with Glassfish. The idea is simple - a
servlet has the Notifier bean injected, calls the doNotify() method on it,
which sends a message via JMS, which is handled by the MDB, and printed to
standard output.
I logged into the admin console and created two resources:
1. Resources -> JMS Resources -> Connection Factories: I created it with a
name "jms/topicFactory" and type "javax.jms.TopicConnectionFactory", deleted
the properties "UserName" and "Password"
2. Resources -> JMS Resources -> Destination Resources: mine is called
"jms/testDestination" and is of type "javax.jms.Topic", it has a "Name"
property with "Destination" as the value - this was created by default,
there is a message at the top of the page that the Name property specifies
some physical destination (?)
The interface / bean producing the messages look like this:

[code]
package ejb;

import javax.ejb.Remote;

@Remote
public interface Notifier {

void doNotify(String notification);

}

package ejb;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.annotation.Resource;
import javax.ejb.Stateless;
import javax.jms.JMSException;
import javax.jms.MessageProducer;
import javax.jms.Session;
import javax.jms.TextMessage;
import javax.jms.Topic;
import javax.jms.TopicConnection;
import javax.jms.TopicConnectionFactory;

@Stateless
public class JMSNotifierBean implements Notifier {

@Resource(mappedName = "jms/topicFactory")
private TopicConnectionFactory connectionFactory;

@Resource(mappedName = "jms/testDestination")
private Topic topic;

private TopicConnection connection;

@Override
public void doNotify(String notification) {
try {
Session s = connection.createSession(true,
Session.AUTO_ACKNOWLEDGE);
MessageProducer p = s.createProducer(topic);
TextMessage tm = s.createTextMessage("<<< " + notification + "
>>>");
p.send(tm);
p.close();
s.close();
} catch (JMSException exc) {
exc.printStackTrace();
}
}

@PostConstruct
public void initialize() {
try {
connection = connectionFactory.createTopicConnection();
} catch (JMSException exc) {
exc.printStackTrace();
}
}

@PreDestroy
public void destroy() {
try {
connection.close();
} catch (JMSException exc) {
exc.printStackTrace();
}
}

}
[/code]

And the Message Driven Bean:

[code]
package ejb;

import javax.ejb.ActivationConfigProperty;
import javax.ejb.MessageDriven;
import javax.jms.Message;
import javax.jms.MessageListener;

@MessageDriven(activationConfig = {
@ActivationConfigProperty(propertyName = "destinationType",
propertyValue = "javax.jms.Topic"),
@ActivationConfigProperty(propertyName = "destinationName",
propertyValue = "jms/testDestination")
})
public class NotificationListenerBean implements MessageListener {

@Override
public void onMessage(Message msg) {
System.out.println(msg);
}
}
[/code]
However, this doesn't work - when deploying this application (in Eclipse, I
get this exception):

[code]
[#|2008-11-10T23:47:50.682+0100|SEVERE|sun-appserver9.1|javax.enterprise.sys
tem.container.ejb.mdb|_ThreadID=17;
_ThreadName=httpWorkerThread-4848-0;_RequestID=0d22116a-556e-4705-97ce-bcf58
a27c639;|com.sun.enterprise.connectors.ConnectorRuntimeException
com.sun.enterprise.connectors.ConnectorRuntimeException: JMS resource not
created :
at
com.sun.enterprise.connectors.system.ActiveJmsResourceAdapter.getPhysicalDes
tinationFromConfiguration(ActiveJmsResourceAdapter.java:1546)
at
com.sun.enterprise.connectors.system.ActiveJmsResourceAdapter.updateMDBRunti
meInfo(ActiveJmsResourceAdapter.java:1380)
at
com.sun.enterprise.connectors.inflow.ConnectorMessageBeanClient.setup(Connec
torMessageBeanClient.java:170)
at
com.sun.ejb.containers.MessageBeanContainer.(MessageBeanContainer.java
:209)
at
com.sun.ejb.containers.ContainerFactoryImpl.createContainer(ContainerFactory
Impl.java:280)
at
com.sun.enterprise.server.AbstractLoader.loadEjbs(AbstractLoader.java:536)
at
com.sun.enterprise.server.ApplicationLoader.doLoad(ApplicationLoader.java:18
8)
at
com.sun.enterprise.server.TomcatApplicationLoader.doLoad(TomcatApplicationLo
ader.java:126)
at
com.sun.enterprise.server.AbstractLoader.load(AbstractLoader.java:244)
at
com.sun.enterprise.server.ApplicationManager.applicationDeployed(Application
Manager.java:336)
at
com.sun.enterprise.server.ApplicationManager.applicationDeployed(Application
Manager.java:210)
at
com.sun.enterprise.server.ApplicationManager.applicationDeployed(Application
Manager.java:645)
at
com.sun.enterprise.admin.event.AdminEventMulticaster.invokeApplicationDeploy
EventListener(AdminEventMulticaster.java:928)
at
com.sun.enterprise.admin.event.AdminEventMulticaster.handleApplicationDeploy
Event(AdminEventMulticaster.java:912)
at
com.sun.enterprise.admin.event.AdminEventMulticaster.processEvent(AdminEvent
Multicaster.java:461)
at
com.sun.enterprise.admin.event.AdminEventMulticaster.multicastEvent(AdminEve
ntMulticaster.java:176)
at
com.sun.enterprise.admin.server.core.DeploymentNotificationHelper.multicastE
vent(DeploymentNotificationHelper.java:308)
at
com.sun.enterprise.deployment.phasing.DeploymentServiceUtils.multicastEvent(
DeploymentServiceUtils.java:226)
at
com.sun.enterprise.deployment.phasing.ServerDeploymentTarget.sendStartEvent(
ServerDeploymentTarget.java:298)
at
com.sun.enterprise.deployment.phasing.ApplicationStartPhase.runPhase(Applica
tionStartPhase.java:132)
at
com.sun.enterprise.deployment.phasing.DeploymentPhase.executePhase(Deploymen
tPhase.java:108)
at
com.sun.enterprise.deployment.phasing.PEDeploymentService.executePhases(PEDe
ploymentService.java:919)
at
com.sun.enterprise.deployment.phasing.PEDeploymentService.start(PEDeployment
Service.java:591)
at
com.sun.enterprise.deployment.phasing.PEDeploymentService.start(PEDeployment
Service.java:635)
at
com.sun.enterprise.admin.mbeans.ApplicationsConfigMBean.start(ApplicationsCo
nfigMBean.java:744)
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:597)
at
com.sun.enterprise.admin.MBeanHelper.invokeOperationInBean(MBeanHelper.java:
375)
at
com.sun.enterprise.admin.MBeanHelper.invokeOperationInBean(MBeanHelper.java:
358)
at
com.sun.enterprise.admin.config.BaseConfigMBean.invoke(BaseConfigMBean.java:
464)
at
com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanSer
verInterceptor.java:836)
at
com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:761)
at sun.reflect.GeneratedMethodAccessor13.invoke(Unknown Source)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl
.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at
com.sun.enterprise.admin.util.proxy.ProxyClass.invoke(ProxyClass.java:90)
at $Proxy1.invoke(Unknown Source)
at
com.sun.enterprise.admin.server.core.jmx.SunoneInterceptor.invoke(SunoneInte
rceptor.java:304)
at
com.sun.enterprise.interceptor.DynamicInterceptor.invoke(DynamicInterceptor.
java:174)
at
com.sun.enterprise.admin.jmx.remote.server.callers.InvokeCaller.call(InvokeC
aller.java:69)
at
com.sun.enterprise.admin.jmx.remote.server.MBeanServerRequestHandler.handle(
MBeanServerRequestHandler.java:155)
at
com.sun.enterprise.admin.jmx.remote.server.servlet.RemoteJmxConnectorServlet
.processRequest(RemoteJmxConnectorServlet.java:122)
at
com.sun.enterprise.admin.jmx.remote.server.servlet.RemoteJmxConnectorServlet
.doPost(RemoteJmxConnectorServlet.java:193)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:738)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:831)
at
org.apache.catalina.core.ApplicationFilterChain.servletService(ApplicationFi
lterChain.java:411)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.ja
va:290)
at
org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContext
Valve.java:271)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.ja
va:202)
at
org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:632
)
at
org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:577
)
at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:94)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:206
)
at
org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:632
)
at
org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:577
)
at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:571)
at
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1080)
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java
:150)
at
org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:632
)
at
org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:577
)
at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:571)
at
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1080)
at
org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:272)
at
com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.invokeAdapter(
DefaultProcessorTask.java:637)
at
com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.doProcess(Defa
ultProcessorTask.java:568)
at
com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.process(Defaul
tProcessorTask.java:813)
at
com.sun.enterprise.web.connector.grizzly.DefaultReadTask.executeProcessorTas
k(DefaultReadTask.java:341)
at
com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadT
ask.java:263)
at
com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadT
ask.java:214)
at
com.sun.enterprise.web.connector.grizzly.TaskBase.run(TaskBase.java:265)
at
com.sun.enterprise.web.connector.grizzly.WorkerThreadImpl.run(WorkerThreadIm
pl.java:116)
|#]
[/code]

The official Java EE 5 tutorial states:
"In the Application Server implementation of JMS, each destination resource
refers to a physical
destination. You can create a physical destination explicitly, but if you do
not, the Application
Server creates it when it is needed and deletes it when you delete the
destination resource." (page 902, the very last paragraph)
This doesn't work for me. The only physical destination in Configuration ->
Java Message Service is mq.sys.dmq, which is always there. I tried to create
a physical destination named "Destination" (to reflect the Name property of
the destination resource I created), but no change in behaviour.
Could someone please help me out and tell me what is wrong here?
Thanks.
[Message sent by forum member 'szczyp' (szczyp)]

http://forums.java.net/jive/thread.jspa?messageID=315915

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
For additional commands, e-mail: users-help@glassfish.dev.java.net

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
For additional commands, e-mail: users-help@glassfish.dev.java.net

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
For additional commands, e-mail: users-help@glassfish.dev.java.net

szczyp

Hi.
You were right, I have to set the mappedName attribute on my MDB to specify the destination on which it listens for new messages. And yes, the physical destination was created for me automatically. My example works fine now.
I am reading "EJB3 in Action", and the code for defininf the MDB was:

[code]
@MessageDriven(
name="ShippingRequestProcessor",
activationConfig = {
@ActivationConfigProperty(
propertyName="destinationType",
propertyValue="javax.jms.Queue"),
@ActivationConfigProperty(
propertyName="destinationName",
propertyValue="jms/ShippingRequestQueue")
}
)
[/code]
and I thought the last @ActivationConfigProperty is used to determine the destination. So, to make things a little clearer for me, I have the following questions:
1. is there any resource somwehere in the net which would tell me which propertyName and their values can be used for Glassfish? As I assume this is not standardized in the specs, and varies from provider to provider, just as JPA properties?
2. there are numerous places I read that mappedName attribute is not portable and may not work with different application servers. What does this actually mean for me? And why do we have to specify the destination with a non-portable attribute?
If these are silly questions to you, forgive me as I am inexperienced in all of this.

And lastly, I would like to thank all the people who helped me in this thread with their examples and explanations.

Gavilan

glassfish@javadesktop.org wrote:
> 1. is there any resource somwehere in the net which would tell me which propertyName and their values
> can be used for Glassfish? As I assume this is not standardized in
the specs,
> and varies from provider to provider, just as JPA properties?

The best resource I have found is the source code for Open MQ which I
downloaded from the glassfish website.

The class to look at is com.sun.messaging.jms.ra.ActivationSpec

There's a comment in the code that marks the start of the list:

/* ActivationSpec attributes for the Sun Java System MQ JMS Resource
Adapter */

Best Wishes,
James

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
For additional commands, e-mail: users-help@glassfish.dev.java.net

szczyp

I looked it up in sun-ejb-jar.xml, but it only mentions four properties the code has more options.
Thank you.

nigeldeakin
Offline
Joined: 2007-10-12
Points: 0

Mr Szczyp,

From looking at the code, the error message you report means one of two things:

1. The JNDI name you specified doesn't exist or
2. That the object that you bound to that name doesn't have its "name" attribute set.

You don't say which version of GF you were using. But when I tried this using V2 UR2 (I navigated to Resources -> JMS Resources -> Destination resources and pressed "New") the dialog was different to your description: it prompted me to supply not only the JNDI name but also the "physical destination name" (which sets the name attribute). That said, you say you set the name attribute anyway, so I can't explain your error. However the problem lies somewhere in the JNDI settings so I would be tempted to try repeating this part of the process.

Although you do need to associate your JNDI name with a physical destination name, you don't have to create the physical destination yourself (though you can). MQ will automatically create it. However you got an error before getting to that stage.

Hope that helps,

Nigel

nigeldeakin
Offline
Joined: 2007-10-12
Points: 0

Yes, I think Wim Verreycken has got it. The error message "JMS resource not created :" should be followed by the JNDI name. Since this was blank in your case, you probably didn't configure it correctly in the annotation.

Nigel

Wim Verreycken

Hi,

>I tried to create a physical destination named "Destination"
According to your code it should be called "testDestination".
You also seem to miss "mappedName" from the @MessageDriven Annotation.
Below is an example that works for me.

Hope it helps.

good luck!
wim

@MessageDriven(mappedName = "jms/ testDestination", activationConfig = {
@ActivationConfigProperty(propertyName = "acknowledgeMode",
propertyValue = "Auto-acknowledge"),
@ActivationConfigProperty(propertyName = "destinationType",
propertyValue = "javax.jms.Topic"),
@ActivationConfigProperty(propertyName = "subscriptionDurability",
propertyValue = "Durable"),
@ActivationConfigProperty(propertyName = "clientId", propertyValue =
" NotificationListenerBean"),
@ActivationConfigProperty(propertyName = "subscriptionName",
propertyValue = " NotificationListenerBean")
})

public class NotificationListenerBean implements MessageListener {

@Resource
private MessageDrivenContext mdc;

public void onMessage(Message inMessage) {
...
}
}

-----Original Message-----
From: glassfish@javadesktop.org [mailto:glassfish@javadesktop.org]
Sent: dinsdag 11 november 2008 0:24
To: users@glassfish.dev.java.net
Subject: [JMS] MDB problem - cannot make this work

Hi.
I wanted to take a look at JMS with Glassfish. The idea is simple - a
servlet has the Notifier bean injected, calls the doNotify() method on it,
which sends a message via JMS, which is handled by the MDB, and printed to
standard output.
I logged into the admin console and created two resources:
1. Resources -> JMS Resources -> Connection Factories: I created it with a
name "jms/topicFactory" and type "javax.jms.TopicConnectionFactory", deleted
the properties "UserName" and "Password"
2. Resources -> JMS Resources -> Destination Resources: mine is called
"jms/testDestination" and is of type "javax.jms.Topic", it has a "Name"
property with "Destination" as the value - this was created by default,
there is a message at the top of the page that the Name property specifies
some physical destination (?)
The interface / bean producing the messages look like this:

[code]
package ejb;

import javax.ejb.Remote;

@Remote
public interface Notifier {

void doNotify(String notification);

}

package ejb;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.annotation.Resource;
import javax.ejb.Stateless;
import javax.jms.JMSException;
import javax.jms.MessageProducer;
import javax.jms.Session;
import javax.jms.TextMessage;
import javax.jms.Topic;
import javax.jms.TopicConnection;
import javax.jms.TopicConnectionFactory;

@Stateless
public class JMSNotifierBean implements Notifier {

@Resource(mappedName = "jms/topicFactory")
private TopicConnectionFactory connectionFactory;

@Resource(mappedName = "jms/testDestination")
private Topic topic;

private TopicConnection connection;

@Override
public void doNotify(String notification) {
try {
Session s = connection.createSession(true,
Session.AUTO_ACKNOWLEDGE);
MessageProducer p = s.createProducer(topic);
TextMessage tm = s.createTextMessage("<<< " + notification + "
>>>");
p.send(tm);
p.close();
s.close();
} catch (JMSException exc) {
exc.printStackTrace();
}
}

@PostConstruct
public void initialize() {
try {
connection = connectionFactory.createTopicConnection();
} catch (JMSException exc) {
exc.printStackTrace();
}
}

@PreDestroy
public void destroy() {
try {
connection.close();
} catch (JMSException exc) {
exc.printStackTrace();
}
}

}
[/code]

And the Message Driven Bean:

[code]
package ejb;

import javax.ejb.ActivationConfigProperty;
import javax.ejb.MessageDriven;
import javax.jms.Message;
import javax.jms.MessageListener;

@MessageDriven(activationConfig = {
@ActivationConfigProperty(propertyName = "destinationType",
propertyValue = "javax.jms.Topic"),
@ActivationConfigProperty(propertyName = "destinationName",
propertyValue = "jms/testDestination")
})
public class NotificationListenerBean implements MessageListener {

@Override
public void onMessage(Message msg) {
System.out.println(msg);
}
}
[/code]
However, this doesn't work - when deploying this application (in Eclipse, I
get this exception):

[code]
[#|2008-11-10T23:47:50.682+0100|SEVERE|sun-appserver9.1|javax.enterprise.sys
tem.container.ejb.mdb|_ThreadID=17;
_ThreadName=httpWorkerThread-4848-0;_RequestID=0d22116a-556e-4705-97ce-bcf58
a27c639;|com.sun.enterprise.connectors.ConnectorRuntimeException
com.sun.enterprise.connectors.ConnectorRuntimeException: JMS resource not
created :
at
com.sun.enterprise.connectors.system.ActiveJmsResourceAdapter.getPhysicalDes
tinationFromConfiguration(ActiveJmsResourceAdapter.java:1546)
at
com.sun.enterprise.connectors.system.ActiveJmsResourceAdapter.updateMDBRunti
meInfo(ActiveJmsResourceAdapter.java:1380)
at
com.sun.enterprise.connectors.inflow.ConnectorMessageBeanClient.setup(Connec
torMessageBeanClient.java:170)
at
com.sun.ejb.containers.MessageBeanContainer.(MessageBeanContainer.java
:209)
at
com.sun.ejb.containers.ContainerFactoryImpl.createContainer(ContainerFactory
Impl.java:280)
at
com.sun.enterprise.server.AbstractLoader.loadEjbs(AbstractLoader.java:536)
at
com.sun.enterprise.server.ApplicationLoader.doLoad(ApplicationLoader.java:18
8)
at
com.sun.enterprise.server.TomcatApplicationLoader.doLoad(TomcatApplicationLo
ader.java:126)
at
com.sun.enterprise.server.AbstractLoader.load(AbstractLoader.java:244)
at
com.sun.enterprise.server.ApplicationManager.applicationDeployed(Application
Manager.java:336)
at
com.sun.enterprise.server.ApplicationManager.applicationDeployed(Application
Manager.java:210)
at
com.sun.enterprise.server.ApplicationManager.applicationDeployed(Application
Manager.java:645)
at
com.sun.enterprise.admin.event.AdminEventMulticaster.invokeApplicationDeploy
EventListener(AdminEventMulticaster.java:928)
at
com.sun.enterprise.admin.event.AdminEventMulticaster.handleApplicationDeploy
Event(AdminEventMulticaster.java:912)
at
com.sun.enterprise.admin.event.AdminEventMulticaster.processEvent(AdminEvent
Multicaster.java:461)
at
com.sun.enterprise.admin.event.AdminEventMulticaster.multicastEvent(AdminEve
ntMulticaster.java:176)
at
com.sun.enterprise.admin.server.core.DeploymentNotificationHelper.multicastE
vent(DeploymentNotificationHelper.java:308)
at
com.sun.enterprise.deployment.phasing.DeploymentServiceUtils.multicastEvent(
DeploymentServiceUtils.java:226)
at
com.sun.enterprise.deployment.phasing.ServerDeploymentTarget.sendStartEvent(
ServerDeploymentTarget.java:298)
at
com.sun.enterprise.deployment.phasing.ApplicationStartPhase.runPhase(Applica
tionStartPhase.java:132)
at
com.sun.enterprise.deployment.phasing.DeploymentPhase.executePhase(Deploymen
tPhase.java:108)
at
com.sun.enterprise.deployment.phasing.PEDeploymentService.executePhases(PEDe
ploymentService.java:919)
at
com.sun.enterprise.deployment.phasing.PEDeploymentService.start(PEDeployment
Service.java:591)
at
com.sun.enterprise.deployment.phasing.PEDeploymentService.start(PEDeployment
Service.java:635)
at
com.sun.enterprise.admin.mbeans.ApplicationsConfigMBean.start(ApplicationsCo
nfigMBean.java:744)
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:597)
at
com.sun.enterprise.admin.MBeanHelper.invokeOperationInBean(MBeanHelper.java:
375)
at
com.sun.enterprise.admin.MBeanHelper.invokeOperationInBean(MBeanHelper.java:
358)
at
com.sun.enterprise.admin.config.BaseConfigMBean.invoke(BaseConfigMBean.java:
464)
at
com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanSer
verInterceptor.java:836)
at
com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:761)
at sun.reflect.GeneratedMethodAccessor13.invoke(Unknown Source)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl
.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at
com.sun.enterprise.admin.util.proxy.ProxyClass.invoke(ProxyClass.java:90)
at $Proxy1.invoke(Unknown Source)
at
com.sun.enterprise.admin.server.core.jmx.SunoneInterceptor.invoke(SunoneInte
rceptor.java:304)
at
com.sun.enterprise.interceptor.DynamicInterceptor.invoke(DynamicInterceptor.
java:174)
at
com.sun.enterprise.admin.jmx.remote.server.callers.InvokeCaller.call(InvokeC
aller.java:69)
at
com.sun.enterprise.admin.jmx.remote.server.MBeanServerRequestHandler.handle(
MBeanServerRequestHandler.java:155)
at
com.sun.enterprise.admin.jmx.remote.server.servlet.RemoteJmxConnectorServlet
.processRequest(RemoteJmxConnectorServlet.java:122)
at
com.sun.enterprise.admin.jmx.remote.server.servlet.RemoteJmxConnectorServlet
.doPost(RemoteJmxConnectorServlet.java:193)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:738)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:831)
at
org.apache.catalina.core.ApplicationFilterChain.servletService(ApplicationFi
lterChain.java:411)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.ja
va:290)
at
org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContext
Valve.java:271)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.ja
va:202)
at
org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:632
)
at
org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:577
)
at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:94)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:206
)
at
org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:632
)
at
org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:577
)
at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:571)
at
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1080)
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java
:150)
at
org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:632
)
at
org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:577
)
at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:571)
at
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1080)
at
org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:272)
at
com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.invokeAdapter(
DefaultProcessorTask.java:637)
at
com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.doProcess(Defa
ultProcessorTask.java:568)
at
com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.process(Defaul
tProcessorTask.java:813)
at
com.sun.enterprise.web.connector.grizzly.DefaultReadTask.executeProcessorTas
k(DefaultReadTask.java:341)
at
com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadT
ask.java:263)
at
com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadT
ask.java:214)
at
com.sun.enterprise.web.connector.grizzly.TaskBase.run(TaskBase.java:265)
at
com.sun.enterprise.web.connector.grizzly.WorkerThreadImpl.run(WorkerThreadIm
pl.java:116)
|#]
[/code]

The official Java EE 5 tutorial states:
"In the Application Server implementation of JMS, each destination resource
refers to a physical
destination. You can create a physical destination explicitly, but if you do
not, the Application
Server creates it when it is needed and deletes it when you delete the
destination resource." (page 902, the very last paragraph)
This doesn't work for me. The only physical destination in Configuration ->
Java Message Service is mq.sys.dmq, which is always there. I tried to create
a physical destination named "Destination" (to reflect the Name property of
the destination resource I created), but no change in behaviour.
Could someone please help me out and tell me what is wrong here?
Thanks.
[Message sent by forum member 'szczyp' (szczyp)]

http://forums.java.net/jive/thread.jspa?messageID=315915

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
For additional commands, e-mail: users-help@glassfish.dev.java.net

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
For additional commands, e-mail: users-help@glassfish.dev.java.net

Wim Verreycken

There is a typo in the example I gave. Two times,
propertyValue = " NotificationListenerBean"),
should have been :
propertyValue = "NotificationListenerBean"),

of course.

Cheers,
wim

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
For additional commands, e-mail: users-help@glassfish.dev.java.net