Hi Patrick, thanks for your answer, just a few minutes ago I found a solution. Basically I needed two enhancements, both at runtime, and the problem was a bug in the version of BCEL used by the other enhancer. Sorry for the noise.
Anyway, I found it rather strange that there is no PCEnhancerClassLoader, it could be rather useful for a number of basic setups, for testing for example, while the other automagic/advanced systems are perfect for more complex setups. I am on Java SUN 1.6.0_03 under linux, and OpenJPA does not manage to auto install its enhancer. Could you point me to the class that tries to install it? Maybe, since I am in a quite "strange" environment, there is something not compliant with what OpenJPA expects. Simone Patrick Linskey wrote: > Hi, > > Can you describe the classloader requirements of your environment in a > bit more detail? In particular, I'm wondering whether or not you can > just run the app in the classloader that has the transformed classes. > Does that make sense? > > Also, what JVM are you using? > > -Patrick > > On Jul 21, 2008, at 9:53 AM, Simone Gianni wrote: > >> Hi All, >> for a number of reasons I cannot explain right now ( :) ), I need to >> load JPA annotated classes, and enhance them with OpenJPA, from a >> ClassLoader, and not from an agent or a J2EE environment. I wrote a >> classloader that calls the PCClassFileTransformer inside the defineClass >> method, I used the code in the PCEnhancerAgent class to do this, and I >> see the classes being (properly ?) rewritten. >> >> BUT, when the class is then used by OpenJPA, it uses a different >> OpenJPAConfiguration, which returns a different MetadataFactory >> (different instance), and an error is raised as if the class was not >> enhanced. >> >> I don't see how to force OpenJPA to use the same configuration/metadata >> used by the PCClassFileTransformer, and don't even understand if this is >> somehow a way to proceed or if there is another (maybe simpler and >> smarter) solution. >> >> Got any idea? >> >> Thanks in advance, >> Simone >> >> --Simone Gianni >> http://www.simonegianni.it/ >> CEO Semeru s.r.l. >> Apache Committer >> > > --Patrick Linskey > 202 669 5907 > -- Simone Gianni http://www.simonegianni.it/ CEO Semeru s.r.l. Apache Committer
