sessionContext.getCallerPrincipal().getName() returns "anonymous" - jboss

I am new to EJB.
I am using Wildfly server.
I have session stateless Ejb as below.
#Stateless(name="PrintHandler")
#RunAs("TrustedExternalModule")
public class PrintHandlerBean extends ActivityBean implements PrintHandlerLocal {
The session ejb is packed to a server-ejb.jar and that jar is packed to .ear
I have created ejb-jar.xml and jboss-ejb3.xml inside META-INF folder in server-ejb.jar as below.
<ejb-jar xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="3.0" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd">
<enterprise-beans>
<session>
<ejb-name>PrintHandler</ejb-name>
<security-identity>
<run-as>
<role-name>TrustedExternalModule</role-name>
</run-as>
</security-identity>
</session>
</enterprise-beans>
</ejb-jar>
<?xml version="1.1" encoding="UTF-8"?>
<jboss:ejb-jar xmlns:jboss="http://www.jboss.com/xml/ns/javaee"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:s="urn:security:1.1"
xsi:schemaLocation="http://www.jboss.com/xml/ns/javaee http://www.jboss.org/j2ee/schema/jboss-ejb3-2_0.xsd http://java.sun.com/xml/ns/javaee http://www.jboss.org/j2ee/schema/jboss-ejb3-spec-2_0.xsd"
version="3.1"
impl-version="2.0">
<jboss:enterprise-beans>
<session>
<ejb-name>PrintHandler</ejb-name>
<session-type>Stateless</session-type>
<security-identity>
<run-as>
<role-name>TrustedExternalModule</role-name>
</run-as>
</security-identity>
</session>
</jboss:enterprise-beans>
<assembly-descriptor>
<s:security>
<ejb-name>PrintHandler</ejb-name>
<s:security-domain>other</s:security-domain>
<s:run-as-principal>TESTCONNECT</s:run-as-principal>
</s:security>
</assembly-descriptor>
</jboss:ejb-jar>
I am injecting SessionContext annotated with Resource in a non ejb class as below.
public abstract class AbstractBean {
protected AbstractBean() {
log = LogMgr.getFrameworkLogger();
clsLog = LogMgr.getClassLogger(FndAbstractBean.class);
if(clsLog.debug) {
clsLog.debug("Created bean [&1]", getClass().getName());
}
}
**#Resource
protected SessionContext sessionContext;**
But when I am calling String user = sessionContext.getCallerPrincipal().getName();
it is returning "anonymous" always.
How can I solve this.
I want to get caller principal as TESTCONNECT.

Hello, this seems to be an expected behavior. The only workaround I found would be to use Interceptor,so then you can propagate the information actually. Interceptors is explained here

Related

Wildfly with Basic Auth blocks requests with HTTP POST is not allowed for this method

I have a strange problem which is not reproducible at the moment.
I have the following endpoints:
#Path("/v1/")
#Produces(MediaType.APPLICATION_JSON)
public class EndpointVersion1Base
{
private BackendRestClient restClient;
#EJB
public void setRestClient(BackendRestClient restClient)
{
this.restClient = restClient;
}
#Path("/dataprivacy/")
public Object getDataPrivacy()
{
return new DataPrivacyEndpoint(restClient);
}
#Path("/crashreporting/")
public Object getCrashReport()
{
return new CrashReportEndpoint(restClient);
}
}
The endpoint crashreporting has a Basic authentication. The endpoint dataprivacy has no authentication. The dataprivacy endpoint looks like this:
#Path("/")
#Produces(MediaType.APPLICATION_JSON)
public class DataPrivacyEndpoint
{
private BackendRestClient restClient;
private Logger logger = LoggerFactory.getLogger(getClass());
public DataPrivacyEndpoint(BackendRestClient restClient)
{
this.restClient = restClient;
}
public DataPrivacyEndpoint()
{
}
#POST
#Path("/")
#Consumes(MediaType.APPLICATION_JSON)
public Response storeConsent(
#NotNull(message = ErrorCodes.ERR_QUERY_PARAM_NULL) #Valid String consentInputBo) throws ForbiddenException, BadRequestException
{
//some code
}
}
I achieved the Basic Auth of the crashreporting endpoint by the following web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0">
<display-name>publicapi</display-name>
<security-constraint>
<web-resource-collection>
<web-resource-name>Crash reporting</web-resource-name>
<description>crash reporting service</description>
<url-pattern>/v1/crashreporting/*</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>publicapi</role-name>
</auth-constraint>
</security-constraint>
<login-config>
<auth-method>BASIC</auth-method>
<realm-name>UserRoles simple realm</realm-name>
</login-config>
<security-role>
<role-name>publicapi</role-name>
</security-role>
</web-app>
and jboss-web.xml
<?xml version="1.0" encoding="UTF-8"?>
<jboss-web xmlns="http://www.jboss.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.jboss.com/xml/ns/javaee http://www.jboss.org/j2ee/schema/jboss-web_5_1.xsd">
<context-root>publicapi</context-root>
<security-domain>other</security-domain>
</jboss-web>
Yesterday all this worked. Today I started the services. Suddenly, as I sent a POST request to the dataprivacy endpoint via http://192.168.0.80:8080/publicapi/v1/dataprivacy/ and I got an HTTP error response "HTTP POST is not allowed for this method".
I wondered why this happened because it worked yesterday. After I restarted the services it suddenly worked again?!. What is going on here? Why does it sometimes work and sometimes not? (Currently I can't reproduce it). Do I have some misconfiguration in here which could lead to some strange behaviour? I'm afraid that this could happen on my LIVE system as well.

EntityManager in JNDI

I need to use different databases in the same Web application, so I can't use a persistent.xml to define the target database. The database changes with the client which is connected.
I found this :
public EntityManager getEntityManager() {
if (em == null}
try{
em = (EntityManager)(new InitialContext())
.lookup("java:comp/ejb/EntityManager");
} catch (Exception e){};
}
return em;
}
at this URL : http://wiki.eclipse.org/EclipseLink/Examples/JPA/EMAPI
My question is now : how recording a EntityManager or a Persistence Unit in the JNDI of GlassFish ?
Suppose that my persistence.xml is:
<persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
<persistence-unit name="ctx-vendor" transaction-type="JTA">
<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
</persistence-unit>
</persistence>
We have two use case:
WAR application WEB-INF/web.xml file:
<persistence-context-ref>
<description>JNDI for lookup EntityManager</description>
<persistence-context-ref-name>persistence/ctx-vendor</persistence-context-ref-name>
<persistence-unit-name>ctx-vendor</persistence-unit-name>
<persistence-context-type>Transaction</persistence-context-type>
</persistence-context-ref>
EAR application META-INF/application.xml file:
<application xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/application_7.xsd"
version="7">
<description>My Vendor System</description>
<display-name>vendor-ear</display-name>
<module>
<web>
<web-uri>vendor-rest.war</web-uri>
<context-root>/vendor-rest</context-root>
</web>
</module>
<module>
<ejb>vendor-service.jar</ejb>
</module>
<library-directory>lib</library-directory>
<persistence-context-ref>
<description>JNDI for lookup EntityManager</description>
<persistence-context-ref-name>persistence/ctx-vendor</persistence-context-ref-name>
<persistence-unit-name>ctx-vendor</persistence-unit-name>
<persistence-context-type>Transaction</persistence-context-type>
</persistence-context-ref>
</application>
Stateless Session Bean
#PersistenceContext(name = "persistence/ctx-vendor", unitName = "ctx-vendor")
public class BaseFacade
{ }
#Stateless
#Local(CatalogFacade.class)
public class CatalogFacadeImpl extends BaseFacade implements CatalogFacade
{
}
Tested in Glassfish 4.1

Spring Resful WS issue

I'm following http://www.java2blog.com/2015/09/spring-restful-web-services-json-example.html and as it's suggested in the article when I deploy my application to tomcat I get the warning:
WARNING: [SetContextPropertiesRule]{Context} Setting property 'source' to 'org.eclipse.jst.j2ee.server:restordering' did not find a matching property.
(restordering is my application context)
And when I try to access my application I get this warning:
WARNING: No mapping found for HTTP request with URI [/restordering] in DispatcherServlet with name 'restordering'
and I see a 404 error page!
I've tested this on tomcat 7 and 8. I've created the war and deployed outside of eclipse and followed all suggested solution including change in server definition (publish module context to separate XML files) and removing and adding and doing all the tricks it's described in the above article and on stackoverflow but nothing has worked so far.
Before I get "this is a warning and ..." yes it is a warning but also I get 404 error and can't access my services.
And yes I have the correct package name in my restordering-servlet.xml ( context:component-scan base-package="com.obp.restordering.controller" ).
As requested here is my web.xml:
<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd" >
<web-app>
<display-name>Archetype Created Web Application</display-name>
<servlet>
<servlet-name>restordering</servlet-name>
<servlet-class>
org.springframework.web.servlet.DispatcherServlet
</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>restordering</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
</web-app>
and restordering-servlet.xml is:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd">
<mvc:annotation-driven />
<context:component-scan base-package="com.obp.restordering.controller" />
</beans>
and my controller file is this:
package com.obp.restordering.controller;
import java.util.ArrayList;
import java.util.List;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import com.obp.restordering.bean.Country;
#RestController
public class CountryController {
#RequestMapping(value = "/countries", method = RequestMethod.GET, headers = "Accept=application/json")
public List<Country> getCountries() {
List<Country> listOfCountries = new ArrayList<Country>();
listOfCountries = createCountryList();
return listOfCountries;
}
#RequestMapping(value = "/country/{id}", method = RequestMethod.GET, headers = "Accept=application/json")
public Country getCountryById(#PathVariable int id) {
List<Country> listOfCountries = new ArrayList<Country>();
listOfCountries = createCountryList();
for (Country country : listOfCountries) {
if (country.getId() == id)
return country;
}
return null;
}
// Utiliy method to create country list.
public List<Country> createCountryList() {
Country indiaCountry = new Country(1, "India");
Country chinaCountry = new Country(4, "China");
Country nepalCountry = new Country(3, "Nepal");
Country bhutanCountry = new Country(2, "Bhutan");
List<Country> listOfCountries = new ArrayList<Country>();
listOfCountries.add(indiaCountry);
listOfCountries.add(chinaCountry);
listOfCountries.add(nepalCountry);
listOfCountries.add(bhutanCountry);
return listOfCountries;
}
}
Any idea?
This is embarrassing but I need to come clean and admit and provide an answer so if others have the same issue they don't circle around days as I did.
Arpit the author of the mentioned tutorial responded to my request for help and after checking my code confirmed all works as expected!
The issue was in how I was trying to access my service! If I go to /restordering/countries I get the 404 error. To access the service I need to go to /restordering/restordering/countries! As simple as that.
The warnings I still get and I can't resolve them at this time but at least the service is working and this seems more of a deployment/setting issue than actual spring development issue.
Anyways, I thought this may help some others.
Cheers

Apache camel cxfrs—Can't find the request for <URL> Observer

I tried to develop a rest service and expose the same via Apache Camel's CXFRS. I followed all the steps given in http://camel.apache.org/cxfrs.html and also referred to many samples given. I already referred to the question Can't find the the request for url Observer, but in my case it is a simple rest request. Below are the Service class, Route class, and cxf context used:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:camel="http://camel.apache.org/schema/spring"
xmlns:cxf="http://camel.apache.org/schema/cxf" xmlns:context="http://www.springframework.org/schema/context"
xmlns:jaxrs="http://cxf.apache.org/jaxrs"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://camel.apache.org/schema/spring
http://camel.apache.org/schema/spring/camel-spring.xsd
http://camel.apache.org/schema/cxf
http://camel.apache.org/schema/cxf/camel-cxf.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://cxf.apache.org/jaxrs
http://cxf.apache.org/schemas/jaxrs.xsd">
<import resource="classpath:META-INF/cxf/cxf.xml" />
<import resource="classpath:META-INF/cxf/cxf-servlet.xml" />
<context:annotation-config />
<!-- enable Spring #Component scan -->
<context:component-scan base-package="org.camelsample.rest" />
<cxf:rsServer id="rsServer" address="/rest"
serviceClass="org.camelsample.rest.service.SampleRestService"
loggingFeatureEnabled="true" loggingSizeLimit="20">
<cxf:providers>
<bean class="org.codehaus.jackson.jaxrs.JacksonJsonProvider" />
</cxf:providers>
</cxf:rsServer>
<camel:camelContext id="samplerestservice"
xmlns="http://camel.apache.org/schema/spring">
<contextScan />
<jmxAgent id="agent" createConnector="true" />
</camel:camelContext>
</beans>
The Service Class:
package org.camelsample.rest.service;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
public class SampleRestService {
#GET
#Path("/")
public String sampleService() {
return null;
}
}
The Route Class:
package org.camelsample.rest.route;
import org.apache.camel.spring.SpringRouteBuilder;
public class SampleRestRoute extends SpringRouteBuilder {
#Override
public void configure() throws Exception {
// TODO Auto-generated method stub
from("cxfrs:bean:rsServer").log("Into Sample Route").setBody(constant("Success"));
}
}
But when I try to hit and test using http://localhost:8080/rest, I always get the following error message:
2015-05-29 13:38:37.920 WARN 6744 --- [nio-8080-exec-2] o.a.c.t.servlet.ServletController : Can't find the the request for http://localhost:8080/favicon.ico's Observer
2015-05-29 13:38:40.295 WARN 6744 --- [nio-8080-exec-3] o.a.c.t.servlet.ServletController : Can't find the the request for http://localhost:8080/rest's Observer
Am using Spring boot to test the rest sample.
Does it work with this URL instead ?
http://localhost:8181/cxf/rest
If you just use address="/rest" as your address then you will probably get the default Jetty port 8181 and default CXF servlet path /cxf as the base URL.
If you specifically want to use the URL you have given then try this instead:
address="http://0.0.0.0:8080/rest"

add a Queue JNDI ref in ejb-jar.xml? sending JMS Msg in a EJB/MDB

I have an EAR application which contains an MDB and a WAR.
In this EAR application I would send a message into an another Queue from other EAR application. Say jms/anotherQueue
If the message sending happens in web context, it works.
I have such setup in web.xml
<message-destination-ref>
<message-destination-ref-name>jms/anotherQueue</message-destination-ref-name>
<message-destination-type>javax.jms.Queue</message-destination-type>
<message-destination-usage>Produces</message-destination-usage>
<message-destination-link>jms/anotherQueue</message-destination-link>
</message-destination-ref>
But if the message sending occurs in EJB (MDB here) context, I will get a JNDI name lookup failure.
javax.naming.NameNotFoundException: anotherQueue
my ejb-jar.xml
<?xml version="1.0" encoding="UTF-8"?>
<ejb-jar version="3.0" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd">
<enterprise-beans>
<message-driven>
<ejb-name>jms/myMDB</ejb-name>
<ejb-class>com.my.MDBImplement</ejb-class>
<messaging-type>javax.jms.MessageListener</messaging-type>
<transaction-type>Container</transaction-type>
<activation-config>
<activation-config-property>
<activation-config-property-name>destination</activation-config-property-name>
<activation-config-property-value>jms/myQueue</activation-config-property-value>
</activation-config-property>
<activation-config-property>
<activation-config-property-name>destinationType</activation-config-property-name>
<activation-config-property-value>javax.jms.Queue</activation-config-property-value>
</activation-config-property>
</activation-config>
<resource-ref>
<res-ref-name>jms/myCF</res-ref-name>
<res-type>javax.jms.QueueConnectionFactory</res-type>
<res-auth>Container</res-auth>
<res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>
</message-driven>
</enterprise-beans>
<assembly-descriptor>
<container-transaction>
<method>
<ejb-name>jms/myMDB</ejb-name>
<method-name>onMessage</method-name>
<method-params>
<method-param>javax.jms.Message</method-param>
</method-params>
</method>
<trans-attribute>NotSupported</trans-attribute>
</container-transaction>
</assembly-descriptor>
</ejb-jar>
the openejb.jar is
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<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>myGroup</dep:groupId>
<dep:artifactId>imyMDB</dep:artifactId>
<dep:version>1.0</dep:version>
<dep:type>ejb</dep:type>
</dep:moduleId>
<dep:dependencies>
<dep:dependency>
<dep:groupId>org.apache.geronimo.configs</dep:groupId>
<dep:artifactId>activemq-broker</dep:artifactId>
<dep:type>car</dep:type>
</dep:dependency>
</dep:dependencies>
</dep:environment>
<ejb:enterprise-beans>
<ejb:message-driven>
<ejb:ejb-name>jms/myMDB</ejb:ejb-name>
<ejb:resource-adapter>
<ejb:resource-link>myJmsResource</ejb:resource-link>
</ejb:resource-adapter>
</ejb:message-driven>
</ejb:enterprise-beans>
</ejb:openejb-jar>
I define myJmsResource in geronimo-application.xml
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<app:application
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:nam="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>myGroup</dep:groupId>
<dep:artifactId>myEAR</dep:artifactId>
<dep:version>1.0</dep:version>
<dep:type>ear</dep:type>
</dep:moduleId>
</dep:environment>
<app:module>
<app:connector>geronimo-activemq-ra-2.1.4.rar</app:connector>
<conn:connector>
<dep:environment>
<dep:moduleId>
<dep:groupId>myGroup</dep:groupId>
<dep:artifactId>myJmsResource</dep:artifactId>
<dep:version>1.0</dep:version>
<dep:type>rar</dep:type>
</dep:moduleId>
<dep:dependencies>
<dep:dependency>
<dep:groupId>org.apache.geronimo.configs</dep:groupId>
<dep:artifactId>activemq-broker</dep:artifactId>
<dep:type>car</dep:type>
</dep:dependency>
</dep:dependencies>
</dep:environment>
<conn:resourceadapter>
<conn:resourceadapter-instance>
<conn:resourceadapter-name>myJmsResource</conn:resourceadapter-name>
<nam:workmanager>
<nam:gbean-link>DefaultWorkManager</nam:gbean-link>
</nam:workmanager>
</conn:resourceadapter-instance>
<conn:outbound-resourceadapter>
<conn:connection-definition>
<conn:connectionfactory-interface>javax.jms.ConnectionFactory</conn:connectionfactory-interface>
<conn:connectiondefinition-instance>
<conn:name>jms/myCF</conn:name>
<conn:implemented-interface>javax.jms.QueueConnectionFactory</conn:implemented-interface>
<conn:implemented-interface>javax.jms.TopicConnectionFactory</conn:implemented-interface>
<conn:connectionmanager>
<conn:xa-transaction>
<conn:transaction-caching />
</conn:xa-transaction>
<conn:single-pool>
<conn:match-all />
</conn:single-pool>
</conn:connectionmanager>
</conn:connectiondefinition-instance>
</conn:connection-definition>
</conn:outbound-resourceadapter>
</conn:resourceadapter>
<conn:adminobject>
<conn:adminobject-interface>javax.jms.Queue</conn:adminobject-interface>
<conn:adminobject-class>org.apache.activemq.command.ActiveMQQueue</conn:adminobject-class>
<conn:adminobject-instance>
<conn:message-destination-name>jms/myQueue</conn:message-destination-name>
<conn:config-property-setting name="PhysicalName">jms/myQueue</conn:config-property-setting>
</conn:adminobject-instance>
<!-- ******************************************************************** -->
<!-- define referred message destination ??? -->
<conn:adminobject-instance>
<conn:message-destination-name>jms/anotherQueue</conn:message-destination-name>
<conn:config-property-setting name="PhysicalName">jms/anotherQueue</conn:config-property-setting>
</conn:adminobject-instance>
</conn:adminobject>
<conn:adminobject>
<conn:adminobject-interface>javax.jms.Topic</conn:adminobject-interface>
<conn:adminobject-class>org.apache.activemq.command.ActiveMQTopic</conn:adminobject-class>
</conn:adminobject>
</conn:connector>
</app:module>
</app:application>
It seems that myMDB cannot understand what jms/anotherQueue is!!!
How can I fix it?
OK, I found a quick fix....
in ejb-jar.xml
<enterprise-beans>
<message-driven>
<ejb-name>jms/myMDB</ejb-name>
.....
<!-- referred queue -->
<resource-env-ref>
<resource-env-ref-name>jms/anotherQueue</resource-env-ref-name>
<resource-env-ref-type>javax.jms.Queue</resource-env-ref-type>
</resource-env-ref>
</message-driven>
</enterprise-beans>
I must admit, I still don't understand how to write a correct deployment plan.
I just goggle, copy, paste.....and mix up those deployment plans.