wood burning stoves 2.0*
The moose likes Ant, Maven and Other Build Tools and the fly likes Finding Maven JBoss and JEE dependencies Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of JavaScript Promises Essentials this week in the JavaScript forum!
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "Finding Maven JBoss and JEE dependencies" Watch "Finding Maven JBoss and JEE dependencies" New topic
Author

Finding Maven JBoss and JEE dependencies

Greg Charles
Sheriff

Joined: Oct 01, 2001
Posts: 2861
    
  11

Every time I think I'm getting the hang of Maven, something else comes along to baffle me. I'm in the progress of porting a legacy web app from JBoss 4.2.3 to JBoss 7. I've got it working, and am trying to get a working build for it. I found a handy tip that you if you put this into the root pom's dependency management section:



... then you don't need to worry about version numbers for the various components included in JBoss and the JEE spec (like JBoss logging, EJBs, Servlets, etc.) in any of your sub-projects.

For example, you could have:



... and be sure that you're compiling against the version of Hibernate included with JBoss 7. So that's cool. I can't figure out the right dependencies though. For example, I'm building an EJB jar (with EJB 3). After some searching, I found various answers for how to bring in the EJB dependencies:








Finally, the one that worked was:



I'm not even sure that's bringing the JBoss 7 version or if it's just close enough that it still works. Next I have to compile a web app, so I'm going to have figure out dependencies for servlets, JSPs, JSFs, and probably a few other things. Where do I find this information?

Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5842
    
    7

Where do I find this information?

Unfortunately, if the JBoss team doesn't provide such information in their documentation, you are left to guess. What I have done in the past is simply installed the JBoss-specific JARs in my local Maven repository. Fortunately, that is usually only a few JARs because most of the JARs you will need for creating an app are not JBoss-specific. Rather, you would use the standard Java EE jars (for servlets, EJBs, etc.) and those should be in Maven central; you just have to determine which version of that technology corresponds to the version of Java EE you are coding against. JBoss AS 7 implements Java EE 6, and you can find the list of technologies (and their versions) here:
http://www.oracle.com/technetwork/java/javaee/tech/index.html

Actually, for Java EE 6 this appears to have been made even simpler. There appears to be a javaee-api JAR file in Maven Central at:
http://repo1.maven.org/maven2/javax/javaee-api/6.0/
which contains the entire API (at lease I saw the EJB, servlet and numerous other packages listed). So you might have to include only that:

Caveat: I haven't used this JAR in any of my projects so I cannot guarantee that it will work.

JBoss In Action
Greg Charles
Sheriff

Joined: Oct 01, 2001
Posts: 2861
    
  11

Thanks Peter. I also dug through my local repository and found these in jboss-javaee-web-6.0-2.0.0.Final.pom:




That's not the greatest interface for finding dependencies, but at least I finally found them.
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10262
    
168

From Java EE development point of view, the Maven dependencies can be broadly divided into:

1) Java EE spec API jars (which allows access to spec mandated APIs like javax.ejb.* or javax.http.servlet.* etc...)
2) Application server specific API jars (which allows access to application server specific APIs, like in JBoss you might be interested in @org.jboss.ejb3.annotation.SecurityDomain)
3) Other application specific dependencies (like Hibernate if you are directly dealing with Hibernate instead of JPA)

For #1, it would have been great if those spec API jars were published by Sun/Oracle directly into Maven central. But last time I checked it wasn't there. So JBoss publishes them in their own Maven repo under the group id org.jboss.spec.javax.*. For example, you'll find EJB3.1 spec API jars under org.jboss.spec.javax.ejb:jboss-ejb-api_3.1_spec. If you want to access all Java EE APIs and not just EJB3.1 then you can just depend on the aggregated Java EE6 "pom" dependency like:


For #2, it's a bit more difficult. Each project within the AS publishes it at a different location. The JBoss EJB3 specific jar which contains the JBoss specific EJB3 annotations (for example) can be found at org.jboss.ejb3:jboss-ejb3-ext-api.

For #3, I usually start looking for the artifacts under the name of their package. For example, If I need Hiberante jars, I look for them under org.hibernate groupd id.

I do agree that it isn't straightforward to narrow down on the group id and artifact id.




[My Blog] [JavaRanch Journal]
Greg Charles
Sheriff

Joined: Oct 01, 2001
Posts: 2861
    
  11

Thanks Jaikiran! When you say, "I usually start looking for the artifacts under the name of their package," do you mean look through your local repository?

I have to say it's nice when asking a question a JBoss and Maven to get a reply from the author of the book on JBoss and another from the developer of many of the POMs I'm working with!
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5842
    
    7

One easy way to search for an artifact is to set up a Nexus server and configure it to mirror all of the public repositories you are interested in. Once Nexus has downloaded the indexes for those repositories, a search in Nexus will find the artifact. Oh, and configure Maven to use only your Nexus repository. Makes life much easier.

Also, if you have my book you will see that I recommend isocra's Jar Finder (http://www.isocra.com/2006/02/jarfinder/) which is invaluable in finding the JAR file containing a missing class. Point it at your JBoss AS base directory and within a few seconds you will find the JAR containing the class. Once you find the JAR, open it to see if it contains a pom.xml in a subdirectory of the META-INF/maven directory. That will give you the artifacts coordinates to use in your dependecy clause.

I also use jar finder to search my local Maven repository. In that case I just look at the pom associated with the JAR.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Finding Maven JBoss and JEE dependencies