2016-06-07 71 views
0

所以我有一個Maven項目,我最終建設成一個罐子,看起來像:的NoClassDefFoundError雖然使用Eclipse的Cloud Foundry插件

C:\Users\myTest\TESTJAR-1.0-jar-with-dependencies.jar

如果我把使用命令行其部署精細到Cloud Foundry:

cf push newProject -p C:\Users\myTest\TESTJAR-1.0-jar-with-dependencies.jar

然而,當我試圖使用插件從Eclipse的部署,我得到以下

'java.lang.NoClassDefFoundError:org.slf4j.LoggerFactory'

任何幫助,將不勝感激

enter image description here

的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> 

<groupId>test.myTest</groupId> 
<artifactId>TESTJAR</artifactId> 
<version>1.0</version> 
<packaging>jar</packaging> 

<name>test</name> 
<url>http://maven.apache.org</url> 

<properties> 
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 
<java.version>1.8</java.version> 
<maven.compiler.source>1.8</maven.compiler.source> 
<maven.compiler.target>1.8</maven.compiler.target> 
</properties> 

<dependencies> 

<dependency> 
<groupId>commons-fileupload</groupId> 
<artifactId>commons-fileupload</artifactId> 
<version>1.2</version> 
</dependency> 

<dependency> 
    <groupId>junit</groupId> 
    <artifactId>junit</artifactId> 
    <version>3.8.1</version> 
    <scope>test</scope> 
</dependency> 



<!-- http://mvnrepository.com/artifact/ch.qos.logback/logback-classic --> 
<dependency> 
<groupId>ch.qos.logback</groupId> 
<artifactId>logback-classic</artifactId> 
<version>1.1.7</version> 
</dependency> 


<dependency> 
<groupId>com.github.lalyos</groupId> 
<artifactId>jfiglet</artifactId> 
<version>0.0.7</version> 
</dependency> 

<dependency> 
<groupId>com.google.guava</groupId> 
<artifactId>guava</artifactId> 
<version>19.0</version> 
</dependency> 


<dependency> 
<groupId>com.google.code.gson</groupId> 
<artifactId>gson</artifactId> 
<version>2.6.1</version> 
</dependency> 

<dependency> 
<groupId>com.thoughtworks.xstream</groupId> 
<artifactId>xstream</artifactId> 
<version>1.4.8</version> 
</dependency> 


<dependency> 
<groupId>com.sparkjava</groupId> 
<artifactId>spark-core</artifactId> 
<version>2.3</version> 

<exclusions> 
    <exclusion> 
    <groupId>org.slf4j</groupId> 
    <artifactId>slf4j-log4j12</artifactId> 
    </exclusion> 
    <exclusion> 
    <groupId>log4j</groupId> 
    <artifactId>log4j</artifactId> 
    </exclusion> 
</exclusions> 

</dependency> 

<dependency> 
<groupId>com.microsoft.sqlserver</groupId> 
<artifactId>sqljdbc4</artifactId> 
<version>4.0</version> 
</dependency> 

</dependencies> 
<build> 
<plugins> 

<plugin> 
    <groupId>org.apache.maven.plugins</groupId> 
    <artifactId>maven-shade-plugin</artifactId> 
    <version>2.4.3</version> 
    <configuration> 
    </configuration> 
    <executions> 
    <execution> 
     <phase>package</phase> 
     <goals> 
     <goal>shade</goal> 
     </goals> 
    </execution> 
    </executions> 
</plugin> 

<plugin> 
<artifactId>maven-assembly-plugin</artifactId> 
<executions> 
    <execution> 
    <phase>package</phase> 
    <goals> 
     <goal>single</goal> 
    </goals> 
    </execution> 
</executions> 
<configuration> 

    <archive> 
    <manifest> 
    <addClasspath>true</addClasspath> 
    <mainClass>com.myTest.Main</mainClass> 
    </manifest> 
    </archive> 

    <descriptorRefs> 
    <descriptorRef>jar-with-dependencies</descriptorRef> 
    </descriptorRefs> 

    </configuration> 
    </plugin> 
    </plugins> 
    </build> 
    </project>' 

回答

0

瓶打包的應用程序可以推到Cloud Foundry使用Eclipse Cloud Foundry Tools(CFT)的兩種方式:

  1. 在Eclipse Maven項目中指定清單YAML文件,該文件指向要推入的文件系統中的jar,使用「path」屬性。例如,在一個工作區項目,MyTestMavenProject,你會碰到這樣的:

MyTestMavenProject/manifest.yml

與清單文件的內容

--- 
applications: 
- name: testjarapp 
    path: C:\Users\myTest\TESTJAR-1.0-jar-with-dependencies.jar 

拖放項目包含此清單文件到Eclipse服務器視圖中的Cloud Foundry目標。

  1. 在沒有清單文件的情況下拖放Maven項目,並且在推送到Cloud Foundry之前,CFT將自動打包該應用程序。但是,這種機制對於jar打包的應用程序有一些已知問題。在某些情況下,需要該項目被刷新之前人工拖動/降:

    • 刷新該項目(通常F5)
    • 右鍵單擊項目:Maven的 - >更新項目
    • 拖/放再次Maven項目到在服務器鑑於CF的目標,看看它是否正確部署

有是這裏跟蹤該問題的錯誤:

https://bugs.eclipse.org/bugs/show_bug.cgi?id=495814

CFT里程碑大致公佈每6周,所以Eclipse的霓虹燈(4.6)之後的下一個里程碑將有各種錯誤修復和改進了的罐子打包的應用程序的部署。