首页 新闻 会员 周边

把springCloud的maven项目打成jar之后运行时报错

0
悬赏园豆:50 [已解决问题] 解决于 2017-11-22 10:08

eCycle] - org.eclipse.jetty.server.ServerConnector$ServerConnectorManager@2d2acd
89 added {org.eclipse.jetty.io.ManagedSelector@42f9c19a id=0 keys=-1 selected=-1
,AUTO}
[26092] [main] [line:322] [DEBUG] [org.eclipse.jetty.util.component.ContainerLif
eCycle] - org.eclipse.jetty.io.ManagedSelector@253b380a id=1 keys=-1 selected=-1
added {EatWhatYouKill@29c2c826/org.eclipse.jetty.io.ManagedSelector$SelectorPro
ducer@3350ebdd/IDLE/0/1,AUTO}
[26092] [main] [line:322] [DEBUG] [org.eclipse.jetty.util.component.ContainerLif
eCycle] - org.eclipse.jetty.server.ServerConnector$ServerConnectorManager@2d2acd
89 added {org.eclipse.jetty.io.ManagedSelector@253b380a id=1 keys=-1 selected=-1
,AUTO}
[26092] [main] [line:185] [DEBUG] [org.eclipse.jetty.util.component.AbstractLife
Cycle] - starting org.eclipse.jetty.io.ManagedSelector@42f9c19a id=0 keys=-1 sel
ected=-1
[26092] [main] [line:185] [DEBUG] [org.eclipse.jetty.util.component.AbstractLife
Cycle] - starting EatWhatYouKill@64bfd6fd/org.eclipse.jetty.io.ManagedSelector$S
electorProducer@2ab2710/IDLE/0/1
[26092] [main] [line:177] [DEBUG] [org.eclipse.jetty.util.component.AbstractLife
Cycle] - STARTED @27516ms EatWhatYouKill@64bfd6fd/org.eclipse.jetty.io.ManagedSe
lector$SelectorProducer@2ab2710/IDLE/0/1
[26123] [main] [line:381] [DEBUG] [org.eclipse.jetty.util.thread.QueuedThreadPoo
l] - queue org.eclipse.jetty.io.ManagedSelector$$Lambda$11/1571278562@78830d9a
[26138] [main] [line:177] [DEBUG] [org.eclipse.jetty.util.component.AbstractLife
Cycle] - STARTED @27566ms org.eclipse.jetty.io.ManagedSelector@42f9c19a id=0 key
s=0 selected=0
[26138] [qtp1154172430-28] [line:590] [DEBUG] [org.eclipse.jetty.util.thread.Que
uedThreadPool] - run org.eclipse.jetty.io.ManagedSelector$$Lambda$11/1571278562@
78830d9a
[26217] [main] [line:185] [DEBUG] [org.eclipse.jetty.util.component.AbstractLife
Cycle] - starting org.eclipse.jetty.io.ManagedSelector@253b380a id=1 keys=-1 sel
ected=-1
[26217] [main] [line:185] [DEBUG] [org.eclipse.jetty.util.component.AbstractLife
Cycle] - starting EatWhatYouKill@29c2c826/org.eclipse.jetty.io.ManagedSelector$S
electorProducer@3350ebdd/IDLE/0/1
[26217] [qtp1154172430-28] [line:123] [DEBUG] [org.eclipse.jetty.util.thread.str
ategy.EatWhatYouKill] - EatWhatYouKill@64bfd6fd/org.eclipse.jetty.io.ManagedSele
ctor$SelectorProducer@2ab2710/PRODUCING/0/1 execute true
[26217] [main] [line:177] [DEBUG] [org.eclipse.jetty.util.component.AbstractLife
Cycle] - STARTED @27646ms EatWhatYouKill@29c2c826/org.eclipse.jetty.io.ManagedSe
lector$SelectorProducer@3350ebdd/IDLE/0/1
[26232] [qtp1154172430-28] [line:206] [DEBUG] [org.eclipse.jetty.util.thread.str
ategy.EatWhatYouKill] - EatWhatYouKill@64bfd6fd/org.eclipse.jetty.io.ManagedSele
ctor$SelectorProducer@2ab2710/PRODUCING/0/1 produce non-blocking
[26248] [main] [line:381] [DEBUG] [org.eclipse.jetty.util.thread.QueuedThreadPoo
l] - queue org.eclipse.jetty.io.ManagedSelector$$Lambda$11/1571278562@5ce4369b
[26248] [qtp1154172430-28] [line:233] [DEBUG] [org.eclipse.jetty.io.ManagedSelec
tor] - Selector loop waiting on select
[26248] [qtp1154172430-30] [line:590] [DEBUG] [org.eclipse.jetty.util.thread.Que
uedThreadPool] - run org.eclipse.jetty.io.ManagedSelector$$Lambda$11/1571278562@
5ce4369b
[26248] [main] [line:177] [DEBUG] [org.eclipse.jetty.util.component.AbstractLife
Cycle] - STARTED @27666ms org.eclipse.jetty.io.ManagedSelector@253b380a id=1 key
s=0 selected=0
[26248] [qtp1154172430-30] [line:123] [DEBUG] [org.eclipse.jetty.util.thread.str
ategy.EatWhatYouKill] - EatWhatYouKill@29c2c826/org.eclipse.jetty.io.ManagedSele
ctor$SelectorProducer@3350ebdd/PRODUCING/0/1 execute true
[26248] [main] [line:177] [DEBUG] [org.eclipse.jetty.util.component.AbstractLife
Cycle] - STARTED @27671ms org.eclipse.jetty.server.ServerConnector$ServerConnect
orManager@2d2acd89
[26248] [qtp1154172430-30] [line:206] [DEBUG] [org.eclipse.jetty.util.thread.str
ategy.EatWhatYouKill] - EatWhatYouKill@29c2c826/org.eclipse.jetty.io.ManagedSele
ctor$SelectorProducer@3350ebdd/PRODUCING/0/1 produce non-blocking
[26248] [main] [line:185] [DEBUG] [org.eclipse.jetty.util.component.AbstractLife
Cycle] - starting HttpConnectionFactory@1f52eb6f{HTTP/1.1}
[26248] [qtp1154172430-30] [line:233] [DEBUG] [org.eclipse.jetty.io.ManagedSelec
tor] - Selector loop waiting on select
[26263] [main] [line:177] [DEBUG] [org.eclipse.jetty.util.component.AbstractLife
Cycle] - STARTED @27678ms HttpConnectionFactory@1f52eb6f{HTTP/1.1}
[26263] [main] [line:322] [DEBUG] [org.eclipse.jetty.util.component.ContainerLif
eCycle] - ServerConnector@59546cfe{HTTP/1.1}{127.0.0.1:8765} added {acceptor-0@7
f829c76,POJO}
[26263] [main] [line:381] [DEBUG] [org.eclipse.jetty.util.thread.QueuedThreadPoo
l] - queue acceptor-0@7f829c76
[26263] [main] [line:266] [INFO ] [org.eclipse.jetty.server.ServerConnector] - S
tarted ServerConnector@59546cfe{HTTP/1.1}{127.0.0.1:8765}
[26263] [qtp1154172430-29] [line:590] [DEBUG] [org.eclipse.jetty.util.thread.Que
uedThreadPool] - run acceptor-0@7f829c76
[26263] [main] [line:177] [DEBUG] [org.eclipse.jetty.util.component.AbstractLife
Cycle] - STARTED @27689ms ServerConnector@59546cfe{HTTP/1.1}{127.0.0.1:8765}
[26263] [main] [line:380] [INFO ] [org.eclipse.jetty.server.Server] - Started @2
7692ms
[26279] [main] [line:177] [DEBUG] [org.eclipse.jetty.util.component.AbstractLife
Cycle] - STARTED @27694ms org.eclipse.jetty.server.Server@17271176
[26295] [main] [line:1349] [WARN ] [org.eclipse.jetty.server.handler.ContextHand
ler] - Empty contextPath
[26295] [main] [line:322] [DEBUG] [org.eclipse.jetty.util.component.ContainerLif
eCycle] - o.e.j.s.h.ContextHandler@1cb19dba{/,null,null} added {org.apache.cxf.t
ransport.http_jetty.JettyHTTPHandler@7c3ebc6b,AUTO}
[26295] [main] [line:322] [DEBUG] [org.eclipse.jetty.util.component.ContainerLif
eCycle] - org.eclipse.jetty.server.handler.ContextHandlerCollection@8ed9cf[o.e.j
.s.h.ContextHandler@1cb19dba{/,null,null}] added {o.e.j.s.h.ContextHandler@1cb19
dba{/,null,null},UNMANAGED}
[26310] [main] [line:141] [DEBUG] [org.eclipse.jetty.server.handler.ContextHandl
erCollection] - ->[{o.e.j.s.h.ContextHandler@1cb19dba{/,null,null},[o.e.j.s.h.Co
ntextHandler@1cb19dba{/,null,null}]}]
[26310] [main] [line:185] [DEBUG] [org.eclipse.jetty.util.component.AbstractLife
Cycle] - starting o.e.j.s.h.ContextHandler@1cb19dba{/,null,null}
[26326] [main] [line:64] [DEBUG] [org.eclipse.jetty.http.PreEncodedHttpField] -
HttpField encoders loaded: [org.eclipse.jetty.http.Http1FieldPreEncoder@1931d99]

