[Messaging, JMS & JBossMQ] - problem with durable mdb - new client id every time
by enesterov
Hi everyone,
I have MDB annotated as follows:
@MessageDriven(activationConfig = {
@ActivationConfigProperty(propertyName = "messagingType", propertyValue = "javax.jms.MessageListener"),
@ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Topic"),
@ActivationConfigProperty(propertyName = "destination", propertyValue = "topic/MOBIDISP_MOT"),
@ActivationConfigProperty(propertyName = "providerAdapterJNDI", propertyValue="java:/DefaultJMSProvider"),
@ActivationConfigProperty(propertyName = "subscriptionDurability", propertyValue="Durable"),
@ActivationConfigProperty(propertyName = "subscriptionName", propertyValue="autoresponder"),
@ActivationConfigProperty(propertyName = "messageSelector", propertyValue="application_id in ('autoresponder')")
})
After I deploy it I get a record in jmx-console cofirming that it is deployed and it is durable. The problem appears when I restart application or redeploy MDB ? it is not recognised as one which subscribed before and new durable subscription is created. Here is what I can see in jmx-console after a couple of server restarts:
...
Topic,MOBIDISP_MOT,DurableSubscription[clientId=ID:11162 name=autoresponder selector=application_id in ('UNKNOWN', 'autoresponder')],true,0,0,2,2,-
Topic,MOBIDISP_MOT,DurableSubscription[clientId=ID:1118 name=autoresponder selector=application_id in ('UNKNOWN', 'autoresponder')],true,0,0,2,2,-
Topic,MOBIDISP_MOT,DurableSubscription[clientId=ID:11183 name=autoresponder selector=application_id in ('UNKNOWN', 'autoresponder')],true,0,0,2,2,-
...
Can anybody tell me what am I doing wrong.
Thanks,
Ed
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4031418#4031418
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4031418
19Â years
[EJB 3.0] - Problem with Entity Manager dependency injection in JBoss 5
by heinza
Hi, everybody!
I'm trying to perform EM dependency injection in servlet using JBoss 5 Beta 1 and get the following deployment exception:
ERROR [org.jboss.kernel.plugins.dependency.AbstractKernelController]
| Error installing to Start: name=jboss.web.deployment:war=/simple-web state=Create mode=Manual requiredState=Installed
|
| java.lang.RuntimeException: @PersistenceContext(name='env/Test/em',unitName='test-jpa') on EJB:
| simple-web.war failed to inject on field javax.persistence.EntityManager Test.em
|
| Unable to find persistence unit: test-jpa for deployment: simple-web.war
| at org.jboss.injection.PcEncInjector.inject(PcEncInjector.java:75)
| at org.jboss.web.tomcat.tc6.TomcatInjectionContainer.populateEnc(TomcatInjectionContainer.java:206)
| ...
NOTE: When there were some errors in persistence.xml (now fixed), server reported them explicitly. Though, how can it be that server is "Unable to find persistence unit: test-jpa", but is able to find errors in it?
And a warning:
WARN [org.hibernate.ejb.Ejb3Configuration] Persistence provider caller does not implements the EJB3 spec correctly. PersistenceUnitInfo.getNewTempClassLoader() is null.
When invoking servlet I get the following response:
exception
|
| javax.servlet.ServletException: Error instantiating servlet class Test
| org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:86)
| org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
| org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:212)
| ...
|
| root cause
|
| java.lang.RuntimeException: Unable to inject jndi dependency: env/Test/em into field interface javax.persistence.EntityManager
| org.jboss.injection.JndiFieldInjector.lookup(JndiFieldInjector.java:85)
| org.jboss.injection.JndiFieldInjector.inject(JndiFieldInjector.java:99)
| ...
|
| root cause
|
| javax.naming.NameNotFoundException: Test not bound
| org.jnp.server.NamingServer.getBinding(NamingServer.java:529)
| org.jnp.server.NamingServer.getBinding(NamingServer.java:537)
| org.jnp.server.NamingServer.getObject(NamingServer.java:543)
| org.jnp.server.NamingServer.lookup(NamingServer.java:267)
| org.jnp.server.NamingServer.lookup(NamingServer.java:270)
Here is my servlet code:
public class Test ... {
|
| @PersistenceContext(unitName="test-jpa")
| EntityManager em;
|
| protected void doGet(...) {
|
| Mytable mytable = em.find(Mytable.class, new Integer(5));
| response.getOutputStream().print(mytable.getName());
| }
| }
Here is persistence.xml:
<?xml version="1.0" encoding="UTF-8"?>
|
| <persistence version="1.0" ... >
| <persistence-unit name="test-jpa" transaction-type="RESOURCE_LOCAL">
| <jta-data-source>java:/MySqlDS</jta-data-source>
| <class>Mytable</class>
| <properties>
| <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLInnoDBDialect" />
| </properties>
| </persistence-unit>
| </persistence>
WAR structure:
simple-web.war
| /META-INF
| manifest.mf
| /WEB-INF
| /classes
| Test.java (servlet)
| Mytable.java (entity)
| web.xml
| persistence.xml
AFAIK, JBoss 5 is supposed to support dependency injection in servlets. So what's wrong?
Any help would be pleased. Thanks in advance.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4031401#4031401
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4031401
19Â years