I was assigned to an application developed some months ago, but has never been deployed in production. It is a war, with embedded EJB. The target server was in JavaEE 7 (Weblogic 12.2.1), but as this server was not available on our infra, the integration tests have been done with Arquillian on a Glassfish-embedded-3.1.
Yes I know, it is not very logical because Glassfish-3.1 is JavaEE 6 compliant. And moreover, the project is built with some Java 8 features. :)
But no problem, the Integration Tests run well with this configuration. This is the pom for this version :
<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>com.my-company</groupId>
<artifactId>my-project</artifactId>
<version>1.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<log4j.version>2.5</log4j.version>
<cxf.version>3.1.6</cxf.version>
<failOnMissingWebXml>false</failOnMissingWebXml>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.jboss.arquillian</groupId>
<artifactId>arquillian-bom</artifactId>
<version>1.1.11.Final</version>
<scope>import</scope>
<type>pom</type>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>7.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>${log4j.version}</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>${log4j.version}</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.4</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.5</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-email</artifactId>
<version>1.4</version>
<scope>compile</scope>
</dependency>
<!-- CXF DEPENDENCIES -->
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-tools-common</artifactId>
<version>${cxf.version}</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
<version>${cxf.version}</version>
<exclusions>
<!--
This dependency should be excluded since it generates java.lang.IncompatibleClassChangeError
on org.objectweb.asm.ClassVisitor (side effect between 2 JAR versions)
-->
<exclusion>
<groupId>org.ow2.asm</groupId>
<artifactId>asm</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
<version>${cxf.version}</version>
</dependency>
<!-- TEST DEPENDENCIES -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.junit</groupId>
<artifactId>arquillian-junit-container</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.container</groupId>
<artifactId>arquillian-glassfish-embedded-3.1</artifactId>
<version>1.0.0.CR4</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.glassfish.main.extras</groupId>
<artifactId>glassfish-embedded-all</artifactId>
<version>4.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eu.ingwar.tools</groupId>
<artifactId>arquillian-suite-extension</artifactId>
<version>1.1.2</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.0.2</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<encoding>${project.build.sourceEncoding}</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.4.3</version>
<configuration>
<encoding>${project.build.sourceEncoding}</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.9.1</version>
<executions>
<execution>
<id>add-source</id>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>${basedir}/target/generated-sources/java</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
<version>${cxf.version}</version>
<executions>
<execution>
<id>generate-sources</id>
<phase>generate-sources</phase>
<configuration>
<wsdlOptions>
<wsdlOption>
<wsdl>${basedir}/src/main/resources/wsdl/MailService.svc.wsdl</wsdl>
<catalog>${basedir}/src/main/resources/wsdl/catalog.xml</catalog>
</wsdlOption>
</wsdlOptions>
</configuration>
<goals>
<goal>wsdl2java</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
<finalName>my-project</finalName>
</build>
<profiles>
<profile>
<id>integration-tests-glassfish</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.19.1</version>
<configuration>
<includes>
<include>**/*IT.java</include>
</includes>
</configuration>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
There some points that sounds strange to me :
- compiler source & target : 1.8
- javaee-api : 7.0 (is it safe to use 1.8 ??)
- arquillian-glassfish-embedded-3.1 (for a javaee 7 ??)
- glassfish-embedded-all : 4.1 (should it not be linked to the arquillian-glassfish-embedded version ?)
That sounds strange, but the Arquillian tests run fine with this configuration, and these points are not the main goal of this question.
Then, some weeks ago, after been frozen for several months, this project needs to be deployed in production. And this project has never been tested or deployed in another environment on the targeted version of weblogic.
And in fact, the weblogic 12.2.1 was still not available on our infrastructure, so I had to downgrade the project to run on weblogic 12.1.3. (compiler source and target :1.8 / javaee-api:7 / removing diamonds, streams, multiple catch, refactoring the EJB Timers, EJB injection with @EJB because strange behaviours with @Inject, refactore LocaleDate, loadResource in try, ...)
I was so in a hurry that I did not take care of maintaining the ITs configuration. (Though, unit Tests are ok.) The project was deployed successfully and runs fine in production.
Now, I have a little bit time to spend again on this project and I try to put ITs straight, but it is a nightmare and I do not understand everything that happens.
My approach :
- Run as is.
Fails in UT :
java.lang.reflect.InvocationTargetException
Caused by: java.lang.ClassFormatError: Absent Code attribute in method that is not native or abstract in class file javax/mail/search/SearchTerm`
Ok, it is because of the dependency on javaee-api 6.0
.
- Replace dependency
javaee-api
byorg.jboss.spec:jboss-javaee-6.0:1.0.0.Final
and later by version 3.0.3.Final
Fails in IT :
java.lang.NoSuchMethodError: javax.validation.spi.ConfigurationState.getParameterNameProvider()Ljavax/validation/ParameterNameProvider;
at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:367)`
Ok, the jboss-javaee-6.0
depends on javax.validation:validation-api:jar:1.0.0.GA
but the ParameterNameProvider
is in the validation-api 1.1
Huh. I do not understand why ParameterNameProvider is needed? By what? By JUnit4 ? Why validates against Validation 1.1?
- Add the dependence to validation-api 1.1 :
javax.validation:validation-api:1.1.0.Final
.
Fails :
Nov 14, 2016 5:25:58 PM com.sun.enterprise.deployment.archivist.Archivist readAnnotations
SEVERE: javax.persistence.PersistenceContext.synchronization()Ljavax/persistence/SynchronizationType;
Nov 14, 2016 5:25:58 PM org.glassfish.api.ActionReport failure
SEVERE: Exception while deploying the app [7eeab354-b7aa-4559-bb55-b49bb5d33209]
Nov 14, 2016 5:25:58 PM com.sun.enterprise.v3.server.ApplicationLifecycle deploy
SEVERE: Exception during lifecycle processing
java.lang.IllegalStateException: javax.persistence.PersistenceContext.synchronization()Ljavax/persistence/SynchronizationType;. Related annotation information: annotation [@javax.persistence.PersistenceContext(type=TRANSACTION, unitName=, properties=[], name=)] on annotated element [protected javax.persistence.EntityManager `
I understand it fails because SynchronizationType
is since Java Persistence 2.1
that does not exist in JavaEE 6. But again, what implies this need in my project ??? In my dependence tree, I have the jboss-javaee-6.0
that depends on hibernate-jpa-2.0-api
that -if I trust its name- is jpa 2.0 compliant.
Oh, I understand. It is because I have a dependency on the glassfish-embedded-all:4.1
that does not match.
- Replace the version of this dependency to
org.glassfish.main.extras:glassfish-embedded-all:3.1.2.2
And still fails... Just at the beginnnig of the ITs, before the server starts, I have this ERROR :
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running com.kneip.writtennotice.business.boundary.test.OutgoingMessageIT
Nov 14, 2016 6:04:20 PM org.reflections.Reflections scan
INFO: Reflections took 896 ms to scan 2 urls, producing 33 keys and 222 values
Nov 14, 2016 6:04:27 PM org.hibernate.validator.internal.util.Version <clinit>
INFO: HV000001: Hibernate Validator 4.3.0.Final
Nov 14, 2016 6:04:29 PM org.glassfish.flashlight.impl.provider.FlashlightProbeProviderFactory processXMLProbeProviders
SEVERE: MNTG0301:Cannot process XML ProbeProvider, xml = META-INF/gfprobe-provider.xml
java.lang.IllegalStateException: Provider already mapped glassfish:javamail:smtp-transport
at org.glassfish.flashlight.impl.core.ProbeProviderRegistry.registerProbeProvider(ProbeProviderRegistry.java:100)
at org.glassfish.flashlight.impl.provider.FlashlightProbeProviderFactory.registerProvider(FlashlightProbeProviderFactory.java:561)
The server starts, JDBC resources are ok, deployment starts but fails :
Nov 14, 2016 6:06:23 PM org.glassfish.webservices.WSServletContextListener contextInitialized
WARNING: Deployment failed
java.lang.ExceptionInInitializerError
at com.sun.enterprise.security.webservices.CommonServerSecurityPipe. <init>(CommonServerSecurityPipe.java:94)
at com.sun.enterprise.security.webservices.GFServerPipeCreator.createSecurityPipe(GFServerPipeCreator.java:101)
at com.sun.xml.wss.provider.wsit.SecurityTubeFactory.createTube(SecurityTubeFactory.java:167)
at com.sun.xml.ws.assembler.TubeCreator.createTube(TubeCreator.java:89)
at com.sun.xml.ws.assembler.TubelineAssemblerFactoryImpl$MetroTubelineAssembler.createServer(TubelineAssemblerFactoryImpl.java:179)
at com.sun.xml.ws.server.WSEndpointImpl.<init>(WSEndpointImpl.java:199)
at com.sun.xml.ws.server.EndpointFactory.create(EndpointFactory.java:304)
at com.sun.xml.ws.server.EndpointFactory.create(EndpointFactory.java:299)
at com.sun.xml.ws.server.EndpointFactory.createEndpoint(EndpointFactory.java:145)
at com.sun.xml.ws.api.server.WSEndpoint.create(WSEndpoint.java:569)
at com.sun.xml.ws.api.server.WSEndpoint.create(WSEndpoint.java:552)
at com.sun.xml.ws.api.server.WSEndpoint.create(WSEndpoint.java:623)
at org.glassfish.webservices.WSServletContextListener.registerEndpoint(WSServletContextListener.java:282)
....
Caused by: java.lang.IllegalStateException: Failed to find AuthConfigFactory : org.jboss.security.auth.message.config.JBossAuthConfigFactory
at javax.security.auth.message.config.AuthConfigFactory.getFactory(AuthConfigFactory.java:171)
at com.sun.enterprise.security.jmac.config.ConfigHelper.<clinit>(ConfigHelper.java:78)
... 134 more
Caused by: java.lang.ClassNotFoundException: org.jboss.security.auth.message.config.JBossAuthConfigFactory
at org.glassfish.web.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1509)
And now... I do not know how to go on.
Now my pom is :
<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>com.myCompany</groupId>
<artifactId>myProject</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>
<properties>
<!--
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
-->
<maven.compiler.source>1.6</maven.compiler.source>
<maven.compiler.target>1.6</maven.compiler.target>
<log4j.version>2.5</log4j.version>
<cxf.version>3.1.6</cxf.version>
<failOnMissingWebXml>false</failOnMissingWebXml>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.jboss.arquillian</groupId>
<artifactId>arquillian-bom</artifactId>
<version>1.1.11.Final</version>
<scope>import</scope>
<type>pom</type>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.jboss.spec</groupId>
<artifactId>jboss-javaee-6.0</artifactId>
<version>3.0.3.Final</version>
<type>pom</type>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>1.1.0.Final</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>${log4j.version}</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>${log4j.version}</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.4</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.5</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-email</artifactId>
<version>1.4</version>
<scope>compile</scope>
</dependency>
<!-- CXF DEPENDENCIES -->
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-tools-common</artifactId>
<version>${cxf.version}</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
<version>${cxf.version}</version>
<exclusions>
<!--
This dependency should be excluded since it generates java.lang.IncompatibleClassChangeError
on org.objectweb.asm.ClassVisitor (side effect between 2 JAR versions)
-->
<exclusion>
<groupId>org.ow2.asm</groupId>
<artifactId>asm</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
<version>${cxf.version}</version>
</dependency>
<!-- TEST DEPENDENCIES -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.junit</groupId>
<artifactId>arquillian-junit-container</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.container</groupId>
<artifactId>arquillian-glassfish-embedded-3.1</artifactId>
<version>1.0.0.CR4</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.glassfish.main.extras</groupId>
<artifactId>glassfish-embedded-all</artifactId>
<version>3.1.2.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eu.ingwar.tools</groupId>
<artifactId>arquillian-suite-extension</artifactId>
<version>1.1.2</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.0.2</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<encoding>${project.build.sourceEncoding}</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.4.3</version>
<configuration>
<encoding>${project.build.sourceEncoding}</encoding>
</configuration>
</plugin>
<!-- Addeed to test compile in one pass. Not needed by Eclipse -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.9.1</version>
<executions>
<execution>
<id>add-source</id>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>${basedir}/target/generated-sources/java</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
<version>${cxf.version}</version>
<executions>
<execution>
<id>generate-sources</id>
<phase>generate-sources</phase>
<configuration>
<wsdlOptions>
<wsdlOption>
<wsdl>${basedir}/src/main/resources/wsdl/MailService.svc.wsdl</wsdl>
<catalog>${basedir}/src/main/resources/wsdl/catalog.xml</catalog>
</wsdlOption>
</wsdlOptions>
</configuration>
<goals>
<goal>wsdl2java</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
<finalName>written-notice</finalName>
</build>
<profiles>
<profile>
<id>integration-tests-glassfish</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.19.1</version>
<configuration>
<includes>
<include>**/*IT.java</include>
</includes>
</configuration>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
Can somebody help me ?