首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何解决Camel3胖罐创建异常?

如何解决Camel3胖罐创建异常?
EN

Stack Overflow用户
提问于 2022-09-30 18:42:28
回答 1查看 140关注 0票数 0

我用阿帕奇骆驼3.18.2女巫骆驼主。为了创建一个胖jar,我在我的pom.xml中配置了以下两个插件:

代码语言:javascript
复制
  <plugin>
    <groupId>org.apache.camel</groupId>
    <artifactId>camel-maven-plugin</artifactId>
    <version>3.18.2</version>
    <executions>
      <execution>
        <phase>package</phase>
        <goals>
          <goal>prepare-fatjar</goal>
        </goals>
      </execution>
    </executions>
  </plugin>
  
  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-assembly-plugin</artifactId>
    <configuration>
      <archive>
        <manifest>
          <mainClass>de.powerstat.camel.homeautomation.MainApp</mainClass>
        </manifest>
      </archive>
    </configuration>
    <executions>
      <execution>
        <id>make-assembly</id>
        <phase>package</phase>
        <goals>
          <goal>single</goal>
        </goals>
      </execution>
    </executions>
  </plugin>

作为受抚养人,我有:

代码语言:javascript
复制
<dependencies>
  <dependency>
    <groupId>org.apache.camel</groupId>
    <artifactId>camel-core</artifactId>
  </dependency>

  <dependency>
    <groupId>org.apache.camel</groupId>
    <artifactId>camel-main</artifactId>
  </dependency>

  <dependency>
    <groupId>org.apache.camel</groupId>
    <artifactId>camel-test</artifactId>
    <scope>test</scope>
  </dependency>

  <dependency>
    <groupId>org.apache.camel</groupId>
    <artifactId>camel-netty</artifactId>
  </dependency>

  <dependency>
    <groupId>org.apache.camel</groupId>
    <artifactId>camel-stream</artifactId>
  </dependency>

  <dependency>
    <groupId>org.apache.camel</groupId>
    <artifactId>camel-paho</artifactId>
  </dependency>

  <dependency>
    <groupId>org.apache.camel</groupId>
    <artifactId>camel-quartz</artifactId>
  </dependency>

  <dependency>
     <groupId>de.powerstat.camel.component</groupId>
     <artifactId>camel-fbaha</artifactId>
    <version>1.0-SNAPSHOT</version>
  </dependency>

  <dependency>
     <groupId>de.powerstat.camel.component</groupId>
     <artifactId>camel-fbtr64</artifactId>
    <version>1.0-SNAPSHOT</version>
  </dependency>

  <dependency>
    <groupId>org.openmuc</groupId>
    <artifactId>jsml</artifactId>
    <version>1.1.2</version>
  </dependency>

  <dependency>
    <groupId>org.apache.logging.log4j</groupId>
    <artifactId>log4j-api</artifactId>
    <version>2.18.0</version>
    <scope>runtime</scope>
  </dependency>

  <dependency>
    <groupId>org.apache.logging.log4j</groupId>
    <artifactId>log4j-core</artifactId>
    <version>2.18.0</version>
    <scope>runtime</scope>
  </dependency>

  <dependency>
    <groupId>org.apache.logging.log4j</groupId>
    <artifactId>log4j-slf4j-impl</artifactId>
    <version>2.18.0</version>
    <scope>runtime</scope>
  </dependency>

</dependencies>

但是在运行mvn干净安装过程中,我得到了:

代码语言:javascript
复制
[INFO] --- camel-maven-plugin:3.18.2:prepare-fatjar (default) @ myhome ---
[INFO] Found 5 Camel type converter loaders from project classpath
[INFO]
[INFO] --- maven-assembly-plugin:2.2-beta-5:single (make-assembly) @ myhome ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-assembly-plugin:2.2-beta-5:single (make-assembly) on project myhome: Error reading assemblies: No assembly descriptors found. -> [Help 1]

