Proguard 混淆的一些经验教训!!!

混淆工具 proguard 前后接触一段时间了,差不多了是明白了,不过遇到很多坑,差点被跳不出来坑了!真的难学啊! 真是是太难了;

 

教训1  ServerKeyStore 是kotlin类,不能 进行普通的混淆。 

2020-02-29 01:28:18,786 [ERROR] PCStarter:167 - Unable to start server. biz.lk.pcng.server.ServerKeyStore$a.invoke()Ljava/lang/Object; [main]
java.lang.AbstractMethodError: ...server.ServerKeyStore$a.invoke()Ljava/lang/Object;
    at kotlin.SynchronizedLazyImpl.getValue(LazyJVM.kt:74)
    at ...server.ServerKeyStore.getCertAlias(ServerKeyStore.kt)
    at ...server.web.Jetty.c(Jetty.java)
    at ...server.web.Jetty.c(Jetty.java)
    at ...server.web.Jetty.a(Jetty.java)
    at ...server.web.Jetty.a(Jetty.java)
    at ...server.web.EmbeddedServer.start(EmbeddedServer.java)
    at com.lk.PCStarter.startWebServer(PCStarter.java:271)
    at com.lk.PCStarter.start(PCStarter.java:158)
    at com.lk.PCStarter.start000(PCStarter.java:115)
    at com.lk.PCStarter.main(PCStarter.java:67)
Disconnected from the target VM, address: '127.0.0.1:44519', transport: 'socket'

原因分析:反编译可以看到ServerKeyStore 的很多信息丢失了,被变成了java 类,但是人家本来就不是java类; 而且kotlin 的一下特有的注解 也不见了;

解决方案:需要保留kotlin 特性 

 

教训2   匿名内部类,被重命名了为a、b、c之类,方法的实现、继承全部失效,而且不抛错误!

org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type '...service.ConfigManager' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}

Proguard 混淆的一些经验教训!!!
2020-02-29 11:13:28,569 [ERROR] ContextLoader:350 - Context initialization failed [main]
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'tipsConfiguration' defined in file [C:\Users\admin\IdeaProjects\lk\out\production\lk3\biz\lk\pcng\web\TipsConfiguration.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type '...service.ConfigManager' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}
    at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:749)
    at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:189)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1198)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1100)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:511)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:481)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:312)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:308)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:761)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:867)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:543)
    at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:443)
    at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:325)
    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:107)
    at org.eclipse.jetty.server.handler.ContextHandler.callContextInitialized(ContextHandler.java:952)
    at org.eclipse.jetty.servlet.ServletContextHandler.callContextInitialized(ServletContextHandler.java:558)
    at org.eclipse.jetty.server.handler.ContextHandler.startContext(ContextHandler.java:917)
    at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:370)
    at org.eclipse.jetty.webapp.WebAppContext.startWebapp(WebAppContext.java:1497)
    at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1459)
    at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:847)
    at org.eclipse.jetty.servlet.ServletContextHandler.doStart(ServletContextHandler.java:287)
    at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:545)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:138)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:108)
    at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:113)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:138)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:117)
    at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:113)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:138)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:108)
    at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:113)
    at org.eclipse.jetty.server.handler.gzip.GzipHandler.doStart(GzipHandler.java:410)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:138)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:108)
    at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:113)
    at org.eclipse.jetty.server.handler.StatisticsHandler.doStart(StatisticsHandler.java:256)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:138)
    at org.eclipse.jetty.server.Server.start(Server.java:416)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:108)
    at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:113)
    at org.eclipse.jetty.server.Server.doStart(Server.java:383)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
    at ...server.web.EmbeddedServer.start(EmbeddedServer.java:81)
    at com.lk.PCStarter.startWebServer(PCStarter.java:271)
    at com.lk.PCStarter.start(PCStarter.java:158)
    at com.lk.PCStarter.start000(PCStarter.java:115)
    at com.lk.PCStarter.main(PCStarter.java:67)
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type '...service.ConfigManager' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoMatchingBeanFound(DefaultListableBeanFactory.java:1491)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1102)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1064)
    at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:835)
    at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:741)
    ... 54 more
