Monday, May 19, 2014

Re: Log4j problems in GWT/Maven project



On Monday, May 19, 2014 5:50:35 PM UTC+2, Arthur Rosenzahl wrote:
Hi all,

i hope this group is suitable for my question, even if it is not directly related to GWT itself.

For GWT+Maven-related questions, you can use https://groups.google.com/d/forum/codehaus-mojo-gwt-maven-plugin-users
In this case however, I believe it's directly related to GWT, independently of whether you'd use Maven or not.
 
I have a Maven GWT project. I included Hibernate and HSQLDB as persistence layer. Running the unit tests is fine, but when it try to run the server component, logging does not work and so i am blind to the errors on the server side. The errors i encouter are:
[ERROR] log4j:ERROR A "org.apache.log4j.RollingFileAppender" object is not assig
nable to a "org.apache.log4j.Appender" variable.
[ERROR] log4j:ERROR The class "org.apache.log4j.Appender" was loaded by
[ERROR] log4j:ERROR [sun.misc.Launcher$AppClassLoader@baf1915] whereas object of
 type
[ERROR] log4j:ERROR "org.apache.log4j.RollingFileAppender" was loaded by [WebApp
ClassLoader=1312837549@4e404fad].
[ERROR] log4j:ERROR Could not instantiate appender named "file".
[ERROR] log4j:ERROR A "org.apache.log4j.ConsoleAppender" object is not assignabl
e to a "org.apache.log4j.Appender" variable.
[ERROR] log4j:ERROR The class "org.apache.log4j.Appender" was loaded by
[ERROR] log4j:ERROR [sun.misc.Launcher$AppClassLoader@baf1915] whereas object of
 type
[ERROR] log4j:ERROR "org.apache.log4j.ConsoleAppender" was loaded by [WebAppClas
sLoader=1312837549@4e404fad].
[ERROR] log4j:ERROR Could not instantiate appender named "stdout".
From googling i am pretty sure it is because two instances of the log4j.jar are present.
Is there a good way or best practice way to solve this issue? I run the project in development mode from the console.
My Pom.xml looks like this:
 <?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
 
<modelVersion>4.0.0</modelVersion>


 
<groupId>testproject</groupId>
 
<artifactId>trustme-mdm-gwtp</artifactId>
 
<version>1.0-SNAPSHOT</version>
 
<packaging>war</packaging>
 
<name>GWTP Basic</name>
 
<description>Basic GWTP application</description>


 
<properties>
 
<!-- client -->
 
<gwt.version>2.6.0</gwt.version>

Try 2.6.1.
2.6.0 has classloading issues in DevMode (for server-side classes).
 

 
<gwtp.version>1.2.1</gwtp.version>
 
<gin.version>2.1.2</gin.version>


 
<!-- server -->
 
<guice.version>3.0</guice.version>


 
<!-- testing -->
 
<junit.version>4.7</junit.version>
 
<jukito.version>1.4</jukito.version>


 
<!-- maven -->
 
<gwt-maven-plugin.version>2.6.0</gwt-maven-plugin.version>
 
<maven-surefire-plugin.version>2.6</maven-surefire-plugin.version>
 
<maven-compiler-plugin.version>2.3.2</maven-compiler-plugin.version>
 
<maven-resources-plugin.version>2.5</maven-resources-plugin.version>
 
<maven-processor-plugin.version>2.0.5</maven-processor-plugin.version>
 
<maven-build-helper-plugin.version>1.7</maven-build-helper-plugin.version>




 
<target.jdk>1.7</target.jdk>
 
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
 
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>


 
<webappDirectory>${project.build.directory}/${project.build.finalName}</webappDirectory>
 
</properties>


 
<build>
 
<outputDirectory>${webappDirectory}/WEB-INF/classes</outputDirectory>


 
<plugins>
 
<!-- JUnit Testing - skip *.GwtTest cases -->
 
<!-- 'mvn test' - runs the Jukito tests -->
 
<plugin>
 
<groupId>org.apache.maven.plugins</groupId>
 
<artifactId>maven-surefire-plugin</artifactId>
 
<version>${maven-surefire-plugin.version}</version>
 
<configuration>
 
<includes>
 
