cglib

How can I double-enhance a class with cglib?

Hi there! Here's the code: Patient patient = factory.createPatient(); Enhancer enhancer = new Enhancer(); enhancer.setSuperclass(patient.getClass()); enhancer.setCallback(new DefaultMethodInterceptor(patient)); patient = (Patient) enhancer.create(); assertThat(patient.getFirstName()).isNotNull(); ...

Spring - Weird Error in Bean Creation

Any idea why I am getting this exception? Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'myService' defined in class path resource [context.xml]: Initialization of bean failed; nested exception is org.springframework.beans.TypeMismatchException: Failed to convert property value of type...

Java Web Start: unsigned cglib

I am using hibernate on the server side with a client application started via Java Web Start. I can't sign the jars (I'd like to but I can't). I get a permission exception when I get a POJO with lazy fields. Caused by: java.security.AccessControlException: access denied (java.util.PropertyPermission cglib.debugLocation read) at java...

Retain annotations on CGLIB proxies?

Hi ! Am trying to create an object using an AOP framework which uses CGLIB to create proxy objects. Strangely enough, the "enhanced" proxy object is devoid of ANY annotations the previous class had! Can anyone tell me how can I make CGLIB retain the annotations on the proxies it creates? Cheers! Nirav ...

Slow CGLIB Performance using Callback Filters

I'm noticing terrible speeds when trying to use CGLIB with a callback filter (on tens of thousands of objects) but I'm unable to find any information about optimizing CGLIB. For a search/list interface, the system is loading multiple properties from an optimized query and populating the domain tree with those properties. For all other p...

Slow to start after upgraded to Spring 3

I use Struts2 and my application has thousands of action classes managed by Spring. I used Spring 2.5.6 before and my application starts quickly. But when I changed Spring to 3.0. I got a extremely slow start up of Tomcat. For each action class, I got the following debug message from Spring: DEBUG (Cglib2AopProxy.java:802) - Unable to a...

Are there alternatives to cglib?

Just out of curiosity, are there any (stable) open source projects for runtime java code generation other than cglib? And why should I use them? ...

How to force Hibernate 3.3 or 3.5 to use CGLib instead of Javassist?

Is it still possible to force Hibernate 3.3 or 3.5 to use CGLib instead of Javassist? In my properties file, I set hibernate.bytecode.provider = cglib But this doesn't seem to do it. Any thoughts? ...

How to know the line of a bug in a spring generated bean ?

Hello, I've got a website build with Spring and jpa (by hibernate). I've got a bug and I don't know how to identify the line where the bug appears. I can't debug it on my ide because it's a live version (all runs fine in local). I've got log which says: o rg.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveM...

Hibernate proxy serialization and receive on client side.

I lack understanding of how does the generated proxy class object (CGLib enhanced POJO) is transferred to the remote client and still retains its ability to generate Lazy Init. Exceptions. Does that mean that there is some kind of contract that all the transferred objects of some kind of class (a proxy) will be reinstantiated as proxies...

CGLIB proxy error after spring bean definition loading into XmlWebApplicationContext at runtime

I load additional singleton beans definitions at runtime from external jar file into existing XmlWebApplicationContext of my application: BeanFactory beanFactory = xmlWebApplicationContext.getBeanFactory(); DefaultListableBeanFactory defaultFactory = (DefaultListableBeanFactory)beanFactory; final URL url = new URL("external.jar"); fin...

Javassist failure in hibernate: invalid constant type: 60

I'm creating a cli tool to manage an existing application. Both the application and the tests build fine and run fine but despite that I receive a javassist failure when running my cli tool that exists within the jar: INFO: Bytecode provider name : javassist ... INFO: Hibernate EntityManager 3.5.1-Final Exception in thread "main" javax....

cheap way to mock an interface with no runtime overhead

Suppose I have an interface with lots of methods that I want to mock for a test, and suppose that I don't need it to do anything, I just need the object under test to have an instance of it. For example, I want to run some performance testing/benchmarking over a certain bit of code and don't want the methods on this interface to contribu...

How can i get my CGLIB proxied classes working with spring framework's ReflectionUtils?

I have a cglib proxied class because the impl uses both the @Repository @Transactional annotations. I would like to use spring's reflection utils to set the field value for mocking out one of the fields. But when reflection utils can not find the field in my class. How can i get this to work? So then i can mock out the field (collab...

Online Cglib Tutorial

Hi All, Where can we find good Cglib Tutorials online? ...

Adding state to bean generated via CGLIB's BeanGenerator

I see the following example code on how a Java Bean can be created dynamically. What I am not able to figure out is how I can update the state of an instance once created. So in the following example how can I set the value of foo to "footest" for instance bean? BeanGenerator bg = new BeanGenerator(); bg.addProperty("foo", Double.TYPE)...

Abstract DAO pattern and Spring's "Proxy cannot be cast to ..." problem!

I know this is very often asked , but I cannot find a working solution : This is my AbstractDAO : public interface AbstractDao<T> { public T get(Serializable id); //other CRUD operations } And this is my JPA's implementation: public abstract class AbstractDaoJpaImpl<T> implements AbstractDao<T> , Serializable { protected Entit...

Java, creating interface dynamiclly?

Hi there, I'm looking for a solution to create an interface in runtime. I don't really know if this is possible in anyway. Problem: I've got a OSGi service which publishes a Map<String,String> where the key defines an action for this service. I want to publish this service directly as Hessianservice with spring but for this, I need to...

Using cglib to override package-local methods

Hi, I have a Java library I'm working on that uses cglib to create subclasses of abstract classes provided by the library user, and provides automatically-generated implementations of abstract methods left in there by the user. My problem is that if the method in question has package-local (i.e. default) accessibility, the method I pro...