Lestard's Blog Software-Development with JavaScript, XUL, Firefox-Addons, XML, Java…

9Jan/120

Project Introduction: Quoll Shop Engine

Today I want to tell something about a new project I'm working on. Actually it is not that new because I'm working on it since september but I haven't mentioned it here. The idea comes from two students from the university of applied science in Görlitz. The like to build an online shop for other students at the students dorm in Görlitz. The idea is that people not only buy things one time but choose products that they like to get regularly like milk, vegetables or beer.

I'm developing the software system for this shop as a Java Web Application. Some buzzwords for technologies that I'm using for this software are JSF2.0, CDI, maven, JPA2.0 with Eclipselink and some more.

At the moment I have done the most part of the user authentication and management. The handling of products will come next. Of cause the code will be available as open source. You can get it on github.com. In the future I will bring more updates on this project to track my development process.

If you are asking what the name "Quoll" means and why I'm using it: "Quoll" is an australien marsupial. We thought that an animel with a bag would be a good mascot for a shop.

 

veröffentlicht unter: Quoll Shop, Software keine Kommentare
26Dez/110

Problem with el-api in Eclipse/Maven/Tomcat

Recently I have worked a lot on Java Web Projects and today I got strange exceptions like this:

java.lang.LinkageError: loader constraint violation: when resolving interface method
"javax.servlet.jsp.JspApplicationContext.addELResolver(Ljavax/el/ELResolver;)V"
the class loader
(instance of  org/apache/catalina/loader/WebappClassLoader)
of the current class, com/sun/faces/config/ConfigureListener,
and the class loader (instance of org/apache/catalina/loader/StandardClassLoader) for resolved class,
javax/servlet/jsp/JspApplicationContext, have different Class objects
for the type javax/el/ELResolver used in the signature

The origin was a little helper method that should lookup an String value in the ExpressionLanguage-Context:

1
2
3
4
5
6
7
8
9
10
11
12
13
private String getStringELValue(final String el) {
   String result = "";
 
   FacesContext fc = FacesContext.getCurrentInstance();
   if (fc != null) {
      String value = fc.getApplication().evaluateExpressionGet(fc, el, String.class);
      if (value != null && !value.isEmpty()) {
         result = value;
      }
   }
 
   return result;
}

This methods depends on classes in that are present in the el-api.jar. This jar is provided by tomcat per default so you don't have to provide it with your application but to be able to compile (and test) the code with maven you have to specify the dependency in your project's pom.xml:

1
2
3
4
5
6
<dependency>
 <groupId>javax.el</groupId>
 <artifactId>el-api</artifactId>
 <version>2.2</version>
 <scope>provided</scope>
</dependency>

Line 5 is important in this dependency definition as it tells maven to use the el-api.jar to compile and test the application but not to put it in the WEB-INF/libs folder of the resulting web-application because this jar is already provided by the server.

After a lot of investigation I found out that the maven-plugin of eclipse doesn't care about this scope declaration. The result is that there are 2 copies of some classes on the classpath which causes the exception mentioned above.

The solution was to install the m2e-wtp plugin. As the name suggests this plugin does some kind of integration between maven and the web tools platform (wtp). After installing this plugin you have to choose "Update Project Configuration" in the maven sub-menu of your project. After this everything was working perfectly. Maven was able to build the application and run all tests and tomcat was able to deploy and run the application without any exceptions.

After installing the plugin I got some red crosses on my projects telling me that there are still some problems. The reason for this was a wrong compiler setting. It seems that the new maven plugin tells the projects that they are of java version 1.5 and not 1.6 as it should be. The solution was to explicitly configure the compiler setting in the pom.xml:

1
2
3
4
5
6
7
8
9
10
11
12
<build>
 <plugins>
  <plugin>
   <artifactId>maven-compiler-plugin</artifactId>
   <version>2.3.2</version>
   <configuration>
    <source>1.6</source>
    <target>1.6</target>
   </configuration>
  </plugin>
 </plugins>
</build>
veröffentlicht unter: Quoll Shop, Software keine Kommentare
   

WP SlimStat