私は数か月前に開発されたアプリケーションに割り当てられましたが、本番環境にデプロイされたことはありません。これは、EJB が組み込まれた戦争です。ターゲット サーバーは JavaEE 7 (Weblogic 12.2.1) でしたが、このサーバーは私たちのインフラでは利用できなかったため、統合テストは Glassfish-embedded-3.1 上の Arquillian で行われました。
はい、わかっています。Glassfish-3.1 は JavaEE 6 に準拠しているため、あまり論理的ではありません。さらに、プロジェクトはいくつかの Java 8 機能で構築されています。:)
しかし問題ありません。統合テストはこの構成でうまく動作します。これは、このバージョンの pom です。
<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>
私には奇妙に聞こえるいくつかの点があります:
- コンパイラのソースとターゲット: 1.8
- javaee-api : 7.0 (1.8 を使用しても安全ですか??)
- arquillian-glassfish-embedded-3.1 (javaee 7 の場合 ??)
- glassfish-embedded-all : 4.1 (arquillian-glassfish-embedded バージョンにリンクすべきではありませんか?)
奇妙に聞こえるかもしれませんが、Arquillian テストはこの構成で問題なく実行されます。これらの点は、この質問の主な目的ではありません。
その後、数週間前、数か月凍結された後、このプロジェクトを本番環境にデプロイする必要があります。また、このプロジェクトは、ターゲット バージョンの weblogic の別の環境でテストまたはデプロイされたことはありません。
実際、weblogic 12.2.1 は私たちのインフラストラクチャではまだ利用できなかったため、プロジェクトをダウングレードして weblogic 12.1.3 で実行する必要がありました。(コンパイラ ソースとターゲット:1.8 / javaee-api:7 / ダイアモンド、ストリーム、複数のキャッチの削除、EJB タイマーのリファクタリング、@EJB による EJB インジェクション @Inject の奇妙な動作のため、LocaleDate のリファクタリング、try の loadResource など)
私はあまりにも急いでいたので、IT 構成の維持に気を配っていませんでした。(ただし、単体テストは問題ありません。) プロジェクトは正常に展開され、運用環境で正常に実行されます。
今、私はこのプロジェクトに再び費やす時間が少しあり、IT を正そうとしていますが、それは悪夢であり、起こっていることすべてを理解していません.
私のアプローチ:
- そのまま実行します。
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`
わかりました、それは への依存が原因ですjavaee-api 6.0
。
- 依存関係
javaee-api
をorg.jboss.spec:jboss-javaee-6.0:1.0.0.Final
バージョン 3.0.3.Final 以降に置き換えます。
IT での失敗 :
java.lang.NoSuchMethodError: javax.validation.spi.ConfigurationState.getParameterNameProvider()Ljavax/validation/ParameterNameProvider;
at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:367)`
OK、jboss-javaee-6.0
依存しますjavax.validation:validation-api:jar:1.0.0.GA
がParameterNameProvider
、validation-api 1.1 にあります
は。ParameterNameProvider が必要な理由がわかりません。何によって?JUnit4で?Validation 1.1 に対して検証するのはなぜですか?
- 依存関係を validation-api 1.1 に追加します
javax.validation:validation-api:1.1.0.Final
。
失敗:
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 `
SynchronizationType
JavaEE 6には存在しないため、失敗することを理解していますJava Persistence 2.1
。しかし、繰り返しになりますが、私のプロジェクトでこの必要性を意味するのは何ですか??? 私の依存ツリーには、jboss-javaee-6.0
それに依存するhibernate-jpa-2.0-api
ものがあります-その名前が信頼できる場合-jpa 2.0に準拠しています。
ああ、わかりました。glassfish-embedded-all:4.1
一致しないに依存しているためです。
- この依存関係のバージョンを次のように置き換えます
org.glassfish.main.extras:glassfish-embedded-all:3.1.2.2
それでも失敗します...サーバーが起動する前のITの開始時に、次のエラーが発生しました:
-------------------------------------------------------
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)
サーバーが起動し、JDBC リソースは問題なく、デプロイが開始されますが失敗します:
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)
そして今... どうすればいいのかわかりません。
今私のポンは:
<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>
誰かが私を助けることができますか?