Arquillian不在Weblogic 12c远程服务器中部署

时间:2019-06-26 16:30:33

标签: maven java-ee weblogic12c remote-server jboss-arquillian

我正在使用Arquillian在Weblogic 12c中运行集成测试,但是它没有部署在远程服务器中。

如今,Arquillian是通过Windows服务器通过Jenkins启动的,而远程服务器是在Linux上使用Weblogic 12c启动的。

我尝试了以下操作:

  • Windows Solaris

  • Windows Windows

  • Solaris Solaris

我看到Arquillian使用“ weblogic.Deployer ”,正如我们在https://docs.oracle.com/cd/E24329_01/web.1211/e24443/wldeployer.htm#DEPGD333中看到的那样,部署具有“ 上传”参数。

  

-上传   将指定的部署文件(包括部署计划和备用部署描述符)传输到Administration Server。当您位于远程计算机上并且无法通过其他方式将部署文件复制到管理服务器时,请使用此选项。在分发和部署之前,应将应用程序文件上载到WebLogic Server管理服务器上载目录。

是否可以通过某种方式在部署期间向Arquillian使用此参数?

我正在使用Weblogic 12.2.1.3.0。


ProtocoloTest.java

package br.gov.mg.fazenda.protocolonegocio.testeintegracao;


import static org.junit.Assert.assertNotNull;

import java.io.File;
import java.io.IOException;

import javax.ejb.EJB;
import javax.xml.parsers.ParserConfigurationException;

import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.shrinkwrap.api.Archive;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.asset.EmptyAsset;
import org.jboss.shrinkwrap.api.spec.EnterpriseArchive;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.jboss.shrinkwrap.resolver.api.maven.Maven;
import org.jboss.shrinkwrap.resolver.api.maven.ScopeType;
import org.junit.Test;
import org.junit.jupiter.api.DisplayName;
import org.junit.runner.RunWith;
import org.xml.sax.SAXException;

import com.unitech.ufw.exception.UFWException;

import gov.sefmg.sicaf.protocolo.controller.ProtocoloFacadeEJB3;
import gov.sefmg.sicaf.protocolo.model.ProtocoloModel;
import gov.sefmg.sicaf.util.identificacao.IdentificacaoCPF;
import gov.sefmg.sicaf.util.identificacao.SolicitanteModel;

@RunWith(Arquillian.class)
public class ProtocoloTest { 

    //Deve ser mantido com Deployents, outras configurações a injeção não funciona.
    @Deployment
    @DisplayName("Empacotando o EAR de testes")
    public static Archive<?> createDeployment() throws ParserConfigurationException, SAXException, IOException {

        File[] lFiles = Maven.configureResolver()
                // Define para utilizar os artefatos disponíveis no repositório local (após o "clean install")
                //.withClassPathResolution(false)
                // Define as configurações do Maven que devem ser utilizadas (contém o usuário, senha e repositório)
                .fromFile("C:/Ambiente/maven/apache-maven-3.5.2/conf/settings.xml")
                // Carrega o arquivo "pom.xml" para a identificação das dependências
                .loadPomFromFile("pom.xml")
                // Importa tudo que é "provided" de forma a garantir que tudo necessário seja disponibilizado
                .importDependencies(ScopeType.PROVIDED)
                // Se baseia no próprio projeto a ser testado
                .resolve("gov.sefmg:protocolonegocio:1.0.0")
                // Garante que o próprio projeto seja incluído
                .withTransitivity()
                .asFile();

        // Gera o JAR com as classes de teste
        JavaArchive lJavaArchive = ShrinkWrap.create(JavaArchive.class, "testeArquillianProtocolo.jar")
                .addClasses(ProtocoloTest.class)
                .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");

        //Criando o ear, não é necessario de jogar tudo, apenas o que achar necessário para os testes.
        final EnterpriseArchive lEnterpriseArchive = ShrinkWrap.create(EnterpriseArchive.class, "testeArquillianProtocolo.ear")
                .setApplicationXML("application.xml") // application.xml com configurações otimizadas, este arquivo esta presente em \src\test\resources
                .addAsApplicationResource(new File("src/test/resources/weblogic-application.xml"))
                .addAsLibrary(lJavaArchive)
                .addAsLibraries(lFiles);    

        //Sysout no console do ear configurado, sempre verificar se foi criado corretamente com as configurações
        System.out.println(lEnterpriseArchive.toString(true));

        return lEnterpriseArchive;
    }

    @EJB(lookup="ProtocoloFacadeEJB3")
    ProtocoloFacadeEJB3 protocoloFacadeEJB3;

    @Test
    @DisplayName("Testa a alteração de um protocolo (Atualmente só ocorre para ITCD). Falhará pois é um protocolo fake.")
    public void testAlterarProtocoloInvalido() throws UFWException {

        NumeroProtocolo lNumeroProtocoloFake = new NumeroProtocolo(999900000012L);

        ProtocoloModel lProtocoloModel = new ProtocoloModel();
        lProtocoloModel.setProtocolo(lNumeroProtocoloFake);
        lProtocoloModel.setDataSolicitacao(new Date());

        SolicitanteModel lSolicitante = new SolicitanteModel();
        lSolicitante.setIdentificacao(new IdentificacaoCPF("88888888888"));
        lSolicitante.setNome("Teste Arquillian");

        lProtocoloModel.setSolicitante(lSolicitante);

        try {
            protocoloFacadeEJB3.alterar(lProtocoloModel);

            // Se não lançar exceção, então indica que a validação falhou.
            assertTrue(false);

        } catch (SicafAplicacaoException e) {
            assertTrue(e.getCodigoErro().equals(SicafConstantesDicionarioIf.PAR_REGISTRO_JA_REMOVIDO));
        }
    }

}

pom.xml

<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>gov.sefmg</groupId>
        <artifactId>projeto-sefmg</artifactId>
        <version>5.8</version>
    </parent>

    <artifactId>protocolonegocio</artifactId>
    <packaging>ejb</packaging>
    <version>1.0.0</version>
    <name>protocolonegocio</name>

    <dependencies>
        <dependency>
            <groupId>org.jboss.arquillian.junit</groupId>
            <artifactId>arquillian-junit-container</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.jboss.arquillian.container</groupId>
            <artifactId>arquillian-wls-remote-12.1.x</artifactId>
            <version>1.0.1.Final</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>org.jboss.shrinkwrap.descriptors</groupId>
            <artifactId>shrinkwrap-descriptors-impl-javaee</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.jboss.shrinkwrap.resolver</groupId>
            <artifactId>shrinkwrap-resolver-impl-maven</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.jboss.shrinkwrap.resolver</groupId>
            <artifactId>shrinkwrap-resolver-api-maven-embedded</artifactId>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>org.junit.platform</groupId>
            <artifactId>junit-platform-launcher</artifactId>
            <version>1.5.0-M1</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.junit.vintage</groupId>
            <artifactId>junit-vintage-engine</artifactId>
            <version>5.3.1</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-api</artifactId>
            <version>5.4.2</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-engine</artifactId>
            <version>5.4.2</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.opentest4j</groupId>
            <artifactId>opentest4j</artifactId>
            <version>1.1.1</version>
            <scope>provided</scope>
        </dependency>
    </dependencies>
    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.jboss.arquillian</groupId>
                <artifactId>arquillian-bom</artifactId>
                <version>1.4.1.Final</version>
                <scope>import</scope>
                <type>pom</type>
            </dependency>
            <dependency>
                <groupId>org.jboss.shrinkwrap.resolver</groupId>
                <artifactId>shrinkwrap-resolver-bom</artifactId>
                <version>3.1.3</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
            <dependency>
                <groupId>org.jboss.shrinkwrap.descriptors</groupId>
                <artifactId>shrinkwrap-descriptors-bom</artifactId>
                <version>2.0.0</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>
