GWT 1.6 - Jetty - Hosted Mode - how to provide JVM parameter "-javaagent"

844 views
Skip to first unread message

M Shannon

unread,
Apr 11, 2009, 12:05:06 PM4/11/09
to Google Web Toolkit
Hi,

I'm testing out GWT 1.6 with Eclipse Ganymede and the GWT plugin.

I've attempted to migrate a simple GWT 1.5 app that was completely
maven/jetty based and see if it can be tested out with hosted mode
jetty.

I need to supply a -javaagent parameter to the Jetty hosted mode
server JVM for spring configuration.

I was hoping by editing the launch configuration VM arguments, I could
easily set this parameter.

So I choose - Edit Launch Configuration > Arguments > VM Arguments:
-javaagent:${project_loc}\war\WEB-INF\lib\spring-agent-2.5.4.jar

And then invoke Run as Web Application

Unfortunately I get an error message when launching this configuration
inferring the -javaagent property is not set

:-

[WARN] Failed startup of context
com.google.gwt.dev.shell.jetty.JettyLauncher
$WebAppContextWithReload@13c29fe{/,C:\technology\workspace\test_web
\war}
org.springframework.beans.factory.BeanCreationException: Error
creating bean with name
'org.springframework.context.weaving.AspectJWeavingEnabler#0':
Initialization of bean failed; nested exception is
org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'loadTimeWeaver': Initialization of bean
failed; nested exception is java.lang.IllegalStateException:
ClassLoader [com.google.gwt.dev.shell.jetty.JettyLauncher
$WebAppContextWithReload$WebAppClassLoaderExtension] does NOT provide
an 'addTransformer(ClassFileTransformer)' method. Specify a custom
LoadTimeWeaver or start your Java virtual machine with Spring's agent:
-javaagent:spring-agent.jar


Is there anything I can do here to get this to work?

EZhulenev

unread,
Apr 13, 2009, 8:06:49 AM4/13/09
to Google Web Toolkit
I have the same problem. How is it possible to use spring-agent in
hosted mode?

Sumit Chandel

unread,
Apr 15, 2009, 9:58:57 PM4/15/09
to Google-We...@googlegroups.com
Hello everyone,

The best way to use custom server-side frameworks or technologies with hosted mode is to use your own server instead of the embedded Jetty instance. This can be accomplished by passing in the -noserver flag, or if you're using the Google Eclipse Plug-in, by setting a couple of options in the Web Application run configuration.

If you're running hosted mode from command line, simply add the following as GWTShell / HostedMode arguments in your script:
-noserver <URL pointing to your development server>

If you're using the Google Eclipse Plug-in, follow these steps instead:

1) Select and open the Web Application run configuration you want to execute (Run > Run Configurations... > Expand the 'Web Application' configurations > Select your run configuration).

2) In the 'Main' tab, under the Embedded Server section, uncheck the "Run built-in server checkbox.

3) Next, in the "GWT" tab, change the URL to point to your development server.

This way you can run hosted mode with your own development server, customized as needed to match your production server-side settings.

Hope that helps,
-Sumit Chandel

marco

unread,
Apr 28, 2009, 5:29:05 PM4/28/09
to Google Web Toolkit
Running a separate server is what I did for the past couple of months
whilst developing my web app and, frankly, is a pain :-)

I ran into exactly the same problem and, after searching in vain for a
Jetty-solution, I decided to just address the issue at the root and do
away with the LocalContainerEntityManagerFactoryBean.
I'm using instead a (much more limited)
org.springframework.orm.jpa.LocalEntityManagerFactoryBean.

so my beans.xml has changed to:

<bean id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalEntityManagerFactoryBean">
<property name="persistenceUnitName" value="StocksPU"/>
</bean>

<!-- no longer used
<bean id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="jpaVendorAdapter">
<bean
class="org.springframework.orm.jpa.vendor.TopLinkJpaVendorAdapter">
<property name="showSql" value="false" />
<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>
-->

this was the original bean def - what I particularly liked was the
fact I could configure the data source from
a properties file, and in fact, I had several of them (prod,
dev and test) all operating on different db's (in fact, the dev
instance was even on a different server altogheter.

<bean id="dataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="url" value="${jdbc.url}" />
<property name="driverClassName" value="${jdbc.driver}" />
<property name="username" value="${jdbc.username}" />
<property name="password" value="${jdbc.password}" />
</bean>

<bean id="testDataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="url" value="${jdbc.test.url}" />
<property name="driverClassName" value="${jdbc.driver}" />
<property name="username" value="${jdbc.test.username}" />
<property name="password" value="${jdbc.test.password}" />
</bean>

This is now all gone out of the window - the datasource parameters are
configured in META-INF/persistence.xml:

<?xml version="1.0" encoding="UTF-8"?>

<persistence xmlns="http://java.sun.com/xml/ns/persistence"
version="1.0" >
<persistence-unit name="StocksPU" transaction-
type="RESOURCE_LOCAL">
<class>com.g.MyClass</class>
<class>com.g.AnotherClass</class>
<class>...</class>

<properties>
<property name="toplink.jdbc.driver"
value="com.mysql.jdbc.Driver" />
<property name="toplink.jdbc.url"
value="jdbc:mysql://fangorn:3306/stocks_dev" />
<property name="toplink.jdbc.user" value="asif" />
<property name="toplink.jdbc.password" value="blah" />
</properties>
</persistence-unit>
</persistence>

although, I guess I could create several PUs and have a similar
flexibility.
This _seems_ to work just fine (at least, for the very limited testing
I've done).

Not sure how can I get access to the other properties for the
datasource and the vendor adapter, so if anyone has any suggestions,
that would be greatly appreciated.
Reply all
Reply to author
Forward
0 new messages