-
1. Re: 7.1.1.: DI for ConnectionFactory and Queue not possible?
sfcoy May 29, 2012 10:47 AM (in response to pi4630)There's a working example attached to JBoss AS 7.1CR1 hangs when deployments reference JMS objects.
-
2. Re: 7.1.1.: DI for ConnectionFactory and Queue not possible?
jaikiran May 29, 2012 9:56 PM (in response to pi4630)Just make you are using the standalone-full.xml or standalone-full-ha.xml profiles while starting the server. Those are the ones which have messaging subsystem enabled.
./standalone.sh -server-config=standalone-full.xml
-
3. Re: 7.1.1.: DI for ConnectionFactory and Queue not possible?
pi4630 May 30, 2012 2:16 AM (in response to jaikiran)Jaikiran, I was using
./standalone.sh -c standalone-full.xml
Not good?
-
4. Re: 7.1.1.: DI for ConnectionFactory and Queue not possible?
jaikiran May 30, 2012 2:29 AM (in response to pi4630)Should be fine. What exactly happens with that code? Do you see any error messages? Can you post any relevant exception stacktraces? And please also post the exact code in that class (is that a EJB)?
-
5. Re: 7.1.1.: DI for ConnectionFactory and Queue not possible?
pi4630 May 30, 2012 3:10 AM (in response to jaikiran)From server.log:
{font:courier new}
ERROR [org.jboss.as] (MSC service thread 1-3) JBAS015875: JBoss AS 7.1.1.Final "Brontes" started (with errors) in 5107ms - Started 226 of 312 services (5 services failed or missing dependencies, 80 services are passive or on-demand)
08:57:19,6
INFO [org.jboss.as.server.deployment] (MSC service thread 1-1) JBAS015877: Stopped deployment HelloMessage.jar in 44ms
08:57:19,662 INFO [org.jboss.as.controller] (DeploymentScanner-threads - 2) JBAS014774: Service status report
JBAS014775: New missing/unsatisfied dependencies:
service jboss.naming.context.java.comp.HelloMessage.HelloMessage.Talker.env.ConnectionFactory (missing) dependents: [service jboss.naming.context.java.comp.HelloMessage.HelloMessage.Talker.env."it.bz.prov.logic.Talker".factory]
service jboss.naming.context.java.comp.HelloMessage.HelloMessage.Talker.env.queue.test (missing) dependents: [service jboss.naming.context.java.comp.HelloMessage.HelloMessage.Talker.env."it.bz.prov.logic.Talker".queue]
27 INFO [org.jboss.as.server] (DeploymentScanner-threads - 2) JBAS015870: Deploy of deployment "HelloMessage.jar" was rolled back with failure message {"JBAS014771: Services with missing/unavailable dependencies" => ["jboss.naming.context.java.comp.HelloMessage.HelloMessage.Talker.env.\"it.bz.prov.logic.Talker\".queuejboss.naming.context.java.comp.HelloMessage.HelloMessage.Talker.env.queue.testMissing[jboss.naming.context.java.comp.HelloMessage.HelloMessage.Talker.env.\"it.bz.prov.logic.Talker\".queuejboss.naming.context.java.comp.HelloMessage.HelloMessage.Talker.env.queue.test]","jboss.naming.context.java.comp.HelloMessage.HelloMessage.Talker.env.\"it.bz.prov.logic.Talker\".factoryjboss.naming.context.java.comp.HelloMessage.HelloMessage.Talker.env.ConnectionFactoryMissing[jboss.naming.context.java.comp.HelloMessage.HelloMessage.Talker.env.\"it.bz.prov.logic.Talker\".factoryjboss.naming.context.java.comp.HelloMessage.HelloMessage.Talker.env.ConnectionFactory]"]}
{font}
Inside my standard-full.xml, the JMS Connection Factory JNDI name is set as well as the destinations:
{code:xml}
<jms-connection-factories>
<connection-factory name="InVmConnectionFactory">
<connectors>
<connector-ref connector-name="in-vm"/>
</connectors>
<entries>
<entry name="java:/ConnectionFactory"/>
</entries>
...
<jms-destinations>
<jms-queue name="testQueue">
<entry name="queue/test"/>
<entry name="java:jboss/exported/jms/queue/test"/>
</jms-queue>
{code}
Finally, here's the code:
{code}
package it.bz.prov.logic;
import javax.annotation.Resource;
import javax.ejb.Stateless;
import javax.jms.Connection;
import javax.jms.ConnectionFactory;
import javax.jms.JMSException;
import javax.jms.MessageProducer;
import javax.jms.Queue;
import javax.jms.Session;
import javax.jms.TextMessage;
import javax.naming.Context;
import javax.naming.InitialContext;
import it.bz.prov.ibusiness.ITalkRemote;
@Stateless
public class Talker implements ITalkRemote {
// Can't do JNDI resource injection
// will be available in 7.1
// see https://issues.jboss.org/browse/AS7-1338
// @Resource(mappedName = "java:/ConnectionFactory")
// Connection factory;
// OLD WAY
@Resource(mappedName = "ConnectionFactory")
ConnectionFactory factory;
@Resource(mappedName = "queue/test")
Queue queue;
@Override
public String greet(String name) {
String answer = null;
if (name != null && !name.equalsIgnoreCase("")) {
answer = "Hello, " + name + "!";
squeal(name);
}
return answer;
}
private void squeal(String name) {
try {
// Context ic = new InitialContext();
// ConnectionFactory factory = (ConnectionFactory) ic
// .lookup("/ConnectionFactory");
// Queue queue = (Queue) ic.lookup("queue/test");
Connection conn = factory.createConnection();
Session session = conn.createSession(false,
Session.AUTO_ACKNOWLEDGE);
MessageProducer sender = session.createProducer(queue);
TextMessage tm = session.createTextMessage();
// TextMessage of type squeal
tm.setStringProperty("Subject", "squeal");
tm.setText(name);
sender.send(tm);
sender.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}
{code}
-
6. Re: 7.1.1.: DI for ConnectionFactory and Queue not possible?
jaikiran May 30, 2012 3:22 AM (in response to pi4630)@Resource(mappedName = "ConnectionFactory")
ConnectionFactory factory;
@Resource(mappedName = "queue/test")
Queue queue;This should be
@Resource(mappedName = "java:/ConnectionFactory")
ConnectionFactory factory;
@Resource(mappedName = "java:/queue/test")
Queue queue; -
7. Re: 7.1.1.: DI for ConnectionFactory and Queue not possible?
jaikiran May 30, 2012 3:23 AM (in response to jaikiran)1 of 1 people found this helpfulBy the way, earlier in your logs you'll see the exact JNDI names to which the queue and connection factory is bound. You just have to use that value in your mappedName attribute.
-
8. Re: 7.1.1.: DI for ConnectionFactory and Queue not possible?
pi4630 May 30, 2012 5:14 AM (in response to jaikiran)Yes, I see it
Just to get it right: In 6.0.0.Final, my JMS destinations is called <entry name="/queue/testQueue"/>, while the ConnectionFactory is called
<entry name="java:/ConnectionFactory"/>. There I inject with just "ConnectionFactory", and the JNDI name is resolved.
Now I see I must use the config entry name(s) "as is" with 7 onwards.
Thanks Jaikiran!