.
.
.
</project>

arquillian.xml

<?xml version="1.0"?>
<arquillian
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns="http://jboss.org/schema/arquillian"
    xsi:schemaLocation="http://jboss.org/schema/arquillian
    http://jboss.org/schema/arquillian/arquillian_1_0.xsd">

    <engine>
        <!-- Exporta o EAR gerado para posterior analise. -->
        <property name="deploymentExportPath">target/deployments</property>
    </engine>

    <!-- https://docs.jboss.org/author/display/ARQ/WLS+12.1+-+Remote -->
    <container qualifier="weblogic" default="true">
        <protocol type="Servlet 3.0" />
        <configuration>
            <!-- Necessario utilizar como base o 12.1 pois as bibliotecas do 12.2 
                tem conflito com o Arquillian e lancam excecao. -->
            <property name="wlHome">C:\Ambiente\as\Oracle\Middleware\wlserver_12.1</property>
            <!-- Necessario para executar diretamente a classe do teste de integracao. 
                Para o funcionamento via "clean install" eh necessario ter as propriedades 
                abaixo configuradas no "pom.xml" ou passadas via argumentos junto com o "clean 
                install", visto que elas sao sobrescritas via "systemPropertyVariables" do 
                plugin "maven-failsafe-plugin". -->
            <property name="adminUrl">t3://testarquillian:7001</property>
            <property name="adminUserName">weblogic</property>
            <property name="adminPassword">welcome1</property>
            <property name="target">AdminServer</property>
        </configuration>
    </container>
</arquillian>

application.xml

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<application xmlns="http://xmlns.jcp.org/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="7"
    xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/application_7.xsd">
    <display-name>ear</display-name>
    <module>
        <ejb>lib/protocolonegocio-1.0.0.jar</ejb>
    </module>
    <library-directory>lib</library-directory>
</application>

weblogic-application.xml

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<wls:weblogic-application
    xmlns:wls="http://xmlns.oracle.com/weblogic/weblogic-application"
    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/javaee_7.xsd http://xmlns.oracle.com/weblogic/weblogic-application http://xmlns.oracle.com/weblogic/weblogic-application/1.7/weblogic-application.xsd">

    <!--weblogic-version:12.2.1 -->

    <wls:application-param>
        <wls:param-name>webapp.encoding.default</wls:param-name>
        <wls:param-value>UTF-8</wls:param-value>
    </wls:application-param>

    <wls:library-ref>
        <wls:library-name>siare-client</wls:library-name>
    </wls:library-ref>

    <wls:library-ref>
        <wls:library-name>lib-sef</wls:library-name>
    </wls:library-ref>

    <wls:library-ref>
        <wls:library-name>siare-libs</wls:library-name>
    </wls:library-ref>

</wls:weblogic-application>

Arquillian正在启动以下错误。

  

org.jboss.arquillian.container.spi.client.container.DeploymentException:java.lang.RuntimeException:[Deployer:149003]无法访问“ /Windows/TEMP/arquillian4372177899218720179testeArquillianProtocolo.ear/testeArquillianProtocolo.ear”中的应用程序源信息,用于应用程序“ testeArquillianProtocolo”。具体错误是:不存在应用程序文件。

Stacktrace

