当前位置: 首页 > news >正文

从jdk8 升级到jdk17的问题总结

目录

1. java.lang.reflect.InaccessibleObjectException:

2. java.lang.UnsatisfiedLinkError in autosys

3.  java.lang.NoClassDefFoundError: Could not initialize class net.sf.jasperreports.engine.util.JRStyledTextParser

4. java.lang.UnsatisfiedLinkError: ***/lib/libfontmanager.so: libfreetype.so.6

5. his method is deprecated and marked for removal. Use the getPeerCertificates() method instead.

6. Could not initialize class com.sybase.jdbc4.jdbc.SybDriver

7. Unrecognized VM option 'UseParNewGC'

8. Failed to execute goal org.codehaus.groovy.maven:gmaven-plugin:1.0

9.  Failed to execute goal org.codehaus.mojo:aspectj-maven-plugin:1.9:

10.InaccessibleObjectException while executing exec-maven-plugin


1. java.lang.reflect.InaccessibleObjectException:

异常:

java.lang.reflect.InaccessibleObjectException: Unable to make java.lang.String(char[],int,int,java.lang.Void) accessible: module java.base does not "opens java.lang" to unnamed module

解决方法:

加下面参数

--add-opens= java.base/java.lang=ALL-UNNAMED

如果是启动报错的话直接下面所有的vm的参数

export _JAVA_OPTIONS="$_JAVA_OPTIONS --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.io=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.rmi/sun.rmi.transport=ALL-UNNAMED --add-opens=java.base/java.lang.reflect=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.math=ALL-UNNAMED --add-opens=java.base/java.nio=ALL-UNNAMED --add-opens=java.base/sun.net=ALL-UNNAMED --add-opens=java.base/sun.net.www.protocol.https=ALL-UNNAMED"

如果是运行maven命令时报错,升级maven-compiler-plugin并加下面vm的参数

<plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-compiler-plugin</artifactId><version>3.8.0</version><configuration><source>${java.version}</source><target>${java.version}</target><compilerArgs><arg>--add-exports</arg><arg>java.base/java.lang=ALL-UNNAMED</arg><arg>--add-exports</arg><arg>java.base/java.io=ALL-UNNAMED</arg><arg>--add-exports</arg><arg>java.base/java.util=ALL-UNNAMED</arg><arg>--add-exports</arg><arg>java.base/java.lang.reflect=ALL-UNNAMED</arg><arg>--add-exports</arg><arg>java.base/java.math=ALL-UNNAMED</arg><arg>--add-exports</arg><arg>java.base/java.nio=ALL-UNNAMED</arg><arg>--add-exports</arg><arg>java.base/sun.security=ALL-UNNAMED</arg><arg>--add-exports</arg><arg>java.base/sun.net=ALL-UNNAMED</arg></compilerArgs></configuration>
</plugin>

2. java.lang.UnsatisfiedLinkError in autosys

异常:

Error: A JNI error has occurred, please check your installation and try again

