I got it working. Here is what I did. First, I made several changes to the source code:
NewMessageBean.java:
// DIFF: removed mappedName
| //DIFF: added destination
| @MessageDriven(activationConfig = {
| @ActivationConfigProperty(propertyName = "acknowledgeMode",
propertyValue = "Auto-acknowledge"),
| @ActivationConfigProperty(propertyName = "destinationType",
propertyValue = "javax.jms.Queue"),
| @ActivationConfigProperty(propertyName = "destination", propertyValue =
"queue/NewMessage")
| })
| ...
| // DIFF: added unitName
| @PersistenceContext(unitName = "newsPU")
| private EntityManager em;
| ...
NewsEntityFacade.java:
// DIFF: added unitName
| @PersistenceContext(unitName = "newsPU")
| private EntityManager em;
ListNews.java:
//DIFF: added mappedName
| @EJB(mappedName = "NewsEntityFacade/local")
| private NewsEntityFacadeLocal newsEntityFacade;
PostMessage.java:
//DIFF: changed mappedName
| @Resource(mappedName = "ConnectionFactory")
| private ConnectionFactory connectionFactory;
|
| //DIFF: changed mappedName
| @Resource(mappedName = "queue/NewMessage")
| private Queue queue;
I deployed four files:
news.jar
news.war
news-destinations-service.xml
news-postgresql-ds.xml
The contents of news.jar:
META-INF/persistence.xml
ejb/NewMessageBean.class
ejb/NewsEntity.class
ejb/NewsEntityFacade.class
ejb/NewsEntityFacadeLocal.class
The contents of news.war:
WEB-INF/web.xml
WEB-INF/classes/web/ListNews.class
WEB-INF/classes/web/PostMessage.class
I listed the contents of news-destinations-service.xml previously.
The contents of news-postgresql-ds.xml:
<datasources>
| <local-tx-datasource>
| <jndi-name>jdbc/newsDS</jndi-name>
| <connection-url>jdbc:postgresql:newsdb</connection-url>
| <driver-class>org.postgresql.Driver</driver-class>
| <user-name>xxx</user-name>
| <password>xxx</password>
| </local-tx-datasource>
| </datasources>
The contents of news.jar/META-INF/persistence.xml:
<?xml version="1.0" encoding="UTF-8"?>
| <persistence
xmlns="http://java.sun.com/xml/ns/persistence"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
| version="1.0">
| <persistence-unit name="newsPU">
| <provider>org.hibernate.ejb.HibernatePersistence</provider>
| <jta-data-source>java:/jdbc/newsDS</jta-data-source>
| <properties>
| <property name="hibernate.hbm2ddl.auto"
value="update"/>
| <property name="hibernate.dialect"
value="org.hibernate.dialect.PostgreSQLDialect"/>
| <property name="hibernate.show_sql" value="true"/>
| <!-- These are the default for JBoss EJB3, but not for HEM: -->
| <property name="hibernate.cache.provider_class"
value="org.hibernate.cache.HashtableCacheProvider"/>
| <property name="hibernate.transaction.manager_lookup_class"
value="org.hibernate.transaction.JBossTransactionManagerLookup"/>
| <property name="jboss.entity.manager.factory.jndi.name"
value="java:/newsEntityManagerFactory"/>
| </properties>
| </persistence-unit>
| </persistence>
The contents of news.war/WEB-INF/web.xml:
<web-app
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/web-app_2_5.xsd"
| version="2.5"
| >
| <servlet>
| <servlet-name>ListServlet</servlet-name>
| <servlet-class>org.jbia.jms.news.web.ListNews</servlet-class>
| </servlet>
| <servlet-mapping>
| <servlet-name>ListServlet</servlet-name>
| <url-pattern>/ListNews</url-pattern>
| </servlet-mapping>
|
| <servlet>
| <servlet-name>NewServlet</servlet-name>
| <servlet-class>org.jbia.jms.news.web.PostMessage</servlet-class>
| </servlet>
| <servlet-mapping>
| <servlet-name>NewServlet</servlet-name>
| <url-pattern>/PostMessage</url-pattern>
| </servlet-mapping>
| </web-app>
That is it. Aimed Firefox at
http://localhost:8080/news/PostMessage. filled in the form,
the list page displayed with the news item.
I have no idea how to get NetBeans to do this. I could not even tell you how to get
Eclipse to do this - I did edited all of these files in Eclipse but I did not use any
wizards or 'magic' to accomplish it. In addition, I used Ant to build and deploy
the various files (I reused/modified an existing build script that I used for some other
MDBs).
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4187838#...
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&a...