[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
Exception in thread "ivy-httpclient-shutdown-handler" java.lang.NoClassDefFoundError: 
org/apache/http/impl/conn/PoolingHttpClientConnectionManager$2
  at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.shutdown(PoolingHttpClientConnectionManager.java:413)
  at org.apache.http.impl.client.HttpClientBuilder$2.close(HttpClientBuilder.java:1244)
  at org.apache.http.impl.client.InternalHttpClient.close(InternalHttpClient.java:201)
  at org.apache.ivy.util.url.HttpClientHandler.close(HttpClientHandler.java:357)
  at org.apache.ivy.util.url.HttpClientHandler$1.run(HttpClientHandler.java:84)
  at java.base/java.lang.Thread.run(Thread.java:833)
Caused by: java.lang.ClassNotFoundException: org.apache.http.impl.conn.PoolingHttpClientConnectionManager$2
  at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(SelfFirstStrategy.java:50)
  at org.codehaus.plexus.classworlds.realm.ClassRealm.unsynchronizedLoadClass(ClassRealm.java:271)
  at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:247)
  at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:239)
  ... 6 more

在我看来,这是一个隐式依赖,还没有被camel-maven插件添加。

那么我的问题是如何解决这个问题呢?

我还尝试使用maven-阴影插件,而不是maven-程序集-插件:

代码语言:javascript
复制
  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-shade-plugin</artifactId>
    <version>3.4.0</version>
    <executions>
      <execution>
        <phase>package</phase>
        <goals>
          <goal>shade</goal>
        </goals>
        <configuration>
          <createDependencyReducedPom>true</createDependencyReducedPom>
          <filters>
            <filter>
              <artifact>*:*</artifact>
              <excludes>
                <exclude>META-INF/*.SF</exclude>
                <exclude>META-INF/*.DSA</exclude>
                <exclude>META-INF/*.RSA</exclude>
              </excludes>
            </filter>
          </filters>
        </configuration>
      </execution>
    </executions>
  </plugin>

然后,在执行过程中,除了以下异常外,还会产生一个fat jar:

代码语言:javascript
复制
[ERROR] 2022-09-30T22:04:48,426 15612/22 org.apache.camel.processor.errorhandler.DefaultErrorHandler Failed delivery for (MessageId: 
08B251E5AD78E72-0000000000000000 on ExchangeId: 
08B251E5AD78E72-0000000000000000). Exhausted after     
delivery attempt: 1 caught: 
org.apache.camel.InvalidPayloadException: No body available of type: java.lang.Integer but has type: 
java.lang.String on: Message. Caused by: No type converter available to convert from type: java.lang.String to the required type: java.lang.Integer. Exchange[]. Caused by: 
[org.apache.camel.NoTypeConversionAvailableException - No type converter available to convert from type: 
java.lang.String to the required type: java.lang.Integer]

因此,它看起来像阴影插件,创造了一个胖罐子,但遗漏了一些骆驼的依赖。

也许这件事可以用一种或另一种方式解决?

最后但同样重要的是,主要问题是如何创建一个完整且工作正常的Camel3胖罐子?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-10-01 16:42:44

基于错误消息

读取程序集时出错:没有找到程序集描述符。

看起来您丢失了程序集描述符。你需要定义描述符或descriptorRef

descriptor示例:

代码语言:javascript
复制
<project>
  [...]
  <build>
    [...]
    <plugins>
      <plugin>
        <artifactId>maven-assembly-plugin</artifactId>
        <version>3.4.2</version>
        <configuration>
          <descriptors>
            <descriptor>src/assembly/src.xml</descriptor>
          </descriptors>
        </configuration>
        [...]
</project>

descriptorRef示例:

代码语言:javascript
复制
<project>
  [...]
  <build>
    [...]
    <plugins>
      <plugin>
        <!-- NOTE: We don't need a groupId specification because the group is
             org.apache.maven.plugins ...which is assumed by default.
         -->
        <artifactId>maven-assembly-plugin</artifactId>
        <version>3.4.2</version>
        <configuration>
          <descriptorRefs>
            <descriptorRef>jar-with-dependencies</descriptorRef>
          </descriptorRefs>
        </configuration>
        [...]
</project>

如果定义了一个descriptor,请参见关于描述符格式的如下内容。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/73912807

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档