use name-"foo" not mappedName="foo" in your annotations.
Annotations work the same in servlets and ejbs. We have a sample that
has an mdb and a servlet that sends messages to the servlet. See the
jms-mdb sample described under http://cwiki.apache.org/GMOxDOC21/sample-applications.html
thanksd
david jencks
On Jan 24, 2009, at 12:24 PM, rsumner wrote:
I've been beating my head on my desk for 2 days on this now. I hope
you'll
have a little patience with me as I'm a little sleep deprived as
I've tried
to "beat" Geronimo into my liking %-|
Anyyyways...
So, here's the layout of my APP:
- One MDB
- One Session Bean
- One Web App
Here's the basic logic that I'm trying to accomplish:
- Web app injects SessionBean, and calls addMessage()
- SessionBeans injects the default DefaultActiveMQConnectionFactory
and
SendReceiveQueue
- SessionBeans's addMessage() method publishes a objectmessage to
the queue
- MDB defines activationconfig annotations to set SendReceiveQueue
as the
destination queue and simply logs the details of the message
I don't have any problems with the webapp injecting the Sesion
bean. I also
don't have any problems with the MDB starting up (or at least not at
this
point).
The problem I have is injecting the Resources for
DefaultActiveMQConnectionFactory and SendReceiveQueue into my
SessionBean.
The annotations that I'm using in the session bean:
@Resource(mappedName="DefaultActiveMQConnectionFactory")
protected ConnectionFactory jmsFactory;
@Resource(mappedName="SendReceiveQueue")
protected Queue jmsQueue;
In my openejb-jar.xml file, I have the following:
<ejb:openejb-jar
xmlns:app="http://geronimo.apache.org/xml/ns/j2ee/application-2.0"
xmlns:client="http://geronimo.apache.org/xml/ns/j2ee/application-client-2.0
"
xmlns:conn="http://geronimo.apache.org/xml/ns/j2ee/connector-1.2"
xmlns:dep="http://geronimo.apache.org/xml/ns/deployment-1.2"
xmlns:ejb="http://openejb.apache.org/xml/ns/openejb-jar-2.2"
xmlns:name="http://geronimo.apache.org/xml/ns/naming-1.2"
xmlns:pers="http://java.sun.com/xml/ns/persistence"
xmlns:pkgen="http://openejb.apache.org/xml/ns/pkgen-2.1"
xmlns:sec="http://geronimo.apache.org/xml/ns/security-2.0"
xmlns:web="http://geronimo.apache.org/xml/ns/j2ee/web-2.0.1">
<dep:environment>
<dep:moduleId>
<dep:groupId>default</dep:groupId>
<dep:artifactId>myApp</dep:artifactId>
<dep:version>1.0</dep:version>
<dep:type>car</dep:type>
</dep:moduleId>
<dep:dependencies>
<dep:dependency>
<dep:groupId>org.apache.geronimo.configs</dep:groupId>
<dep:artifactId>openjpa</dep:artifactId>
<dep:version>2.1.1</dep:version>
<dep:type>car</dep:type>
</dep:dependency>
<dep:dependency>
<dep:groupId>console.dbpool</dep:groupId>
<dep:artifactId>myDS</dep:artifactId>
<dep:version>1.0</dep:version>
<dep:type>rar</dep:type>
</dep:dependency>
<dep:dependency>
<dep:groupId>org.apache.geronimo.configs</dep:groupId>
<dep:artifactId>activemq-ra</dep:artifactId>
<dep:version>2.1.3</dep:version>
<dep:type>car</dep:type>
</dep:dependency>
</dep:dependencies>
</dep:environment>
<ejb:enterprise-beans>
<ejb:message-driven>
<ejb:ejb-name>MyMDB</ejb:ejb-name>
<name:resource-adapter>
<name:resource-link>ActiveMQ RA</name:resource-link>
</name:resource-adapter>
</ejb:message-driven>
<ejb:session>
<ejb:ejb-name>MySessionBean</ejb:ejb-name>
<name:resource-ref>
<name:ref-name>DefaultActiveMQConnectionFactory</name:ref-
name>
<name:resource-link>DefaultActiveMQConnectionFactory</name:resource-
link>
</name:resource-ref>
<name:resource-env-ref>
<name:ref-name>SendReceiveQueue</name:ref-name>
<name:message-destination-link>SendReceiveQueue</name:message-
destination-link>
</name:resource-env-ref>
</ejb:session>
</ejb:enterprise-beans>
<dep:gbean
class
=
"org
.apache
.geronimo.system.logging.log4j.ApplicationLog4jConfigurationGBean"
name="DirectoryLog4jConfiguration">
<dep:attribute name="log4jResource">log4j.properties</
dep:attribute>
</dep:gbean>
</ejb:openejb-jar>
From the hundreds of HOWTOs, examples, and code snippets that I've
read,
that should do the trick, but I will get the following pesky error
upon
deployment:
Distribution of module failed. See log for details.
Unable to resolve resource reference 'my.MySessonBean/
jmsFactory' (Could
not auto-map to resource. Try adding a resource-ref mapping to your
Geronimo deployment plan.
Search conducted in current module and dependencies:
[ALL: org.apache.geronimo.configs/j2ee-server//car]
[ALL: org.apache.geronimo.configs/openjpa/2.1.1/car]
[ALL: console.dbpool/myDS/1.0/rar]
[ALL: org.apache.geronimo.configs/activemq-ra/2.1.3/car]
[ALL: org.apache.geronimo.configs/openejb//car]
[ALL: org.apache.geronimo.configs/system-database//car]
[ALL: org.apache.geronimo.configs/tomcat6//car]
[ALL: org.apache.geronimo.configs/axis//car]
[ALL: org.apache.geronimo.configs/axis2//car]
[ALL: org.apache.geronimo.configs/openjpa//car]
[ALL: org.apache.geronimo.configs/j2ee-corba-yoko//car]
)
org.apache.geronimo.common.DeploymentException: Unable to resolve
resource
reference 'my.MySessionBean/jmsFactory' (Could not auto-map to
resource.
Try adding a resource-ref mapping to your Geronimo deployment plan.
Search conducted in current module and dependencies:
[ALL: org.apache.geronimo.configs/j2ee-server//car]
[ALL: org.apache.geronimo.configs/openjpa/2.1.1/car]
[ALL: console.dbpool/myDS/1.0/rar]
[ALL: org.apache.geronimo.configs/activemq-ra/2.1.3/car]
[ALL: org.apache.geronimo.configs/openejb//car]
[ALL: org.apache.geronimo.configs/system-database//car]
[ALL: org.apache.geronimo.configs/tomcat6//car]
[ALL: org.apache.geronimo.configs/axis//car]
[ALL: org.apache.geronimo.configs/axis2//car]
[ALL: org.apache.geronimo.configs/openjpa//car]
[ALL: org.apache.geronimo.configs/j2ee-corba-yoko//car]
)
I've also tried adding things like this to my ejb-jar.xml, but they
don't
help a bit:
<enterprise-beans>
<session>
<ejb-name>MySessionBean</ejb-name>
<ejb-class>my.MySessionBean</ejb-class>
<session-type>Stateless</session-type>
<resource-ref>
<res-ref-name>DefaultActiveMQConnectionFactory</res-ref-name>
<res-type>javax.jms.ConnectionFactory</res-type>
<res-auth>Container</res-auth>
<res-sharing-scope>Shareable</res-sharing-scope>
<mapped-name>DefaultActiveMQConnectionFactory</mapped-name>
</resource-ref>
....
I feel that I've done quite a bit of searching and looking and just
can't
anything to help. Most examples that I've find have people
conneting to JMS
directly from the webapp. I'd like to have all my core business
logic down
in the session bean and use JMS as a way to provide asyncronous
functionality to my session bean when the load is high on the web
side of
the house. All of this, without having to worry about threads, etc,
etc.
So, I figured this would be a perfect test-case for ActiveMQ and
Stateless
sessoin beans.
--
View this message in context:
http://www.nabble.com/JMS-ConnectionFactory-Resource-injection-into-a-Session-Bean-tp21644793s134p21644793.html
Sent from the Apache Geronimo - Users mailing list archive at
Nabble.com.