ejb-throws-exception quickstart #383

Closed
wants to merge 1 commit into
from

Projects

None yet

3 participants

@bmaxwell
Contributor

No description provided.

Owner
pmuir commented Dec 23, 2012

@bmaxwell please ping back when you've fixed for Sande here (actually make a comment) and I'll do a review.

Contributor
bmaxwell commented Mar 5, 2013

@sgilda I made changes to the README.md, did they show up automatically on the pull request?

Contributor
sgilda commented Mar 5, 2013

Hi Brad, I'll try to look at this one today. :-)

Contributor
sgilda commented Mar 5, 2013

Hi Brad,
Your README file is perfect! Very informative. I wish they were all this detailed. I also tested this and it works great!

The only comments I have are related to the POM files. Since you wrote this, there have been a few changes.

  • We have created BOM files and now use properties to define versions. Then we use the properties within the dependencies in the file. This makes it easier for us to automate updates of version numbers as they change and we don't have to search through the text to find them.
  • We fixed a bug where version numbers were appended to archive names. You can find the fixes for ejb-in-ear in this commit:
    e87e865

You might want to rebase your branch with the upstream change to make it easier to see what has changed.

Let me know if you need any help.
Sande

@sgilda sgilda commented on an outdated diff Mar 5, 2013
ejb-throws-exception/README.md
+====================================================================
+Author: Brad Maxwell
+
+What is it?
+-----------
+This example extends the `ejb-in-ear` quickstart and demonstrates how to handle Exceptions across JARs in an EAR. In this quickstart, an EJB in the EJB JAR throws a custom Exception. The web application in the client JAR catches the Exception and displays it in a nicely formatted message. The EAR contains: *JSF 2.0 WAR*, an *EJB 3.1* JAR and a client library JAR containg classes that both the WAR and EJB JAR use.
+
+The example is composed of three Maven projects, each with a shared parent. The projects are as follows:
+
+1. `ejb`: This project contains the EJB code and can be built independently to produce the JAR archive. The EJB has a single method `sayHello` which will take in a String `name` and return "Hello <name>" if the `name` is not null or an empty String. If the `name` is null or an empty String, then it will throw a custom Exception (`GreeterException`) back to the client.
+
+2. `web`: This project contains the JSF pages and the CDI managed bean. The CDI Managed Bean (GreeterBean) will be bound to the JSF page (index.xhtml) and will invoke the GreeterEJB and display the response back from the EJB. The GreeterBean catches the custom Exception (GreeterException) thrown by GreeterEJB and displays the Exception message in the response text on the JSF page.
+
+3. `ear`: This project builds the EAR artifact and pulls in the ejb, web, and client artifacts.
+
+4. `ejb-api`: This project builds the ejb-api library artifact which is used by the ejb, web, as well as remote client artifacts. The ejb-api directory contains the EJB interfaces, custom exceptions the EJB throws and any other transfer objects which the EJB may receive or send back to the client. The EJB interfaces, custom exceptions and other transfer objects are split into a separate jar which are packaged in the ear/lib which allows all sub deployments of the ear to see the classes of the ejb-api jar in their classpath. This is also useful for remote clients. The ejb-api jar can be distributed to a remote client and give the remote clients the classes that are needed to interact with the EJB
sgilda
sgilda Mar 5, 2013 Contributor

This line is a little wordy:
The EJB interfaces, custom exceptions and other transfer objects are split into a separate jar which are packaged in the ear/lib which allows all sub deployments of the ear to see the classes of the ejb-api jar in their classpath.

suggest:
The EJB interfaces, custom exceptions, and other transfer objects are split into a separate jar which is packaged in the ear/lib. This allows all sub deployments of the ear to see the classes of the ejb-api jar in their classpath.

Contributor
sgilda commented Mar 13, 2013

@bmaxwell : Look at the kitchensink-ear or ejb-in-ear to see how to use peroperties, prevent version numbers from appearing in the archives, and for general structure.

Contributor
sgilda commented Mar 14, 2013

@bmaxwell : Your POM files still build the archives with the version number appended to the name, for example:

    jboss-as-ejb-throws-exception-ejb-7.1.2-SNAPSHOT

I will try to get it to work and then add comments to the files.

