Spring Boot应用程序因未知原因崩溃

时间:2018-01-28 21:01:28

标签: java spring spring-boot

我将Spring Boot应用程序打包到 jar 中,就像其他正常工作的应用程序一样。它几乎是相同的应用程序。但是这个应用失败了,错误:

2018-01-28 23:43:57.661 DEBUG 14109 --- [           main] o.s.w.c.s.StandardServletEnvironment     : Adding PropertySource 'servletConfigInitParams' with lowest search precedence
2018-01-28 23:43:57.670 DEBUG 14109 --- [           main] o.s.w.c.s.StandardServletEnvironment     : Adding PropertySource 'servletContextInitParams' with lowest search precedence
2018-01-28 23:43:57.671 DEBUG 14109 --- [           main] o.s.w.c.s.StandardServletEnvironment     : Adding PropertySource 'systemProperties' with lowest search precedence
2018-01-28 23:43:57.672 DEBUG 14109 --- [           main] o.s.w.c.s.StandardServletEnvironment     : Adding PropertySource 'systemEnvironment' with lowest search precedence
2018-01-28 23:43:57.673 DEBUG 14109 --- [           main] o.s.w.c.s.StandardServletEnvironment     : Initialized StandardServletEnvironment with PropertySources [StubPropertySource {name='servletConfigInitParams'}, StubPropertySource {name='servletContextInitParams'}, MapPropertySource {name='systemProperties'}, SystemEnvironmentPropertySource {name='systemEnvironment'}]
2018-01-28 23:43:57.780  INFO 14109 --- [           main] com.contedevel.virto.Application         : Starting Application on CONTEDEVEL with PID 14109 (/home/ghostman/Projects/Virto/out/virto.jar started by ghostman in /home/ghostman/Projects/Virto/out)
2018-01-28 23:43:57.781  INFO 14109 --- [           main] com.contedevel.virto.Application         : No active profile set, falling back to default profiles: default
2018-01-28 23:43:57.925  INFO 14109 --- [           main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@928763c: startup date [Sun Jan 28 23:43:57 MSK 2018]; root of context hierarchy
2018-01-28 23:43:59.766  INFO 14109 --- [           main] o.s.b.f.s.DefaultListableBeanFactory     : Overriding bean definition for bean 'httpRequestHandlerAdapter' with a different definition: replacing [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.web.servlet.config.annotation.DelegatingWebMvcConfiguration; factoryMethodName=httpRequestHandlerAdapter; initMethodName=null; destroyMethodName=(inferred); defined in org.springframework.web.servlet.config.annotation.DelegatingWebMvcConfiguration] with [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.data.rest.webmvc.config.RepositoryRestMvcConfiguration; factoryMethodName=httpRequestHandlerAdapter; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/data/rest/webmvc/config/RepositoryRestMvcConfiguration.class]]
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.springframework.cglib.core.ReflectUtils$1 (file:/home/ghostman/Projects/Virto/out/spring-core-4.3.13.RELEASE.jar) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain)
WARNING: Please consider reporting this to the maintainers of org.springframework.cglib.core.ReflectUtils$1
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
2018-01-28 23:44:00.354 DEBUG 14109 --- [           main] o.s.w.c.s.StandardServletEnvironment     : Adding PropertySource 'applicationConfig: [classpath:/application.properties]' with search precedence immediately lower than 'applicationConfigurationProperties'
2018-01-28 23:44:00.355 DEBUG 14109 --- [           main] o.s.w.c.s.StandardServletEnvironment     : Removing PropertySource 'applicationConfigurationProperties'
2018-01-28 23:44:00.355 DEBUG 14109 --- [           main] o.s.w.c.s.StandardServletEnvironment     : Removing PropertySource 'defaultProperties'
2018-01-28 23:44:00.695  INFO 14109 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$430fc63b] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2018-01-28 23:44:01.549  INFO 14109 --- [           main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8080 (http)
2018-01-28 23:44:01.574  INFO 14109 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2018-01-28 23:44:01.576  INFO 14109 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet Engine: Apache Tomcat/8.5.23
2018-01-28 23:44:01.733  INFO 14109 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2018-01-28 23:44:01.734 DEBUG 14109 --- [ost-startStop-1] o.s.web.context.ContextLoader            : Published root WebApplicationContext as ServletContext attribute with name [org.springframework.web.context.WebApplicationContext.ROOT]
2018-01-28 23:44:01.734  INFO 14109 --- [ost-startStop-1] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 3819 ms
2018-01-28 23:44:01.979  INFO 14109 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean  : Mapping servlet: 'dispatcherServlet' to [/]
2018-01-28 23:44:01.988  INFO 14109 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'characterEncodingFilter' to: [/*]
2018-01-28 23:44:01.989  INFO 14109 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'requestLoggingFilter' to: [/*]
2018-01-28 23:44:02.062 DEBUG 14109 --- [ost-startStop-1] o.s.w.f.CommonsRequestLoggingFilter      : Initializing filter 'requestLoggingFilter'
2018-01-28 23:44:02.069 DEBUG 14109 --- [ost-startStop-1] o.s.w.f.CommonsRequestLoggingFilter      : Filter 'requestLoggingFilter' configured successfully
2018-01-28 23:44:02.099 DEBUG 14109 --- [           main] o.s.w.c.s.StandardServletEnvironment     : Replacing PropertySource 'servletContextInitParams' with 'servletContextInitParams'
2018-01-28 23:44:02.838  WARN 14109 --- [           main] ationConfigEmbeddedWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfiguration.class]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: Unable to resolve persistence unit root URL
2018-01-28 23:44:02.860  INFO 14109 --- [           main] o.apache.catalina.core.StandardService   : Stopping service [Tomcat]
2018-01-28 23:44:02.919  INFO 14109 --- [           main] utoConfigurationReportLoggingInitializer : 

Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled.
2018-01-28 23:44:02.936 ERROR 14109 --- [           main] o.s.boot.SpringApplication               : Application startup failed

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfiguration.class]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: Unable to resolve persistence unit root URL
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1628) ~[spring-beans-4.3.13.RELEASE.jar:4.3.13.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:555) ~[spring-beans-4.3.13.RELEASE.jar:4.3.13.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483) ~[spring-beans-4.3.13.RELEASE.jar:4.3.13.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) ~[spring-beans-4.3.13.RELEASE.jar:4.3.13.RELEASE]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.3.13.RELEASE.jar:4.3.13.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.3.13.RELEASE.jar:4.3.13.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) ~[spring-beans-4.3.13.RELEASE.jar:4.3.13.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1080) ~[spring-context-4.3.13.RELEASE.jar:4.3.13.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:857) ~[spring-context-4.3.13.RELEASE.jar:4.3.13.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:543) ~[spring-context-4.3.13.RELEASE.jar:4.3.13.RELEASE]
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) ~[spring-boot-1.5.9.RELEASE.jar:1.5.9.RELEASE]
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:693) [spring-boot-1.5.9.RELEASE.jar:1.5.9.RELEASE]
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:360) [spring-boot-1.5.9.RELEASE.jar:1.5.9.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:303) [spring-boot-1.5.9.RELEASE.jar:1.5.9.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1118) [spring-boot-1.5.9.RELEASE.jar:1.5.9.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1107) [spring-boot-1.5.9.RELEASE.jar:1.5.9.RELEASE]
    at com.contedevel.virto.Application.main(Application.java:17) [virto.jar:na]
Caused by: javax.persistence.PersistenceException: Unable to resolve persistence unit root URL
    at org.springframework.orm.jpa.persistenceunit.DefaultPersistenceUnitManager.determineDefaultPersistenceUnitRootUrl(DefaultPersistenceUnitManager.java:605) ~[spring-orm-4.3.13.RELEASE.jar:4.3.13.RELEASE]
    at org.springframework.orm.jpa.persistenceunit.DefaultPersistenceUnitManager.preparePersistenceUnitInfos(DefaultPersistenceUnitManager.java:445) ~[spring-orm-4.3.13.RELEASE.jar:4.3.13.RELEASE]
    at org.springframework.orm.jpa.persistenceunit.DefaultPersistenceUnitManager.afterPropertiesSet(DefaultPersistenceUnitManager.java:426) ~[spring-orm-4.3.13.RELEASE.jar:4.3.13.RELEASE]
    at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.afterPropertiesSet(LocalContainerEntityManagerFactoryBean.java:325) ~[spring-orm-4.3.13.RELEASE.jar:4.3.13.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1687) ~[spring-beans-4.3.13.RELEASE.jar:4.3.13.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1624) ~[spring-beans-4.3.13.RELEASE.jar:4.3.13.RELEASE]
    ... 16 common frames omitted
Caused by: java.io.FileNotFoundException: class path resource [] cannot be resolved to URL because it does not exist
    at org.springframework.core.io.ClassPathResource.getURL(ClassPathResource.java:187) ~[spring-core-4.3.13.RELEASE.jar:4.3.13.RELEASE]
    at org.springframework.orm.jpa.persistenceunit.DefaultPersistenceUnitManager.determineDefaultPersistenceUnitRootUrl(DefaultPersistenceUnitManager.java:601) ~[spring-orm-4.3.13.RELEASE.jar:4.3.13.RELEASE]
    ... 21 common frames omitted

我无法得到我的错误。我使用java --add-modules java.xml.bind -jar virto.jar命令来运行app。 Jar包含MANIFEST.MF.properties个文件,就像其他我的应用程序一样完美 有人有什么想法我应该在哪里搜索错误?在我的build.gradle下方

buildscript {
    ext {
        springBootVersion = '1.5.9.RELEASE'
    }
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
    }
}

apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'

group = 'com.contedevel'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = 1.9

repositories {
    mavenCentral()
}


dependencies {
    compile('org.springframework.boot:spring-boot-starter-data-jpa')
    compile('org.springframework.boot:spring-boot-starter-data-rest')
    compile('org.springframework.boot:spring-boot-starter-web')
    compile('org.json:json')
    runtime('org.postgresql:postgresql')
    testCompile('org.springframework.boot:spring-boot-starter-test')
}

我的MANIFEST.MF

Manifest-Version: 1.0
Class-Path: jackson-core-2.8.10.jar jackson-annotations-2.8.0.jar logb
 ack-classic-1.1.11.jar tomcat-annotations-api-8.5.23.jar logback-core
 -1.1.11.jar slf4j-api-1.7.25.jar spring-data-commons-1.13.9.RELEASE.j
 ar antlr-2.7.7.jar spring-data-rest-core-2.6.9.RELEASE.jar spring-hat
 eoas-0.23.0.RELEASE.jar spring-boot-starter-logging-1.5.9.RELEASE.jar
  hibernate-validator-5.3.6.Final.jar spring-boot-starter-web-1.5.9.RE
 LEASE.jar snakeyaml-1.17.jar hibernate-core-5.0.12.Final.jar jcl-over
 -slf4j-1.7.25.jar spring-boot-autoconfigure-1.5.9.RELEASE.jar dom4j-1
 .6.1.jar spring-beans-4.3.13.RELEASE.jar spring-core-4.3.13.RELEASE.j
 ar jackson-databind-2.8.10.jar tomcat-embed-el-8.5.23.jar spring-boot
 -starter-data-jpa-1.5.9.RELEASE.jar spring-web-4.3.13.RELEASE.jar evo
 -inflector-1.2.2.jar hibernate-commons-annotations-5.0.1.Final.jar js
 on-20140107.jar spring-aop-4.3.13.RELEASE.jar log4j-over-slf4j-1.7.25
 .jar tomcat-jdbc-8.5.23.jar hibernate-jpa-2.1-api-1.0.0.Final.jar spr
 ing-data-rest-webmvc-2.6.9.RELEASE.jar jul-to-slf4j-1.7.25.jar spring
 -boot-starter-1.5.9.RELEASE.jar spring-expression-4.3.13.RELEASE.jar 
 spring-boot-1.5.9.RELEASE.jar spring-orm-4.3.13.RELEASE.jar classmate
 -1.3.4.jar hibernate-entitymanager-5.0.12.Final.jar tomcat-juli-8.5.2
 3.jar spring-boot-starter-aop-1.5.9.RELEASE.jar spring-data-jpa-1.11.
 9.RELEASE.jar spring-boot-starter-tomcat-1.5.9.RELEASE.jar validation
 -api-1.1.0.Final.jar spring-tx-4.3.13.RELEASE.jar spring-aspects-4.3.
 13.RELEASE.jar tomcat-embed-core-8.5.23.jar jandex-2.0.0.Final.jar jb
 oss-logging-3.3.1.Final.jar javax.transaction-api-1.2.jar spring-boot
 -starter-jdbc-1.5.9.RELEASE.jar spring-jdbc-4.3.13.RELEASE.jar spring
 -context-4.3.13.RELEASE.jar aspectjweaver-1.8.13.jar postgresql-9.4.1
 212.jre7.jar spring-webmvc-4.3.13.RELEASE.jar spring-boot-starter-dat
 a-rest-1.5.9.RELEASE.jar javassist-3.21.0-GA.jar spring-plugin-core-1
 .2.0.RELEASE.jar tomcat-embed-websocket-8.5.23.jar
Main-Class: com.contedevel.virto.Application

application.properties

spring.datasource.url=jdbc:postgresql://localhost:5432/virto
spring.datasource.username=virto_user
spring.datasource.password=****
#spring.datasource.driver-class-name=xxx
spring.jpa.hibernate.ddl-auto=create-drop
#show sql statement
logging.level.org.hibernate.SQL=error
#show sql values
logging.level.org.hibernate.type.descriptor.sql=trace
logging.level.org.springframework.web=DEBUG
logging.level.org.hibernate=ERROR
logging.file=${user.home}/Logs/virto.log
#server
server.port = 8080

2 个答案:

答案 0 :(得分:2)

看起来这是Spring项目中的一个错误。你并不是第一个遇到它的人。有几个地方似乎被报告为一个错误:

github.com/spring-projects/spring-boot/issues/6635
github.com/spring-projects/spring-boot/issues/6314

stackoverflow.com/questions/38686708/spring-boot-1-4-class-path-resource-cannot-be-resolved-to-url-because-it-do

由于它是一个错误,可能不值得花时间去理解它,只需使用列出的解决方案或解决方法之一。

答案 1 :(得分:1)

如果您正在Linux或EC2中运行它,则AWS Linux使用nohup命令如下运行jar filr。

nohup java -jar /web/server.jar> /var/log/yourservice.log 2>&1

相关问题