[26467] [main] [line:58] [DEBUG] [org.eclipse.jetty.server.handler.AbstractHandl
er] - starting o.e.j.s.h.ContextHandler@1cb19dba{/,null,STARTING}
[26467] [main] [line:185] [DEBUG] [org.eclipse.jetty.util.component.AbstractLife
Cycle] - starting org.apache.cxf.transport.http_jetty.JettyHTTPHandler@7c3ebc6b
[26467] [main] [line:58] [DEBUG] [org.eclipse.jetty.server.handler.AbstractHandl
er] - starting org.apache.cxf.transport.http_jetty.JettyHTTPHandler@7c3ebc6b
[26467] [main] [line:177] [DEBUG] [org.eclipse.jetty.util.component.AbstractLife
Cycle] - STARTED @27887ms org.apache.cxf.transport.http_jetty.JettyHTTPHandler@7
c3ebc6b
[26467] [main] [line:745] [INFO ] [org.eclipse.jetty.server.handler.ContextHandl
er] - Started o.e.j.s.h.ContextHandler@1cb19dba{/,null,AVAILABLE}
[26467] [main] [line:177] [DEBUG] [org.eclipse.jetty.util.component.AbstractLife
Cycle] - STARTED @27891ms o.e.j.s.h.ContextHandler@1cb19dba{/,null,AVAILABLE}
[26467] [main] [line:127] [DEBUG] [org.apache.cxf.endpoint.ServerImpl] - registe
r the server to serverRegistry
[27763] [main] [line:121] [WARN ] [com.netflix.config.sources.URLConfigurationSo
urce] - No URLs will be polled as dynamic configuration sources.
[27763] [main] [line:122] [INFO ] [com.netflix.config.sources.URLConfigurationSo
urce] - To enable URLs as dynamic configuration sources, define System property
archaius.configurationSource.additionalUrls or make config.properties available
on classpath.
[27779] [main] [line:121] [WARN ] [com.netflix.config.sources.URLConfigurationSo
urce] - No URLs will be polled as dynamic configuration sources.
[27779] [main] [line:122] [INFO ] [com.netflix.config.sources.URLConfigurationSo
urce] - To enable URLs as dynamic configuration sources, define System property
archaius.configurationSource.additionalUrls or make config.properties available
on classpath.
[27842] [main] [line:103] [DEBUG] [org.hibernate.validator.internal.engine.resol
ver.DefaultTraversableResolver] - Found javax.persistence.Persistence on classpa
th containing 'getPersistenceUtil'. Assuming JPA 2 environment. Trying to instan
tiate JPA aware TraversableResolver
[27842] [main] [line:114] [DEBUG] [org.hibernate.validator.internal.engine.resol
ver.DefaultTraversableResolver] - Instantiated JPA aware TraversableResolver of
type org.hibernate.validator.internal.engine.resolver.JPATraversableResolver.
[27857] [main] [line:103] [DEBUG] [org.hibernate.validator.internal.engine.resol
ver.DefaultTraversableResolver] - Found javax.persistence.Persistence on classpa
th containing 'getPersistenceUtil'. Assuming JPA 2 environment. Trying to instan
tiate JPA aware TraversableResolver
[27857] [main] [line:114] [DEBUG] [org.hibernate.validator.internal.engine.resol
ver.DefaultTraversableResolver] - Instantiated JPA aware TraversableResolver of
type org.hibernate.validator.internal.engine.resolver.JPATraversableResolver.
[27857] [main] [line:163] [DEBUG] [org.hibernate.validator.internal.engine.Confi
gurationImpl] - Setting custom MessageInterpolator of type org.springframework.v
alidation.beanvalidation.LocaleContextMessageInterpolator
[27857] [main] [line:185] [DEBUG] [org.hibernate.validator.internal.engine.Confi
gurationImpl] - Setting custom ConstraintValidatorFactory of type org.springfram
ework.validation.beanvalidation.SpringConstraintValidatorFactory
[27857] [main] [line:199] [DEBUG] [org.hibernate.validator.internal.engine.Confi
gurationImpl] - Setting custom ParameterNameProvider of type com.sun.proxy.$Prox
y33
[27857] [main] [line:99] [DEBUG] [org.hibernate.validator.internal.xml.Validatio
nXmlParser] - Trying to load META-INF/validation.xml for XML based Validator con
figuration.
[27857] [main] [line:47] [DEBUG] [org.hibernate.validator.internal.xml.ResourceL
oaderHelper] - Trying to load META-INF/validation.xml via user class loader
[27873] [main] [line:54] [DEBUG] [org.hibernate.validator.internal.xml.ResourceL
oaderHelper] - Trying to load META-INF/validation.xml via TCCL
[27873] [main] [line:60] [DEBUG] [org.hibernate.validator.internal.xml.ResourceL
oaderHelper] - Trying to load META-INF/validation.xml via Hibernate Validator's
class loader
[27873] [main] [line:106] [DEBUG] [org.hibernate.validator.internal.xml.Validati
onXmlParser] - No META-INF/validation.xml found. Using annotation based configur
ation only.
[29029] [main] [line:154] [DEBUG] [org.apache.cxf.endpoint.ServerImpl] - Server
is stopping.
[29029] [main] [line:63] [DEBUG] [org.apache.cxf.transport.http_jetty.JettyHTTPD
estination] - unregistering incoming observer: org.apache.cxf.transport.ChainIni
tiationObserver@287f7811
[29029] [main] [line:189] [DEBUG] [org.apache.cxf.transport.http_jetty.JettyHTTP
Destination] - Deactivating receipt of incoming messages
[29029] [main] [line:194] [DEBUG] [org.eclipse.jetty.util.component.AbstractLife
Cycle] - stopping o.e.j.s.h.ContextHandler@1cb19dba{/,null,AVAILABLE}
[29029] [main] [line:72] [DEBUG] [org.eclipse.jetty.server.handler.AbstractHandl
er] - stopping o.e.j.s.h.ContextHandler@1cb19dba{/,null,UNAVAILABLE}
[29029] [main] [line:194] [DEBUG] [org.eclipse.jetty.util.component.AbstractLife
Cycle] - stopping org.apache.cxf.transport.http_jetty.JettyHTTPHandler@7c3ebc6b
[29029] [main] [line:72] [DEBUG] [org.eclipse.jetty.server.handler.AbstractHandl
er] - stopping org.apache.cxf.transport.http_jetty.JettyHTTPHandler@7c3ebc6b
[29029] [main] [line:204] [DEBUG] [org.eclipse.jetty.util.component.AbstractLife
Cycle] - STOPPED org.apache.cxf.transport.http_jetty.JettyHTTPHandler@7c3ebc6b
[29029] [main] [line:864] [INFO ] [org.eclipse.jetty.server.handler.ContextHandl
er] - Stopped o.e.j.s.h.ContextHandler@1cb19dba{/,null,UNAVAILABLE}
[29029] [main] [line:204] [DEBUG] [org.eclipse.jetty.util.component.AbstractLife
Cycle] - STOPPED o.e.j.s.h.ContextHandler@1cb19dba{/,null,UNAVAILABLE}
[29029] [main] [line:185] [DEBUG] [org.apache.cxf.endpoint.ServerImpl] - unregis
ter the server to serverRegistry
[29029] [main] [line:1054] [DEBUG] [org.hibernate.internal.SessionFactoryImpl] -
HHH000031: Closing
[29029] [main] [line:407] [DEBUG] [org.hibernate.service.internal.AbstractServic
eRegistryImpl] - Implicitly destroying ServiceRegistry on de-registration of all
child ServiceRegistries
[29029] [main] [line:286] [DEBUG] [org.hibernate.boot.registry.internal.Bootstra
pServiceRegistryImpl] - Implicitly destroying Boot-strap registry on de-registra
tion of all child ServiceRegistries
[29045] [main] [line:91] [DEBUG] [org.hibernate.jpa.internal.EntityManagerFactor
yRegistry] - Remove: name=default
[29201] [main] [line:179] [INFO ] [org.apache.catalina.core.StandardService] - S
topping service [Tomcat]
Exception in thread "main" java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner
.java:48)
at org.springframework.boot.loader.Launcher.launch(Launcher.java:87)
at org.springframework.boot.loader.Launcher.launch(Launcher.java:50)
at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:51)