@sgilda sgilda commented on an outdated diff Mar 14, 2013
ejb-throws-exception/ear/pom.xml
+
+ <build>
+ <finalName>${project.artifactId}</finalName>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-ear-plugin</artifactId>
+ <version>${version.ear.plugin}</version>
+ <configuration>
+ <!-- Tell Maven we are using Java EE 6 -->
+ <version>${version.javaee}</version>
+ <!-- Use Java EE ear libraries as needed. Java EE ear
+ libraries are in easy way to package any libraries needed in the ear, and
+ automatically have any modules (EJB-JARs and WARs) use them -->
+ <defaultLibBundleDir>lib</defaultLibBundleDir>
+ </configuration>
sgilda
sgilda Mar 14, 2013 Contributor

Insert the following line after defaultLibBundleDir and before the ending configuration tag:

<fileNameMapping>no-version</fileNameMapping>

@sgilda sgilda commented on an outdated diff Mar 14, 2013
ejb-throws-exception/ear/pom.xml
+ <!-- Use Java EE ear libraries as needed. Java EE ear
+ libraries are in easy way to package any libraries needed in the ear, and
+ automatically have any modules (EJB-JARs and WARs) use them -->
+ <defaultLibBundleDir>lib</defaultLibBundleDir>
+ </configuration>
+ </plugin>
+ <!-- The JBoss AS plugin deploys your ear to a local JBoss AS
+ container -->
+ <!-- Due to Maven's lack of intelligence with EARs we need to
+ configure the jboss-as maven plugin to skip deployment for all modules. We
+ then enable it specifically in the ear module. -->
+ <plugin>
+ <groupId>org.jboss.as.plugins</groupId>
+ <artifactId>jboss-as-maven-plugin</artifactId>
+ <configuration>
+ <skip>false</skip>
sgilda
sgilda Mar 14, 2013 Contributor

Insert the following line after the configuration tag and before the skip false tag:

<filename>${project.artifactId}.ear</filename>

