升级到 jdk11问题总结
一、主要考虑兼容性问题
1.比如原来项目里可能有一些接口是用的jdk1.7的接口 但是升级后 这种接口可能在jdk11中就取消了
对于jdk11来说可能就的 添加jar包这种形式来实现了
2.另一种是 可能现在有些接口jdk1.7没有 然后他是借助的第三方jar包
然后换做jdk11后 有些接口可能jdk11就包含了 那么就不用借助三方jar包
二、具体问题分析
1.idea + maven 项目 升级jdk
一些用到的jar 的升级 如 下面的这些
JavaBeans Activation Framework (JAF) (javax.activation),需要独立引入,maven依赖如下:
<dependency>
<groupId>com.sun.activation</groupId>
<artifactId>javax.activation</artifactId>
<version>1.2.0</version>
</dependency>
JavaBeans Activation Framework (JAF) (javax.activation),需要独立引入,maven依赖如下:
<dependency>
<groupId>com.sun.activation</groupId>
<artifactId>javax.activation</artifactId>
<version>1.2.0</version>
</dependency>
JTA (java.transaction)变成了独立依赖:
<dependency>
<groupId>javax.transaction</groupId>
<artifactId>javax.transaction-api</artifactId>
<version>1.2</version>
</dependency>
JAXB和JAX-WS:
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.2.8</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-core</artifactId>
<version>2.2.8</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<version>2.2.8</version>
</dependency>
<dependency>
<groupId>com.sun.xml.ws</groupId>
<artifactId>jaxws-ri</artifactId>
<version>2.3.0</version>
<type>pom</type>
</dependency>
Common Annotations:
<dependency>
<groupId>javax.annotation</groupId>
<artifactId>javax.annotation-api</artifactId>
<version>1.3.1</version>
</dependency>
注意 spring的版本 不升级会报很多错误 如:
09-Feb-2021 13:38:36.504 严重 [RMI TCP Connection(3)-127.0.0.1] org.apache.tomcat.util.modeler.BaseModelMBean.invoke 调用方法[manageApp]时发生异常
java.lang.IllegalStateException: 启动子级时出错
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:720)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:690)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:706)
at org.apache.catalina.startup.HostConfig.manageApp(HostConfig.java:1671)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:288)
at java.management/com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:809)
at java.management/com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801)
at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:459)
at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:408)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:288)
at java.management/com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:809)
at java.management/com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801)
at java.management/com.sun.jmx.remote.security.MBeanServerAccessController.invoke(MBeanServerAccessController.java:468)
at java.management.rmi/javax.management.remote.rmi.RMIConnectionImpl.doOperation(RMIConnectionImpl.java:1466)
at java.management.rmi/javax.management.remote.rmi.RMIConnectionImpl$PrivilegedOperation.run(RMIConnectionImpl.java:1307)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at java.management.rmi/javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(RMIConnectionImpl.java:1406)
at java.management.rmi/javax.management.remote.rmi.RMIConnectionImpl.invoke(RMIConnectionImpl.java:827)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at java.rmi/sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:359)
at java.rmi/sun.rmi.transport.Transport$1.run(Transport.java:200)
at java.rmi/sun.rmi.transport.Transport
1.
r
u
n
(
T
r
a
n
s
p
o
r
t
.
j
a
v
a
:
197
)
a
t
j
a
v
a
.
b
a
s
e
/
j
a
v
a
.
s
e
c
u
r
i
t
y
.
A
c
c
e
s
s
C
o
n
t
r
o
l
l
e
r
.
d
o
P
r
i
v
i
l
e
g
e
d
(
N
a
t
i
v
e
M
e
t
h
o
d
)
a
t
j
a
v
a
.
r
m
i
/
s
u
n
.
r
m
i
.
t
r
a
n
s
p
o
r
t
.
T
r
a
n
s
p
o
r
t
.
s
e
r
v
i
c
e
C
a
l
l
(
T
r
a
n
s
p
o
r
t
.
j
a
v
a
:
196
)
a
t
j
a
v
a
.
r
m
i
/
s
u
n
.
r
m
i
.
t
r
a
n
s
p
o
r
t
.
t
c
p
.
T
C
P
T
r
a
n
s
p
o
r
t
.
h
a
n
d
l
e
M
e
s
s
a
g
e
s
(
T
C
P
T
r
a
n
s
p
o
r
t
.
j
a
v
a
:
562
)
a
t
j
a
v
a
.
r
m
i
/
s
u
n
.
r
m
i
.
t
r
a
n
s
p
o
r
t
.
t
c
p
.
T
C
P
T
r
a
n
s
p
o
r
t
1.run(Transport.java:197) at java.base/java.security.AccessController.doPrivileged(Native Method) at java.rmi/sun.rmi.transport.Transport.serviceCall(Transport.java:196) at java.rmi/sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:562) at java.rmi/sun.rmi.transport.tcp.TCPTransport
1.run(Transport.java:197)atjava.base/java.security.AccessController.doPrivileged(NativeMethod)atjava.rmi/sun.rmi.transport.Transport.serviceCall(Transport.java:196)atjava.rmi/sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:562)atjava.rmi/sun.rmi.transport.tcp.TCPTransportConnectionHandler.run0(TCPTransport.java:796)
at java.rmi/sun.rmi.transport.tcp.TCPTransport
C
o
n
n
e
c
t
i
o
n
H
a
n
d
l
e
r
.
l
a
m
b
d
a
ConnectionHandler.lambda
ConnectionHandler.lambdarun
0
(
T
C
P
T
r
a
n
s
p
o
r
t
.
j
a
v
a
:
677
)
a
t
j
a
v
a
.
b
a
s
e
/
j
a
v
a
.
s
e
c
u
r
i
t
y
.
A
c
c
e
s
s
C
o
n
t
r
o
l
l
e
r
.
d
o
P
r
i
v
i
l
e
g
e
d
(
N
a
t
i
v
e
M
e
t
h
o
d
)
a
t
j
a
v
a
.
r
m
i
/
s
u
n
.
r
m
i
.
t
r
a
n
s
p
o
r
t
.
t
c
p
.
T
C
P
T
r
a
n
s
p
o
r
t
0(TCPTransport.java:677) at java.base/java.security.AccessController.doPrivileged(Native Method) at java.rmi/sun.rmi.transport.tcp.TCPTransport
0(TCPTransport.java:677)atjava.base/java.security.AccessController.doPrivileged(NativeMethod)atjava.rmi/sun.rmi.transport.tcp.TCPTransportConnectionHandler.run(TCPTransport.java:676)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: org.apache.catalina.LifecycleException: 无法启动组件[StandardEngine[Catalina].StandardHost[localhost].StandardContext[]]
at org.apache.catalina.util.LifecycleBase.handleSubClassException(LifecycleBase.java:440)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:198)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:717)
… 42 more
Caused by: java.lang.IllegalArgumentException: 找到多个名为spring_web的片段。这是不合法的相对排序。有关详细信息,请参阅Servlet规范的第8.2.2 2c节。考虑使用绝对排序。
at org.apache.tomcat.util.descriptor.web.WebXml.orderWebFragments(WebXml.java:2260)
at org.apache.tomcat.util.descriptor.web.WebXml.orderWebFragments(WebXml.java:2218)
at org.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.java:1294)
at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:986)
at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:303)
at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:123)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5082)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
… 43 more