Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven - how to create ejb client when packing war

Tags:

maven-3

I've an eclipse base ejb project that I have just converted into a maven module. It is structured in web app layout (as preferred by Tomee). So, in pom.xml, the packaging type is set to war, which maven correctly generated the war file. But I'm not very successful in getting maven to also create a ejb-client jar when packaging the war. I added this to the pom.xml but it does not seems to be doing anything:

    <build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-ejb-plugin</artifactId>
            <version>2.5</version>
            <executions>
                <execution>
                    <id>BossClient</id>
                    <phase>compile</phase>
                    <configuration>
                        <ejbVersion>3.1</ejbVersion>
                        <generateClient>true</generateClient>
                        <clientIncludes>
                            <clientInclude>/com/**</clientInclude>
                        </clientIncludes>
                    </configuration>
                </execution>
            </executions>
        </plugin>
      </plugins>
    </build>

Any idea how I can get maven to generate the ejb-client when packaging the war?

like image 348
HockChai Lim Avatar asked Dec 30 '25 10:12

HockChai Lim


1 Answers

The configuration of maven-ejb-plugin can be simplified like this:

<project>
   <groupId>..</groupId>
   <artifactId>..</artifactId>

   <packaging>ejb</packagin>

   <build>
     <pluginManagement>
       <plugins>
         <artifactId>maven-ejb-plugin</artifactId>
         <version>2.5.1</version>
         <configuration>
           <ejbVersion>3.1</ejbVersion>
           <generateClient>true</generateClient>
           <clientIncludes>
             <clientInclude>/com/**</clientInclude>
           </clientIncludes>
         </configuration>
       </plugins>
     <pluginManagement>
   </build>
..
</project>

Based on the default life cycle binding there is no need to make an execution block cause maven-ejb-plugin is already part of the life cycle. So only need to align the configuration to your needs.

Furthermore you should think about making a separate module which contains the ejb part and you shouldn't combine war and ejb part together in a single module.

like image 111
khmarbaise Avatar answered Jan 05 '26 11:01

khmarbaise



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!