0 Replies Latest reply on Jun 9, 2008 4:07 PM by jonharvey

    EJB3 TrailBlazer fixes to code to run on jboss-5.0.0.Beta2

      Hi Folks,

      I noticed this site was not working:
      http://trailblazer.demo.jboss.com/EJB3Trail/

      I needed to use a JMS Queue and MDB on JBoss 5 Beta2 and get it to deploy cleanly on start and restart.

      I downloaded the TrailBlazer source (from http://www.jboss.com/docs/trailblazer), updated:

      build.xml by adding this line after line: 43

      <include name="*-service.xml" />


      so package-ejb looks like:
      <target name="package-ejb" depends="compile">
       <jar jarfile="${build.dir}/jar/beans.jar">
       <fileset dir="${build.dir}/classes">
       <include name="trail/**"/>
       </fileset>
      
       <fileset dir="dd/ejb">
       <include name="import.sql" />
       <include name="*-service.xml" />
       <include name="*.properties"/>
       </fileset>
      
       <metainf dir="dd/ejb">
       <include name="persistence.xml"/>
       </metainf>
       </jar>
       </target>


      Edited file: application.xml in dd/ear to be:
      <?xml version="1.0" encoding="UTF-8"?>
      <!DOCTYPE application PUBLIC
       "-//Sun Microsystems, Inc.//DTD J2EE Application 1.3//EN"
       "http://java.sun.com/dtd/application_1_3.dtd">
      <application>
       <display-name>EJB3Trail</display-name>
       <description>J2EE Made Easy Trail Map</description>
       <module>
       <ejb>beans.jar</ejb>
       </module>
       <module>
       <web>
       <web-uri>web.war</web-uri>
       <context-root>EJB3Trail</context-root>
       </web>
       </module>
      </application>


      Added this file, named: ejb3trail-jms-service.xml to: dd/ejb/ directory:
      <?xml version="1.0" encoding="UTF-8"?>
      <!DOCTYPE server PUBLIC "-//JBoss//DTD MBean Service 5.0//EN" "http://www.jboss.org/j2ee/dtd/jboss-service_5_0.dtd">
      <server>
       <mbean code="org.jboss.jms.server.destination.QueueService"
       name="jboss.messaging.destination:service=Queue,name=mdb"
       xmbean-dd="xmdesc/Queue-xmbean.xml">
       <depends optional-attribute-name="ServerPeer">jboss.messaging:service=ServerPeer</depends>
       <depends>jboss.messaging:service=PostOffice</depends>
       <attribute name="RedeliveryDelay">5000</attribute>
       </mbean>
       <mbean code="org.jboss.jms.server.destination.QueueService"
       name="jboss.messaging.destination:service=Queue,name=mdpojo"
       xmbean-dd="xmdesc/Queue-xmbean.xml">
       <depends optional-attribute-name="ServerPeer">jboss.messaging:service=ServerPeer</depends>
       <depends>jboss.messaging:service=PostOffice</depends>
       <attribute name="RedeliveryDelay">5000</attribute>
       </mbean>
       <mbean code="org.jboss.jms.server.destination.QueueService"
       name="jboss.messaging.destination:service=Queue,name=injection"
       xmbean-dd="xmdesc/Queue-xmbean.xml">
       <depends optional-attribute-name="ServerPeer">jboss.messaging:service=ServerPeer</depends>
       <depends>jboss.messaging:service=PostOffice</depends>
       <attribute name="RedeliveryDelay">5000</attribute>
       </mbean>
      </server>




      Edited the file: web.xml in dd/web to be:
      <?xml version="1.0" encoding="UTF-8"?>
      <!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>EJB3Trail</display-name>
      
       <security-constraint>
       <web-resource-collection>
       <web-resource-name>
       The Protected Calculator
       </web-resource-name>
       <url-pattern>/services/security/addfund.jsp</url-pattern>
       <url-pattern>/services/security/addinvestor.jsp</url-pattern>
       <url-pattern>/services/security/calculator.jsp</url-pattern>
       <http-method>GET</http-method>
       <http-method>POST</http-method>
       </web-resource-collection>
       <auth-constraint>
       <role-name>AdminUser</role-name>
       <role-name>RegularUser</role-name>
       </auth-constraint>
       <user-data-constraint>
       <transport-guarantee>NONE</transport-guarantee>
       </user-data-constraint>
       </security-constraint>
      
       <login-config>
       <auth-method>FORM</auth-method>
       <form-login-config>
       <form-login-page>/services/security/login.html</form-login-page>
       <form-error-page>/services/security/loginFailed.html</form-error-page>
       </form-login-config>
       </login-config>
      
       <security-role>
       <role-name>AdminUser</role-name>
       </security-role>
       <security-role>
       <role-name>RegularUser</role-name>
       </security-role>
      
      </web-app>


      After the annotation:
      @MessageDriven
      in src/trail/injection/CalculatorMDB.java and
      src/trail/mdb/CalculatorBean.java
      and
      @Consumer
      in: src/trail/mdpojo/MdpojoCalculator.java

      I added this annotation:
      @Depends( { "jboss.messaging:service=ServerPeer" })


      So for: src/trail/injection/CalculatorMDB.java class begins:
      @MessageDriven(activationConfig = {
       @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
       @ActivationConfigProperty(propertyName = "destination", propertyValue = "queue/injection") })
      @Depends( { "jboss.messaging:service=ServerPeer" })
      public class CalculatorMDB implements MessageListener {

      Now if you run ant (default target) and deploy the EJB3Trail.ear into default/deploy, it should all work.

      Browse to see all is OK at: http://localhost:8080/EJB3Trail/