-1
我得到ClassNotFoundException的異常,當我與Maven打包我的代碼,然後用啓動時:的ClassNotFoundException開始春季啓動應用程序
java -jar target\factorify-1.0-SNAPSHOT.jar
我可以看到,在我的「胖罐子」是文件夾的lib具有所有依賴性我可以手動找到拋出ClassNotFoundException的類。
清單:
Manifest-Version: 1.0
Archiver-Version: Plexus Archiver
Built-By: Jakub
Start-Class: me.factorify.server.Application
Spring-Boot-Version: 1.2.0.RELEASE
Created-By: Apache Maven 3.1.1
Build-Jdk: 1.8.0_25
Main-Class: org.springframework.boot.loader.JarLauncher
的pom.xml:
<packaging>jar</packaging>
<properties>
<org.springframework.version>4.1.3.RELEASE</org.springframework.version>
<spring.boot.version>1.2.0.RELEASE</spring.boot.version>
<org.javalite.activejdbc.version>1.4.10-SNAPSHOT</org.javalite.activejdbc.version>
</properties>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.2.0.RELEASE</version>
</parent>
...
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${spring.boot.version}</version>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
當我從我的IDE中運行的類,但它拋出ClassNotFoundException的,當我從命令行中運行它,它的工作原理。
任何想法可能導致此?
感謝
編輯
整個異常:
Caused by: java.lang.NoClassDefFoundError: org/javalite/activejdbc/Model
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at com.google.common.reflect.ClassPath$ClassInfo.load(ClassPath.java:266)
at me.factorify.server.common.Utils.getAllEntities(Utils.java:29)
at me.factorify.server.config.JacksonMappingContext.<init>(JacksonMappingContext.java:29)
at me.factorify.server.config.JacksonMappingContext$$EnhancerBySpringCGLIB$$accc13cb.<init>(<generated>)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:147)
... 107 more
Caused by: java.lang.ClassNotFoundException: org.javalite.activejdbc.Model
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 128 more
EDIT 2
我可以看到在日誌文件中該行與廣口瓶(activejdbc-1.4 .10-SNAPSHOT.jar)與org.javalite.activejdbc.Model在那裏。 JarLauncher必須以某種方式無法加載它。
2015-01-16 01:24:04.790 INFO 7316 --- [ main] .b.l.ClasspathLoggingApplicationListener : Application failed to start with classpath: [jar:file:/D:/Projekty/Factorify/target/factorify-1.0-SNAPSHOT.jar!/, jar:file:/D:/Projekty/Factorify/target/factorify-1.0-SNAPSHOT.jar!/lib/spring-boot-starter-web-1.2.0.RELEASE.jar!/, jar:file:/D:/Projekty/Factorify/target/factorify-1.0-SNAPSHOT.jar!/lib/spring-boot-starter-1.2.0.RELEASE.jar!/, jar:file:/D:/Projekty/Factorify/target/factorify-1.0-SNAPSHOT.jar!/lib/spring-boot-1.2.0.RELEASE.jar!/, jar:file:/D:/Projekty/Factorify/target/factorify-1.0-SNAPSHOT.jar!/lib/spring-boot-autoconfigure-1.2.0.RELEASE.jar!/, jar:file:/D:/Projekty/Factorify/target/factorify-1.0-SNAPSHOT.jar!/lib/spring-boot-starter-logging-1.2.0.RELEASE.jar!/, jar:file:/D:/Projekty/Factorify/target/factorify-1.0-SNAPSHOT.jar!/lib/jcl-over-slf4j-1.7.7.jar!/, jar:file:/D:/Projekty/Factorify/target/factorify-1.0-SNAPSHOT.jar!/lib/jul-to-slf4j-1.7.7.jar!/, jar:file:/D:/Projekty/Factorify/target/factorify-1.0-SNAPSHOT.jar!/lib/log4j-over-slf4j-1.7.7.jar!/, jar:file:/D:/Projekty/Factorify/target/factorify-1.0-SNAPSHOT.jar!/lib/logback-classic-1.1.2.jar!/, jar:file:/D:/Projekty/Factorify/target/factorify-1.0-SNAPSHOT.jar!/lib/logback-core-1.1.2.jar!/, jar:file:/D:/Projekty/Factorify/target/factorify-1.0-SNAPSHOT.jar!/lib/snakeyaml-1.14.jar!/, jar:file:/D:/Projekty/Factorify/target/factorify-1.0-SNAPSHOT.jar!/lib/spring-boot-starter-tomcat-1.2.0.RELEASE.jar!/, jar:file:/D:/Projekty/Factorify/target/factorify-1.0-SNAPSHOT.jar!/lib/tomcat-embed-core-8.0.15.jar!/, jar:file:/D:/Projekty/Factorify/target/factorify-1.0-SNAPSHOT.jar!/lib/tomcat-embed-el-8.0.15.jar!/, jar:file:/D:/Projekty/Factorify/target/factorify-1.0-SNAPSHOT.jar!/lib/tomcat-embed-logging-juli-8.0.15.jar!/, jar:file:/D:/Projekty/Factorify/target/factorify-1.0-SNAPSHOT.jar!/lib/tomcat-embed-websocket-8.0.15.jar!/, jar:file:/D:/Projekty/Factorify/target/factorify-1.0-SNAPSHOT.jar!/lib/jackson-databind-2.4.4.jar!/, jar:file:/D:/Projekty/Factorify/target/factorify-1.0-SNAPSHOT.jar!/lib/jackson-annotations-2.4.0.jar!/, jar:file:/D:/Projekty/Factorify/target/factorify-1.0-SNAPSHOT.jar!/lib/jackson-core-2.4.4.jar!/, jar:file:/D:/Projekty/Factorify/target/factorify-1.0-SNAPSHOT.jar!/lib/hibernate-validator-5.1.3.Final.jar!/, jar:file:/D:/Projekty/Factorify/target/factorify-1.0-SNAPSHOT.jar!/lib/validation-api-1.1.0.Final.jar!/, jar:file:/D:/Projekty/Factorify/target/factorify-1.0-SNAPSHOT.jar!/lib/jboss-logging-3.1.3.GA.jar!/, jar:file:/D:/Projekty/Factorify/target/factorify-1.0-SNAPSHOT.jar!/lib/classmate-1.0.0.jar!/, jar:file:/D:/Projekty/Factorify/target/factorify-1.0-SNAPSHOT.jar!/lib/spring-web-4.1.3.RELEASE.jar!/, jar:file:/D:/Projekty/Factorify/target/factorify-1.0-SNAPSHOT.jar!/lib/spring-context-4.1.3.RELEASE.jar!/, jar:file:/D:/Projekty/Factorify/target/factorify-1.0-SNAPSHOT.jar!/lib/spring-webmvc-4.1.3.RELEASE.jar!/, jar:file:/D:/Projekty/Factorify/target/factorify-1.0-SNAPSHOT.jar!/lib/spring-expression-4.1.3.RELEASE.jar!/, jar:file:/D:/Projekty/Factorify/target/factorify-1.0-SNAPSHOT.jar!/lib/guava-18.0.jar!/, jar:file:/D:/Projekty/Factorify/target/factorify-1.0-SNAPSHOT.jar!/lib/persistence-api-1.0.2.jar!/, jar:file:/D:/Projekty/Factorify/target/factorify-1.0-SNAPSHOT.jar!/lib/spring-test-4.1.3.RELEASE.jar!/, jar:file:/D:/Projekty/Factorify/target/factorify-1.0-SNAPSHOT.jar!/lib/spring-jdbc-4.1.3.RELEASE.jar!/, jar:file:/D:/Projekty/Factorify/target/factorify-1.0-SNAPSHOT.jar!/lib/spring-beans-4.1.3.RELEASE.jar!/, jar:file:/D:/Projekty/Factorify/target/factorify-1.0-SNAPSHOT.jar!/lib/spring-tx-4.1.3.RELEASE.jar!/, jar:file:/D:/Projekty/Factorify/target/factorify-1.0-SNAPSHOT.jar!/lib/spring-aop-4.1.3.RELEASE.jar!/, jar:file:/D:/Projekty/Factorify/target/factorify-1.0-SNAPSHOT.jar!/lib/aopalliance-1.0.jar!/, jar:file:/D:/Projekty/Factorify/target/factorify-1.0-SNAPSHOT.jar!/lib/spring-aspects-4.1.3.RELEASE.jar!/, jar:file:/D:/Projekty/Factorify/target/factorify-1.0-SNAPSHOT.jar!/lib/aspectjweaver-1.8.4.jar!/, jar:file:/D:/Projekty/Factorify/target/factorify-1.0-SNAPSHOT.jar!/lib/spring-core-4.1.3.RELEASE.jar!/, jar:file:/D:/Projekty/Factorify/target/factorify-1.0-SNAPSHOT.jar!/lib/commons-logging-1.2.jar!/, jar:file:/D:/Projekty/Factorify/target/factorify-1.0-SNAPSHOT.jar!/lib/jsr250-api-1.0.jar!/, jar:file:/D:/Projekty/Factorify/target/factorify-1.0-SNAPSHOT.jar!/lib/jbcrypt-0.3m.jar!/, jar:file:/D:/Projekty/Factorify/target/factorify-1.0-SNAPSHOT.jar!/lib/jsr305-3.0.0.jar!/, jar:file:/D:/Projekty/Factorify/target/factorify-1.0-SNAPSHOT.jar!/lib/activejdbc-1.4.10-SNAPSHOT.jar!/, jar:file:/D:/Projekty/Factorify/target/factorify-1.0-SNAPSHOT.jar!/lib/slf4j-api-1.7.5.jar!/, jar:file:/D:/Projekty/Factorify/target/factorify-1.0-SNAPSHOT.jar!/lib/javalite-common-1.4.10-SNAPSHOT.jar!/, jar:file:/D:/Projekty/Factorify/target/factorify-1.0-SNAPSHOT.jar!/lib/postgresql-9.1-901-1.jdbc4.jar!/, jar:file:/D:/Projekty/Factorify/target/factorify-1.0-SNAPSHOT.jar!/lib/commons-dbcp-1.4.jar!/, jar:file:/D:/Projekty/Factorify/target/factorify-1.0-SNAPSHOT.jar!/lib/commons-pool-1.5.4.jar!/, jar:file:/D:/Projekty/Factorify/target/factorify-1.0-SNAPSHOT.jar!/lib/activejdbc-instrumentation-1.4.10-SNAPSHOT.jar!/]
「讀取錯誤,改正錯誤。」請包括ClassNotFoundException的實際消息。 – digitaljoel
你確定包含'org.javalite.activejdbc.Model'的jar在你的jar的lib目錄下嗎?你描述的症狀的一個可能的原因是,你已經在你的pom中標記了依賴關係爲' test ',所以它在你的IDE的類路徑中,但沒有包含在你的fat jar中。 –
這個罐子被包含在脂肪罐中。 (我打開了胖罐,我可以在lib /中看到它,而且我可以在那裏找到這個類) –