2020-02-29 11:13:28,575 [WARN ] WebAppContext:554 - Failed startup of context o.e.j.w.WebAppContext@f90849{lk,/,file:/C:/Users/admin/IdeaProjects/lk/web/,UNAVAILABLE}{./web} [main]
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'tipsConfiguration' defined in file [C:\Users\admin\IdeaProjects\lk\out\production\lk3\biz\lk\pcng\web\TipsConfiguration.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type '...service.ConfigManager' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}
    at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:749)
    at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:189)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1198)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1100)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:511)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:481)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:312)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:308)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:761)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:867)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:543)
    at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:443)
    at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:325)
    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:107)
    at org.eclipse.jetty.server.handler.ContextHandler.callContextInitialized(ContextHandler.java:952)
    at org.eclipse.jetty.servlet.ServletContextHandler.callContextInitialized(ServletContextHandler.java:558)
    at org.eclipse.jetty.server.handler.ContextHandler.startContext(ContextHandler.java:917)
    at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:370)
    at org.eclipse.jetty.webapp.WebAppContext.startWebapp(WebAppContext.java:1497)
    at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1459)
    at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:847)
    at org.eclipse.jetty.servlet.ServletContextHandler.doStart(ServletContextHandler.java:287)
    at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:545)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:138)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:108)
    at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:113)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:138)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:117)
    at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:113)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:138)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:108)
    at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:113)
    at org.eclipse.jetty.server.handler.gzip.GzipHandler.doStart(GzipHandler.java:410)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:138)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:108)
    at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:113)
    at org.eclipse.jetty.server.handler.StatisticsHandler.doStart(StatisticsHandler.java:256)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:138)
    at org.eclipse.jetty.server.Server.start(Server.java:416)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:108)
    at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:113)
    at org.eclipse.jetty.server.Server.doStart(Server.java:383)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
    at ...server.web.EmbeddedServer.start(EmbeddedServer.java:81)
    at com.lk.PCStarter.startWebServer(PCStarter.java:271)
    at com.lk.PCStarter.start(PCStarter.java:158)
    at com.lk.PCStarter.start000(PCStarter.java:115)
    at com.lk.PCStarter.main(PCStarter.java:67)
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type '...service.ConfigManager' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoMatchingBeanFound(DefaultListableBeanFactory.java:1491)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1102)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1064)
    at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:835)
    at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:741)
    ... 54 more
2020-02-29 11:13:29,367 [ERROR] PCStarter:273 - Error occurred starting server. Start error server. [main]
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'tipsConfiguration' defined in file [C:\Users\admin\IdeaProjects\lk\out\production\lk3\biz\lk\pcng\web\TipsConfiguration.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type '...service.ConfigManager' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}
    at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:749)
    at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:189)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1198)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1100)
    
    
    
View Code

原因分析:因为它不是public 类,本来需要一个, 结果找不到,因为混淆之后,某些package 没有被扫描到! 混淆之后 原来继承jetty框架的类, 因为是内部类,被重命名了为a、b、c之类的导致 相当于没有继承,从而没有执行,从而导致了 严重问题!

解决方案:需要保留某些内部匿名类、非public内等

 

教训3  private 方法,混淆之后被重命名,hibernate 反射访问出错:

 Could not find a setter for property groupLinks in class ...domain.User