Exception in thread "main" java.lang.UnsatisfiedLinkError: /opt/jdk/17.0_6l64/lib/libnio.so: /opt/jdk/17.0_6l64/lib/libjava.so: version `SUNWprivate_1.1' not found (required by /opt/CA/WorkloadAutomationAE/SystemAgent/WA1_AGENT/jre/lib/amd64/libnet.so)

解决方法:

export PATH=/opt/jdk/latest/bin:$PATH

export LD_LIBRARY_PATH=/opt/jdk/latest/lib:$LD_LIBRARY_PATH

3.  java.lang.NoClassDefFoundError: Could not initialize class net.sf.jasperreports.engine.util.JRStyledTextParser

解决方法:

-Djava.io.tmpdir=/yourdirectory/tmp

4. java.lang.UnsatisfiedLinkError: ***/lib/libfontmanager.so: libfreetype.so.6

异常:

SEVERE: Servlet.service() for servlet [dispatcherServlet] in context with path [/***] threw exception [Handler dispatch failed; nested exception is java.lang.UnsatisfiedLinkError: ***/lib/libfontmanager.so: libfreetype.so.6: cannot open shared object file: No such file or directory] with root cause
java.lang.UnsatisfiedLinkError: ***/lib/libfontmanager.so: libfreetype.so.6: cannot open shared object file: No such file or directory

解决方法:

yum -y install freetype&&\
yum-y install fontconfig

5. his method is deprecated and marked for removal. Use the getPeerCertificates() method instead.

异常:

java.lang.UnsupportedOperationException: This method is deprecated and marked for removal. Use the getPeerCertificates() method instead.

               at java.base/javax.net.ssl.SSLSession.getPeerCertificateChain(SSLSession.java:295)

               at java.base/javax.net.ssl.HandshakeCompletedEvent.getPeerCertificateChain(HandshakeCompletedEvent.java:173)

解决方法:

升级下面jar

<dependency><groupId>com.ibm.mq</groupId><artifactId>com.ibm.mq.allclient</artifactId><version>9.2.4.0</version>
</dependency>

6. Could not initialize class com.sybase.jdbc4.jdbc.SybDriver

异常:

Caused by: java.lang.NoClassDefFoundError: Could not initialize class com.sybase.jdbc4.jdbc.SybDriver

at java.lang.Class.forName0(Native Method) ~[?:?]

at java.lang.Class.forName(Class.java:467) ~[?:?]

at java.sql.DriverManager.isDriverAllowed(DriverManager.java:558) ~[java.sql:?]

at java.sql.DriverManager.isDriverAllowed(DriverManager.java:550) ~[java.sql:?]

at java.sql.DriverManager.getDrivers(DriverManager.java:451) ~[java.sql:?]

解决方法:

没有好的解决方法。既不能升级sybDriver也不能fix , 最后只能remove了。

7. Unrecognized VM option 'UseParNewGC'

异常:
Unrecognized VM option 'UseParNewGC'
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.

Unrecognized VM option 'UseConcMarkSweepGC'
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.

Error: Could not find or load main class XX:+AlwaysPreTouch
Caused by: java.lang.ClassNotFoundException: XX:+AlwaysPreTouch

Unrecognized VM option 'UseCMSInitiatingOccupancyOnly'

解决方法:

删掉这些参数,因为CMS Garbage Collector不能用了。

8. Failed to execute goal org.codehaus.groovy.maven:gmaven-plugin:1.0

[ERROR] Failed to execute goal org.codehaus.groovy.maven:gmaven-plugin:1.0:execute (default-cli) on project aspen-positions-core: java.lang.reflect.InaccessibleObjectException: Unable to make java.lang.String(char[],int,int,java.lang.Void) accessible: module java.base does not "opens java.lang" to unnamed module @2e2ccf82 -> [Help 1]

解决方法:

升级gmaven-plugin.

<plugin><groupId>org.codehaus.gmavenplus</groupId><artifactId>gmavenplus-plugin</artifactId> <version>3.0.0</version>
....
</plugin>

9.  Failed to execute goal org.codehaus.mojo:aspectj-maven-plugin:1.9:

[ERROR] Failed to execute goal org.codehaus.mojo:aspectj-maven-plugin:1.9:compile (default) on project aspen-positions-web: Execution default of goal org.codehaus.mojo:aspectj-maven-plugin:1.9:compile failed: Plugin org.codehaus.mojo:aspectj-maven-plugin:1.9 or one of its dependencies could not be resolved: Could not find artifact com.sun:tools:jar:17.0.5 at specified path C:\apps\jdk-17.0.5/../lib/tools.jar -> [Help 1]

解决方法:

升级aspectj-maven-plugin注意要把dependency全去掉

<plugin><groupId>dev.aspectj</groupId><artifactId>aspectj-maven-plugin</artifactId><version>1.13.1</version>.........</plugin>

10.InaccessibleObjectException while executing exec-maven-plugin

<plugin><groupId>org.codehaus.mojo</groupId><artifactId>exec-maven-plugin</artifactId><version>3.1.0</version>
<plugin>

Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make protected final java.lang.Class java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int) throws java.lang.ClassFormatError accessible: module java.base does not "opens java.lang" to unnamed module @5aea386f

解决方法:

再运行maven命令之前,加入下面vm参数,英文exec-maven-plugin运行的时候不是独立的jvm process.

MAVEN_OPTS=--add-opens=java.base/java.lang=ALL-UNNAMED

http://www.lryc.cn/news/158311.html

相关文章:

  • 一百七十二、Flume——Flume采集Kafka数据写入HDFS中(亲测有效、附截图)
  • pnpm 升级
  • 有关使用HttpServletRequest的Cookie的设置和获取
  • 关于 Nginx 的哪些事
  • 插入排序——希尔排序
  • C语言之初阶总结篇
  • Android签名查看
  • Educational Codeforces Round 3
  • Docker Compose常用命令
  • C++——智能指针
  • CVE-2023-3836:大华智慧园区综合管理平台任意文件上传漏洞复现
  • LAMP搭建WordPress
  • 【数学建模竞赛】预测类赛题常用算法解析
  • OFDM 系统在 AWGN 信道下对不同载波频率偏移 (CFO) 的 BER 灵敏度研究(Matlab代码实现)
  • go基础07-了解map实现原理并高效使用
  • SpringMVC进阶:常用注解、参数传递和请求响应以及页面跳转
  • nacos - centos7.x环境单机与集群快速部署
  • 文心一言初体验,和ChatGPT语言理解能力比较
  • 浏览器进程,性能指标,性能优化
  • Python基础set集合定义与函数
  • 【大数据之Kafka】九、Kafka Broker之文件存储及高效读写数据
  • Android 使用Camera2 API 和 GLSurfaceView实现相机预览
  • 说说IO多路复用
  • mysql 锁解决的办法
  • C++零碎记录(五)
  • 玩转Mysql系列 - 第16篇:变量详解
  • Windows云服务器 PHP搭建网站外网无法访问的问题
  • TuyaOS Sensor Hub组件介绍
  • 【实战】React17+React Hook+TS4 最佳实践,仿 Jira 企业级项目(总结展望篇)
  • Leetcode.321 拼接最大数