0

我正在尝试将生菜 6.0.2 部署在连接 AWS elasticache 的 Wildfly 10(定制为部署 OSGI 包)上。连接 URL 如下所示:

RedisURI redisURI = RedisURI.Builder.redis(configProperties.getProperty("ECclusterhost"), Integer.parseInt(configProperties.getProperty("ECclusterport"))).withPassword(pswdcharArray).withSsl(true).build();

独立程序执行良好,但是当我尝试在 wildfly 上部署时,它在调用时出现以下错误:RedisClusterClient.create(redisURI);

原因:org.apache.felix.log.LogException: java.lang.NoClassDefFoundError: javax/net/ssl/SSLParameters ... 42 更多原因:java.lang.ClassNotFoundException: javax.net.ssl.SSLParameters from [Module来自服务模块加载器的“deployment.elasticache-1.0.0.jar:main”]

pom.xml 具有以下依赖项:

<dependency>
    <groupId>io.lettuce</groupId>
    <artifactId>lettuce-core</artifactId>
    <version>6.0.2.RELEASE</version>
    <scope>compile</scope>
</dependency>

<dependency>
    <groupId>org.apache.commons</groupId>
    <artifactId>commons-pool2</artifactId>
    <version>2.9.0</version>
    <scope>compile</scope>
</dependency>

<dependency>
    <groupId>io.netty</groupId>
    <artifactId>netty-common</artifactId>
    <version>4.1.59.Final</version>
    <scope>compile</scope>
</dependency>

<dependency>
    <groupId>io.netty</groupId>
    <artifactId>netty-handler</artifactId>
    <version>4.1.59.Final</version>
    <scope>compile</scope>
</dependency>

<dependency>
    <groupId>io.netty</groupId>
    <artifactId>netty-transport</artifactId>
    <version>4.1.59.Final</version>
    <scope>compile</scope>
</dependency>
<dependency>
    <groupId>io.projectreactor</groupId>
    <artifactId>reactor-core</artifactId>
    <version>3.3.14.RELEASE</version>
    <scope>compile</scope>
</dependency>
 <dependency>
        <groupId>org.reactivestreams</groupId>
        <artifactId>reactive-streams</artifactId>
        <version>1.0.3</version>
       <scope>compile</scope>
        <optional>true</optional>
    </dependency>

由于 javax.net.ssl 是 JDK 8 的一部分,为什么它在与 wildfly-10 一起部署时不可用。为了加快响应时间,我在生菜组问了同样的问题。

更新:

经过几次调整后,原始错误消失了。但是 OSGI 仍然无法部署反应器 API,现在我收到以下错误:

ERROR [com.icare.elasticacheclient] (Thread-91) [MSC service thread 1-7] Invocation of 'init' failed.: java.lang.NoClassDefFoundError: Failed to link reactor/core/publisher/DirectProcessor (Module "deployment.elasticacheclient-1.0.0.jar:main" from Service Module Loader): Failed to link reactor/core/publisher/FluxProcessor (Module "deployment.elasticacheclient-1.0.0.jar:main" from Service Module Loader): org/reactivestreams/Processor

这是导入包在 pom.xml 中的样子

    <Import-Package>
    org.slf4j;version="1.7.7",javax.net.ssl,javax.security.cert
    </Import-Package>
    <Embed-Dependency>lettuce-core,commons-pool2,netty-transport,netty-common,netty-handler,reactor-core,org.reactivestream</Embed-Dependency>
 <Embed-Transitive>true</Embed-Transitive>

不确定反应器的 OSGI 集成是否存在问题。

4

1 回答 1

0

跑了几天马拉松后,我能够解决这个问题。原因之一是 log4j2 API 的版本,因为我使用的是更高版本,但是在 2.8.2 版本之后,log4j-api.jar 文件也包含为 Java 9 编译的文件,并且旧版本的 OSGI 无法理解分包系统。不知何故,javax 包也不是直接取自 JVM。我的最终 pom.xml 文件如下所示:

<?xml version="1.0" encoding="UTF-8"?>

<parent>
    <artifactId>master</artifactId>
    <groupId>com.companyname.projectmaster</groupId>
    <version>1.0.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<packaging>bundle</packaging>
<artifactId>elasticache</artifactId>
<groupId>com.companyname</groupId>

<properties>
    <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.target>1.8</maven.compiler.target>
    <log4j2Version>2.8.2</log4j2Version>
    <slf4j-api.version>1.7.7</slf4j-api.version>
    <io.netty.version>4.1.59.Final</io.netty.version>
</properties>

