How to run a JSF 2.0 application on JavaEE5? - java

For one reason or another, we need to run our JSF2 application on a JavaEE5 server (weblogic10).
Before trying to compile my application with Java5 instead of Java6, does anyone know if this will actually be possible?

JSF 2.0 is compatible with Servlet 2.5 (Java EE 5) containers. See also the Mojarra 2.0 release notes:
Webtier Specification Requirements
This release of JSF requires:
Java Servlet 2.5
JavaServerTM Pages 2.1
JavaServerTM Pages Standard Tag Library 1.2
Only JSF 2.1 requires Servlet 3.0 (Java EE 6) containers. See also the Mojarra 2.1 release notes.

Related

How to change JSP version in Tomcat?

I am upgrading my old Java webapp using JSP spec 2.0 to tomcat 7 that uses JSP specs 2.2 and the EL specs have changed much in recent versions of Tomcat 7. I have a lot of JSPs that uses old EL that are not compatible with newer versions of EL in JSP 2.2.
My question (Futile alert!), can I somehow change Tomcat 7 to use JSP 2.0 spec. You'd say why don't I use older Tomcat; I can't because I need to use Servlet 3.0 specs.
No you can't. If you somehow did, you wouldn't be able to use Servlet 3.0 because your JSP(s) are compiled into Servlets. Tomcat releases are tied to JSP and Servlet versions.
Per the Apache Tomcat 7 documentation,
Apache Tomcat version 7.0 implements the Servlet 3.0 and JavaServer Pages 2.2 specifications from the Java Community Process, and includes many additional features that make it a useful platform for developing and deploying web applications and web services.

How to figure out what spec version of api is implemented

I am migrating my app from jetty 7 to 9. jetty server 9 depends on org.eclipse.jetty.orbit:javax.servlet:3.0.0.v201112011016
I need to know what version of servlet-api is implemented by this artifact in order to add dependency on it. I want to add maven dependency only on api not implementation, so I could easily change servlet container later.
Google for Jetty documentation, click on the link, and find this page: http://www.eclipse.org/jetty/documentation/current/what-jetty-version.html, which indicates every Jetty version with the corresponding version of the servlet and JSP spec.
You can get the best about jetty here. According to the servlet api javadoc...
You have a few things to take care of.
Set your Servlet API version in your WEB-INF/web.xml
Ensure you use the appropriate Servlet API in your project for the version of Jetty you intend on running on.
Jetty 6 - Servlet API 2.4
Jetty 7 - Servlet API 2.5
Jetty 8 - Servlet API 3.0
Jetty 9 - Servlet API 3.0 (tracking 3.1 and will switch over to 3.1 when spec is finalized)
Grab the appropriate Servlet API jar file from maven
<!-- Servlet API 3.0 / OSGi bundle ready -->
<dependency>
<groupId>org.eclipse.jetty.orbit</groupId>
<artifactId>javax.servlet</artifactId>
<version>3.0.0.v201112011016</version>
<scope>provided</scope>
</dependency>

is a way to run jsf 2.0 on oc4j 10.1.3.5?

i'm trying to run jsf 2.0 on oc4j server 10.1.3.5 but the problem oc4j server support
servlet 2.4 .
Is a way to let the servet use servlet 2.5 to support jsf 2.0 ???
Simple, no. You have to upgrade your server to some which supports at least Servlet 2.5 (and better 3.0).

servlet/jsp spec for various web servers

According to this table here, it is easy to see which tomcat version adheres to which servlet/jsp specs.
Does anyone know where to find similar information for WebSphere Application Server (I am interested in versions 6 and 7), JBoss AS (versions 4.2, 5.1 and 6) and WebLogic?
The application server comparison wiki page is a good place to start, but it typically only lists the newest version (although it does provide links to vendor sites which may be helpful).
Also, WAS 6 was servlet 2.4, JSP 2.0. Not sure about JBoss.

Which technologies does Tomcat support?

I read a lot about GlassFish application server that it supports the whole Java EE 6 specification. But which does Tomcat support?
I know that Tomcat is a JSP/Servlet container, but I see articles in web about "JSF and Tomcat", "Hibernate and Tomcat" and many more.
Can tomcat play with these technologies: EJB, JSF, JPA, Hibernate, Spring, etc..?
Tomcat as being a barebones servletcontainer provides indeed only JSP, Servlet, EL and WS APIs out the box. You can however just provide JSF, JSTL, CDI, JPA, Hibernate, Spring, etc yourself along with the web application in flavor of JAR file(s) in the /WEB-INF/lib folder and some configuration files where necessary.
EJB is only a story apart since you can't just add "some JARs" to get that to work, but in fact yes, you can put an EJB container on top of Tomcat too if you modify the server core. That's also basically what TomEE has done. You might as well consider it if your intent is to go Java EE.
See also:
What exactly is Java EE?
I read a lot about GlassFish application server that it supports the whole Java EE 6 specification. But which does Tomcat support?
Tomcat (which is not the RI of the Servlet spec anymore since Java EE 5) doesn't support any of the Java EE 6 APIs out of the box. In its latest version, Tomcat 6 ships with:
Servlet 2.5
JSP 2.1/EL 2.1
While the "web" part of GlassFish implements:
Java Servlet 3.0
JavaServer Faces 2.0
JavaServer Pages 2.2/Expression Language 2.2
Standard Tag Library for JavaServer Pages (JSTL) 1.2
Can tomcat play with these technologies: EJB, JSF, JPA, Hibernate, Spring, etc..?
You can use some of them by packaging them inside your application (this article has a nice summary):
EJB 3.1: no, there is no standalone EJB 3.1 container at the time of writing this (and if you consider using EJB, use a real Java EE server, Tomcat with a standalone EJB container is not an equivalent, especially from a Transaction Manager point of view).
JSF 2.0 and EL 2.2: yes, possible with some pain
CDI 1.0: yes, possible
Bean validation 1.0: yes possible with JSF 2.0 and JPA
JPA 2.0: yes, possible but you'll have to obtain the EntityManager yourself and to manage transaction yourself (or to use a third party container like Spring).
But let me insist: whatever you'll add to Tomcat, you won't get an equivalent of a Java EE 6 container, even if we just compare with a Web Profile implementation (like GlassFish v3 Web Profile): no EJB 3.1 Lite, no JTA 1.1, no descriptor-less applications, etc.
If you have the choice, my suggestion would to use GlassFish v3 Web Profile and to embrace Java EE 6.
Tomcat is not an EJB container, therefore you should use full blown JavaEE 6 server for that (such as Glassfish, Websphere, Weblogic, etc.).
Tomcat can use Spring/Hibernate as this only requires relevant jars and configs/context definitions. Same applies for JSF.
JPA is an abstract spec, and Hibernate (along others) is an implementation of this spec, therefore the answer is "yes, it can be implemented on Tomcat".
I found the table on the tomcat page helpful.
Page: http://tomcat.apache.org/whichversion.html
Tomcat supports depending on it's version:
JSTL 1.0 : Servlet 2.3 : JSP 1,2 (tomcat 4)
JSTL 1.1 : Servlet 2.4 : JSP 2.0 (tomcat 5)
JSTL 1.2 : Servlet 2.5 : JSP 2.1 (tomcat 6)
That tomcat offers no EJB support by default has already be answered.
EasyBeans covers this issue.
To include JSF 1.2 in tomcat6 there is a tutorial
EDIT:
Unfortunately there is no single dependency(/compatibility) matrix out there.
JPA is an API, which is implemented by i.g. Hibernate. It should not be hard to find out which versions match. And yes they can be used with Tomcat (besides) Spring.

Categories