Rake loading time

I'm trying to use load time during a Grails project to be able to serialize and deserialize an object and have automatic spring dependency injection. After some searching, I found a simple example and it seems to work as expected. But after applying the same configuration to a simple Grails project, I get a lot of errors. For instance:

[ TomcatInstrumentableClassLoader@413a2870 ] error at org/springframework/web/servlet/theme/AbstractThemeResolver.java::0 class 'org.springframework.web.servlet.theme.AbstractThemeResolver' is already woven and has not been built in reweavable mode 

To test this, I created a new grails project and changed applicationContext.xml:

 <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd"> <context:spring-configured /> <context:load-time-weaver aspectj-weaving="autodetect" weaver-class="org.springframework.instrument.classloading.ReflectiveLoadTimeWeaver"/> 

In this file, I also created a new bean:

 <bean class="be.testweaving.Person" scope="prototype"> <property name="name" value="Timon"/> </bean> 

This defines a prototype for the Person class and introduces the Timon value in the name property.

I pack this as a war using grails war and deploy it on the tomcat server. This tomcat has org.springframework.instrument.tomcat-3.0.5.RELEASE.jar in its lib directory, and after deployment I see a huge list of errors that I mentioned above.

Has anyone been able to set load times in Grails?

+6
source share
1 answer

Why don't you just add your property through the metaclass?

 class ExampleBootStrap { def init = { servletContext -> Person.metaClass.constructor = { def person = BeanUtils.instantiateClass(Person) person.name = "Timon" person } } } 
0
source

Source: https://habr.com/ru/post/896203/


All Articles