1 Reply Latest reply on Sep 23, 2016 5:13 AM by John Heiding

    Wildfly with spring framework; Problem with javaagent (using InstrumentationLoadTimeWeaver)

    John Heiding Newbie

      Hello fellow developers!

       

      I am trying to upgrade an application previously running on jboss 4.2.2 using spring 2.5.4 to wildfly 10.1.0 and spring 4.2.7 (and java 8).

       

      When I launch the application I get the following errors;

       

      WARN  [org.springframework.web.context.support.XmlWebApplicationContext] (ServerService Thread Pool -- 59) Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [spring-dao-cfg.xml]: Invocation of init method failed; nested exception is java.lang.IllegalStateException: Must start with Java agent to use InstrumentationLoadTimeWeaver. See Spring documentation.

       

      XmlWebApplicationContext 546 Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [spring-dao-cfg.xml]: Invocation of init method failed; nested exception is java.lang.IllegalStateException: Must start with Java agent to use InstrumentationLoadTimeWeaver. See Spring documentation.

       

      ERROR [org.springframework.web.context.ContextLoader] (ServerService Thread Pool -- 59) Context initialization failed: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [spring-dao-cfg.xml]: Invocation of init method failed; nested exception is java.lang.IllegalStateException: Must start with Java agent to use InstrumentationLoadTimeWeaver. See Spring documentation.

             at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1578)

             at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:545)

             at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)

             at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)

             at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)

             at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)

             at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)

             at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1054)

             at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:829)

             at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:538)

             at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:444)

             ...

       

      Arguments to wildfly are;

      JAVA_OPTS:  -server -Xms64m -Xmx512m -XX:MetaspaceSize=96M -XX:MaxMetaspaceSize=256m -Djava.net.preferIPv4Stack=true -Djboss.modules.system.pkgs=org.jboss.byteman -Djava.awt.headless=true -javaagent:/usr/local/wildfly-10.0.0.Final/spring-instrument-4.2.7.RELEASE.jar

       

      I have also checked using -verbose:class that the InstrumentationSavingAgent and InstrumentationLoadTimeWeaver classes are loaded just once.

      ( With exception of the line "Loaded org.springframework.instrument.classloading.InstrumentationLoadTimeWeaver$FilteringClassFileTransformer from vfs:/content/myApplication.war/WEB-INF/lib/spring-context-4.2.7.RELEASE.jar" )

       

      From spring-dao-cfg.xml;

      <!--  cofiguring the entity manager -->

      <bean id="entityManagerFactory"

      class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">

      <property name="dataSource" ref="dataSource" />

      <property name="jpaVendorAdapter">

      <bean class="org.springframework.orm.jpa.vendor.EclipseLinkJpaVendorAdapter"> <!-- Changed from TopLinkJpaVendorAdapter when upgrading to spring 4.x -->

      <property name="showSql" value="true" />

      <property name="generateDdl" value="false" />

      <property name="databasePlatform" value="oracle.toplink.essentials.platform.database.MySQL4Platform" />

      </bean>

      </property>

      <property name="loadTimeWeaver">

      <bean

      class="org.springframework.instrument.classloading.InstrumentationLoadTimeWeaver" />

      </property>

      </bean>

       

       

       

      I would be most grateful for any help on what to try next.

       

      Could the problem stem from the fact that most of my dependencies are baked into the war-file? (spring-context, etc.)

       

      Must the spring-instrument agent have to be in the modules or standalone/lib folders? I have tested this, however perhaps I missed some configuration step.

       

      I am pretty new to development using spring and jboss / wildfly, so please tell me if you need more information.

       

      Best regards,

      John

       

      Edit: Added pom file.