java.lang.LinkageError: loader constraint violation: loader 问题解决方案

  • Post author:
  • Post category:java


**



java.lang.LinkageError: loader constraint violation: loader 问题解决方案

**

在这里插入图片描述

java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Tomcat].StandardHost[localhost].StandardContext[/admin]]

at java.util.concurrent.FutureTask.report(FutureTask.java:122)

at java.util.concurrent.FutureTask.get(FutureTask.java:192)

at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1123)

at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:800)

at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)

at org.apache.catalina.core.ContainerBase



S

t

a

r

t

C

h

i

l

d

.

c

a

l

l

(

C

o

n

t

a

i

n

e

r

B

a

s

e

.

j

a

v

a

:

1559

)

a

t

o

r

g

.

a

p

a

c

h

e

.

c

a

t

a

l

i

n

a

.

c

o

r

e

.

C

o

n

t

a

i

n

e

r

B

a

s

e

StartChild.call(ContainerBase.java:1559) at org.apache.catalina.core.ContainerBase






S


t


a


r


t


C


h


i


l


d


.


c


a


l


l


(


C


o


n


t


a


i


n


e


r


B


a


s


e


.


j


a


v


a




:








1


5


5


9


)


a


t


o


r


g


.


a


p


a


c


h


e


.


c


a


t


a


l


i


n


a


.


c


o


r


e


.


C


o


n


t


a


i


n


e


r


B


a


s


e





StartChild.call(ContainerBase.java:1549)

at java.util.concurrent.FutureTask.run(FutureTask.java:266)

at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)

at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)

at java.lang.Thread.run(Thread.java:748)

Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Tomcat].StandardHost[localhost].StandardContext[/admin]]

at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)

… 6 more

Caused by: java.lang.LinkageError: loader constraint violation: loader (instance of org/apache/catalina/loader/WebappClassLoader) previously initiated loading for a different type with name “javax/servlet/ServletContext”

at java.lang.ClassLoader.defineClass1(Native Method)

at java.lang.ClassLoader.defineClass(ClassLoader.java:763)

at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)

at java.net.URLClassLoader.defineClass(URLClassLoader.java:468)

at java.net.URLClassLoader.access$100(URLClassLoader.java:74)

at java.net.URLClassLoader$1.run(URLClassLoader.java:369)

at java.net.URLClassLoader$1.run(URLClassLoader.java:363)

at java.security.AccessController.doPrivileged(Native Method)

at java.net.URLClassLoader.findClass(URLClassLoader.java:362)

at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1191)

at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1669)

at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1547)

at java.lang.Class.getDeclaredFields0(Native Method)

at java.lang.Class.privateGetDeclaredFields(Class.java:2583)

at java.lang.Class.getDeclaredFields(Class.java:1916)

at org.apache.catalina.util.Introspection.getDeclaredFields(Introspection.java:106)

at org.apache.catalina.startup.WebAnnotationSet.loadFieldsAnnotation(WebAnnotationSet.java:263)

at org.apache.catalina.startup.WebAnnotationSet.loadApplicationFilterAnnotations(WebAnnotationSet.java:112)

at org.apache.catalina.startup.WebAnnotationSet.loadApplicationAnnotations(WebAnnotationSet.java:66)

at org.apache.catalina.startup.ContextConfig.applicationAnnotationsConfig(ContextConfig.java:405)

at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:881)

at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:376)

at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)

at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)

at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5322)

at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)

… 6 more

若发生上述问题一定是因为依赖包冲突导致。

故我们先看一下Maven项目jar包的依赖树:

在这里插入图片描述

maven命令:mvn dependency:tree

在这里插入图片描述

执行完成后,发现javax的servlet包与logging包中的servlet包冲突,即在pom文件中添加配置。

Alt

问题解决。



版权声明:本文为weixin_43148411原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。