Upgrading To The Java EE 6 Web Profile

By , 21 March 2012

Upgrading To The Java EE 6 Web Profile
Upgrading To The Java EE 6 Web Profile

Here are my notes from our upgrade of the Sunburnt SEO software to the Java EE 6 Web Profile. Previously our stack was pretty similar to Java Web Profile, just with a lot more dependencies than is now necessary with EE 6.

We can now deploy to Glassfish 3.1 or a modified Tomcat 7.0, since we aren't using the EJB features of Java EE 6.

Code Changes

persistence.xml is now version 2.0

<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" 

web.xml is now version 3.0

<web-app xmlns="http://java.sun.com/xml/ns/javaee" version="3.0"

Remove vendor-specific JPA annotations.

  • //@Index
  • //@ForeignKey
  • //@ElementForeignKey
  • //@ContainerTable
  • //@PersistentMap
  • //import org.apache.openjpa
Upgrading To The Java EE 6 Web Profile


[1] Missing API Code

Bytecode enhancement fails with OpenJPA and EclipseLink because of the default API jars missing code. This also affects JSF.

The workaround is to change the pom.xml dependency to

    <!-- default Jave EE jars don't include code necessary fo
         bytecode enhancement so we use these instead -->

[2] EL expressions throw an exception

Passing bean references by EL fails when they are dereferenced. This is a known bug.

Adding this to the pom.xml "fixes" the problem.

    <!-- default Glassfish EL is broken
         http://java.net/jira/browse/JAVASERVERFACES-1828 -->

[3] Multipart Forms Fail Silently

commons-upload doesn't work with Servlet-3.0, but the Servlet-3.0 Multipart API is almost identical so it is easy to replace. Tomcat needs

<Context path="" allowCasualMultipartParsing="true">

since we cannot add the @MultipartConfig tag to the Faces Servlet and <multipart-config/> in web.xml doesn't seem to work. Glassfish does not seem to need this configuration.

[4] Glassfish EL Calls Incorrect Method

EL 2.2 doesn't seem to distinguish between methods like getItem(String url) and getItem(Long id) which used to work with JBoss EL. I just changed the method names to fix this.

They are the main problems we hit. Hopefully these links will help you out upgrading your app.

About Roger Keays

Upgrading To The Java EE 6 Web Profile

Roger Keays is an artist, an engineer, and a student of life. He has no fixed address and has left footprints on 40-something different countries around the world. Roger is addicted to surfing. His other interests are music, psychology, languages, the proper use of semicolons, and finding good food.

Leave a Comment

Please visit https://rogerkeays.com/upgrading-to-the-java-ee-6-web-profile to add your comments.