<include>**/*Test.java</include>
 
</includes>
 
<excludes>
 
<exclude>**/*GwtTest.java</exclude>
 
</excludes>
 
</configuration>
 
</plugin>
 
<plugin>
 
<groupId>org.apache.maven.plugins</groupId>
 
<artifactId>maven-compiler-plugin</artifactId>
 
<version>2.3.2</version>
 
<configuration>
 
<source>1.7</source>
 
<target>1.7</target>
 
</configuration>
 
</plugin>


 
<!-- GWT -->
 
<!-- 'mvn gwt:run' - runs development mode -->
 
<!-- 'mvn gwt:debug' - runs debug mode -->
 
<!-- 'mvn gwt:compile' - compiles gwt -->
 
<!-- 'mvn integration-test' - runs the gwt tests (*GwtTest.java) -->
 
<plugin>
 
<groupId>org.codehaus.mojo</groupId>
 
<artifactId>gwt-maven-plugin</artifactId>
 
<version>${gwt.version}</version>
 
<configuration>
 
<!-- With multiple tests use GwtTestSuite.java for speed -->
 
<includes>**/*GwtTest.java</includes>
 
<extraJvmArgs>-Xss1024K -Xmx1024M -XX:MaxPermSize=256M</extraJvmArgs>


 
<copyWebapp>true</copyWebapp>
 
<hostedWebapp>${webappDirectory}</hostedWebapp>


 
<runTarget>Project.html</runTarget>
 
<modules>
 
<module>testproject.Project</module>
 
</modules>
 
</configuration>
 
<executions>
 
<execution>
 
<goals>
 
<goal>compile</goal>
 
<goal>test</goal>
 
</goals>
 
</execution>
 
</executions>
 
</plugin>
 
</plugins>
 
</build>


 
<dependencies>
 
<!-- Google Web Toolkit -->
 
<dependency>
 
<groupId>com.google.gwt</groupId>
 
<artifactId>gwt-user</artifactId>
 
<version>${gwt.version}</version>
 
</dependency>


 
<!-- GWT-Platform -->
 
<dependency>
 
<groupId>com.gwtplatform</groupId>
 
<artifactId>gwtp-all</artifactId>
 
<version>${gwtp.version}</version>
 
</dependency>


 
<!-- DI -->
 
<dependency>
 
<groupId>com.google.inject</groupId>
 
<artifactId>guice</artifactId>
 
<version>${guice.version}</version>
 
</dependency>
 
<dependency>
 
<groupId>com.google.inject.extensions</groupId>
 
<artifactId>guice-servlet</artifactId>
 
<version>${guice.version}</version>
 
</dependency>
 
<dependency>
 
<groupId>com.google.inject.extensions</groupId>
 
<artifactId>guice-assistedinject</artifactId>
 
<version>${guice.version}</version>
 
</dependency>
 
<dependency>
 
<groupId>com.google.gwt.inject</groupId>
 
<artifactId>gin</artifactId>
 
<version>${gin.version}</version>
 
</dependency>


 
<!-- Test -->
 
<dependency>
 
<groupId>junit</groupId>
 
<artifactId>junit</artifactId>
 
<version>${junit.version}</version>
 
<scope>test</scope>
 
</dependency>
 
<dependency>
 
<groupId>org.jukito</groupId>
 
<artifactId>jukito</artifactId>
 
<version>${jukito.version}</version>
 
<scope>test</scope>
 
</dependency>
 
<!-- Hibernate -->
 
<!-- for JPA, use hibernate-entitymanager instead of hibernate-core -->
 
<dependency>
 
<groupId>org.hibernate</groupId>
 
<artifactId>hibernate-entitymanager</artifactId>
 
<version>4.3.5.Final</version>
 
</dependency>
 
<!-- hSQLDB -->
 
<dependency>
 
<groupId>org.hsqldb</groupId>
 
<artifactId>hsqldb</artifactId>
 
<version>2.3.2</version>
 
</dependency>
 
<!-- add slf4j interfaces to classpath -->
 
<dependency>
 
<groupId>org.slf4j</groupId>
 
<artifactId>slf4j-log4j12</artifactId>
 
<version>1.7.7</version>
 
</dependency>
 
<!--  GWT-Log -->
 
<dependency>
 </span
...

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment