1 Reply Latest reply on May 29, 2019 3:35 PM by Bin Gao

    Spring-instrument in wildfly 14 or 15

    Carlos Serrano Newbie

      Hi.

       

      We currently have a JAVA-WEB application deployed in production with the following frameworks:

      - Richfaces 3.3.3.Final

      - Jsf 1.2

      - JPA 2.0 and eclipselink 2.3.6

      - Spring 3.2.18.RELEASE

      - Java 8

       

      and we have not had any problems neither in Weblogic 10.3.6 nor in Tomcat 6 and 9.

       

      The idea is to pass the application for use in Wilfly 14 or 15 (the most current today) and we did not get it. In principle we have the problem with the agent spring-instrument. In Weblogic, for us to use it we include the following in the applicationContext.xml

       

      <context:load-time-weaver weaver-class="org.springframework.instrument.classloading.weblogic.WebLogicLoadTimeWeaver"/>

       

      and for Tomcat we include the library "spring-instrument-tomcat-3.0.5.RELEASE.jar" in the lib directory of tomcat, and in the "common.loader" parameter of the file "catalina.properties" we include that library and in the applicationContext.xml file remove the instruction:

       

      <context:load-time-weaver weaver-class="org.springframework.instrument.classloading.weblogic.WebLogicLoadTimeWeaver"/>

       

      which is specific to WebLogic and include the following:

       

      <property name="loadTimeWeaver">

        <bean class="org.springframework.instrument.classloading.ReflectiveLoadTimeWeaver"/> </property>

       

      But for Wildfly we are not able to make the application work and in principle we believe that it is because we can not include the jar of spring-instrument.

       

      The tests we have done to try to get the deployment of our application in wildfly have been:

       

      For all tests, in the applicationContext.xml file delete the weblogic and tomcat instructions seen before and include the following:

       

      <property name="loadTimeWeaver">

      <bean class="org.springframework.instrument.classloading.InstrumentationLoadTimeWeaver" /> </property>

       

      Option 1. Later we have modified the file: standalone.bat and we have included the following:

       

      If we try to deploy with this configuration, the error we get is:

       

      Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'loadTimeWeaver': Initialization of bean failed; nested exception is java.lang.IllegalStateException: ClassLoader [org.jboss.modules.ModuleClassLoader] does NOT provide an 'addTransformer(ClassFileTransformer)' method. Specify a custom LoadTimeWeaver or start your Java virtual machine with Spring's agent: -javaagent:org.springframework.instrument.jar

       

      Option 2. If we do not modify the file standalone.bat and modify the file standalone.conf.bat

      including "org.springframework" in the JAVA_OPTS:

       

      set "JAVA_OPTS=%JAVA_OPTS% -Djboss.modules.system.pkgs=org.jboss.byteman,org.springframework"

       

      and including the library of the module of spring-instrument-3.2.18.RELEASE.jar as module in wildfly, that is, creating the directory: C: \ wildfly-14.0.1.Final \ modules \ system \ layers \ base \ org \ springframework \ main files: module.xml and spring-instrument-3.2.18.RELEASE.jar, when executing the project we get the following error:

       

      ERROR [org.jboss.msc.service.fail] (MSC service thread 1-8) MSC000001: Failed to start service jboss.deployment.unit."aplicacion.war".POST_MODULE: org.jboss.msc.service.StartException in service jboss.deployment.unit."aplicacion.war".POST_MODULE: WFLYSRV0153: Failed to process phase POST_MODULE of deployment "aplicacion.war"

        at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:151)

        at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1736)

        at org.jboss.msc.service.ServiceControllerImpl$StartTask.execute(ServiceControllerImpl.java:1698)

        at org.jboss.msc.service.ServiceControllerImpl$ControllerTask.run(ServiceControllerImpl.java:1556)

        at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)

        at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:1985)

        at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1487)

        at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1378)

        at java.lang.Thread.run(Thread.java:745)

      Caused by: java.lang.NoClassDefFoundError: org/springframework/context/ApplicationContext

        at java.lang.Class.getDeclaredConstructors0(Native Method)

        at java.lang.Class.privateGetDeclaredConstructors(Class.java:2671)

        at java.lang.Class.getConstructor0(Class.java:3075)

        at java.lang.Class.getConstructor(Class.java:1825)

        at org.jboss.as.jsf.deployment.JSFComponentProcessor.deploy(JSFComponentProcessor.java:106)

        at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:144)

        ... 8 more

      Caused by: java.lang.ClassNotFoundException: org.springframework.context.ApplicationContext

       

      Please, do you know what it is that has to be configured to deploy an application that uses spring in wildfly? Do you know how to configure the agent "spring-instrument" in wildfly ?.

       

      Greetings and thank you.