java.lang.NoClassDefFoundError: com/yworks/yguard/obf/NoSuchMappingException
neil-benn opened this issue · 5 comments
Hello,
I've got a spring boot jar I'm attempting to obfuscate and I'm in the early stages. I've tried executing the obfuscation on the plain spring boot jar using version 2.9.1 (retrieved from maven) but I get the following stack trace:
C:\Users\neilb\Documents\GitHub\datapaq5\build.xml:20: java.lang.NoClassDefFoundError: com/yworks/yguard/obf/NoSuchMappingException at com.yworks.yguard.YGuardTask.createRename(YGuardTask.java:157) 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.tools.ant.IntrospectionHelper$CreateNestedCreator.create(IntrospectionHelper.java:1427) at org.apache.tools.ant.IntrospectionHelper$Creator.create(IntrospectionHelper.java:1343) at org.apache.tools.ant.UnknownElement.handleChild(UnknownElement.java:574) at org.apache.tools.ant.UnknownElement.handleChildren(UnknownElement.java:359) at org.apache.tools.ant.UnknownElement.configure(UnknownElement.java:205) at org.apache.tools.ant.UnknownElement.maybeConfigure(UnknownElement.java:164) at org.apache.tools.ant.Task.perform(Task.java:351) at org.apache.tools.ant.Target.execute(Target.java:437) at org.apache.tools.ant.Target.performTasks(Target.java:458) at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1406) at org.apache.tools.ant.Project.executeTarget(Project.java:1377) at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41) at org.apache.tools.ant.Project.executeTargets(Project.java:1261) at org.apache.tools.ant.Main.runBuild(Main.java:857) at org.apache.tools.ant.Main.startAnt(Main.java:236) at org.apache.tools.ant.launch.Launcher.run(Launcher.java:287) at org.apache.tools.ant.launch.Launcher.main(Launcher.java:112) Caused by: java.lang.ClassNotFoundException: com.yworks.yguard.obf.NoSuchMappingException at org.apache.tools.ant.AntClassLoader.findClassInComponents(AntClassLoader.java:1386) at org.apache.tools.ant.AntClassLoader.findClass(AntClassLoader.java:1335) at org.apache.tools.ant.AntClassLoader.loadClass(AntClassLoader.java:1090) at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521) ... 22 more
However when running with 2.7.1; it works just fine. For now I'm using the 2.7.1 version because that is what is on the yguard webpage but I thought it might help to report the problem. Please see my build.xml below:
`
<target name="setup-properties">
<!-- setup properties -->
<echo>setup properties</echo>
<property name="target.dir" value="${basedir}/target" />
<property name="dp5.jar.file" value="etc/yguard/DP5-0.1.jar" />
</target>
<target name="obfuscate-dp5" depends="setup-properties">
<taskdef name="yguard" classname="com.yworks.yguard.YGuardTask" classpath="etc/yguard/yguard-2.7.1.jar" />
<yguard>
<inoutpair in="${dp5.jar.file}" out="${dp5.jar.file}.obs" />
<rename mainclass="com.ziath.datapaq5.Datapaq5Application" logfile="renamelog.xml">
<property name="language-conformity" value="illegal" />
<property name="naming-scheme" value="mix" />
<keep>
<!-- No obfuscate non ziath libraries -->
<class classes="private" methods="private" fields="private">
<patternset>
<include name="**" />
<exclude name="com.ziath.**" />
</patternset>
</class>
</keep>
</rename>
</yguard>
<copy file="${dp5.jar.file}" tofile="${dp5.jar.file}.original" />
<copy file="${dp5.jar.file}.obs" tofile="${dp5.jar.deploy.file}" />
</target>
Thanks.
Cheers,
Neil
Cheers,
Neil
Hey @neil-benn, yguard.jar
depends on the other libraries delivered with the bundle. Did you copy these as well to the folder? They need to be in the same folder, otherwise yguard
cannot find them, hence a NoClassDefFoundError
That is a very good point! I've just looked at the pom for 2.9.1 - I'm running ant off maven so maybe the classpath of the dependent POMs isn't being passed through. I'll check that now.
Hmm, not so easy because the classpath is buried somewhere. I'll keep looking but I agree that is likely the issue. I'll work on it to help the project but I'm happy with 2.7.1 and I don't think I need the features between 2.7.1 and 2.9.1.
Closing this for now.