`

@sgilda sgilda commented on an outdated diff Mar 14, 2013
ejb-throws-exception/ejb-api/pom.xml
+ </parent>
+
+ <artifactId>jboss-as-ejb-throws-exception-ejb-api</artifactId>
+ <packaging>jar</packaging>
+
+ <name>ejb-throws-exception-ejb-api</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.jboss.spec.javax.ejb</groupId>
+ <artifactId>jboss-ejb-api_3.1_spec</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+
+</project>
sgilda
sgilda Mar 14, 2013 Contributor

Insert the following before the end project tag (the indentation doesn't appear correctly unless you go into edit mode on the comment):

<build> <finalName>${project.artifactId}</finalName> </build>

@sgilda sgilda commented on an outdated diff Mar 14, 2013
ejb-throws-exception/pom.xml
+ to repeat ourselves in every module -->
+ <dependency>
+ <groupId>org.jboss.as.quickstarts</groupId>
+ <artifactId>jboss-as-ejb-throws-exception-ejb</artifactId>
+ <version>${project.version}</version>
+ <type>ejb</type>
+ </dependency>
+
+ <!-- Define the version of the WAR so that we don't need to repeat
+ ourselves in every module -->
+ <dependency>
+ <groupId>org.jboss.as.quickstarts</groupId>
+ <artifactId>jboss-as-ejb-throws-exception-web</artifactId>
+ <version>${project.version}</version>
+ <type>war</type>
+ </dependency>
sgilda
sgilda Mar 14, 2013 Contributor

I'm not sure if this is necessary, but the other EAR quickstarts add <scope>compile</scope after the <type>war</type> element.

@sgilda sgilda commented on an outdated diff Mar 14, 2013
ejb-throws-exception/web/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/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.jboss.as.quickstarts</groupId>
+ <artifactId>jboss-as-ejb-throws-exception</artifactId>
+ <version>7.1.2-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>jboss-as-ejb-throws-exception-web</artifactId>
+ <packaging>war</packaging>
+
+ <name>JBoss AS Quickstarts: EJB throws exception (WAR)</name>
+
+ <dependencies>
sgilda
sgilda Mar 14, 2013 Contributor

Insert the licence before dependencies"

<licenses> <license> <name>Apache License, Version 2.0</name> <distribution>repo</distribution> <url>http://www.apache.org/licenses/LICENSE-2.0.html</url> </license> </licenses>

@sgilda sgilda commented on an outdated diff Mar 14, 2013
ejb-throws-exception/web/pom.xml
+ in JBoss AS 7 -->
+ <dependency>
+ <groupId>org.hibernate.javax.persistence</groupId>
+ <artifactId>hibernate-jpa-2.0-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.spec.javax.ejb</groupId>
+ <artifactId>jboss-ejb-api_3.1_spec</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
sgilda
sgilda Mar 14, 2013 Contributor

Insert the finalName before the plugins:

<finalName>${project.artifactId}</finalName>

@sgilda sgilda commented on an outdated diff Mar 14, 2013
ejb-throws-exception/ejb/pom.xml
+ <!-- Hibernate Validator is shipped in JBoss AS 7 -->
+ <dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-validator</artifactId>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.as.quickstarts</groupId>
+ <artifactId>jboss-as-ejb-throws-exception-ejb-api</artifactId>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <plugins>
sgilda
sgilda Mar 14, 2013 Contributor

Insert the finalName before the plugins:

<finalName>${project.artifactId}</finalName>

Contributor
sgilda commented Mar 14, 2013

@bmaxwell : I think I marked all the changes required to get rid of version numbers in the archive names. Let me know if you have any questions.

Contributor

Pushed again. I build and the version numbers are in the build ear,jars or war.

Contributor
sgilda commented Mar 15, 2013

@bmaxwell : Did you mean the version numbers are no longer appended to the archive names? This looks good to me. They now build with the names ejb-throws-exception-ear.ear, jboss-as-ejb-throws-exception-ejb.jar, jboss-as-ejb-throws-exception-ejb-api.jar , and jboss-as-ejb-throws-exception-web.war.

@pmuir: Would you like to review?

Contributor

@sgilda yes sorry, busy week, apparently I'm losing it :) Yes, I made the changes and the version number are not in the ear,war,jars.

Contributor
sgilda commented Mar 15, 2013

@bmaxwell : I'm glad to know I'm not the only one losing it.
After @pmuir reviews this one, I will merge it.

@sgilda sgilda commented on an outdated diff Mar 18, 2013
ejb-throws-exception/ejb-api/pom.xml
+ <artifactId>jboss-as-ejb-throws-exception-ejb-api</artifactId>
+ <packaging>jar</packaging>
+
+ <name>ejb-throws-exception-ejb-api</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.jboss.spec.javax.ejb</groupId>
+ <artifactId>jboss-ejb-api_3.1_spec</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <finalName>${project.artifactId}</finalName>
+ </build>
sgilda
sgilda Mar 18, 2013 Contributor

I think you might also need to add the following:
<plugins> <plugin> <artifactId>maven-jar-plugin</artifactId> <version>${version.jar.plugin}</version> </plugin> </plugins>
See the helloworld-jms quickstart for an example.

@sgilda sgilda commented on the diff Mar 18, 2013
ejb-throws-exception/ejb-api/pom.xml
+ language governing permissions and limitations under the License. -->
+<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>
+
+ <parent>
+ <groupId>org.jboss.as.quickstarts</groupId>
+ <artifactId>jboss-as-ejb-throws-exception</artifactId>
+ <version>7.1.2-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>jboss-as-ejb-throws-exception-ejb-api</artifactId>
+ <packaging>jar</packaging>
+
+ <name>ejb-throws-exception-ejb-api</name>
+
sgilda
sgilda Mar 18, 2013 Contributor

I think you might need the following also:
<licenses> <license> <name>Apache License, Version 2.0</name> <distribution>repo</distribution> <url>http://www.apache.org/licenses/LICENSE-2.0.html</url> </license> </licenses>
<properties> <version.jar.plugin>2.2</version.jar.plugin> </properties>

Contributor
sgilda commented Mar 28, 2013

@pmuir : Would you like to review this one last time?

Owner
pmuir commented Mar 28, 2013

Yes, next week :-)

On 28 Mar 2013, at 17:31, sgilda notifications@github.com wrote:

@pmuir : Would you like to review this one last time?


Reply to this email directly or view it on GitHub.

Owner
pmuir commented Apr 11, 2013

Looks good. I've merged it. Thanks @bmaxwell!

@pmuir pmuir closed this Apr 11, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment