Proguard error when creating beans

I’m using jaxrs:serviceBeans for my resource classes when i try to deploy project after obfucation i got errors like second screenshot.I think this error about class names but i don’t know hot to fix this problem.

   <jaxrs:server id="adtsResource" address="/rs">
        <jaxrs:serviceBeans>
            <ref bean="authenticationResource"/>
            <ref bean="apiKeyResource"/>
            <ref bean="authorityResource"/>
            <ref bean="userResource"/>
            <ref bean="ruleEditorResource"/>
            <ref bean="beResource"/>
            <ref bean="beConfigResource"/>
            <ref bean="eventStreamResource"/>
            <ref bean="ruleBookResource"/>
            <ref bean="ruleResource"/>
            <ref bean="txnDataResource"/>
            <ref bean="generalDataResource"/>
            <ref bean="strListResource"/>
            <ref bean="converterResource"/>
            <ref bean="customActionResource"/>
            <ref bean="taskResource"/>
            <ref bean="activeDirectoryResource"/>
            <ref bean="appFraudResource"/>
            <ref bean="airSystemResource"/>
            <ref bean="auditLogResource"/>
            <ref bean="checkerSettingsResource"/>
            <ref bean="ruleBookWorkspaceResource"/>
        </jaxrs:serviceBeans>

Hi @grrkaan ,

Can you please try adding a -keep rule for the missing Bean(s)? Based on the stack trace above, I believe a rule as follows should do the trick;

-keep class com.ihs.adts.srv.SrvAuthentication

This will prevent ProGuard from removing (shrinking), optimizing, and obfuscating the name of this class. Please note you may need to repeat the process for different beans as you continue to test/debug your web app.

Best regards,

Jonas

I already used this command nothing changed.I also keep classes inside the SrvAuthentication class.

-target 11

-printmapping proguard.map

#-packageobfuscationdictionary package-dictionary.txt
-dontwarn

-dontshrink

-dontoptimize

#-dontpreverify

-dontnote

-dontskipnonpubliclibraryclassmembers

-dontskipnonpubliclibraryclasses

-keepdirectories

-keepattributes Exceptions,InnerClasses,Signature,Deprecated,SourceFile,LineNumberTable,LocalVariable*Table,*Annotation*,Synthetic,EnclosingMethod

-renamesourcefileattribute SourceFile

-keepclassmembers class * {
    @javax.annotation.Resource *;
}

-keepclasseswithmembers public class * {
   public static void main(java.lang.String[]);
  }

-keepclassmembers class * {
  ** MODULE$;
  }

-keepclasseswithmembernames,includedescriptorclasses class * {
  native <methods>;
  }

-keepclassmembers class * extends java.lang.Enum {
    <fields>;
    public static **[] values();
    public static ** valueOf(java.lang.String);
    public static ** fromValue(java.lang.String);
}  

-keepclassmembers class * implements java.io.Serializable {
     static final long serialVersionUID;
     private static final java.io.ObjectStreamField[] serialPersistentFields;
     !static !transient <fields>;
     !private <fields>;
     !private <methods>;
     private void writeObject(java.io.ObjectOutputStream);
     private void readObject(java.io.ObjectInputStream);
     java.lang.Object writeReplace();
     java.lang.Object readResolve();
}

-keepclassmembers class * {

     @javax.annotation.PostConstruct <methods>;
     @javax.annotation.PreDestroy <methods>;

     @org.springframework.beans.factory.annotation.Qualifier *;
     @org.springframework.context.annotation.Bean *;
     @org.springframework.beans.factory.annotation.Autowired <fields>;
     @org.springframework.beans.factory.annotation.Autowired <methods>;
     @org.springframework.beans.factory.annotation.Autowired *;
     @org.springframework.beans.factory.annotation.* *;
     @org.springframework.context.annotation.Primary *;
     @org.springframework.security.access.prepost.PreAuthorize <methods>;
     @org.springframework.beans.factory.annotation.Value *;
     @org.springframework.beans.factory.annotation.Required *;
     @org.springframework.security.crypto.* *;
     @javax.inject.Inject *;
     @javax.annotation.PostConstruct *;
     @javax.annotation.PreDestroy *;
}

-keepclassmembers class com.ihs.adts.common.** {
	<fields>;
	<methods>;
}

-keep class * {
  !static !transient <fields>;
}

-keepclassmembers class * {
    *** get*();
    void set*(***);
}

-keep class com.ihs.adts.mem.** { *; }
-keep class com.ihs.adts.rs.** { *; }
-keep class com.ihs.adts.config.** { *; }
-keep class com.ihs.adts.core.config.** { *; }
-keep class com.ihs.adts.core.cc.** { *; }
-keep class com.ihs.adts.data.config.** { *; }
-keep class com.ihs.adts.ruleengine.config.** { *; }
-keep class com.ihs.adts.srv.config.** { *; }
-keep class com.ihs.adts.srv.reqres.** { *;}
-keep class com.ihs.adts.srv.SrvBe{ *;}
-keep class com.ihs.adts.constants.** { *; }
-keep class com.ihs.adts.resp.** { *; }
-keep class com.ihs.adts.dto.** { *; }
-keep class com.ihs.adts.rs.resource.BeResource { *; }
-keep class com.ihs.adts.data.domain.** { *; }
-keep class com.ihs.adts.core.user.** { *; }
-keep class com.ihs.adts.core.authority.** { *; }
-keep class com.ihs.adts.core.CheckerSettingsService  { *; }
-keep class com.ihs.adts.context.annotation.** { *; }
-keep class com.ihs.adts.rs.resource.AuthenticationResource { *; }
-keep class com.ihs.adts.srv.SrvAuthentication { *; }
-keep class com.ihs.adts.srv.SrvCaptcha { *; }

-keep class com.ihs.adts.core.mapper.** { *; }
-keep class com.ihs.adts.srv.SrvActiveDirectoryOperations { *; }
-keep class com.ihs.adts.core.auditlog.** { *; }
-keep class com.ihs.adts.mem.ops.AuthenticationMemOps { *; }


-keeppackagenames com.ihs.adts.common, com.ihs.adts.data, com.ihs.adts.core, com.ihs.adts.srv, com.ihs.adts.ruleengine, com.ihs.adts.rs, com.ihs.adts.mem

this is my config file.

I see that you already have -dontshrink, -dontoptimize in your configuration.

If you also add -dontobfuscate: does that solve the issue? If yes, then it indicates that some required classes are still being renamed.

You should then try to narrow down -keep rules to keep the classes, methods and fields that you need. For example, start with some broad -keep rule: -keep class com.ihs.** {*; }

If that works, then narrow the rule down further.

1 Like