0

I have a fairly large legacy module which contains both EJB 3.0 and some business logic classes. I am trying to convert the build process to use maven and am having difficulty configuring the maven-ejb-plugin.

I'm trying to generate the client EJB package using the maven-ejb-plugin, but notice that the client package contains all the business logic classes as well - even if they are not referenced by the EJBs.

My current configuration is: org.apache.maven.plugins maven-ejb-plugin default-ejb ${project.build.outputDirectory} ejb 3.0 true

Unfortunately, there is not a very clear separation of packages for business classes/models/DTOs so it is a not easy to pinpoint exactly which EJBs depend on which classes.

Is there a mechanism in the maven-ejb-plugin to instruct maven to only include the require EJB interfaces/implementations & dependent classes in the client package and ignore/skip everything else? Or do I have to manually figure out exactly what dependent classes are required by the individual interfaces and configure the plugin to only include those files?

Eric B.
  • 23,425
  • 50
  • 169
  • 316

2 Answers2

1

As I understand you have some packages including for example the interfaces of your remote or local EJB, and you have the definition (stateless statefull, mdb, whatever) in the same package of your interfaces, and you want to import only the classes (or interfaces) that your client needs, it does not need the implementantion for logic reasons.

Well, we have two points here, as recomendation you should have at least your remotes or local interfaces in a separate project to decouple this (as Maven project) and everyone who wants to use them just have to import it as dependency, with no need to know about their implementation.

The other point is if you have follow some naming conventions maybe you could acomplish whan you want by including (or excluding) .java class with some patter.

You can check the link above:

http://maven.apache.org/surefire/maven-surefire-plugin/examples/inclusion-exclusion.html

If you use some conventions like these: http://www.oracle.com/technetwork/java/namingconventions-139351.html

You would be able to, for instance:

<plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>2.19.1</version>
        <configuration>
          <excludes>
            <include>**/Local*.java</include>
          </excludes>
        </configuration>
      </plugin>
    </plugins>
Daniel Hernández
  • 4,078
  • 6
  • 27
  • 38
  • I agree with your points entirely. But at the moment, I am trying to avoid refactoring this large module as a first step even if I am technically breaking maven conventions. So I'm trying to find a workaround in the meantime, and once I am assured that my maven builds are working properly and generating the correct type of artifacts, I can work on refactoring the projects appropriately. That being said, if I only specify my inclusion as my interface, it doesn't seem to include the dependent classes (since they aren't specified in my inclusion filter) – Eric B. May 11 '16 at 15:23
0

Recently I started working for migrating the EJB project to Maven Project. We use EJB 2.0 in our project, I don't know were to start about migration process, currently the existing EJB project includes STUBS & TIES(Through RAD tool we generate the jar file.). Not sure how can I make this Maven to have this STUBS & TIES included in the jar which I'm generating through the Maven process.

I use this below configuration in POM.xml

<profile>
    <id>xdoclet</id>
    <activation>
        <property>
            <name>xdoclet</name>
        </property>
    </activation>
    <build>
        <plugins>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>xdoclet-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>xdoclet</goal>
                        </goals>
                        <configuration>
                            <tasks>
                                <ejbdoclet
                                        destDir="${project.build.sourceDirectory}"
                                        force="true" ejbSpec="2.0"
                                        verbose="true">
                                    <fileset
                                            dir="${project.build.sourceDirectory}">
                                        <include name="**/*Bean.java" />
                                    </fileset>
                                    <packageSubstitution
                                            packages="service" useFirst="true"
                                            substituteWith="interface" />
                                    <homeinterface />
                                    <remoteinterface />
                                    <deploymentdescriptor
                                            displayname="Service Name"
                                            description=""
                                            destDir="${basedir}/src/main/resources/META-INF"
                                            validateXML="true" useIds="true" />
                                    <websphere
                                            destDir="${basedir}/src/main/resources/META-INF"
                                            validateXML="true" />
                                </ejbdoclet>
                            </tasks>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</profile>
<profile>
    <id>was-ejb</id>
    <activation>
        <property>
            <name>was-ejb</name>
        </property>
    </activation>
    <build>
        <plugins>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>was6-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <goals>
                            <goal>ejbdeploy</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <wasHome>C:/Program Files/IBM/WebSphere/AppServer</wasHome>
                </configuration>
            </plugin>
        </plugins>
    </build>
</profile>
Rajshekar
  • 1
  • 2