NullPointerException:ProGuard,春季启动 [英] NullPointerException: ProGuard, Spring Boot

查看:101
本文介绍了NullPointerException:ProGuard,春季启动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了空指针异常,并且对如何克服此问题和混淆代码一无所知.你有什么主意吗?

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?

我正在使用Proguard(proguard + proguard-maven-plugin)混淆[Maven] Spring-Boot项目的某些库

I'm working to obfuscate some libraries of a [Maven] Spring-Boot project with Proguard (proguard + proguard-maven-plugin)

堆栈跟踪:

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构建插件:

<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:

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     }

这最有可能意味着lib.toString()是对null引用的方法的调用.

Which means most probably the lib.toString() is an invocation of a method on a null reference.

从您提到的插件配置中,我们可以看到:

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>

因此,很可能未设置这些Maven属性之一,将其传递为空/空并导致错误.

So, most probably one of these Maven properties is not set, passed as empty/null and causing the error.

您应该检查这些属性是否具有有效值,或者应该从命令行传递而不是这种情况.

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.

这篇关于NullPointerException:ProGuard,春季启动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