[英]NullPointerException: ProGuard, Spring Boot
I'm getting null pointer exception and have no ideas on how to overcome this issue and obfuscate the code. 我遇到了空指针异常,并且对如何解决此问题和混淆代码一无所知。 Do you have any ideas?
你有什么想法?
I'm working to obfuscate some libraries of a [Maven] Spring-Boot project with Proguard (proguard + proguard-maven-plugin) 我正在使用Proguard混淆[Maven] Spring-Boot项目的某些库(proguard + proguard-maven-plugin)
Stack trace: 堆栈跟踪:
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal com.github.wvengen:proguard-maven-plugin:2.0.11:proguard (proguard) on project XXX: Execution proguard of goal com.github.wvengen:proguard-maven-plugin:2.0.11:proguard failed.
(...)
Caused by: org.apache.maven.plugin.PluginExecutionException: Execution proguard of goal com.github.wvengen:proguard-maven-plugin:2.0.11:proguard failed.
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:110)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
... 19 more
Caused by: java.lang.NullPointerException
at com.github.wvengen.maven.proguard.ProGuardMojo.execute(ProGuardMojo.java:506)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
... 20 more
POM build plugin: POM构建插件:
<plugin>
<groupId>com.github.wvengen</groupId>
<artifactId>proguard-maven-plugin</artifactId>
<version>2.0.11</version>
<executions>
<execution>
<id>proguard</id>
<phase>package</phase>
<goals>
<goal>proguard</goal>
</goals>
</execution>
</executions>
<configuration>
<obfuscate>true</obfuscate>
<injar>${project.build.finalName}.jar</injar>
<outjar>${project.build.finalName}-small.jar</outjar>
<outputDirectory>${project.build.directory}/proguard</outputDirectory>
<proguardInclude>${basedir}/proguard.conf</proguardInclude>
<libs>
<lib>${java.bootstrap.classes}</lib>
<lib>${java.cryptographic.extension.classes}</lib>
<lib>${java.secure.socket.extension.classes}</lib>
</libs>
<injarNotExistsSkip>true</injarNotExistsSkip>
<options>
</options>
</configuration>
<dependencies>
<dependency>
<groupId>net.sf.proguard</groupId>
<artifactId>proguard-base</artifactId>
<version>5.2.1</version>
<scope>runtime</scope>
</dependency>
</dependencies>
</plugin>
Given the mentioned stacktrace and looking a the source code of the plugin for the 2.0.11 version, the NullPointerException is thrown in this block of the ProGuardMojo
class: 给定上述堆栈跟踪并查找2.0.11版本的插件的源代码 ,在
ProGuardMojo
类的此块中抛出NullPointerException:
502 if (libs != null) {
503 for (Iterator i = libs.iterator(); i.hasNext();) {
504 Object lib = i.next();
505 args.add("-libraryjars");
506 args.add(fileNameToString(lib.toString()));
507 }
508 }
Which means most probably the lib.toString()
is an invocation of a method on a null
reference. 这意味着
lib.toString()
最有可能是对null
引用的方法的调用。
From the plugin configuration you mentioned, we can see: 从您提到的插件配置中,我们可以看到:
<libs>
<lib>${java.bootstrap.classes}</lib>
<lib>${java.cryptographic.extension.classes}</lib>
<lib>${java.secure.socket.extension.classes}</lib>
</libs>
So, most probably one of these Maven properties is not set, passed as empty/null and causing the error. 因此,很可能未设置这些Maven属性之一,将其传递为空/空并导致错误。
You should check whether these properties have a valid value or were supposed to be passed from the command line and was not the case. 您应该检查这些属性是否具有有效值,或者应该从命令行传递而不是这种情况。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.