Proguard 混淆的一些经验教训!!!
2020-02-29 12:05:03,910 [DEBUG] DataSourceConfig:44 - Creating primary datasource router for main: org.springframework.jdbc.datasource.IsolationLevelDataSourceAdapter@1ea9f02, secondary: org.springframework.jdbc.datasource.IsolationLevelDataSourceAdapter@18cb7c6 [main]
2020-02-29 12:05:06,174 [ERROR] ContextLoader:350 - Context initialization failed [main]
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'tipsConfiguration' defined in file [C:\Users\admin\IdeaProjects\lk\out\production\lk3\biz\lk\pcng\web\TipsConfiguration.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'configManager' defined in URL [jar:file:/D:/dev/svn_new/trunk/pc-webserver/server/lib/pcng-server-18.3.2.jar!/biz/lk/pcng/service/impl/ConfigManagerImpl.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'configPropertyDAO' defined in class path resource [biz/lk/pcng/persistence/hibernate/applicationContext-hibernate.xml]: Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [biz/lk/pcng/persistence/hibernate/applicationContext-hibernate.xml]: Invocation of init method failed; nested exception is org.hibernate.HibernateException: Unable to instantiate default tuplizer [org.hibernate.tuple.entity.PojoEntityTuplizer]
    at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:749)
    at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:189)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1198)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1100)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:511)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:481)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:312)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:308)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:761)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:867)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:543)
    at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:443)
    at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:325)
    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:107)
    at org.eclipse.jetty.server.handler.ContextHandler.callContextInitialized(ContextHandler.java:952)
    at org.eclipse.jetty.servlet.ServletContextHandler.callContextInitialized(ServletContextHandler.java:558)
    at org.eclipse.jetty.server.handler.ContextHandler.startContext(ContextHandler.java:917)
    at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:370)
    at org.eclipse.jetty.webapp.WebAppContext.startWebapp(WebAppContext.java:1497)
    at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1459)
    at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:847)
    at org.eclipse.jetty.servlet.ServletContextHandler.doStart(ServletContextHandler.java:287)
    at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:545)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:138)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:108)
    at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:113)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:138)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:117)
    at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:113)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:138)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:108)
    at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:113)
    at org.eclipse.jetty.server.handler.gzip.GzipHandler.doStart(GzipHandler.java:410)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:138)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:108)
    at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:113)
    at org.eclipse.jetty.server.handler.StatisticsHandler.doStart(StatisticsHandler.java:256)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:138)
    at org.eclipse.jetty.server.Server.start(Server.java:416)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:108)
    at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:113)
    at org.eclipse.jetty.server.Server.doStart(Server.java:383)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
    at ...server.web.EmbeddedServer.start(EmbeddedServer.java:81)
    at com.lk.PCStarter.startWebServer(PCStarter.java:271)
    at com.lk.PCStarter.start(PCStarter.java:158)
    at com.lk.PCStarter.start000(PCStarter.java:115)
    at com.lk.PCStarter.main(PCStarter.java:67)
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'configManager' defined in URL [jar:file:/D:/dev/svn_new/trunk/pc-webserver/server/lib/pcng-server-18.3.2.jar!/biz/lk/pcng/service/impl/ConfigManagerImpl.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'configPropertyDAO' defined in class path resource [biz/lk/pcng/persistence/hibernate/applicationContext-hibernate.xml]: Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [biz/lk/pcng/persistence/hibernate/applicationContext-hibernate.xml]: Invocation of init method failed; nested exception is org.hibernate.HibernateException: Unable to instantiate default tuplizer [org.hibernate.tuple.entity.PojoEntityTuplizer]
    at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:749)
    at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:189)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1198)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1100)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:511)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:481)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:312)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:308)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
    at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:208)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1136)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1064)
    at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:835)
    at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:741)
    ... 54 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'configPropertyDAO' defined in class path resource [biz/lk/pcng/persistence/hibernate/applicationContext-hibernate.xml]: Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [biz/lk/pcng/persistence/hibernate/applicationContext-hibernate.xml]: Invocation of init method failed; nested exception is org.hibernate.HibernateException: Unable to instantiate default tuplizer [org.hibernate.tuple.entity.PojoEntityTuplizer]
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:359)
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:108)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1534)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1281)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:551)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:481)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:312)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:308)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
    at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:208)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1136)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1064)
    at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:835)
    at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:741)
    ... 68 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [biz/lk/pcng/persistence/hibernate/applicationContext-hibernate.xml]: Invocation of init method failed; nested exception is org.hibernate.HibernateException: Unable to instantiate default tuplizer [org.hibernate.tuple.entity.PojoEntityTuplizer]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1631)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:553)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:481)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:312)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:308)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:351)
    ... 82 more
Caused by: org.hibernate.HibernateException: Unable to instantiate default tuplizer [org.hibernate.tuple.entity.PojoEntityTuplizer]
    at org.hibernate.tuple.entity.EntityTuplizerFactory.constructTuplizer(EntityTuplizerFactory.java:108)
    at org.hibernate.tuple.entity.EntityTuplizerFactory.constructDefaultTuplizer(EntityTuplizerFactory.java:133)
    at org.hibernate.tuple.entity.EntityEntityModeToTuplizerMapping.<init>(EntityEntityModeToTuplizerMapping.java:80)
    at org.hibernate.tuple.entity.EntityMetamodel.<init>(EntityMetamodel.java:322)
    at org.hibernate.persister.entity.AbstractEntityPersister.<init>(AbstractEntityPersister.java:485)
    at org.hibernate.persister.entity.SingleTableEntityPersister.<init>(SingleTableEntityPersister.java:133)
    at org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:84)
    at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:286)
    at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1872)
    at org.springframework.orm.hibernate3.LocalSessionFactoryBean.newSessionFactory(LocalSessionFactoryBean.java:795)
    at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:717)
    at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:191)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1689)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1627)
    ... 89 more
