2

I'm having a strange problem in my project (Spring, log4j, maven, jOOQ). The project is a multi-jar with a parent and a common poms shared by all the children projects.

The problem

If I use jOOQ 3.1 in one of the child projects, the rolling file is created and updated with all the logs. If I recompile the project using jOOQ 3.4 (jar is a dependency of the common pom project) my rolling file is not created and I don't get any logs.

Why did I upgrade from 3.1 to 3.4? Because I was getting this error.

My log4j.properties file is as follows:

log4j.rootCategory=DEBUG, stdout, rollingFile

log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%5p [%t %c] - %m%n

log4j.appender.stdout.layout.ConversionPattern=%p [%c{3}] %m%n

log4j.appender.rollingFile=org.apache.log4j.RollingFileAppender
log4j.appender.rollingFile.File=${catalina.base}/logs/my_file.log
log4j.appender.rollingFile.layout.ConversionPattern=%5p %d{dd MMM yyyy HH:mm:ss} [%c] - %m%n
log4j.appender.rollingFile.Append=true
log4j.appender.rollingFile.layout=org.apache.log4j.PatternLayout
log4j.appender.rollingFile.DatePattern='.'yyyy-MM-dd
log4j.appender.rollingFile.MaxFileSize=10MB
log4j.appender.rollingFile.MaxBackupIndex=99

I can't think of a relation between the jOOQ version and printing / not printing logs, especially as the jOOQ documentation makes clear that it's very easy to log. So that's why I have to ask you guys.

Please don't hesitate to ask for more details.

Thanks everyone!

UPDATE 1 - Pom sources

These are all the concerned poms (some details have been modified for obvious reasons)

super_parent_module

