Differences of maven JSF api artifacts - java

Do you know guys the differences between the following artifacts?
Which one should I use in which circumstances?
<dependency>
<groupId>org.jboss.spec.javax.faces</groupId>
<artifactId>jboss-jsf-api_2.1_spec</artifactId>
<scope>provided</scope>
</dependency>
and
<dependency>
<groupId>javax.faces</groupId>
<artifactId>javax.faces-api</artifactId>
<version>2.1</version>
<scope>provided</scope>
</dependency>
Or more specifically I am planning to replace the 1st dependency with 2nd one for my webapp which will deploy to both JBoss 7.1.1 and Glassfish 3.1.2.1. Should I expect any side effects?

The first one is provided by jboss.org and the second one is Developed through the Java Community Process under JSR - 314.You can replace 1st dependency with 2nd one. There is no side effects.

Related

Maven Dependency for EJB 3.1 [jboss-ejb-api_3.1_spec]

I followed some tutorials on EJB 3.1 and those were using the following dependency for EJB-API.
<dependency>
<groupId>org.jboss.spec.javax.ejb</groupId>
<artifactId>jboss-ejb-api_3.1_spec</artifactId>
<version>1.0.2.Final</version>
</dependency>
My problem is, this is only for jboss or can I used this in any other application servers. If not why there are dependency like these which are not independent from the application server it gets deployed. And also I found this reference for ejb 3.1 api. Therefore please elaborate what are these and why those are there.
You can use it on any server you like. Just remember to put add the <scope>provided</scope> tag to the dependency like this:
<dependency>
<groupId>org.jboss.spec.javax.ejb</groupId>
<artifactId>jboss-ejb-api_3.1_spec</artifactId>
<version>1.0.2.Final</version>
<scope>provided</scope>
</dependency>
The provided scope means that this dependency is only used to compile your code and not included in the resulting EAR/WAR/JAR. In the runtime this dependency is provided by your application server (JBoss, Websphere, whatever). If you omit the scope specification section very bad things may happen.
Here you go. This is from EJB specs.
<dependency>
<groupId>javax.ejb</groupId>
<artifactId>javax.ejb-api</artifactId>
<version>3.2</version>
</dependency>
Hope this helps.

Which dependencies to create REST services on Tomcat7 (Netbeans project with Maven)

My webapp includes REST web services and is running on GlassFish 3.1.2.
I would like to run this app on Tomcat 7 instead of GlassFish. What dependencies should I add and remove to enable REST services on Tomcat?
(At the moment I just changed "GlassFish" to "Tomcat" in the "Run" menu of Netbeans, but my http requests give a 404.)
Note: this is a Maven project on Netbeans.
Ok here is the list of dependencies you may need. Please note I just put latest version but you may want to use a different version. Please also check for compatibility of these versions with each other.
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet-core</artifactId>
<version>2.8</version>
</dependency>
<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs-api</artifactId>
<version>2.0</version>
</dependency>
Needed if you are using jackson to parse json
<dependency>
<groupId>com.fasterxml.jackson.jaxrs</groupId>
<artifactId>jackson-jaxrs-json-provider</artifactId>
<version>2.3.3</version>
</dependency>
This is what I am using on my tomcat but little bit older versions
Now about your 404
First check if the dependencies fix your problem. 404 may be an issue from some thing not configured right in your web.xml as well.
I hope it helps you solve your problem :)

Single/complete Maven dependencies for Java EE 5 API

Is there a single maven dependency containing whole Java EE 5 spec API. Just like
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>6.0</version>
</dependency>
for Java EE 6.
I'm using JBoss 5 and want to add single (or several) dependency as provided scope and be sure that I have everyting that is available in JBoss.
Maybe some kind of archetype exist for JBoss 5.x.x deployed project?
Based on maven central I think you need the following:
<dependency>
<groupId>javaee</groupId>
<artifactId>javaee-api</artifactId>
<version>5</version>
</dependency>

IntelliJ IDEA 11 adding CDI facet fails?

I have the follwing dependencies in my POM. I am trying to add the CDI facet in IntelliJ IDEA 11 because I thought I would get an option for creating the beans.xml file without manually having to write it, just as you do with persistence.xml etc. However even though I have the dependencies it says Weld is missing, but why do I need to download these when I have everything I need in the POM?
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>6.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.enterprise</groupId>
<artifactId>cdi-api</artifactId>
<version>1.0</version>
<scope>provided</scope>
</dependency>
On a JBoss stack, I usually use that dependency:
<dependency>
<groupId>org.jboss.spec</groupId>
<artifactId>jboss-javaee-6.0</artifactId>
<version>1.0.0.Final</version>
<type>pom</type>
<scope>provided</scope>
</dependency>
(Requires JBoss Repo)
Have a look at that configuration here, which I used for a plain Java EE 6 stack (on a JBoss AS 6)
I've never had weld on the classpath. Simply the cdi-api and the beans.xml and it finds the facet just fine. If you're worried about having to manually create the beans.xml, create a template for it and be done.

java ee api is missing on project classpath while using httpunit for servlet testing in maven

I want to run the servlet testing example available here using maven. Javaee web api should be declared as provided:
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-web-api</artifactId>
<version>6.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>httpunit</groupId>
<artifactId>httpunit</artifactId>
<version>1.7</version>
<scope>test</scope>
</dependency>
However, one of the tests in the example throws ServletException. NetBeans complains that java ee api is missing on project classpath. How does one solve this issue?
EDIT
It is not a NetBeans issue, it is a maven issue.
Now this is the most debilitating issue I have ever faced in my Java days. And it is followed by the most ridiculous workaround I have ever seen, ever:
<dependency>
<groupId>httpunit</groupId>
<artifactId>httpunit</artifactId>
<version>1.7</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-web-api</artifactId>
<version>6.0</version>
<scope>provided</scope>
</dependency>
Yes, permute the declaration of dependencies in the pom.xml (see here for "why") and make javaee-web-api last.
It means that maven (or netbeans...I haven't used netbeans in 10 years), couldn't download or find that artifact in the local repository.
The scope provided means: I need the jar to compile my source code, but don't bundle the jar in the final package.

Categories

Resources