Caused by: java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at org.hibernate.tuple.entity.EntityTuplizerFactory.constructTuplizer(EntityTuplizerFactory.java:105)
    ... 102 more
Caused by: org.hibernate.PropertyNotFoundException: Could not find a setter for property groupLinks in class ...domain.User
    at org.hibernate.property.BasicPropertyAccessor.createSetter(BasicPropertyAccessor.java:262)
    at org.hibernate.property.BasicPropertyAccessor.getSetter(BasicPropertyAccessor.java:255)
    at org.hibernate.mapping.Property.getSetter(Property.java:335)
    at org.hibernate.tuple.entity.PojoEntityTuplizer.buildPropertySetter(PojoEntityTuplizer.java:304)
    at org.hibernate.tuple.entity.AbstractEntityTuplizer.<init>(AbstractEntityTuplizer.java:156)
    at org.hibernate.tuple.entity.PojoEntityTuplizer.<init>(PojoEntityTuplizer.java:77)
    ... 107 more 
    
View Code

原因分析:本来需要一个 setGroupLinks, 结果因为 setGroupLinks 是 private 方法,混淆之后被重命名..  ———— 没想到 hibernate需要对 private 方法进行反射, 实在没想到。

解决方案:需要保留persistent层 hibernate用到的一些 domain 类 的private  属性

 

教训4 无法进行转换: Cannot convert value of type '...$$..' to required type '...'

    
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'synchronisationManager' defined in class path resource [biz/lk/pcng/service/applicationContext-service.xml]: Cannot resolve reference to bean 'userManager' while setting bean property 'userManager'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'userManager' defined in class path resource [biz/lk/pcng/service/applicationContext-service.xml]: Unsatisfied dependency expressed through constructor parameter 0: Could not convert argument value of type [...service.impl.AccountManagerImpl$$EnhancerBySpringCGLIB$$9dcff66f] to required type [...persistence.UserDAO]: Failed to convert value of type '...service.impl.AccountManagerImpl$$EnhancerBySpringCGLIB$$9dcff66f' to required type '...persistence.UserDAO'; nested exception is java.lang.IllegalStateException: Cannot convert value of type '...service.impl.AccountManagerImpl$$EnhancerBySpringCGLIB$$9dcff66f' to required type '...persistence.UserDAO': no matching editors or conversion strategy found

 

