I'm getting some inconsistent behaviour in my unit test logging when either:
Running tests via IntelliJ's Run interface
Running tests via mvn test
I really want to see the following log statements when running mvn test, however they do not seem to be visible:
May 12, 2022 12:00:13 PM org.junit.jupiter.api.ClassOrderer$Random <clinit>
CONFIG: ClassOrderer.Random default seed: 155513463168987
May 12, 2022 12:00:13 PM org.junit.jupiter.engine.config.InstantiatingConfigurationParameterConverter logSuccessMessage
CONFIG: Using default class orderer 'org.junit.jupiter.api.ClassOrderer$Random' set via the 'junit.jupiter.testclass.order.default' configuration parameter.
May 12, 2022 12:00:13 PM org.junit.jupiter.api.MethodOrderer$Random <clinit>
CONFIG: MethodOrderer.Random default seed: 155513483010989
Inside my pom.xml:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M5</version>
<configuration>
<systemPropertyVariables>
<java.util.logging.config.file>
${project.build.testOutputDirectory}/logging.properties
</java.util.logging.config.file>
</systemPropertyVariables>
</configuration>
</plugin>
Contents of src/test/resources/logging.properties:
.level=CONFIG
.handlers=java.util.logging.ConsoleHandler
java.util.logging.ConsoleHandler.level=CONFIG
When running tests via IntelliJ's Run interface, I can see the following output, with the desired logs towards the bottom:
/Users/ian.jones/Library/Java/JavaVirtualMachines/openjdk-17.0.2/Contents/Home/bin/java -ea -Djava.util.logging.config.file=/Users/ian.jones/Development/my-app/target/test-classes/logging.properties -Didea.test.cyclic.buffer.size=1048576 -javaagent:/Applications/IntelliJ IDEA.app/Contents/lib/idea_rt.jar=61653:/Applications/IntelliJ IDEA.app/Contents/bin -Dfile.encoding=UTF-8 -classpath [omitted for brevity] com.intellij.rt.junit.JUnitStarter -ideVersion5 -junit5 com.myorg.OpenApiDocsGeneratorTest
May 12, 2022 12:00:13 PM org.junit.platform.launcher.core.ServiceLoaderTestEngineRegistry loadTestEngines
CONFIG: Discovered TestEngines with IDs: [junit-jupiter (group ID: org.junit.jupiter, artifact ID: junit-jupiter-engine, version: 5.8.2, location: jar:file:/Users/ian.jones/.m2/repository/org/junit/jupiter/junit-jupiter-engine/5.8.2/junit-jupiter-engine-5.8.2.jar!/org/junit/jupiter/engine/JupiterTestEngine.class)]
May 12, 2022 12:00:13 PM org.junit.platform.launcher.core.ServiceLoaderRegistry load
CONFIG: Loaded PostDiscoveryFilter instances: []
May 12, 2022 12:00:13 PM org.junit.platform.launcher.core.ServiceLoaderRegistry load
CONFIG: Loaded LauncherDiscoveryListener instances: []
May 12, 2022 12:00:13 PM org.junit.platform.launcher.core.ServiceLoaderRegistry load
CONFIG: Loaded TestExecutionListener instances: [org.junit.platform.launcher.listeners.UniqueIdTrackingListener#2781e022]
May 12, 2022 12:00:13 PM org.junit.platform.launcher.core.LauncherConfigurationParameters loadClasspathResource
CONFIG: Loading JUnit Platform configuration parameters from classpath resource [file:/Users/ian.jones/Development/my-app/target/test-classes/junit-platform.properties].
May 12, 2022 12:00:13 PM org.junit.platform.launcher.core.ServiceLoaderRegistry load
CONFIG: Loaded LauncherSessionListener instances: []
May 12, 2022 12:00:13 PM org.junit.platform.launcher.core.LauncherConfigurationParameters loadClasspathResource
CONFIG: Loading JUnit Platform configuration parameters from classpath resource [file:/Users/ian.jones/Development/my-app/target/test-classes/junit-platform.properties].
May 12, 2022 12:00:13 PM org.junit.jupiter.api.ClassOrderer$Random <clinit>
CONFIG: ClassOrderer.Random default seed: 155513463168987
May 12, 2022 12:00:13 PM org.junit.jupiter.engine.config.InstantiatingConfigurationParameterConverter logSuccessMessage
CONFIG: Using default class orderer 'org.junit.jupiter.api.ClassOrderer$Random' set via the 'junit.jupiter.testclass.order.default' configuration parameter.
May 12, 2022 12:00:13 PM org.junit.jupiter.api.MethodOrderer$Random <clinit>
CONFIG: MethodOrderer.Random default seed: 155513483010989
May 12, 2022 12:00:13 PM org.junit.jupiter.engine.config.InstantiatingConfigurationParameterConverter logSuccessMessage
CONFIG: Using default method orderer 'org.junit.jupiter.api.MethodOrderer$Random' set via the 'junit.jupiter.testmethod.order.default' configuration parameter.
However, when running mvn clean install, the logs which are important to me do not appear:
[INFO] --- maven-surefire-plugin:3.0.0-M5:test (default-test) # my-app ---
[INFO]
[INFO] -------------------------------------------------------
[INFO] T E S T S
[INFO] -------------------------------------------------------
[ERROR] May 12, 2022 12:10:06 PM org.junit.platform.launcher.core.ServiceLoaderTestEngineRegistry loadTestEngines
[ERROR] CONFIG: Discovered TestEngines with IDs: [junit-jupiter (group ID: org.junit.jupiter, artifact ID: junit-jupiter-engine, version: 5.8.2, location: jar:file:/Users/ian.jones/.m2/repository/org/junit/jupiter/junit-jupiter-engine/5.8.2/junit-jupiter-engine-5.8.2.jar!/org/junit/jupiter/engine/JupiterTestEngine.class)]
[ERROR] May 12, 2022 12:10:06 PM org.junit.platform.launcher.core.ServiceLoaderRegistry load
[ERROR] CONFIG: Loaded PostDiscoveryFilter instances: []
[ERROR] May 12, 2022 12:10:06 PM org.junit.platform.launcher.core.ServiceLoaderRegistry load
[ERROR] CONFIG: Loaded LauncherDiscoveryListener instances: []
[ERROR] May 12, 2022 12:10:06 PM org.junit.platform.launcher.core.ServiceLoaderRegistry load
[ERROR] CONFIG: Loaded TestExecutionListener instances: [org.junit.platform.launcher.listeners.UniqueIdTrackingListener#76c3e77a]
[ERROR] May 12, 2022 12:10:06 PM org.junit.platform.launcher.core.LauncherConfigurationParameters loadClasspathResource
[ERROR] CONFIG: Loading JUnit Platform configuration parameters from classpath resource [file:/Users/ian.jones/Development/my-app/target/test-classes/junit-platform.properties].
[ERROR] May 12, 2022 12:10:06 PM org.junit.platform.launcher.core.ServiceLoaderRegistry load
[ERROR] CONFIG: Loaded LauncherSessionListener instances: []
[INFO] Running ...
I have tried changing the version of maven-surefire-plugin to 3.0.0-M4 or 3.0.0-M6 but in both cases, this results in all the CONFIG logs disappearing from the output.
I have also tried explicitly setting the handlers for the classes in question, e.g.:
org.junit.jupiter.api.MethodOrderer$Random.handlers=java.util.logging.ConsoleHandler
But all this does is result in duplicate output log lines when running tests with Run, and doesn't change the output when running tests with mvn test.
Clearly it's partially working in that it is reading logging.config in both cases (if I remove this file, all CONFIG logs disappear when running mvn test) - but I have no idea why the behaviour is different, or how to fix that.
EDIT: Minimal pom.xml file
Here's a minimal pom.xml demonstrating the issue (I'm using Maven 3.8.5)
<?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>org.example</groupId>
<artifactId>surefire-problem-demo</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>5.8.2</version>
<scope>test</scope>
</dependency>
</dependencies>
<properties>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M7</version>
<configuration>
<systemPropertyVariables>
<java.util.logging.config.file>
${project.build.testOutputDirectory}/logging.properties
</java.util.logging.config.file>
</systemPropertyVariables>
</configuration>
</plugin>
</plugins>
</build>
</project>
Introduction
Let's consider the following versions as the current versions:
Maven Surefire Plugin 3.0.0-M7.
JUnit 5.8.2.
Root cause analysis
Analysis
Maven Surefire Plugin uses its JUnitPlatformProvider class. It may be observed in the output right before the «Tests» section:
<…>
[INFO] --- maven-surefire-plugin:3.0.0-M7:test (default-test) # the-project ---
[INFO] Using auto detected provider org.apache.maven.surefire.junitplatform.JUnitPlatformProvider
[INFO]
[INFO] -------------------------------------------------------
[INFO] T E S T S
[INFO] -------------------------------------------------------
<…>
Please, see the implementation of the JUnitPlatformProvider.setupJunitLogger() method: maven-surefire/JUnitPlatformProvider.java at surefire-3.0.0-M7 · apache/maven-surefire:
private static void setupJunitLogger()
{
Logger logger = Logger.getLogger( "org.junit" );
if ( logger.getLevel() == null )
{
logger.setLevel( WARNING );
}
}
Please, note the condition:
logger.getLevel() == null
Please, see the documentation of the Logger.getLevel() method:
public Level getLevel()
Get the log Level that has been specified for this Logger. The result may be null, which means that this logger's effective level will be inherited from its parent.
Returns:
this Logger's level
Please, note the statement:
The result may be null, which means that this logger's effective level will be inherited from its parent.
Analysis summary
This is (see the «Analysis» subsection) why:
A parent logger configuration is not taken into account by Maven Surefire Plugin.
It does not seem to be a user-friendly behavior.
Maybe, it is worth reporting it as a Maven Surefire Plugin issue.
It is necessary to introduce the explicit logger configuration for the org.junit package.
Solution
It is necessary to introduce the explicit logger configuration for the org.junit package:
org.junit.level=CONFIG
Follow-up: Checking provided complete pom.xml file
I have used the provided complete pom.xml file with the following preconditions.
I had used the same preconditions to test the solution.
Preconditions
Added test classes
Added 3 test classes annotated with #TestMethodOrder(MethodOrderer.Random.class) like this one:
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.MethodOrderer;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestMethodOrder;
#TestMethodOrder(MethodOrderer.Random.class)
public class Application1Test {
#Test
public void shouldAnswerWithTrue() {
Assertions.assertTrue(true);
}
#Test
public void shouldAnswerWithTrue2() {
Assertions.assertTrue(true);
}
}
Enabled parallel test execution
The content of the src/test/resources/junit-platform.properties file:
junit.jupiter.execution.parallel.enabled=true
junit.jupiter.execution.parallel.mode.default=concurrent
Added JUnit-related log level
The content of the src/test/resources/logging.properties:
.level=CONFIG
.handlers=java.util.logging.ConsoleHandler
java.util.logging.ConsoleHandler.level=CONFIG
org.junit.level=CONFIG
Output
$ ./mvnw clean test 2>&1 | grep -F 'MethodOrderer.Random'
CONFIG: MethodOrderer.Random default seed: 7225497639767
Related
I'm still working on a multi-module maven project which I upgraded from openJDK 15 to openJDK 19. I'm working on a MBP with macOS 13 Ventura.
Before the upgrade the unit test are passing with the maven-surefire-plugin without any problems.
After upgrading to openJDK 19 the mvn clean test command fails with the following error-message.
[INFO] --- maven-surefire-plugin:3.0.0-M5:test (default-test) # core ---
[INFO]
[INFO] -------------------------------------------------------
[INFO] T E S T S
[INFO] -------------------------------------------------------
[ERROR] Error occurred during initialization of boot layer
[ERROR] java.lang.module.FindException: Module javafx.graphics not found, required by common
I downloaded the files (openJDK 19 and JavaFX 19), unzipped them to a desired location, added an environment variable pointing to the lib directory of the runtime.
I can run the program from IntelliJ without any problems.
My question is, what did I missed in the configuration to get the test running?
My issues are gone with the advice from #Slavomir Jaranowski.
The changed pom looks like
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M7</version>
<configuration>
<!--<skipTests>${skipUnitTests}</skipTests>-->
<testFailureIgnore>false</testFailureIgnore>
<forkCount>1.5C</forkCount>
<reuseForks>true</reuseForks>
<parallel>methods</parallel>
<threadCount>4</threadCount>
<useUnlimitedThreads>true</useUnlimitedThreads>
<perCoreThreadCount>true</perCoreThreadCount>
<reportFormat>plain</reportFormat>
<trimStackTrace>false</trimStackTrace>
<redirectTestOutputToFile>true</redirectTestOutputToFile>
</configuration>
</plugin>
The configuration is not finished yet.
I am practicing with Kotlin and wanting to run a lightweight Rest application. I have experience with Undertow with Jersey, Jackson and Weld CDI in Java.
I wrote the minimum to startup the web container and it's running fine in IntelliJ.
Altough, when I try to run the jar-with-dependencies with java -jar app-with-dependencies.jar, I get errors.
Main class:
package nl.orhun.samplerestapp
import io.undertow.Handlers
import io.undertow.Undertow
import io.undertow.servlet.Servlets
import io.undertow.servlet.Servlets.servlet
import nl.orhun.samplerestapp.config.JerseyConfig
import org.glassfish.jersey.servlet.ServletContainer
import org.jboss.weld.environment.servlet.Listener
fun main() {
val servletBuilder = Servlets.deployment()
servletBuilder.setClassLoader(ClassLoader.getSystemClassLoader())
.setContextPath("/app")
.setDeploymentName("app.war")
.addListener(Servlets.listener(Listener::class.java))
.addServlets(
servlet("jerseyServlet", ServletContainer::class.java)
.setLoadOnStartup(1)
.addInitParam("javax.ws.rs.Application", JerseyConfig::class.java.name)
.addMapping("/rest/*")
)
val manager = Servlets.defaultContainer().addDeployment(servletBuilder)
manager.deploy()
val path = Handlers.path(Handlers.redirect("/app"))
.addPrefixPath("/app", manager.start())
val server = Undertow.builder()
.addHttpListener(8090, "localhost")
.setHandler(path)
.build()
server.start()
}
Error:
$ java -jar target/nl.orhun.samplerestapi-1.0-SNAPSHOT-jar-with-dependencies.jar
Mar 06, 2019 9:04:48 PM org.jboss.weld.environment.servlet.Listener contextInitialized
INFO: WELD-ENV-001007: Initialize Weld using ServletContextListener
Mar 06, 2019 9:04:48 PM org.jboss.weld.bootstrap.WeldStartup <clinit>
INFO: WELD-000900: 2.4.8 (Final)
Mar 06, 2019 9:04:48 PM org.jboss.weld.bootstrap.WeldStartup startContainer
INFO: WELD-000101: Transactional services not available. Injection of #Inject UserTransaction not available. Transactional observers will be invoked synchronously.
Mar 06, 2019 9:04:49 PM org.jboss.weld.bootstrap.MissingDependenciesRegistry handleResourceLoadingException
INFO: WELD-000119: Not generating any bean definitions from org.glassfish.hk2.osgiresourcelocator.ServiceLoaderImpl because of underlying class loading error: Type org.osgi.framework.BundleListener not found. If this is unexpected, enable DEBUG logging to see the full error.
Mar 06, 2019 9:04:49 PM org.jboss.weld.bootstrap.MissingDependenciesRegistry handleResourceLoadingException
INFO: WELD-000119: Not generating any bean definitions from org.jboss.logging.JBossLogManagerLogger because of underlying class loading error: Type org.jboss.logmanager.Level not found. If this is unexpected, enable DEBUG logging to see the full error.
Mar 06, 2019 9:04:49 PM org.jboss.weld.bootstrap.MissingDependenciesRegistry handleResourceLoadingException
INFO: WELD-000119: Not generating any bean definitions from org.jboss.weld.injection.spi.helpers.ForwardingJpaInjectionServices because of underlying class loading error: Type javax.persistence.EntityManager not found. If this is unexpected, enable DEBUG logging to see the full error.
Mar 06, 2019 9:04:49 PM org.jboss.weld.bootstrap.MissingDependenciesRegistry handleResourceLoadingException
INFO: WELD-000119: Not generating any bean definitions from io.undertow.servlet.osgi.Activator because of underlying class loading error: Type org.osgi.framework.BundleActivator not found. If this is unexpected, enable DEBUG logging to see the full error.
Mar 06, 2019 9:04:49 PM org.jboss.weld.bootstrap.MissingDependenciesRegistry handleResourceLoadingException
INFO: WELD-000119: Not generating any bean definitions from org.jboss.weld.jsf.FacesUrlTransformer because of underlying class loading error: Type javax.faces.context.FacesContext not found. If this is unexpected, enable DEBUG logging to see the full error.
Mar 06, 2019 9:04:49 PM org.jboss.weld.bootstrap.MissingDependenciesRegistry handleResourceLoadingException
INFO: WELD-000119: Not generating any bean definitions from org.glassfish.jersey.internal.OsgiRegistry$OsgiServiceFinder because of underlying class loading error: Type org.osgi.framework.SynchronousBundleListener not found. If this is unexpected, enable DEBUG logging to see the full error.
Mar 06, 2019 9:04:49 PM org.jboss.weld.bootstrap.MissingDependenciesRegistry handleResourceLoadingException
INFO: WELD-000119: Not generating any bean definitions from org.glassfish.jersey.server.internal.scanning.PackageNamesScanner$1 because of underlying class loading error: Type org.osgi.framework.SynchronousBundleListener not found. If this is unexpected, enable DEBUG logging to see the full error.
Mar 06, 2019 9:04:49 PM org.jboss.weld.bootstrap.MissingDependenciesRegistry handleResourceLoadingException
<.... truncated...>
Exception in thread "main" java.lang.RuntimeException: org.jboss.weld.exceptions.DeploymentException: Malformed class name
at io.undertow.servlet.core.DeploymentManagerImpl.deploy(DeploymentManagerImpl.java:252)
at nl.orhun.samplerestapp.MainKt.main(Main.kt:26)
at nl.orhun.samplerestapp.MainKt.main(Main.kt)
Caused by: org.jboss.weld.exceptions.DeploymentException: Malformed class name
at org.jboss.weld.executor.AbstractExecutorServices.checkForExceptions(AbstractExecutorServices.java:66)
at org.jboss.weld.executor.AbstractExecutorServices.invokeAllAndCheckForExceptions(AbstractExecutorServices.java:43)
at org.jboss.weld.executor.AbstractExecutorServices.invokeAllAndCheckForExceptions(AbstractExecutorServices.java:51)
at org.jboss.weld.bootstrap.ConcurrentBeanDeployer.addClasses(ConcurrentBeanDeployer.java:58)
at org.jboss.weld.bootstrap.BeanDeployment.createClasses(BeanDeployment.java:224)
at org.jboss.weld.bootstrap.WeldStartup.startInitialization(WeldStartup.java:398)
at org.jboss.weld.bootstrap.WeldBootstrap.startInitialization(WeldBootstrap.java:76)
at org.jboss.weld.environment.servlet.WeldServletLifecycle.initialize(WeldServletLifecycle.java:191)
at org.jboss.weld.environment.servlet.Listener.contextInitialized(Listener.java:125)
at io.undertow.servlet.core.ApplicationListeners.contextInitialized(ApplicationListeners.java:187)
at io.undertow.servlet.core.DeploymentManagerImpl$1.call(DeploymentManagerImpl.java:216)
at io.undertow.servlet.core.DeploymentManagerImpl$1.call(DeploymentManagerImpl.java:185)
at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:42)
at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43)
at io.undertow.servlet.core.DeploymentManagerImpl.deploy(DeploymentManagerImpl.java:250)
... 2 more
Caused by: java.lang.InternalError: Malformed class name
at java.lang.Class.getSimpleBinaryName(Unknown Source)
at java.lang.Class.isMemberClass(Unknown Source)
at org.jboss.weld.util.reflection.Reflections.getNesting(Reflections.java:138)
at org.jboss.weld.annotated.slim.backed.BackedAnnotatedConstructor.initParameters(BackedAnnotatedConstructor.java:50)
at org.jboss.weld.annotated.slim.backed.BackedAnnotatedConstructor.initParameters(BackedAnnotatedConstructor.java:28)
at org.jboss.weld.annotated.slim.backed.BackedAnnotatedCallable.<init>(BackedAnnotatedCallable.java:34)
at org.jboss.weld.annotated.slim.backed.BackedAnnotatedConstructor.<init>(BackedAnnotatedConstructor.java:38)
at org.jboss.weld.annotated.slim.backed.BackedAnnotatedConstructor.of(BackedAnnotatedConstructor.java:32)
at org.jboss.weld.annotated.slim.backed.BackedAnnotatedType$BackedAnnotatedConstructors.computeValue(BackedAnnotatedType.java:168)
at org.jboss.weld.annotated.slim.backed.BackedAnnotatedType$BackedAnnotatedConstructors.computeValue(BackedAnnotatedType.java:161)
at org.jboss.weld.util.LazyValueHolder.get(LazyValueHolder.java:58)
at org.jboss.weld.annotated.slim.backed.BackedAnnotatedType$EagerlyInitializedLazyValueHolder.<init>(BackedAnnotatedType.java:157)
at org.jboss.weld.annotated.slim.backed.BackedAnnotatedType$BackedAnnotatedConstructors.<init>(BackedAnnotatedType.java:161)
at org.jboss.weld.annotated.slim.backed.BackedAnnotatedType$BackedAnnotatedConstructors.<init>(BackedAnnotatedType.java:161)
at org.jboss.weld.annotated.slim.backed.BackedAnnotatedType.<init>(BackedAnnotatedType.java:62)
at org.jboss.weld.annotated.slim.backed.BackedAnnotatedType.of(BackedAnnotatedType.java:46)
at org.jboss.weld.resources.ClassTransformer$TransformClassToBackedAnnotatedType.apply(ClassTransformer.java:80)
at org.jboss.weld.resources.ClassTransformer$TransformClassToBackedAnnotatedType.apply(ClassTransformer.java:77)
at org.jboss.weld.util.cache.ReentrantMapBackedComputingCache$1.apply(ReentrantMapBackedComputingCache.java:55)
at org.jboss.weld.util.cache.ReentrantMapBackedComputingCache$1.apply(ReentrantMapBackedComputingCache.java:51)
at org.jboss.weld.util.cache.ReentrantMapBackedComputingCache.getValue(ReentrantMapBackedComputingCache.java:64)
at org.jboss.weld.util.cache.ReentrantMapBackedComputingCache.getCastValue(ReentrantMapBackedComputingCache.java:80)
at org.jboss.weld.resources.ClassTransformer.getBackedAnnotatedType(ClassTransformer.java:175)
at org.jboss.weld.resources.ClassTransformer.getBackedAnnotatedType(ClassTransformer.java:192)
at org.jboss.weld.bootstrap.AnnotatedTypeLoader.loadAnnotatedType(AnnotatedTypeLoader.java:83)
at org.jboss.weld.bootstrap.AnnotatedTypeLoader.loadAnnotatedType(AnnotatedTypeLoader.java:62)
at org.jboss.weld.bootstrap.BeanDeployer.addClass(BeanDeployer.java:94)
at org.jboss.weld.bootstrap.ConcurrentBeanDeployer$1.doWork(ConcurrentBeanDeployer.java:61)
at org.jboss.weld.bootstrap.ConcurrentBeanDeployer$1.doWork(ConcurrentBeanDeployer.java:58)
at org.jboss.weld.executor.IterativeWorkerTaskFactory$1.call(IterativeWorkerTaskFactory.java:62)
at org.jboss.weld.executor.IterativeWorkerTaskFactory$1.call(IterativeWorkerTaskFactory.java:55)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.StringIndexOutOfBoundsException: String index out of range: -6
at java.lang.String.substring(Unknown Source)
... 35 more
Build segment of the pom:
<build>
<plugins>
<plugin>
<artifactId>kotlin-maven-plugin</artifactId>
<groupId>org.jetbrains.kotlin</groupId>
<version>${kotlin.version}</version>
<executions>
<execution>
<id>compile</id>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<sourceDirs>
<sourceDir>${project.basedir}/src/main/kotlin</sourceDir>
<sourceDir>${project.basedir}/src/main/java</sourceDir>
</sourceDirs>
</configuration>
</execution>
<execution>
<id>test-compile</id>
<goals>
<goal>test-compile</goal>
</goals>
<configuration>
<sourceDirs>
<sourceDir>${project.basedir}/src/test/kotlin</sourceDir>
<sourceDir>${project.basedir}/src/test/java</sourceDir>
</sourceDirs>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>nl.orhun.samplerestapp.MainKt</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>make-assembly</id> <!-- this is used for inheritance merges -->
<phase>package</phase> <!-- bind to the packaging phase -->
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
I am thinking that this has something to do with how I create the jar file but I'm not sure.
Why is my application not starting up when I run the jar file?
I'm not using Undertow, but I use Weld SE in a servlet setup running on Jetty and ran into the same issue as you, it seems like. I had some luck with excluding kotlin-packages from the bean discovery scan in my beans.xml:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/beans_1_1.xsd"
bean-discovery-mode="all"
version="1.1">
<scan>
...
<exclude name="kotlin.**" />
<exclude name="kotlinx.**" />
</scan>
</beans>
I tried debugging the issue, and for me, the java.lang.InternalError: Malformed class name originated from the Java Class.getSimpleBinaryName called on some lambda in the body of kotlin.coroutines.CoroutineContext.plus, named kotlin.coroutines.CoroutineContext$plus$1 that apparently has the enclosing class kotlin.coroutines.CoroutineContext$DefaultImpls which is 6 characters longer than the lambda class name, causing an IndexOutOfBoundsException when trying to substring the lambda name with the length of the enclosing class name to get the simple name of the lambda. This may be seen as a bug in the way Kotlin names/types lambdas. A least with respect to reflection.
I also tried replicating the problem by creating this interface:
interface Foo {
fun fooBar(operation: (Foo) -> Foo): Foo
fun plus(foo: Foo): Foo = fooBar { f -> f.plus(f) }
}
And it causes the same problem (with or without operator before fun). Making Foo a class, and implementing fooBar, makes the problem go away though. Don't know why.
Using for instance let in the body of Foo.plus didn't cause any problems. Probably because let is inlined. So if you can stay away from using un-inlined lambdas in interface function bodies, you might be okay. And you can always put the interface causing problems in a package of its own and exclude this from being scanned, if you are not going to inject it. Hopefully this problem is not widespread.
Hope this helped, despite not being an Undertow-specific answer!
EDIT: You can add the #JvmDefault (https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.jvm/-jvm-default/index.html) annotation to an implemented function in an interface to create default method (Java 8 feature) compatible bytecode, and hence eliminate the problem described above. Note that you then have to specify the -Xjvm-default=enable or -Xjvm-default=compatibility compiler argument. More light is shed over #JvmDefault in this article: https://realjenius.com/2018/06/29/jvm-default/.
I tried to find the answer in already asked questions as well as in this post that some users recommended: http://www.operatornew.com/2012/11/automatic-db-migration-for-java-web.html but without any luck.
The problem is that I have a complete configuration of Liquibase for my Java project with Maven build tool and Postgres DB but even though I have defined Hibernate entities, the Liquibase diff does not take them into consideration and does not produce changelock based on JPA annotated entities.
I tried everything but with empty changelock-master.xml and with defined 2 entities the resulting diff.xml is empty.
Here is my pom.xml:
<!--LIQUIBASE-->
<dependency>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-core</artifactId>
</dependency>
<dependency>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-maven-plugin</artifactId>
<version>3.4.1</version>
</dependency>
...
<plugin>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-maven-plugin</artifactId>
<version>3.5.3</version>
<dependencies>
<dependency>
<groupId>org.liquibase.ext</groupId>
<artifactId>liquibase-hibernate4</artifactId>
<version>3.6</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>4.1.7.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-jpa</artifactId>
<version>1.7.3.RELEASE</version>
</dependency>
</dependencies>
<configuration>
<propertyFile>src/main/resources/liquibase.properties</propertyFile>
<changeLogFile>src/main/resources/db/changelog/changelog-master.xml</changeLogFile>
</configuration>
</plugin>
Here I have my liquibase.properties defined:
referenceUrl=hibernate:spring:com.victus.applied.entity?dialect=org.hibernate.dialect.PostgreSQLDialect
referenceDriver=liquibase.ext.hibernate.database.connection.HibernateDriver
referenceUsername=testusername
referencePassword=
driver=org.postgresql.Driver
url=jdbc:postgresql://localhost:5432/applied
username=testusername
password=
changeLogFile=src/main/resources/db/changelog/changelog-master.xml
diffChangeLogFile=src/main/resources/liquibase-diff.xml
outputChangeLogFile=src/main/resources/db/changelog/changelog-master.xml
In my application.properties I have also:
##Liquibase
spring.liquibase.change-log=classpath:/db/changelog/changelog-master.xml
logging.level.liquibase = INFO
##Postgres DB
spring.datasource.url= jdbc:postgresql://localhost:5432/applied
spring.datasource.driver-class-name=org.postgresql.Driver
spring.datasource.username=wiktordyngosz
spring.datasource.password=
# The SQL dialect makes Hibernate generate better SQL for the chosen database
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect
spring.jpa.properties.hibernate.temp.use_jdbc_metadata_defaults = false
# Hibernate ddl auto (create, create-drop, validate, update)
spring.jpa.hibernate.ddl-auto=create
spring.jpa.show-sql=true
spring.messages.basename=validation
I defined simple two entities, for example one of them:
#Entity
#Table(name = "user")
#Getter
#Setter
#NoArgsConstructor
#EqualsAndHashCode
public class User {
#Id
#GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
#NotNull
private String username;
#NotNull
private String password;
#Transient
private String passwordConfirm;
#ManyToMany
#JoinTable(name = "user_role", joinColumns = #JoinColumn(name = "user_id"), inverseJoinColumns = #JoinColumn(name = "role_id"))
private Set<Role> roles;
}
When I have an empty changelock-master.xml file and invoke mvn liquibase:diff to generate changelock based on my entities the resulting changelock is empty.
The log looks like this:
[INFO] ------------------------------------------------------------------------
[INFO] Parsing Liquibase Properties File
[INFO] File: src/main/resources/liquibase.properties
[INFO] 'outputChangeLogFile' in properties file is not being used by this task.
[INFO] ------------------------------------------------------------------------
[INFO] Executing on Database: jdbc:postgresql://localhost:5432/applied
INFO 20.02.19 21:19: liquibase-hibernate: Reading hibernate configuration hibernate:spring:com.victus.applied.entity?dialect=org.hibernate.dialect.PostgreSQLDialect
INFO 20.02.19 21:19: liquibase-hibernate: Found package com.victus.applied.entity
INFO 20.02.19 21:19: liquibase-hibernate: Found dialect org.hibernate.dialect.PostgreSQLDialect
INFO 20.02.19 21:19: liquibase-hibernate: Found hibernate.enhanced_idfalse
lut 20, 2019 9:19:26 PM org.hibernate.jpa.internal.util.LogHelper logPersistenceUnitInformation
INFO: HHH000204: Processing PersistenceUnitInfo [
name: default
...]
lut 20, 2019 9:19:26 PM org.hibernate.Version logVersion
INFO: HHH000412: Hibernate Core {4.3.11.Final}
lut 20, 2019 9:19:26 PM org.hibernate.cfg.Environment <clinit>
INFO: HHH000206: hibernate.properties not found
lut 20, 2019 9:19:26 PM org.hibernate.cfg.Environment buildBytecodeProvider
INFO: HHH000021: Bytecode provider name : javassist
lut 20, 2019 9:19:27 PM org.hibernate.annotations.common.reflection.java.JavaReflectionManager <clinit>
INFO: HCANN000001: Hibernate Commons Annotations {4.0.5.Final}
lut 20, 2019 9:19:27 PM org.hibernate.dialect.Dialect <init>
INFO: HHH000400: Using dialect: org.hibernate.dialect.PostgreSQLDialect
INFO 20.02.19 21:19: liquibase-hibernate: Using dialect org.hibernate.dialect.PostgreSQLDialect
[INFO] Performing Diff on database wiktordyngosz # jdbc:postgresql://localhost:5432/applied (Default Schema: public)
INFO 20.02.19 21:19: liquibase: src/main/resources/liquibase-diff.xml exists, appending
[INFO] Differences written to Change Log File, src/main/resources/liquibase-diff.xml
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
The root cause could be that the Liquibase plugin doesn't find your compiled classes on the classpath.
I find it suspicious that you refer to your logfiles by src/main/resources/.... When executing the Liquibase plugin as part of the Maven build, all resources should be available on class path directly, e.g. changelog-master.xml (without the relative path).
Try executing the diff goal as part of the Maven build after compiling.
This POM configuration binds the plugin to the process-classes phase:
<build>
<plugins>
<plugin>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-maven-plugin</artifactId>
<version>3.6.3</version>
<dependencies>
...
</dependencies>
<configuration>
<verbose>true</verbose>
</configuration>
<executions>
<execution>
<goals>
<goal>diff</goal>
</goals>
<phase>process-classes</phase>
</execution>
</executions>
</plugin>
To execute this, run mvn process-classes or a later phase like mvn test.
When I run my selenium test below from within Eclipse, I get a series of Could not instantiate TestExecutionListener messages in my log.
This is the actual test.
#RunWith(SpringJUnit4ClassRunner.class)
#ContextConfiguration(classes = SeleniumConfig.class)
public final class TestWebpage {
private static final Logger LOG = Logger.getLogger(TestWebpage.class);
#Autowired
private WebDriver driver;
#Test
public void testLoadingPage() {
LOG.debug("Hello World!");
}
}
And this is the log
0 [main] INFO org.springframework.test.context.support.DefaultTestContextBootstrapper - Loaded default TestExecutionListener class names from location [META-INF/spring.factories]: [org.springframework.test.context.web.ServletTestExecutionListener, org.springframework.test.context.support.DependencyInjectionTestExecutionListener, org.springframework.test.context.support.DirtiesContextTestExecutionListener, org.springframework.test.context.transaction.TransactionalTestExecutionListener, org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener]
5 [main] INFO org.springframework.test.context.support.DefaultTestContextBootstrapper - Could not instantiate TestExecutionListener [org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener]. Specify custom listener classes or make the default listener classes (and their required dependencies) available. Offending class: [org/springframework/transaction/interceptor/TransactionAttribute]
6 [main] INFO org.springframework.test.context.support.DefaultTestContextBootstrapper - Could not instantiate TestExecutionListener [org.springframework.test.context.transaction.TransactionalTestExecutionListener]. Specify custom listener classes or make the default listener classes (and their required dependencies) available. Offending class: [org/springframework/transaction/interceptor/TransactionAttributeSource]
7 [main] INFO org.springframework.test.context.support.DefaultTestContextBootstrapper - Could not instantiate TestExecutionListener [org.springframework.test.context.web.ServletTestExecutionListener]. Specify custom listener classes or make the default listener classes (and their required dependencies) available. Offending class: [javax/servlet/ServletContext]
8 [main] INFO org.springframework.test.context.support.DefaultTestContextBootstrapper - Using TestExecutionListeners: [org.springframework.test.context.support.DependencyInjectionTestExecutionListener#152c95a3, org.springframework.test.context.support.DirtiesContextTestExecutionListener#22140b31]
127 [main] INFO org.springframework.context.support.GenericApplicationContext - Refreshing org.springframework.context.support.GenericApplicationContext#35523de0: startup date [Wed Oct 01 01:20:22 EST 2014]; root of context hierarchy
3961 [main] DEBUG org.rmb.selenium.external.TestWebpage - Hello World!
3963 [Thread-8] INFO org.springframework.context.support.GenericApplicationContext - Closing org.springframework.context.support.GenericApplicationContext#35523de0: startup date [Wed Oct 01 01:20:22 EST 2014]; root of context hierarchy
Note that I am using Spring 4.1.0.RELEASE.
One Solution, three Extra Dependencies
I noticed in the answer to a previous question the suggestion to add #WebAppConfiguration
#RunWith(SpringJUnit4ClassRunner.class)
#ContextConfiguration(classes = SeleniumConfig.class)
#WebAppConfiguration
public final class TestWebpage {
Which I then needed three extra dependencies in my pom.xml to support:
javax.servlet-api
spring-jdbc
spring-web
Why do I need all this extra when I am not actually using JDBC at all, or anything using spring-web/servlet - this is just a selenium test with some of my own configuration.
Is there an easier way? Am I missing something bigger?
Config Class
This is the class I configure my tests with.
public final class SeleniumConfig {
#Bean
public String baseUrl() {
return "http://localhost:8888/";
}
#Bean
public WebDriver driver() {
return new CloseableFirefoxDriver();
}
class CloseableFirefoxDriver extends FirefoxDriver implements DisposableBean {
public void destroy() throws Exception {
quit();
}
}
}
POM
My pom.xml (before I added the extra dependencies).
<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>
<groupId>WebAppWithSeleniumTest</groupId>
<artifactId>WebAppWithSeleniumTest</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>WebAppWithSeleniumTest Maven Webapp</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.16</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.43.1</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>${spring.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${spring.version}</version>
</dependency>
</dependencies>
<build>
<finalName>WebAppWithSeleniumTest</finalName>
<resources>
<resource>
<directory>src/main/resources</directory>
<targetPath>${basedir}/target/classes</targetPath>
<includes>
<include>log4j.properties</include>
</includes>
</resource>
</resources>
</build>
<description>Web App with Selenium Tests - a base</description>
<properties>
<spring.version>4.1.0.RELEASE</spring.version>
</properties>
</project>
If I leave in the three extra dependencies
javax.servlet-api
spring-jdbc
spring-web
I can leave my test class defined as this:
#RunWith(SpringJUnit4ClassRunner.class)
#ContextConfiguration(classes = SeleniumConfig.class)
public final class TestWebpage {
and I will get this logging:
0 [main] INFO org.springframework.test.context.support.DefaultTestContextBootstrapper - Loaded default TestExecutionListener class names from location [META-INF/spring.factories]: [org.springframework.test.context.web.ServletTestExecutionListener, org.springframework.test.context.support.DependencyInjectionTestExecutionListener, org.springframework.test.context.support.DirtiesContextTestExecutionListener, org.springframework.test.context.transaction.TransactionalTestExecutionListener, org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener]
20 [main] INFO org.springframework.test.context.support.DefaultTestContextBootstrapper - Using TestExecutionListeners: [org.springframework.test.context.web.ServletTestExecutionListener#3997ebf6, org.springframework.test.context.support.DependencyInjectionTestExecutionListener#25048104, org.springframework.test.context.support.DirtiesContextTestExecutionListener#4ab24098, org.springframework.test.context.transaction.TransactionalTestExecutionListener#7caee177, org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener#3d548b94]
132 [main] INFO org.springframework.context.support.GenericApplicationContext - Refreshing org.springframework.context.support.GenericApplicationContext#6f55137: startup date [Wed Oct 01 21:55:02 EST 2014]; root of context hierarchy
4183 [main] DEBUG org.rmb.selenium.external.TestWebpage - Hello World!
4186 [Thread-8] INFO org.springframework.context.support.GenericApplicationContext - Closing org.springframework.context.support.GenericApplicationContext#6f55137: startup date [Wed Oct 01 21:55:02 EST 2014]; root of context hierarchy
No errors, but obviously Spring is doing a fair bit of work in the background.
Alternatively, I can remove the three extra dependencies and add this minimal #TestExecutionListeners annotation.
#RunWith(SpringJUnit4ClassRunner.class)
#ContextConfiguration(classes = SeleniumConfig.class)
#TestExecutionListeners(listeners = {DependencyInjectionTestExecutionListener.class})
public final class TestWebpage {
I get logging as below:
0 [main] INFO org.springframework.test.context.support.DefaultTestContextBootstrapper - Using TestExecutionListeners: [org.springframework.test.context.support.DependencyInjectionTestExecutionListener#4fce6eaf]
117 [main] INFO org.springframework.context.support.GenericApplicationContext - Refreshing org.springframework.context.support.GenericApplicationContext#42695958: startup date [Wed Oct 01 21:59:05 EST 2014]; root of context hierarchy
4189 [main] DEBUG org.rmb.selenium.external.TestWebpage - Hello World!
4190 [Thread-8] INFO org.springframework.context.support.GenericApplicationContext - Closing org.springframework.context.support.GenericApplicationContext#42695958: startup date [Wed Oct 01 21:59:05 EST 2014]; root of context hierarchy
At least no errors.
As to why I need any of this, I don't understand yet. I am leaving this here as a reference, at the very least to show the minimal changes required to get rid of the Could not instantiate TestExecutionListener messages.
To stay close to the original Spring implementation, use this instead:
#TestExecutionListeners(listeners = { DependencyInjectionTestExecutionListener.class,
DirtiesContextTestExecutionListener.class, TransactionalTestExecutionListener.class })
as defined in org.springframework.test.context.TestContextManager:
private static final String[] DEFAULT_TEST_EXECUTION_LISTENER_CLASS_NAMES = new String[] {
"org.springframework.test.context.web.ServletTestExecutionListener",
"org.springframework.test.context.support.DependencyInjectionTestExecutionListener",
"org.springframework.test.context.support.DirtiesContextTestExecutionListener",
"org.springframework.test.context.transaction.TransactionalTestExecutionListener" };
Only ServletTestExecutionListener should be evicted.
Any INFO messages like:
Could not instantiate TestExecutionListener org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener]
Can safely be ignored if you are not using or testing JDBC or WEB related spring features. That is just an INFO message telling us that Spring did not activate these listeners as the required dependencies (pom dependencies) have not been added. Which is fine, in case you are not using those features.
However lets say you are using #Sql to load some test data into a database, AND you see this warning, THEN we need to wire in required dependencies (spring-jdbc with test scope in your project pom.xml) in order for the required listener (SqlScriptsTestExecutionListener in this case) to be activated by Spring
At least for my setup using TestNG, the original answer was not quite enough. I had to add the following annotation:
#TestExecutionListeners(inheritListeners = false, listeners =
{DependencyInjectionTestExecutionListener.class, DirtiesContextTestExecutionListener.class})
I have a large JEE Maven Multi module project, and share a custom set of rules and suppressions for Checkstyle via build-tools module. I find very hard to release a stable version of this build-tools due to the testing of this same module.
Each time I run a Maven phase, I get a different execution result.
This is Checkstyle configuration in parent pom.xml:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>${checkstyle.plugin.version}</version>
<configuration>
<skip>${skipQATests}</skip>
<configLocation>qa/checkstyle_rules.xml</configLocation>
<propertiesLocation>${checkstyleDir}/checkstyle.properties</propertiesLocation>
<suppressionsLocation>qa/suppressions.xml</suppressionsLocation>
<encoding>UTF-8</encoding>
<consoleOutput>true</consoleOutput>
<failsOnError>true</failsOnError>
<failOnViolation>true</failOnViolation>
<linkXRef>false</linkXRef>
</configuration>
<executions>
<execution>
<id>checkstyle-compile</id>
<phase>compile</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
I'm trying to find a pattern in the executions, project is set to fail in one particular check and I cannot find the 'bug'.
I execute compile maven phase (mvn clean compile) and it fails on the given check.
I execute package maven phase (mvn clean package) and it fails too.
I execute again compile phase (mvn clean compile) and it doesn't fail (all SUCCESS)
I execute again package and it fails
It does not fail for a couple of runs and then it fails again on some different execution
I know this behavior is kind of difficult to trace without all project information. But is there any kind of procedure, log, tool that would give more information on debuging this problem so that I can determine if it's a bug or some mis-configuration??
Thanks in advance!!
UPDATE:
I have just executed the same mvn command twice on the sub-module I'm testing Checkstyle (test that forces a rule violation) - mvn checkstyle:check -X
Result was different from each other, the main differences are that the CORRECT EXECUTION (the one that fails the build does not find the files at the first try) and the WRONG EXECUTION (the one that ends in SUCCESS finds the configuration files at the first attempt)
EXEC_1: ...
[DEBUG] The resource 'qa/suppressions.xml' was not found with resourceLoader org.codehaus.plexus.resource.loader.FileResourceLoader.
[DEBUG] The resource 'qa/suppressions.xml' was found as jar:file:/C:/Users/usuario/.m2/repository/com/company/tools/build-tools/0.0.2-SNAPSHOT/build-tools-0.0.2-SNAPSHOT.jar!/qa/suppressions.xml.
[DEBUG] Adding the outputDirectory file:/C:/LAB/PRJ/prj-ejbws/target/classes/ to the Checkstyle class path
[DEBUG] The resource 'qa/checkstyle_N4_JEE.xml' was not found with resourceLoader org.codehaus.plexus.resource.loader.FileResourceLoader.
[DEBUG] The resource 'qa/checkstyle_N4_JEE.xml' was found as jar:file:/C:/Users/usuario/.m2/repository/com/company/tools/build-tools/0.0.2-SNAPSHOT/build-tools-0.0.2-SNAPSHOT.jar!/qa/checkstyle_JEE.xml.
[DEBUG] The resource 'ubic.properties' was found as C:\LAB\PRJ\ubic.properties.
[INFO] Starting audit...
[INFO] --------------------------------------------
[INFO] BUILD FAILURE
[INFO] --------------------------------------------
[INFO] Total time: 1.542s
[INFO] Finished at: Thu Feb 20 16:35:22 CET 2014
[INFO] Final Memory: 8M/20M
[INFO] --------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-checkstyle-plugin:2.11:check (default-cli) on project GestionDelContacto-opsa-ejbws: Failed during checkstyle execution: There are 2 checkstyle errors.
EXEC_2:...
[DEBUG] The resource 'qa/suppressions.xml' was found as jar:file:/C:/Users/usuario/.m2/repository/com/company/tools/build-tools/0.0.2-SNAPSHOT/build-tools-0.0.2-SNAPSHOT.jar!/qa/suppressions.xml.
[DEBUG] Adding the outputDirectory file:/C:/LAB/PRJ/prj-ejbws/target/classes/ to the Checkstyle class path
[DEBUG] The resource 'qa/checkstyle_N4_JEE.xml' was found as jar:file:/C:/Users/usuario/.m2/repository/com/company/tools/build-tools/0.0.2-SNAPSHOT/build-tools-0.0.2-SNAPSHOT.jar!/qa/checkstyle_JEE.xml.
[DEBUG] The resource 'ubic.properties' was not found with resourceLoader org.codehaus.plexus.resource.loader.ThreadContextClasspathResourceLoader.
[DEBUG] The resource 'ubic.properties' was not found with resourceLoader org.codehaus.plexus.resource.loader.JarResourceLoader.
[DEBUG] The resource 'ubic.properties' was found as C:\LAB\PRJ\ubic.properties.
[INFO] Starting audit...
[INFO] --------------------------------------------
[INFO] BUILD SUCCESS
[INFO] --------------------------------------------
[INFO] Total time: 1.570s
[INFO] Finished at: Thu Feb 20 16:37:05 CET 2014
[INFO] Final Memory: 8M/20M
[INFO] ---------------------------------------------
any clue?
Stop using Maven, run CheckStyle separately. You already have sufficient "clues": sometimes Maven initializes CheckStyle correctly, sometimes not, and depending on unreliable infrastructure is a bad idea.