<?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>my_group_id</groupId>
    <artifactId>super_parent_module</artifactId>
    <version>1.0.1-SNAPSHOT</version>
    <packaging>pom</packaging>

    <name>name</name>
    <description>description</description>
    <url>http://maven.apache.org</url>

    <scm>
        <developerConnection>XXXXX</developerConnection>
    </scm>

    <distributionManagement>
       <!-- repository -->
    </distributionManagement>

    <profiles>
        <!-- profiles -->
    </profiles>

    <properties>
        <deployment.local.directory>XXXXX</deployment.local.directory>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

    <dependencies>
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.17</version>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.11</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.5.1</version>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-checkstyle-plugin</artifactId>
                <version>2.10</version>
                <configuration>
                    <configLocation>XXXXXXX</configLocation>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>cobertura-maven-plugin</artifactId>
                <version>2.6</version>
                <configuration>
                    <instrumentation>
                        <excludes>
                            <exclude>**/generated/**</exclude>
                        </excludes>
                    </instrumentation>
                </configuration>
            </plugin>
            <plugin>
               <groupId>org.apache.maven.plugins</groupId>
               <artifactId>maven-release-plugin</artifactId>
               <version>2.4.2</version>
               <configuration>
                  <tagNameFormat>v@{project.version}</tagNameFormat>
                  <autoVersionSubmodules>true</autoVersionSubmodules>
                  <releaseProfiles>releases</releaseProfiles>
                  <remoteTagging>true</remoteTagging>
                  <tagBase>XXXXXXXX</tagBase>
               </configuration>
            </plugin>
        </plugins>
    </build>


</project>

super_common_module

<?xml version="1.0"?>
<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">

    <parent> 
        <groupId>my_group_id</groupId>  
        <artifactId>super_parent_module</artifactId>
        <version>1.0.1-SNAPSHOT</version>
        <relativePath />
    </parent>

    <modelVersion>4.0.0</modelVersion>
    <artifactId>super_common_module</artifactId>
    <version>1.0.10-SNAPSHOT</version>
    <name>name</name>
    <url>http://maven.apache.org</url>

    <scm>
        <developerConnection>XXXXXX</developerConnection>
    </scm>

    <dependencies>
        <dependency>
            <!-- guava 15 -->
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-jdbc</artifactId>
            <version>3.2.4.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>args4j</groupId>
            <artifactId>args4j</artifactId>
            <version>2.0.26</version>
        </dependency>
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-all</artifactId>
            <version>1.9.5</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>ojdbc</groupId>
            <artifactId>ojdbc</artifactId>
            <version>14</version>
            <scope>provided</scope>
        </dependency>
    </dependencies>

    <build>
        <resources>
            <resource>
                <directory>${project.build.sourceDirectory}</directory>
            </resource>
            <resource>
                <directory>${basedir}/src/main/resources</directory>
            </resource>
        </resources>

        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <version>2.1</version>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                        <configuration>
                            <transformers>
                                <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
                                  <resource>META-INF/spring.handlers</resource>
                                </transformer>
                                <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
                                  <resource>META-INF/spring.schemas</resource>
                                </transformer>
                            </transformers>
                            <shadedArtifactAttached>true</shadedArtifactAttached>
                            <shadedClassifierName>with-deps</shadedClassifierName>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>

    </build>

</project>

parent_module

<?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">

    <parent> 
        <groupId>my_group_id</groupId>  
        <artifactId>super_parent_module</artifactId>
        <version>1.0.1-SNAPSHOT</version>
    </parent>

    <modelVersion>4.0.0</modelVersion>

    <groupId>my_group_id.client</groupId>
    <artifactId>parent_module</artifactId>
    <version>1.0.0-SNAPSHOT</version>
    <packaging>pom</packaging>

    <name>parent_module</name>
    <description>description</description>
    <url>http://maven.apache.org</url>

    <scm>
        <developerConnection>XXXXXX</developerConnection>
    </scm>

    <modules>
        <module>common_module</module>
        <module>my_problematic_module</module>
        <module>other_module</module>
        <module>other_module</module>       
    </modules>

    <profiles>
        <!-- profiles -->
    </profiles>

    <properties>
        <springws.version>2.1.3.RELEASE</springws.version>
        <spring.version>3.2.4.RELEASE</spring.version>
        <jooq.version>3.4.0</jooq.version>
        <jooq-codegen.url>XXXXX</jooq-codegen.url>
        <jooq-codegen.user>XXXXX</jooq-codegen.user>
        <jooq-codegen.password>XXXX</jooq-codegen.password>
    </properties>

    <dependencies>
        <dependency>
            <groupId>my_group_id</groupId>
            <artifactId>super_common_module</artifactId>
            <version>1.0.10-SNAPSHOT</version>
        </dependency>
    </dependencies>

</project>

common_module

<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>

    <parent> 
        <groupId>my_group_id.client</groupId>  
        <artifactId>parent_module</artifactId>
        <version>1.0.0-SNAPSHOT</version>
    </parent>

    <artifactId>common_module</artifactId>
    <description>description</description>
    <packaging>jar</packaging>

    <name>name</name>
    <url>http://maven.apache.org</url>

    <dependencies>

        <dependency>
            <groupId>org.jooq</groupId>
            <artifactId>jooq-codegen-maven</artifactId>
            <version>${jooq.version}</version>
        </dependency>
        <dependency>
            <groupId>org.jooq</groupId>
            <artifactId>jooq</artifactId>
            <version>${jooq.version}</version>
        </dependency>
        <dependency>
            <groupId>org.jooq</groupId>
            <artifactId>jooq-meta</artifactId>
            <version>${jooq.version}</version>
        </dependency>

    </dependencies>

    <build>
        <plugins>

            <!-- jOOQ configuration -->
            <plugin>
                <groupId>org.jooq</groupId>
                <artifactId>jooq-codegen-maven</artifactId>
                <version>${jooq.version}</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                    </execution>
                </executions>
                <dependencies>
                    <dependency>
                        <groupId>ojdbc</groupId>
                        <artifactId>ojdbc</artifactId>
                        <version>14</version>
                    </dependency>
                    <dependency>
                        <groupId>javax.xml.bind</groupId>
                        <artifactId>jaxb-api</artifactId>
                        <version>2.2.6</version>
                    </dependency>
                    <dependency>
                        <groupId>my_group_id</groupId>
                        <artifactId>jooq-ext</artifactId>
                        <version>1.0.3-SNAPSHOT</version>
                    </dependency>
                </dependencies>
                <configuration>
                    <jdbc>
                        <driver>oracle.jdbc.OracleDriver</driver>
                        <url>${jooq-codegen.url}</url>
                        <user>${jooq-codegen.user}</user>
                        <password>${jooq-codegen.password}</password>
                    </jdbc>
                    <generator>
                        <name>org.jooq.util.MyGenerator</name>
                        <database>
                            <name>org.jooq.util.oracle.OracleDatabase</name>
                            <includes>tables and packages</includes>
                            <excludes />
                            <inputSchema>my_schema</inputSchema>
                        </database>
                        <generate>
                            <relations>true</relations>
                            <deprecated>false</deprecated>
                            <instanceFields>true</instanceFields>
                            <generatedAnnotation>false</generatedAnnotation>
                            <records>true</records>
                            <pojos>false</pojos>
                            <immutablePojos>false</immutablePojos>
                            <interfaces>false</interfaces>
                            <daos>false</daos>
                            <jpaAnnotations>false</jpaAnnotations>
                            <validationAnnotations>false</validationAnnotations>
                            <globalObjectReferences>false</globalObjectReferences>
                        </generate>
                        <target>
                            <packageName>my_group_id.model.generated</packageName>
                            <directory>${project.build.directory}/generated-xxxxx/jooq</directory>
                        </target>
                    </generator>
                </configuration>
            </plugin>
        </plugins>
    </build>

</project>

my_problematic_module

<?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/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>my_group_id.client</groupId>
        <artifactId>parent_module</artifactId>
        <version>1.0.0-SNAPSHOT</version>
    </parent>

    <artifactId>my_problematic_module</artifactId>
    <packaging>war</packaging>
    <name>name</name>
    <description>description</description>
    <url>http://www.springframework.org/spring-ws</url>

    <profiles>
        <!-- profiles... -->
    </profiles>

    <scm>
        <connection>XXXXXX</connection>
    </scm>

    <build>
        <finalName>${project.artifactId}-${project.version}-${lane}</finalName>

        <resources>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>true</filtering>
            </resource>
        </resources>

        <plugins>   
            <plugin>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.4</version>
                <configuration>
                    <attachClasses>true</attachClasses>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.tomcat.maven</groupId>
                <artifactId>tomcat6-maven-plugin</artifactId>
                <version>2.1</version>
                <configuration>
                    <url>http://localhost:8084/manager</url>
                    <server>mytomcat</server>
                    <path>/project_path</path>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.jvnet.jax-ws-commons</groupId>
                <artifactId>jaxws-maven-plugin</artifactId>
                <version>2.3</version>
                <dependencies>
                    <dependency>
                        <groupId>org.jvnet.jaxb2_commons</groupId>
                        <artifactId>jaxb2-basics</artifactId>
                        <version>0.6.5</version>
                    </dependency>
                </dependencies>
                <executions>
                    <execution>
                        <id>exec_id</id>
                        <goals>
                            <goal>wsimport</goal>
                        </goals>
                        <configuration>
                            <target>2.0</target>
                            <wsdlDirectory>src/main/resources/wsdl</wsdlDirectory>
                            <wsdlFiles>
                                <wsdlFile>exec_id.wsdl</wsdlFile>
                            </wsdlFiles>
                            <extension>true</extension>
                            <xjcArgs>
                                <!-- xjcArg>some args</xjcArg -->
                            </xjcArgs>
                        </configuration>
                    </execution>
                    <execution>
                        <!-- another execution -->
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>cobertura-maven-plugin</artifactId>
                <version>2.6</version>
                <configuration>
                    <instrumentation>
                        <excludes>
                            <exclude>XXXXX</exclude>
                            <exclude>**/generated/**</exclude>
                        </excludes>
                    </instrumentation>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <dependencies>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>common_module</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.ws</groupId>
            <artifactId>spring-ws-test</artifactId>
            <version>${springws.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-jdbc</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.jvnet.jaxb2_commons</groupId>
            <artifactId>jaxb2-basics</artifactId>
            <version>0.6.5</version>
        </dependency>
        <dependency>
            <groupId>commons-dbcp</groupId>
            <artifactId>commons-dbcp</artifactId>
            <version>1.4</version>
        </dependency>
    </dependencies>

    <reporting>
        <plugins>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>cobertura-maven-plugin</artifactId>
                <version>2.6</version>
                <configuration>
                    <instrumentation>
                        <excludes>
                            <exclude>XXXXX</exclude>
                            <exclude>**/generated/**</exclude>
                        </excludes>
                    </instrumentation>
                </configuration>
            </plugin>
        </plugins>
    </reporting>

</project>
Community
  • 1
  • 1
Edu Castrillon
  • 527
  • 1
  • 12
  • 28

2 Answers2

1

I found a solution:

I have noticed that jooq-codegen-maven-3.4.0.jar has a log4j.xml and that jooq-codegen-maven-3.1.0.jar doesn't.

I have then created a log4j.xml file to replace my log4j.properties and the rollingFile has started writing again!

I believe log4j was using the xml version in jooq-codegen-maven-3.4.0.jar (which writes in console only) and not my log4j.properties. Maybe there's a way to tell log4j which file has more priority, but apparently creating this other log4j.xml has overriden jooq's.

@LukasEder, do you think this should be taken care of in jooq?

Thanks

Edu Castrillon
  • 527
  • 1
  • 12
  • 28
  • 1
    You're right, having added this XML to the Maven plugin was probably a mistake. That should be fixed: https://github.com/jOOQ/jOOQ/issues/3408 – Lukas Eder Jul 16 '14 at 13:56
0

It looks like you're missing the log4j dependency in your pom.xml file. jOOQ tries to find that dependency on the classpath, but you haven't added it (at least not in that module).

Try adding

<dependency>
    <groupId>log4j</groupId>
    <artifactId>log4j</artifactId>
    <version>1.2.17</version>
</dependency>

(It's curious that this would have worked prior to jOOQ 3.4)

Lukas Eder
  • 211,314
  • 129
  • 689
  • 1,509
  • Sorry Lukas, the dependencies go higher than I thought. I've refactored all dependencies to avoid repetitions and have added the super_parent_module and super_common_module. You'll see that log4j is in the super_parent_module. When I create the final war, log4j is present under the lib folder – Edu Castrillon Jul 09 '14 at 12:19
  • Hmm, OK. I'm not that good with Maven, I hope someone else will be able to sort it out. Sorry about that... – Lukas Eder Jul 09 '14 at 12:45
  • Hi Lukas, regarding this problem, I have found a difference between jooq 3.1 and 3.4. In jooq-codegen-maven-3.4.0.jar there's a log4j.xml file and in jooq-codegen-maven-3.1.0.jar that file doesn't exist. Maybe this configuration overrides mine. Can this be a possibility? – Edu Castrillon Jul 16 '14 at 08:19
  • @EduCastrillon: Hmm, nice catch. This was indeed changed in jOOQ 3.2: https://github.com/jOOQ/jOOQ/issues/2733. Maybe that was a bad idea... [I guess we can revert that](https://github.com/jOOQ/jOOQ/issues/3408) – Lukas Eder Jul 16 '14 at 13:53