1 Reply Latest reply on May 22, 2010 7:27 PM by Bjarne Hansen

    Problem building and deploying EJB3

    Bjarne Hansen Newbie

      Hi

       

      I am building a test EJB3 on JBoss AS 5 and have problems making it work at all. I have looked at numerous howtos and such, and apparently I am doing the right thing and still it does not work.

       

      This is the recipe of how I did it, the details are at the bottom:

       

      Running on ubuntu 9.10 with JBoss AS 5 5.1.0.GA-jdk6 and jdk 1.6.0_16

       

      - Build a simple stateless EJB3 interface with @Remote tag, and a Bean with @Statelss tag

      - Compiled with Maven 2 and ejb-plugin

      - copied .jar file to jboss default/deploy directory

       

      Then nothing happens, no message in the logs or any thing

      If I use the jboss console to specifically deploy it, the console replies "deployed" with the following message in the log, but I cant find the EJB bean in the conolse window.

       

      12:40:40,051 INFO  [DeployHandler] Begin distribute, content url: file:/data/local/jboss-5.1.0.GA/server/default/deploy/currency-1.0-SNAPSHOT.jar
      12:40:40,052 INFO  [DeployHandler] End distribute, vfsfile:/data/local/jboss-5.1.0.GA/server/default/deploy/currency-1.0-SNAPSHOT.jar/
      12:40:40,054 INFO  [DeployHandler] Begin start, [vfsfile:/data/local/jboss-5.1.0.GA/server/default/deploy/currency-1.0-SNAPSHOT.jar/]
      12:40:40,096 INFO  [DeployHandler] End start, [vfsfile:/data/local/jboss-5.1.0.GA/server/default/deploy/currency-1.0-SNAPSHOT.jar/]
      12:40:40,927 WARN  [AbstractManagedObjectPopulator] Cannot create String name from non-Simple property: ManagedProperty{JNDIName,JNDIName,metaType=SimpleMetaType:java.lang.String}, value=null
      12:40:40,990 WARN  [AbstractManagedObjectPopulator] Cannot create String name from non-Simple property: ManagedProperty{JNDIName,JNDIName,metaType=SimpleMetaType:java.lang.String}, value=null
      12:40:44,042 WARN  [AbstractManagedObjectPopulator] Cannot create String name from non-Simple property: ManagedProperty{JNDIName,JNDIName,metaType=SimpleMetaType:java.lang.String}, value=null
      12:40:44,049 WARN  [AbstractManagedObjectPopulator] Cannot create String name from non-Simple property: ManagedProperty{JNDIName,JNDIName,metaType=SimpleMetaType:java.lang.String}, value=null

       

      So the question is what is going on?

       

      1- why does it not hot deploy, even though the installation is brand new with no config changes. All the docs and tutorial says it should be deployed under such circumstances

      2- in the manual deployment scheme described with the console, is the bean actually deployed and why does it not show in the console window?

       

      the code, pom and jar structure is show below.

       

      regards

       

      bjarne

       

      ---------------------------------------------------------

       

      package fc.converter;

       

      import java.math.BigDecimal;
      import javax.ejb.Remote;

       

      @Remote
      public interface CurrencyConverter {

       

          public BigDecimal hkdollarToPounds(BigDecimal hkdollar);
          public BigDecimal poundsToKroner(BigDecimal pounds);
      }

       

       

      ---------------------------------------------------------

       

      package fc.converter;

       

      import java.math.BigDecimal;
      import javax.ejb.*;

       

      @Stateless
      public class CurrencyConverterBean implements CurrencyConverter {

       

          /** how many HKD for 1 Pound */
          private BigDecimal hkdollarToPoundsRate = new BigDecimal(2.45);
         
          /** how many Pounds for 1 Kroner */
          private BigDecimal poundsToKronerRate = new BigDecimal(0.08);
         
          public BigDecimal hkdollarToPounds(BigDecimal hkdollar) {
              return(hkdollar.divide(hkdollarToPoundsRate);
          }

       

          public BigDecimal poundsToKroner(BigDecimal pounds) {
              return pounds.divide(poundsToKronerRate);
          }

       

      }

       

       

      ---------------------------------------------------------

      pom.xml:

       

      <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
              xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
              <modelVersion>4.0.0</modelVersion>

       

              <groupId>fc.converter</groupId>
              <artifactId>currency</artifactId>
              <version>1.0-SNAPSHOT</version>
              <packaging>ejb</packaging>

       

              <name>currency</name>
              <url>http://currency.fcon.no</url>

       

              <dependencies>
                      <dependency>
                              <groupId>junit</groupId>
                              <artifactId>junit</artifactId>
                              <version>3.8.1</version>
                              <scope>test</scope>
                      </dependency>
              </dependencies>

       

              <build>
                      <plugins>
                              <plugin>
                                      <groupId>org.apache.maven.plugins</groupId>
                                      <artifactId>maven-ejb-plugin</artifactId>
                                      <version>2.1</version>
                                      <configuration>
                                              <ejbVersion>3.0</ejbVersion>
                                      </configuration>
                              </plugin>
                      </plugins>
              </build>

       

      </project>

       

       

      ---------------------------------------------------------

       

      jar file contents (manifest.mf is empty, as I understand its is not needed in EJB3)

       

      Archive:  currency-1.0-SNAPSHOT.jar
        Length      Date    Time    Name
      ---------  ---------- -----   ----
              0  2010-05-20 13:26   META-INF/
            123  2010-05-20 13:26   META-INF/MANIFEST.MF
              0  2010-05-20 12:55   fc/
              0  2010-05-20 13:24   fc/converter/
            583  2010-05-20 13:16   fc/converter/CurrencyConverter.class
           1097  2010-05-20 13:20   fc/converter/CurrencyConverterBean.class
              0  2010-05-20 13:26   META-INF/maven/
              0  2010-05-20 13:26   META-INF/maven/fc.converter/
              0  2010-05-20 13:26   META-INF/maven/fc.converter/currency/
            888  2010-05-20 13:22   META-INF/maven/fc.converter/currency/pom.xml
            113  2010-05-20 13:26   META-INF/maven/fc.converter/currency/pom.properties
      ---------                     -------
           2804                     11 files

       

       

       

      ---------------------------------------------------------

        • 1. Re: Problem building and deploying EJB3
          Bjarne Hansen Newbie

          I solved the problem. The problem was an incomplete pom.xml.

           

          The new and complete pom.xml is shown below.

           

          I added this and cleaned and packaged again, then it hotdeployed.

          So the experience might be that, maven dependencies are difficult and that JBoss should perhaps show messages of faulty jar files instead of being silent.

           

          regards

           

          Bjarne

           

          <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
              xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
              <modelVersion>4.0.0</modelVersion>

           

              <groupId>fc.converter</groupId>
              <artifactId>currency</artifactId>
              <version>1.0-SNAPSHOT</version>
              <packaging>ejb</packaging>

           

              <name>currency</name>
              <url>http://currency.fcon.no</url>

           

              <parent>
                  <groupId>jboss</groupId>
                  <artifactId>jboss-parent</artifactId>
                  <version>2</version>
              </parent>
              <repositories>
                  <repository>
                      <id>jboss-maven2</id>
                      <url>http://repository.jboss.com/maven2</url>
                  </repository>
              </repositories>

           

              <dependencies>
                  <dependency>
                      <groupId>junit</groupId>
                      <artifactId>junit</artifactId>
                      <version>3.8.1</version>
                      <scope>test</scope>
                  </dependency>

           

                  <dependency>
                      <groupId>jboss</groupId>
                      <artifactId>jboss-ejb3</artifactId>
                      <version>4.2.3.GA</version>
                  </dependency>

           

                  <dependency>
                      <groupId>jboss</groupId>
                      <artifactId>jboss-ejb-api</artifactId>
                      <version>4.2.0.GA</version>
                  </dependency>
              </dependencies>

           

              <build>
                  <plugins>
                      <plugin>
                          <groupId>org.apache.maven.plugins</groupId>
                          <artifactId>maven-ejb-plugin</artifactId>
                          <version>2.2.1</version>
                          <configuration>
                              <ejbVersion>3.0</ejbVersion>
                          </configuration>
                      </plugin>
                  </plugins>
              </build>

           

          </project>