You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by Gary Weaver <ga...@duke.edu> on 2008/06/06 17:21:43 UTC
log4j.properties/log4j configuration not recognized when using maven
2.0.7 and axis2 1.3 - solution is to upgrade to maven 2.0.9
This was a little tricky so I thought I'd share...
I am working on a test client for integrating with an external
webservice using Axis2, and found a strange issue related to log4j
configuration.
I was originally using:
* maven2 2.0.7
* axis2-wsdl2code-maven-plugin 1.4
* dependencies:
**
<groupId>org.apache.axis2</groupId><artifactId>axis2</artifactId><version>1.4</version>
**
<groupId>org.apache.axis2</groupId><artifactId>axis2-xmlbeans</artifactId><version>1.4</version>
I was able to define log4j.properties for the unit tests in
/src/test/resources/log4j.properties per the following to output the
SOAP request and response from Axis2:
---start log4j.properties---
# Set root category priority to INFO and its only appender to CONSOLE.
log4j.rootCategory=INFO, CONSOLE
# CONSOLE is set to be a ConsoleAppender using a PatternLayout.
log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
log4j.appender.CONSOLE.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n
log4j.logger.httpclient.wire.content=DEBUG
---end log4j.properties---
Then I learned that I would need to use WS-Security for the client that
there was only a 1.3 version of Axis2 rampart, which meant that I
changed to use:
* (still) maven2 2.0.7
* axis2-wsdl2code-maven-plugin 1.3
* dependencies:
**
<groupId>org.apache.axis2</groupId><artifactId>axis2</artifactId><version>1.3</version>
**
<groupId>org.apache.axis2</groupId><artifactId>axis2-xmlbeans</artifactId><version>1.3</version>
**
<groupId>org.apache.rampart</groupId><artifactId>rampart-core</artifactId><version>1.3</version>
(btw- I don't know yet whether those are all of the dependencies needed
for rampart to work- am just starting down that road now)
When I did that though, I noticed when running unit tests in Maven 2
(using surefire and junit 3.8.1) that while running tests, it was
ignoring my log4j.properties that I had defined that it was using
previously.
My first solution to this was to define the path to the log4j.properties
file as a system property in the surefire plugin. The following worked,
but I didn't like it:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
...
<systemProperties>
<property>
<name>log4j.configuration</name>
<value>file:///path/to/project/src/main/resources/log4j.properties</value>
</property>
</systemProperties>
</configuration>
</plugin>
Then I thought that it had been a long time since I updated Maven 2,
even though I didn't think that would have anything to do with it.
Sure enough, after updating to Maven 2.0.9, I could comment out/remove
the hardcoded path to log4j.properties in the surefire plugin config,
and it recognized the log4j.properties file regardless of whether I used
1.3 or 1.4 dependencies.
Hopefully this helps someone else...
Thanks,
Gary
By the way, here is the full thing that I have so far, using Maven 2.0.9
(using Axis2 1.3 for use with rampart 1.3. If you guys can see any
dependencies that I'll need to get WS-Security to work client-side,
please let me know).
pom.xml:
...
<dependencies>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.1</version>
<scope>provided</scope>
<exclusions>
<exclusion>
<groupId>logkit</groupId>
<artifactId>logkit</artifactId>
</exclusion>
<exclusion>
<groupId>avalon-framework</groupId>
<artifactId>avalon-framework</artifactId>
</exclusion>
<exclusion>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2</artifactId>
<version>1.3</version>
</dependency>
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-xmlbeans</artifactId>
<version>1.3</version>
</dependency>
<dependency>
<groupId>org.apache.rampart</groupId>
<artifactId>rampart-core</artifactId>
<version>1.3</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-wsdl2code-maven-plugin</artifactId>
<version>1.3</version>
<configuration>
<packageName>edu.duke.oit.psv9integration.client</packageName>
<wsdlFile>...relative path to wsdl including wsdl
filename...</wsdlFile>
<generateTestcase>true</generateTestcase>
<databindingName>xmlbeans</databindingName>
</configuration>
<executions>
<execution>
<goals>
<goal>wsdl2code</goal>
</goals>
</execution>
</executions>
</plugin>
<!--
XmlBeans classes generated in wsdl2code need to be included
in jar, or will get java.lang.ExceptionInInitializerError
-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<phase>generate-resources</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<tasks>
<mkdir dir="${pom.basedir}/target/classes"/>
<copy todir="${pom.basedir}/target/classes">
<fileset
dir="${pom.basedir}/target/generated-sources/axis2/wsdl2code/resources/">
<include
name="schemaorg_apache_xmlbeans/**"/>
</fileset>
</copy>
</tasks>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<reportFormat>brief</reportFormat>
<useFile>false</useFile>
</configuration>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<snapshots>
<enabled>true</enabled>
</snapshots>
<id>central-m2-repository</id>
<name>Central Maven 2 Repository</name>
<url>http://repo1.maven.org/maven2</url>
</repository>
</repositories>
...
--
Gary Weaver
Internet Framework Services
Office of Information Technology
Duke University
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org