Proguard 混淆的一些经验教训!!!
2020-02-29 16:05:32,728 [WARN ] WebAppContext:554 - Failed startup of context o.e.j.w.WebAppContext@f90849{lk,/,file:/C:/Users/admin/IdeaProjects/lk/web/,UNAVAILABLE}{./web} [main]
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'userSourceUtils' defined in file [C:\Users\admin\IdeaProjects\lk\out\production\lk3\biz\lk\pcng\web\util\UserSourceUtils.class]: Unsatisfied dependency expressed through constructor parameter 1; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'synchronisationManager' defined in class path resource [biz/lk/pcng/service/applicationContext-service.xml]: Cannot resolve reference to bean 'userManager' while setting bean property 'userManager'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'userManager' defined in class path resource [biz/lk/pcng/service/applicationContext-service.xml]: Unsatisfied dependency expressed through constructor parameter 0: Could not convert argument value of type [...service.impl.AccountManagerImpl$$EnhancerBySpringCGLIB$$a4971023] to required type [...persistence.UserDAO]: Failed to convert value of type '...service.impl.AccountManagerImpl$$EnhancerBySpringCGLIB$$a4971023' to required type '...persistence.UserDAO'; nested exception is java.lang.IllegalStateException: Cannot convert value of type '...service.impl.AccountManagerImpl$$EnhancerBySpringCGLIB$$a4971023' to required type '...persistence.UserDAO': no matching editors or conversion strategy found
    at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:749)
    at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:189)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1198)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1100)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:511)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:481)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:312)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:308)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:761)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:867)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:543)
    at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:443)
    at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:325)
    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:107)
    at org.eclipse.jetty.server.handler.ContextHandler.callContextInitialized(ContextHandler.java:952)
    at org.eclipse.jetty.servlet.ServletContextHandler.callContextInitialized(ServletContextHandler.java:558)
    at org.eclipse.jetty.server.handler.ContextHandler.startContext(ContextHandler.java:917)
    at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:370)
    at org.eclipse.jetty.webapp.WebAppContext.startWebapp(WebAppContext.java:1497)
    at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1459)
    at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:847)
    at org.eclipse.jetty.servlet.ServletContextHandler.doStart(ServletContextHandler.java:287)
    at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:545)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:138)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:108)
    at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:113)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:138)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:117)
    at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:113)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:138)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:108)
    at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:113)
    at org.eclipse.jetty.server.handler.gzip.GzipHandler.doStart(GzipHandler.java:410)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:138)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:108)
    at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:113)
    at org.eclipse.jetty.server.handler.StatisticsHandler.doStart(StatisticsHandler.java:256)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:138)
    at org.eclipse.jetty.server.Server.start(Server.java:416)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:108)
    at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:113)
    at org.eclipse.jetty.server.Server.doStart(Server.java:383)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
    at ...server.web.EmbeddedServer.start(EmbeddedServer.java)
    at com.lk.PCStarter.startWebServer(PCStarter.java:271)
    at com.lk.PCStarter.start(PCStarter.java:158)
    at com.lk.PCStarter.start000(PCStarter.java:115)
    at com.lk.PCStarter.main(PCStarter.java:67)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'synchronisationManager' defined in class path resource [biz/lk/pcng/service/applicationContext-service.xml]: Cannot resolve reference to bean 'userManager' while setting bean property 'userManager'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'userManager' defined in class path resource [biz/lk/pcng/service/applicationContext-service.xml]: Unsatisfied dependency expressed through constructor parameter 0: Could not convert argument value of type [...service.impl.AccountManagerImpl$$EnhancerBySpringCGLIB$$a4971023] to required type [...persistence.UserDAO]: Failed to convert value of type '...service.impl.AccountManagerImpl$$EnhancerBySpringCGLIB$$a4971023' to required type '...persistence.UserDAO'; nested exception is java.lang.IllegalStateException: Cannot convert value of type '...service.impl.AccountManagerImpl$$EnhancerBySpringCGLIB$$a4971023' to required type '...persistence.UserDAO': no matching editors or conversion strategy found
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:359)
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:108)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1534)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1281)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:551)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:481)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:312)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:308)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
    at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:208)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1136)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1064)
    at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:835)
    at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:741)
    ... 54 more
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'userManager' defined in class path resource [biz/lk/pcng/service/applicationContext-service.xml]: Unsatisfied dependency expressed through constructor parameter 0: Could not convert argument value of type [...service.impl.AccountManagerImpl$$EnhancerBySpringCGLIB$$a4971023] to required type [...persistence.UserDAO]: Failed to convert value of type '...service.impl.AccountManagerImpl$$EnhancerBySpringCGLIB$$a4971023' to required type '...persistence.UserDAO'; nested exception is java.lang.IllegalStateException: Cannot convert value of type '...service.impl.AccountManagerImpl$$EnhancerBySpringCGLIB$$a4971023' to required type '...persistence.UserDAO': no matching editors or conversion strategy found
    at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:723)
    at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:189)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1198)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1100)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:511)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:481)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:312)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:308)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:351)
    ... 68 more
View Code

原因分析:注意看,错误是 : Cannot convert value of type '...service.impl.AccountManagerImpl$$..' to required type '...persistence.UserDAO, 简直不可思议, 为什么会进行 AccountManagerImpl 和 UserDAO 的转换? 猜测是因为 userManager 的构造器有多个参数, 混淆之后 参数名字丢失, 无法 根据applicationContext-service.xml进行名字的设定,所以出现了这等奇怪问题;

解决方案:  UserManager 及 UserManagerImpl 等service类不进行任何的混淆.. 暂时只能这样。

 

教训4  需一个类, 结果却有多个:

biz.papercut.pcng.server.config.CommonConfig#propertyConfigurer

@ImportResource(
    locations = {"classpath:/applicationContext-main.xml", "classpath:/biz/papercut/pcng/persistence/hibernate/applicationContext-hibernate.xml", "classpath:/biz/papercut/pcng/service/applicationContext-service.xml", "classpath:/biz/papercut/pcng/webservices/xmlrpc/applicationContext-xmlrpc.xml", "classpath*:/com/papercut/device/web/**/applicationContext-device-web-*.xml"}
)
@Configuration
public class CommonConfig {
    public CommonConfig() {
    }

    @Bean
    public ServerConfig bootstrapConfig() {
        return ServerConfig.getInstance();
    }

    @Bean
    public Properties bootstrapProperties(ServerConfig serverConfig) {
        return serverConfig.getAllProperties();
    }

    @Bean
    public PropertySourcesPlaceholderConfigurer propertyConfigurer(Properties bootstrapProperties) {
        PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer = new PropertySourcesPlaceholderConfigurer();
        propertySourcesPlaceholderConfigurer.setProperties(bootstrapProperties);
        propertySourcesPlaceholderConfigurer.setIgnoreResourceNotFound(true);
        propertySourcesPlaceholderConfigurer.setIgnoreUnresolvablePlaceholders(true);
        return propertySourcesPlaceholderConfigurer;
    }
}

propertyConfigurer 方法需要一个 Properties , 结果发现有多个:

Proguard 混淆的一些经验教训!!!

 

 

 

原因分析:反编译可以看到 propertyConfigurer 方法的参数名字已经丢失了,不知道为什么, 本来应该是 bootstrapProperties, 结果却..   猜测是 不能通过name进行自动注入,于是只能通过type,但是可选的 type有多个, 故出现错误..

解决方案: 保留必要的方法签名, 包括名字、参数

 

...

 

我的配置参考:

 
-injars 'C:\Users\admin\IdeaProjects\test\out\production\test3'
-outjars 'D:\dev\svn_new\测试\test-lk-3.0.2.852741.jar'

-libraryjars 'C:\Program Files (x86)\Java\jdk1.8.0_121\jre\lib\rt.jar'

-skipnonpubliclibraryclasses
-forceprocessing
-dontshrink
-dontoptimize
-keepattributes Exceptions,InnerClasses,Signature,Deprecated,SourceFile,*Annotation*,Synthetic,EnclosingMethod
-verbose
-dontnote
-dontwarn
-dontpreverify 
# -dontobfuscate
# -dontwarn kotlin.**// 同一个dontwarn 指定多次,以后者为准...  -dontwarn kotlin 的意思是 kotlin目录下的类 不warn, 但是其他的 还是需要的!! 非常容易混淆!

-keep,allowshrinking class * {
    !private <fields>;
    !private <methods>;
}
 

# Also keep - Enumerations. Keep the special static methods that are required in
# enumeration classes.
-keepclassmembers enum  * {
    public static **[] values();
    public static ** valueOf(java.lang.String);
}


-keep class kotlin.** { *; }
-keep class kotlin.Metadata { *; }

-keepclassmembers class **$WhenMappings {
    <fields>;
}
 

-keepclassmembers class kotlin.Metadata { *; }

-keep @kotlin.Metadata class * 
-keepclasseswithmembers @kotlin.Metadata class * { *; }

-assumenosideeffects class kotlin.jvm.internal.Intrinsics {
    static void checkParameterIsNotNull(java.lang.Object, java.lang.String);
}
 
-keepclassmembers class **$** {
    *;
}
-keepclasseswithmembers class **$** {
    *;
}

-keep class biz.papercut.pcng.domain.** { *; }
-keep class biz.papercut.pcng.service.** { *; }
-keep class biz.papercut.pcng.persistence.** { *; }

-keep class biz.papercut.pcng.server.config.** { *; }
 

-keep @org.springframework.stereotype.Service class *
 
-keep @org.springframework.context.annotation.Configuration class * { *; }


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

 

注意 

dontwarn不能出现多次, 否则以后者为准 ,忽视前面的, Proguard 这个配置 非常蛋疼, 一不小心结果面目全非。

 

 

 

 

 

 

 

 

org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type '...service.ConfigManager' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}

上一篇:菜鸡的Spring学习—BeanFactoryPostProcessor和BeanPostProcessor


下一篇:数据挖掘——概述