[INFO] -------------------------------------------------------
[INFO]  T E S T S
[INFO] -------------------------------------------------------
[INFO] Running ProtocoloTest
Problem creating dummy orb: org.omg.CORBA.COMM_FAILURE:   vmcid: SUN  minor code: 203  completed: No
testeArquillianProtocolo.ear:
/META-INF/
/META-INF/application.xml
/META-INF/weblogic-application.xml
/lib/
/lib/testeArquillianProtocolo.jar
/lib/junit-platform-launcher-1.5.0-M1.jar
/lib/apiguardian-api-1.0.0.jar
/lib/junit-platform-engine-1.5.0-M1.jar
/lib/junit-vintage-engine-5.3.1.jar
/lib/junit-4.12.jar
/lib/hamcrest-core-1.3.jar
/lib/junit-jupiter-api-5.4.2.jar
/lib/junit-platform-commons-1.4.2.jar
/lib/junit-jupiter-engine-5.4.2.jar
/lib/opentest4j-1.1.1.jar
/protocolonegocio-1.0.0.jar
[ERROR] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 11.438 s <<< FAILURE! - in ProtocoloTest
[ERROR] ProtocoloTest  Time elapsed: 11.438 s  <<< ERROR!
org.jboss.arquillian.container.spi.client.container.DeploymentException: java.lang.RuntimeException: [Deployer:149003]Unable to access application source information in "/Windows/TEMP/arquillian4372177899218720179testeArquillianProtocolo.ear/testeArquillianProtocolo.ear" for application "testeArquillianProtocolo". The specific error is: No application files exist.
Caused by: javax.management.RuntimeMBeanException: java.lang.RuntimeException: [Deployer:149003]Unable to access application source information in "/Windows/TEMP/arquillian4372177899218720179testeArquillianProtocolo.ear/testeArquillianProtocolo.ear" for application "testeArquillianProtocolo". The specific error is: No application files exist.
Caused by: java.lang.RuntimeException: [Deployer:149003]Unable to access application source information in "/Windows/TEMP/arquillian4372177899218720179testeArquillianProtocolo.ear/testeArquillianProtocolo.ear" for application "testeArquillianProtocolo". The specific error is: No application files exist.

[INFO] 
[INFO] Results:
[INFO] 
[ERROR] Errors: 
[ERROR]   ProtocoloTest » Deployment java.lang.RuntimeException: [Deployer:149003]Unable...
[INFO] 
[ERROR] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0
[INFO] 
[INFO] 
[INFO] --- maven-failsafe-plugin:3.0.0-M3:verify (default) @ protocolonegocio ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 17.976 s
[INFO] Finished at: 2019-06-13T16:31:17-03:00
[INFO] Final Memory: 16M/491M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-failsafe-plugin:3.0.0-M3:verify (default) on project protocolonegocio: There are test failures.
[ERROR] 
[ERROR] Please refer to C:\Jenkins\jobs\AMBIENTE SIARE QUEBRA DE ARQUITETURA\jobs\SIARE (QA) - PROTOCOLO - NEGOCIO - HOM - TESTE\workspace\negocio\..\negocio\target\failsafe-reports for the individual test results.
[ERROR] Please refer to dump files (if any exist) [date].dump, [date]-jvmRun[N].dump and [date].dumpstream.
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=512m; support was removed in 8.0
Build step 'Invoke top-level Maven targets' marked build as failure
[WeblogicDeploymentPlugin] - Build didn't finish successfully. The plugin execution is disabled.
[INFO] ------------------------------------------------------------------------
[INFO] DEPLOYMENT UNSTABLE
[INFO] ------------------------------------------------------------------------
Finished: FAILURE

任何人都可以给小费吗?

1 个答案:

答案 0 :(得分:0)

我找到了解决方法。

我将项目更改为使用“ arquillian-wls-remote-rest”,而不是以前的版本。


pom.xml

我更改了依赖关系...

<dependency>
    <groupId>org.jboss.arquillian.container</groupId>
    <artifactId>arquillian-wls-remote-12.1.x</artifactId>
    <version>1.0.1.Final</version>
    <scope>provided</scope>
</dependency>

对于依赖性...

<dependency>
    <groupId>org.jboss.arquillian.container</groupId>
    <artifactId>arquillian-wls-remote-rest</artifactId>
    <version>1.0.1.Final</version>
    <scope>test</scope>
</dependency>

然后在文件“ arquillian.xml ”中,将协议从“ t3 ”更改为“ http ”。

我希望能有所帮助。