Maven EJB Plugin
  1. Maven EJB Plugin
  2. MEJB-3

Add ejb bundle feature like in maven 1

    Details

    • Type: New Feature New Feature
    • Status: Open Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Labels:
      None
    • Environment:
      windows
    • Number of attachments :
      0

      Description

      It could be nice if we could include dependencies in the ejb jar produce by the ejb plugin. In fact, I think an ejb bundle feature like in Maven 1 will be useful. We could use the dependencies scope or whatever. (Perhaps it can be handy to add a new scope name "bundle" that could be use with ejb, war and ear plugin ???? )
      Thanks.

      Alexandre Vivien

        Activity

        Hide
        Louisa Nilsen-Nygaard added a comment -

        I am in somewhat desperate need of this feature to bundle stuff into my EJB JAR. Has there been any progress on it?

        Show
        Louisa Nilsen-Nygaard added a comment - I am in somewhat desperate need of this feature to bundle stuff into my EJB JAR. Has there been any progress on it?
        Hide
        Alexandre Vivien added a comment -

        I don't know, I didn't use the EJB plugin since this issue. What does the EJB plugin produce when you try to use it ???

        Show
        Alexandre Vivien added a comment - I don't know, I didn't use the EJB plugin since this issue. What does the EJB plugin produce when you try to use it ???
        Hide
        Louisa Nilsen-Nygaard added a comment -

        all that it produces is a JAR containing the class files that are in the EJB source. i haven't been able to find a way to include the neccessary jars into the EJB jar, but using a manifest file i have been able to include them into the WAR file in which the EJB is packaged. it isn't the best solution in my case, and doesn't seem to work in every situation, but it will probably do for the moment..

        Show
        Louisa Nilsen-Nygaard added a comment - all that it produces is a JAR containing the class files that are in the EJB source. i haven't been able to find a way to include the neccessary jars into the EJB jar, but using a manifest file i have been able to include them into the WAR file in which the EJB is packaged. it isn't the best solution in my case, and doesn't seem to work in every situation, but it will probably do for the moment..
        Hide
        Sam Wilson added a comment -

        Any status on this issue? I saw it was "downgraded" to being a "new feature", although this functionality is supported in the Maven 1.0 version of the plugin.

        Has anybody tried any work arounds? I'm going to explore the maven-assembly-plugin to see if I can accomplish the same thing that way.

        Show
        Sam Wilson added a comment - Any status on this issue? I saw it was "downgraded" to being a "new feature", although this functionality is supported in the Maven 1.0 version of the plugin. Has anybody tried any work arounds? I'm going to explore the maven-assembly-plugin to see if I can accomplish the same thing that way.
        Hide
        Sam Wilson added a comment -

        Alright. I've got this working with the maven-assembly-plugin as my workaround. I am deploying to JBoss and so far this is working for me.

        Basically, in your POM you want to to include the following:

        [pom.xml]
        <build>
        <plugins>
        <plugin>
        <artifactId>maven-ejb-plugin</artifactId>
        <configuration>
        <archive>
        <manifest>
        <!-- include dependencies in manifest classpath -->
        <addClasspath>true</addClasspath>
        </manifest>
        </archive>
        </configuration>
        </plugin>

        <!-- utilize maven assembly plugin to include dependency jars for standalone ejb-jar deployment -->
        <plugin>
        <artifactId>maven-assembly-plugin</artifactId>
        <configuration>
        <descriptors>
        <descriptor>src/assembly/assembly.xml</descriptor>
        </descriptors>
        </configuration>
        <executions>
        <execution>
        <id>package-dependencies</id>
        <phase>package</phase>
        <goals>
        <goal>attached</goal>
        </goals>
        </execution>
        </executions>
        </plugin>
        </plugins>
        </build>
        [/pom.xml]

        Then, you'll have to create a directory called $

        {root.dir}

        /src/assembly and in there create a file named assembly.xml with the following:

        [assembly.xml]
        <?xml version="1.0" encoding="UTF-8"?>

        <assembly>
        <id>jar-with-dependencies-packed</id>
        <formats>
        <format>jar</format>
        </formats>
        <includeBaseDirectory>false</includeBaseDirectory>
        <dependencySets>
        <dependencySet>
        <scope>runtime</scope>
        <excludes>
        <!-- for some reason the assembly plugin includes the actual jar for the project which causes JBoss to
        try and register the EJB twice. we exclude it here so that we don't run into this error on startup/redeploy -->
        <exclude>$

        {pom.groupId}

        :$

        {pom.artifactId}

        </exclude>
        </excludes>
        </dependencySet>

        </dependencySets>
        <fileSets>
        <fileSet>
        <!-- include the code for the EJB -->
        <directory>target/classes</directory>
        </fileSet>
        </fileSets>
        </assembly>
        [/assembly.xml]

        I still think the plugin should be fixed, but I hope this helps people. If the plugin isn't going to be fixed, then perhaps this info should be posted to the site so that people are aware of a workaround for this feature.

        Show
        Sam Wilson added a comment - Alright. I've got this working with the maven-assembly-plugin as my workaround. I am deploying to JBoss and so far this is working for me. Basically, in your POM you want to to include the following: [pom.xml] <build> <plugins> <plugin> <artifactId>maven-ejb-plugin</artifactId> <configuration> <archive> <manifest> <!-- include dependencies in manifest classpath --> <addClasspath>true</addClasspath> </manifest> </archive> </configuration> </plugin> <!-- utilize maven assembly plugin to include dependency jars for standalone ejb-jar deployment --> <plugin> <artifactId>maven-assembly-plugin</artifactId> <configuration> <descriptors> <descriptor>src/assembly/assembly.xml</descriptor> </descriptors> </configuration> <executions> <execution> <id>package-dependencies</id> <phase>package</phase> <goals> <goal>attached</goal> </goals> </execution> </executions> </plugin> </plugins> </build> [/pom.xml] Then, you'll have to create a directory called $ {root.dir} /src/assembly and in there create a file named assembly.xml with the following: [assembly.xml] <?xml version="1.0" encoding="UTF-8"?> <assembly> <id>jar-with-dependencies-packed</id> <formats> <format>jar</format> </formats> <includeBaseDirectory>false</includeBaseDirectory> <dependencySets> <dependencySet> <scope>runtime</scope> <excludes> <!-- for some reason the assembly plugin includes the actual jar for the project which causes JBoss to try and register the EJB twice. we exclude it here so that we don't run into this error on startup/redeploy --> <exclude>$ {pom.groupId} :$ {pom.artifactId} </exclude> </excludes> </dependencySet> </dependencySets> <fileSets> <fileSet> <!-- include the code for the EJB --> <directory>target/classes</directory> </fileSet> </fileSets> </assembly> [/assembly.xml] I still think the plugin should be fixed, but I hope this helps people. If the plugin isn't going to be fixed, then perhaps this info should be posted to the site so that people are aware of a workaround for this feature.
        Hide
        Sam Wilson added a comment -

        Just found a minor mistake in my post above.

        Be sure to include "<outputDirectory></outputDirectory>" after <directory>target/classes</directory> in the assembly.xml file or else your EJB code will be packaged under target/classes inside the jar.

        Sorry 'bout that.

        Show
        Sam Wilson added a comment - Just found a minor mistake in my post above. Be sure to include "<outputDirectory></outputDirectory>" after <directory>target/classes</directory> in the assembly.xml file or else your EJB code will be packaged under target/classes inside the jar. Sorry 'bout that.
        Hide
        johan Eltes added a comment -

        I'm on Maven 2.0.5. Although I've added the ejb plugin configuration stated above...

        <build>
        <plugins>
        <plugin>
        <artifactId>maven-ejb-plugin</artifactId>
        <configuration>
        <archive>
        <manifest>
        <!-- include dependencies in manifest classpath -->
        <addClasspath>true</addClasspath>
        </manifest>
        </archive>
        </configuration>
        </plugin>

        ... my dependencies don't get listed in the ClassPath: entry of the generated MANIFEST.MF. Is there anything else I need to do? Any specific scope to be defined for the dependencies?

        Show
        johan Eltes added a comment - I'm on Maven 2.0.5. Although I've added the ejb plugin configuration stated above... <build> <plugins> <plugin> <artifactId>maven-ejb-plugin</artifactId> <configuration> <archive> <manifest> <!-- include dependencies in manifest classpath --> <addClasspath>true</addClasspath> </manifest> </archive> </configuration> </plugin> ... my dependencies don't get listed in the ClassPath: entry of the generated MANIFEST.MF. Is there anything else I need to do? Any specific scope to be defined for the dependencies?
        Hide
        Michal Galet added a comment -

        If you just want to include your dependencies into your EJB jar file a simple workaround is:

         
          <build>
            <plugins>
              <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <executions>
                  <execution>
                    <phase>process-resources</phase>
                    <goals>
                      <goal>copy-dependencies</goal>
                    </goals>
                  </execution>
                </executions>
                <configuration>
                  <outputDirectory>target/classes</outputDirectory>
                  <includeScope>runtime</includeScope>
                </configuration>
              </plugin>
          . . .
        
        Show
        Michal Galet added a comment - If you just want to include your dependencies into your EJB jar file a simple workaround is: <build> <plugins> <plugin> <groupId> org.apache.maven.plugins </groupId> <artifactId> maven-dependency-plugin </artifactId> <executions> <execution> <phase> process-resources </phase> <goals> <goal> copy-dependencies </goal> </goals> </execution> </executions> <configuration> <outputDirectory> target/classes </outputDirectory> <includeScope> runtime </includeScope> </configuration> </plugin> . . .

          People

          • Assignee:
            Unassigned
            Reporter:
            Alexandre Vivien
          • Votes:
            6 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

            • Created:
              Updated: