Announcement Announcement Module
Collapse
No announcement yet.
VMware vFabric tc Server does not save launch configuration Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • VMware vFabric tc Server does not save launch configuration

    I cannot save the VM argument for the Java agent, set to the Spring instrument.

    Whenever I save the launch configuration, it resets when I start the server in run or debug mode.

    What am I doing wrong?

    VMware vFabric tc Server Developer Edition (Runtime) v2.6

    SpringSource Tool Suite Version: 2.9.1.RELEASE, Build Id: 201203221000

    http://i.imgur.com/Wtic0.png
    Last edited by hawleyal; May 2nd, 2012, 12:35 PM. Reason: Added screenshot

  • #2
    Hey!

    The launch configuration is controlled (and possibly re-written) by the server adaptor. But you should be able to copy the launch configuration and modify it then without loosing your settings all over again.

    HTH,
    Martin

    Comment


    • #3
      Originally posted by Martin Lippert View Post
      should be able to copy the launch configuration and modify it then without loosing your settings all over again
      Thanks for the quick reply!

      One would think so. But it is not the case. Every launch configuration loses settings.

      Besides, you can't use alternate launch configurations from the servers widget.

      It seems highly inconceivable that Spring forces the use of a custom Java agent to use JPA, but bars the use of a custom Java agent with it's own built-in server.

      I must be missing something.

      Comment


      • #4
        Hey!

        I tried this myself again to configure a custom launch config and it looks like it is working as described. Go to the "run as..." menu, select the launch config of your tc Server instance that you are using, duplicate that, give it a new name, and change the VM parameter as you need it. That press "apply" and the new launch config is saved and can be used to start the server (directly from the menu in this case, instead of from the servers view).

        But I agree that this is not the easiest way of working with tc Server from within STS if you want to add custom stuff to your launch configuration. It would be better to have more options in the server editor directly available, like we provide an option to enable/disable the agent-based reloading (that then automatically configures the javaagent for this).

        But as far as I know Spring JPA doesn't require to use an javaagent for instrumentation. This should work without it on tc Server, so are you sure you need the instrumentation agent in this case?

        HTH,
        -Martin

        Comment


        • #5
          Originally posted by Martin Lippert View Post
          But as far as I know Spring JPA doesn't require to use an javaagent for instrumentation. This should work without it on tc Server, so are you sure you need the instrumentation agent in this case?
          Context without JPA property for load time weaver, returns error.

          servlet-context.xml
          Code:
          <beans:bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
              <beans:property name="dataSource" ref="dataSource"/>
              <!-- <beans:property name="loadTimeWeaver">
                  <beans:bean class="org.springframework.instrument.classloading.InstrumentationLoadTimeWeaver"/>
              </beans:property> -->
              <beans:property name="jpaVendorAdapter">
                  <beans:bean class="org.springframework.orm.jpa.vendor.EclipseLinkJpaVendorAdapter"/>
              </beans:property>
          </beans:bean>
          Code:
          ERROR: org.springframework.web.servlet.DispatcherServlet - Context initialization failed
          org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'postsController': Injection of persistence dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in ServletContext resource [/WEB-INF/spring/appServlet/servlet-context.xml]: 
          Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in ServletContext resource [/WEB-INF/spring/appServlet/servlet-context.xml]: Invocation of init method failed; nested exception is java.lang.reflect.UndeclaredThrowableException
          Caused by: java.lang.reflect.UndeclaredThrowableException
          Caused by: java.lang.reflect.InvocationTargetException
          Caused by: java.lang.IllegalStateException: Cannot apply class transformer without LoadTimeWeaver specified
          Context with JPA property for load time weaver, but not started with Java agent as Spring instrument, returns error.

          servlet-context.xml
          Code:
          <beans:bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
              <beans:property name="dataSource" ref="dataSource"/>
              <beans:property name="loadTimeWeaver">
                  <beans:bean class="org.springframework.instrument.classloading.InstrumentationLoadTimeWeaver"/>
              </beans:property>
              <beans:property name="jpaVendorAdapter">
                  <beans:bean class="org.springframework.orm.jpa.vendor.EclipseLinkJpaVendorAdapter"/>
              </beans:property>
          </beans:bean>
          Code:
          ERROR: org.springframework.web.servlet.DispatcherServlet - Context initialization failed
          org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'postsController': Injection of persistence dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in ServletContext resource [/WEB-INF/spring/appServlet/servlet-context.xml]: 
          Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in ServletContext resource [/WEB-INF/spring/appServlet/servlet-context.xml]: Invocation of init method failed; nested exception is java.lang.reflect.UndeclaredThrowableException
          Caused by: java.lang.reflect.UndeclaredThrowableException
          Caused by: java.lang.reflect.InvocationTargetException
          Caused by: java.lang.IllegalStateException: Must start with Java agent to use InstrumentationLoadTimeWeaver. See Spring documentation.
          Context with JPA property for load time weaver, and started with Java agent as Spring instrument, runs successfully.

          servlet-context.xml
          Code:
          <beans:bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
              <beans:property name="dataSource" ref="dataSource"/>
              <beans:property name="loadTimeWeaver">
                  <beans:bean class="org.springframework.instrument.classloading.InstrumentationLoadTimeWeaver"/>
              </beans:property>
              <beans:property name="jpaVendorAdapter">
                  <beans:bean class="org.springframework.orm.jpa.vendor.EclipseLinkJpaVendorAdapter"/>
              </beans:property>
          </beans:bean>
          VM arguments
          Code:
          -javaagent:"C:\Users\Alex\.m2\repository\org\springframework\spring-instrument\3.1.0.RELEASE\spring-instrument-3.1.0.RELEASE.jar"

          Comment


          • #6
            Ah, okay, you are using EclipseLink JPA... I see... My fault... Thanks for the details!
            Were you successful in duplicating the launch config in the meantime?

            I will also file a JIRA ticket to improve the tc Server integration to support this setting directly, as good as we can. Since the instrumentation JAR file is typically part of the project setup, it could get easily more complicated then we would wish... ;-)

            -Martin

            Comment


            • #7
              This is a stock template for Spring MVC Project, using Maven.
              • Added some models/entities.
              • Added the libraries for JPA, EclipseLink, and HSQLDB.
              • Added persistence.xml.
              • Modified servlet-context.xml for JPA, EclipseLink, and HSQLDB (embedded).

              Post.java
              Code:
              package app.models;
              
              import javax.persistence.Entity;
              import javax.persistence.GeneratedValue;
              import javax.persistence.GenerationType;
              import javax.persistence.Id;
              
              @Entity(name = "Posts")
              public class Post {
                  @Id @GeneratedValue(strategy=GenerationType.IDENTITY)
                  private Integer id; /* standard */ public Integer getId() {return this.id;} public void setId(Integer value) {this.id = value;}
              
                  private String name; /* standard */ public String getName() {return this.name;} public void setName(String value) {this.name = value;}
              
                  private String title; /* standard */ public String getTitle() {return this.title;} public void setTitle(String value) {this.title = value;}
              
                  private String body; /* standard */ public String getBody() {return this.body;} public void setBody(String value) {this.body = value;}
              }
              servlet-context.xml
              Code:
              <?xml version="1.0" encoding="UTF-8"?>
              <beans:beans xmlns="http://www.springframework.org/schema/mvc"
              	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
              	xmlns:beans="http://www.springframework.org/schema/beans"
              	xmlns:context="http://www.springframework.org/schema/context"
                  xmlns:jdbc="http://www.springframework.org/schema/jdbc"
              	xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
              		http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
              		http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
                      http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-3.0.xsd">
              
              	<!-- DispatcherServlet Context: defines this servlet's request-processing infrastructure -->
              	
              	<!-- Enables the Spring MVC @Controller programming model -->
              	<annotation-driven />
              
              	<!-- Handles HTTP GET requests for /resources/** by efficiently serving up static resources in the ${webappRoot}/resources directory -->
              	<resources mapping="/resources/**" location="/resources/" />
              
              	<!-- Resolves views selected for rendering by @Controllers to .jsp resources in the /WEB-INF/views directory -->
              	<beans:bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
              		<beans:property name="prefix" value="/WEB-INF/views/" />
              		<beans:property name="suffix" value=".jsp" />
              	</beans:bean>
              	
              	<context:component-scan base-package="app" />
                 
                  <!-- JPA -->
              	<beans:bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
              		<beans:property name="dataSource" ref="dataSource"/>
              		<beans:property name="loadTimeWeaver">
              			<beans:bean class="org.springframework.instrument.classloading.InstrumentationLoadTimeWeaver"/>
              		</beans:property>
                      <beans:property name="jpaVendorAdapter">
                          <beans:bean class="org.springframework.orm.jpa.vendor.EclipseLinkJpaVendorAdapter"/>
                      </beans:property>
              	</beans:bean>
              	
                  <!-- Embedded HSQL database -->
                  <jdbc:embedded-database id="dataSource" type="HSQL"/>
              	
              </beans:beans>
              persistence.xml
              Code:
              <?xml version="1.0" encoding="UTF-8"?>
              <persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence"
              	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
              	xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
                  <persistence-unit name="persistenceUnit" transaction-type="RESOURCE_LOCAL">
              		<properties>
              			<!-- <property name="eclipselink.ddl-generation" value="none"/> -->
              			<property name="eclipselink.ddl-generation" value="drop-and-create-tables"/>
              			<property name="eclipselink.ddl-generation.output-mode" value="database"/>
              			<property name="eclipselink.logging.level" value="FINEST"/>
              		</properties>
              	</persistence-unit>
              </persistence>
              pom.xml (attached)
              Attachment
              Attached Files

              Comment


              • #8
                Originally posted by Martin Lippert View Post
                EclipseLink JPA
                Right. My bosses idea of a good time. So that's where I'm going wrong?

                file a JIRA ticket
                You are awesome.

                Thanks a ton for your help, Martin.

                Comment

                Working...
                X