• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Finding Maven JBoss and JEE dependencies

 
Sheriff
Posts: 3063
12
Mac IntelliJ IDE Python VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?

 
author
Posts: 5856
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
Greg Charles
Sheriff
Posts: 3063
12
Mac IntelliJ IDE Python VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.


 
Greg Charles
Sheriff
Posts: 3063
12
Mac IntelliJ IDE Python VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 5856
7
Android Eclipse IDE Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic