I have a general about obfuscating Hibernate-based Java application based on hibernate 3.0.
Hibernate can update a POJO object via its DAO and Base persistent layer and the associated JDBC driver to the database. Everything works great in my application with Hibernate 3.0.
I have a need to use an obfuscation tool to obfuscate the compiled Java code. One problem that I have is that Hibernate uses a lot of Java Reflection API such as Class.forName(), Class.getName(), etc. that requires the field names of the POJO classes. Therefore, if I obfuscate the POJO class, it breaks the code after obfuscation. The Hiberante-based application is deployed as a web application running under Tomcat. I have attached the detailed log trace from that exception below. (Note that everything works great before obfuscation).
I tried to leave out various layers of the hibernate related code (the POJO, DAO, Base, etc.) so that they are not obfuscated. However, I always find that some hibernate-related classes still need to be un-obfuscated.
Does anyone have any experience successfully obfuscating the hibernate-based application?
Any suggestions is much appreciated.
Regards,
Shuh
=============================================
Exception trace in log file:
ERROR 2006-10-20 16:47:35,389 - org.hibernate.PropertyNotFoundException: Could not find a getter for myPOJOField1 in class com.my.sample.MyPOJOClass
at org.hibernate.property.BasicPropertyAccessor.createGetter(BasicPropertyAccessor.java:213)
at org.hibernate.property.BasicPropertyAccessor.getGetter(BasicPropertyAccessor.java:207)
at org.hibernate.mapping.Property.getGetter(Property.java:240)
at org.hibernate.tuple.PojoTuplizer.buildPropertyGetter(PojoTuplizer.java:237)
at org.hibernate.tuple.AbstractTuplizer.<init>(AbstractTuplizer.java:73)
at org.hibernate.tuple.PojoTuplizer.<init>(PojoTuplizer.java:54)
at org.hibernate.tuple.TuplizerLookup.create(TuplizerLookup.java:47)
at org.hibernate.tuple.EntityMetamodel.<init>(EntityMetamodel.java:218)
at org.hibernate.persister.entity.BasicEntityPersister.<init>(BasicEntityPersister.java:400)
at org.hibernate.persister.entity.SingleTableEntityPersister.<init>(SingleTableEntityPersister.java:104)
at org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:55)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:211)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1005)
at com.my.sample._BaseRootDAO.initialize(_BaseRootDAO.java:59)
at com.my.sample._BaseRootDAO.initialize(_BaseRootDAO.java:47)
at com.my.sample._BaseRootDAO.initialize(_BaseRootDAO.java:38)
at com.my.sample.MyDAO.initializeLayer(MyDAO.java:101)
at com.my.sample.MyFunctions.init(MyFunctions.java:71)
at com.my.sample.HibernateInitServlet.<clinit>(HibernateInitServlet.java:23)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at java.lang.Class.newInstance0(Unknown Source)
at java.lang.Class.newInstance(Unknown Source)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1055)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:932)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:3917)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4201)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:759)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:739)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:524)
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:904)
at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:867)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:474)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1122)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:310)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1021)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:718)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1013)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:442)
at org.apache.catalina.core.StandardService.start(StandardService.java:450)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:709)
at org.apache.catalina.startup.Catalina.start(Catalina.java:551)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:294)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:432)
[/list]
|