<dependencies>

    <dependency>
        <groupId>io.lettuce</groupId>
        <artifactId>lettuce-core</artifactId>
        <version>6.0.2.RELEASE</version>
        <scope>compile</scope>
    </dependency>

    <dependency>
        <groupId>org.apache.commons</groupId>
        <artifactId>commons-pool2</artifactId>
        <version>2.9.0</version>
        <scope>compile</scope>
        <optional>true</optional>
    </dependency>

       <dependency>
           <groupId>io.netty</groupId>
           <artifactId>netty-common</artifactId>
           <version>${io.netty.version}</version>
           <scope>compile</scope>
       </dependency>

       <dependency>
           <groupId>io.netty</groupId>
           <artifactId>netty-handler</artifactId>
           <version>${io.netty.version}</version>
           <scope>compile</scope>
       </dependency>

       <dependency>
           <groupId>io.netty</groupId>
           <artifactId>netty-transport</artifactId>
           <version>${io.netty.version}</version>
          <scope>compile</scope>
       </dependency>

    <dependency>
        <groupId>io.projectreactor.tools</groupId>
        <artifactId>blockhound</artifactId>
        <version>1.0.4.RELEASE</version>
        <scope>compile</scope>
    </dependency>

    <dependency>
        <groupId>org.reactivestreams</groupId>
        <artifactId>reactive-streams</artifactId>
        <version>1.0.3</version>
        <scope>compile</scope>

    </dependency>

    <dependency>
        <groupId>io.projectreactor</groupId>
        <artifactId>reactor-core</artifactId>
        <version>3.3.14.RELEASE</version>
       <scope>compile</scope>

    </dependency>


    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-api</artifactId>
        <version>${slf4j-api.version}</version>
        <scope>provided</scope>
    </dependency>

    <dependency>
        <groupId>org.apache.logging.log4j</groupId>
        <artifactId>log4j-core</artifactId>
        <version>${log4j2Version}</version>
        <scope>runtime</scope>
    </dependency>

    <dependency>
        <groupId>org.apache.logging.log4j</groupId>
        <artifactId>log4j-api</artifactId>
        <version>${log4j2Version}</version>
        <scope>runtime</scope>
    </dependency>


    <!-- SLF4J Bridge -->
    <dependency>
        <groupId>org.apache.logging.log4j</groupId>
        <artifactId>log4j-slf4j-impl</artifactId>
        <version>${log4j2Version}</version>
        <scope>runtime</scope>
    </dependency>


</dependencies>
<profiles>

    <profile>
        <id>standalone</id>
        <activation>
            <activeByDefault>false</activeByDefault>
        </activation>
        <properties>
            <redisclusterhost>ElasticacheClusterName</redisclusterhost>
            <redisclusterport>6380</redisclusterport>
            <authpassword>password</authpassword>
            <minidleconnection>2</minidleconnection>
            <maxidleconnection>5</maxidleconnection>
            <maxtotalconnection>5</maxtotalconnection>
        </properties>
    </profile>
</profiles>
<build>
    <resources>
        <resource>
            <directory>src/main/resources</directory>
            <filtering>true</filtering>
        </resource>
    </resources>
    <plugins>
        <plugin>
            <groupId>org.apache.felix</groupId>
            <artifactId>maven-bundle-plugin</artifactId>
            <version>3.2.0</version>
            <extensions>true</extensions>
            <configuration>
                <instructions>
                    <Bundle-SymbolicName>${project.groupId}.${project.artifactId}</Bundle-SymbolicName>
                    <Bundle-Version>1.0.0</Bundle-Version>
                    <Bundle-Activator>com.companyname.ElastiCacheActivator</Bundle-Activator>
                    <Bundle-Vendor>Company Name</Bundle-Vendor>
                    <Bundle-Category>osgi</Bundle-Category>
                    <Export-Package>
                        custom packages to be exported
                    </Export-Package>
                    <Import-Package>
                        org.slf4j;version="1.7.7",javax.net.ssl,javax.security.cert,javax.management
                    </Import-Package>
                   <Embed-Dependency>lettuce-core,commons-pool2,netty-transport,netty-common,netty-handler,reactive-streams,blockhound,reactor-core,log4j-api,log4j-core</Embed-Dependency>
                    <Embed-Transitive>true</Embed-Transitive>
            </instructions>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.6.1</version>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.wildfly.plugins</groupId>
            <artifactId>wildfly-maven-plugin</artifactId>
            <version>1.0.2.Final</version>
            <inherited>true</inherited>
            <configuration>
                <skip>false</skip>
                <filename>${project.build.finalName}.jar</filename>
            </configuration>
        </plugin>
    </plugins>

</build>

<properties>
    <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.target>1.8</maven.compiler.target>
    <log4j2Version>2.8.2</log4j2Version>
    <slf4j-api.version>1.7.7</slf4j-api.version>
    <io.netty.version>4.1.59.Final</io.netty.version>
</properties>

<dependencies>

    <dependency>
        <groupId>io.lettuce</groupId>
        <artifactId>lettuce-core</artifactId>
        <version>6.0.2.RELEASE</version>
        <scope>compile</scope>
    </dependency>

    <dependency>
        <groupId>org.apache.commons</groupId>
        <artifactId>commons-pool2</artifactId>
        <version>2.9.0</version>
        <scope>compile</scope>
        <optional>true</optional>
    </dependency>

       <dependency>
           <groupId>io.netty</groupId>
           <artifactId>netty-common</artifactId>
           <version>${io.netty.version}</version>
           <scope>compile</scope>
       </dependency>

       <dependency>
           <groupId>io.netty</groupId>
           <artifactId>netty-handler</artifactId>
           <version>${io.netty.version}</version>
           <scope>compile</scope>
       </dependency>

       <dependency>
           <groupId>io.netty</groupId>
           <artifactId>netty-transport</artifactId>
           <version>${io.netty.version}</version>
          <scope>compile</scope>
       </dependency>

    <dependency>
        <groupId>io.projectreactor.tools</groupId>
        <artifactId>blockhound</artifactId>
        <version>1.0.4.RELEASE</version>
        <scope>compile</scope>
    </dependency>

    <dependency>
        <groupId>org.reactivestreams</groupId>
        <artifactId>reactive-streams</artifactId>
        <version>1.0.3</version>
        <scope>compile</scope>

    </dependency>

    <dependency>
        <groupId>io.projectreactor</groupId>
        <artifactId>reactor-core</artifactId>
        <version>3.3.14.RELEASE</version>
       <scope>compile</scope>

    </dependency>


    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-api</artifactId>
        <version>${slf4j-api.version}</version>
        <scope>provided</scope>
    </dependency>

    <dependency>
        <groupId>org.apache.logging.log4j</groupId>
        <artifactId>log4j-core</artifactId>
        <version>${log4j2Version}</version>
        <scope>runtime</scope>
    </dependency>

    <dependency>
        <groupId>org.apache.logging.log4j</groupId>
        <artifactId>log4j-api</artifactId>
        <version>${log4j2Version}</version>
        <scope>runtime</scope>
    </dependency>


    <!-- SLF4J Bridge -->
    <dependency>
        <groupId>org.apache.logging.log4j</groupId>
        <artifactId>log4j-slf4j-impl</artifactId>
        <version>${log4j2Version}</version>
        <scope>runtime</scope>
    </dependency>
    <profile>
        <id>standalone</id>
        <activation>
            <activeByDefault>false</activeByDefault>
        </activation>
        <properties>
            <redisclusterhost>ElasticacheClusterName</redisclusterhost>
            <redisclusterport>6380</redisclusterport>
            <authpassword>password</authpassword>
            <minidleconnection>2</minidleconnection>
            <maxidleconnection>5</maxidleconnection>
            <maxtotalconnection>5</maxtotalconnection>
        </properties>
    </profile>
</profiles>
<build>
    <resources>
        <resource>
            <directory>src/main/resources</directory>
            <filtering>true</filtering>
        </resource>
    </resources>
    <plugins>
        <plugin>
            <groupId>org.apache.felix</groupId>
            <artifactId>maven-bundle-plugin</artifactId>
            <version>3.2.0</version>
            <extensions>true</extensions>
            <configuration>
                <instructions>
                    <Bundle-SymbolicName>${project.groupId}.${project.artifactId}</Bundle-SymbolicName>
                    <Bundle-Version>1.0.0</Bundle-Version>
                    <Bundle-Activator>com.companyname.ElastiCacheActivator</Bundle-Activator>
                    <Bundle-Vendor>Company Name</Bundle-Vendor>
                    <Bundle-Category>osgi</Bundle-Category>
                    <Export-Package>
                        custom packages to be exported
                    </Export-Package>
                    <Import-Package>
                        org.slf4j;version="1.7.7",javax.net.ssl,javax.security.cert,javax.management
                    </Import-Package>
                   <Embed-Dependency>lettuce-core,commons-pool2,netty-transport,netty-common,netty-handler,reactive-streams,blockhound,reactor-core,log4j-api,log4j-core</Embed-Dependency>
                    <Embed-Transitive>true</Embed-Transitive>
            </instructions>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.6.1</version>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.wildfly.plugins</groupId>
            <artifactId>wildfly-maven-plugin</artifactId>
            <version>1.0.2.Final</version>
            <inherited>true</inherited>
            <configuration>
                <skip>false</skip>
                <filename>${project.build.finalName}.jar</filename>
            </configuration>
        </plugin>
    </plugins>

</build>
于 2021-02-25T03:16:21.653 回答