Caused by: org.springframework.beans.factory.BeanCreationException: Error creati
ng bean with name 'resourceHandlerMapping' defined in class path resource [org/s
pringframework/boot/autoconfigure/web/WebMvcAutoConfiguration$EnableWebMvcConfig
uration.class]: Bean instantiation via factory method failed; nested exception i
s org.springframework.beans.BeanInstantiationException: Failed to instantiate [o
rg.springframework.web.servlet.HandlerMapping]: Factory method 'resourceHandlerM
apping' threw exception; nested exception is java.lang.NullPointerException
at org.springframework.beans.factory.support.ConstructorResolver.instant
iateUsingFactoryMethod(ConstructorResolver.java:599)
at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:11
73)
at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1067)
at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.doCreateBean(AbstractAutowireCapableBeanFactory.java:513)
at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.createBean(AbstractAutowireCapableBeanFactory.java:483)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getOb
ject(AbstractBeanFactory.java:306)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistr
y.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBe
an(AbstractBeanFactory.java:302)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean
(AbstractBeanFactory.java:197)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.
preInstantiateSingletons(DefaultListableBeanFactory.java:761)
at org.springframework.context.support.AbstractApplicationContext.finish
BeanFactoryInitialization(AbstractApplicationContext.java:867)
at org.springframework.context.support.AbstractApplicationContext.refres
h(AbstractApplicationContext.java:543)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationConte
xt.refresh(EmbeddedWebApplicationContext.java:122)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.
java:693)
at org.springframework.boot.SpringApplication.refreshContext(SpringAppli
cation.java:360)
at org.springframework.boot.SpringApplication.run(SpringApplication.java
:303)
at org.springframework.boot.SpringApplication.run(SpringApplication.java
:1118)
at org.springframework.boot.SpringApplication.run(SpringApplication.java
:1107)
at com.example.producer.SpringcloudProducerApplication.main(SpringcloudP
roducerApplication.java:14)
... 8 more
Caused by: org.springframework.beans.BeanInstantiationException: Failed to insta
ntiate [org.springframework.web.servlet.HandlerMapping]: Factory method 'resourc
eHandlerMapping' threw exception; nested exception is java.lang.NullPointerExcep
tion
at org.springframework.beans.factory.support.SimpleInstantiationStrategy
.instantiate(SimpleInstantiationStrategy.java:189)
at org.springframework.beans.factory.support.ConstructorResolver.instant
iateUsingFactoryMethod(ConstructorResolver.java:588)
... 26 more
Caused by: java.lang.NullPointerException
at com.example.producer.set.resources.MyWebAppConfigurer.addResourceHand
lers(MyWebAppConfigurer.java:19)
at org.springframework.web.servlet.config.annotation.WebMvcConfigurerCom
posite.addResourceHandlers(WebMvcConfigurerComposite.java:94)
at org.springframework.web.servlet.config.annotation.DelegatingWebMvcCon
figuration.addResourceHandlers(DelegatingWebMvcConfiguration.java:87)
at org.springframework.web.servlet.config.annotation.WebMvcConfiguration
Support.resourceHandlerMapping(WebMvcConfigurationSupport.java:450)
at org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration$En
ableWebMvcConfiguration$$EnhancerBySpringCGLIB$$d7db632b.CGLIB$resourceHandlerMa
pping$40(<generated>)
at org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration$En
ableWebMvcConfiguration$$EnhancerBySpringCGLIB$$d7db632b$$FastClassBySpringCGLIB
$$f4cb3413.invoke(<generated>)
at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.j
ava:228)
at org.springframework.context.annotation.ConfigurationClassEnhancer$Bea
nMethodInterceptor.intercept(ConfigurationClassEnhancer.java:358)
at org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration$En
ableWebMvcConfiguration$$EnhancerBySpringCGLIB$$d7db632b.resourceHandlerMapping(
<generated>)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy
.instantiate(SimpleInstantiationStrategy.java:162)
... 27 more

yuexijing的主页 yuexijing | 初学一级 | 园豆:154
提问于:2017-11-21 18:59
< >
分享
最佳答案
0

这个问题是主要的报错信息是at com.example.producer.set.resources.MyWebAppConfigurer.addResourceHand
lers(MyWebAppConfigurer.java:19),看了下我的工程,发现这一行为String projectPath = Class.class.getClass().getResource("/").getPath();空指针异常是Class.class.getClass().getResource("/")返回为null,解决办法是替换为

new MyWebAppConfigurer().getClass().getProtectionDomain().getCodeSource().getLocation().getPath();

new MyWebAppConfigurer()为本类

yuexijing | 初学一级 |园豆:154 | 2017-11-22 10:08
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册