tomcat里,生成二维码,偶尔会报错。
第一次调用报错,载入awt.dll失败.
java.lang.UnsatisfiedLinkError: D:\Program Files (x86)\Tcsl\CanYin7\environment\jre64\bin\awt.dll: Can't find dependent libraries at java.lang.ClassLoader$NativeLibrary.MPENGc91c1b38_75e5_4838_b774_6d9d97f45026load(Native Method) at java.lang.ClassLoader$NativeLibrary.load(Unknown Source) at java.lang.ClassLoader.loadLibrary1(Unknown Source) at java.lang.ClassLoader.loadLibrary0(Unknown Source) at java.lang.ClassLoader.loadLibrary(Unknown Source) at java.lang.Runtime.loadLibrary0(Unknown Source) at java.lang.System.loadLibrary(Unknown Source) at sun.security.action.LoadLibraryAction.run(Unknown Source) at sun.security.action.LoadLibraryAction.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.awt.image.ColorModel.loadLibraries(Unknown Source) at java.awt.image.ColorModel.<clinit>(Unknown Source) at java.awt.image.BufferedImage.<clinit>(Unknown Source) at com.google.zxing.client.j2se.MatrixToImageWriter.toBufferedImage(MatrixToImageWriter.java:62) at com.google.zxing.client.j2se.MatrixToImageWriter.writeToStream(MatrixToImageWriter.java:153) at com.google.zxing.client.j2se.MatrixToImageWriter.writeToStream(MatrixToImageWriter.java:139)
后面再调,报另一个错:
java.lang.NoClassDefFoundError: Could not initialize class java.awt.image.BufferedImage at com.google.zxing.client.j2se.MatrixToImageWriter.toBufferedImage(MatrixToImageWriter.java:62) at com.google.zxing.client.j2se.MatrixToImageWriter.writeToStream(MatrixToImageWriter.java:153) at com.google.zxing.client.j2se.MatrixToImageWriter.writeToStream(MatrixToImageWriter.java:139)
根源还是第一次,awt.dll载入失败了。
出现问题后,重启tomcat,就好使了,莫名其妙。 ------------------ 搜了下, 一种说增加启动参数:-Djava.awt.headless=true 一种认为载入awt.dll时,缺少依赖的dll,需要安装vc运行库。
由于只有一家有问题,安装vc运行库大礼包,再观察吧。 ---------------------
另外,由于tomcat是通过服务方式运行的,通过jvm.dll载入的。 jre的路径,并没有放到PATH变量里,或许也会影响到吧?
|