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

Skip to first unread message

M Shannon

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

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

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:

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
org.springframework.beans.factory.BeanCreationException: Error
creating bean with name
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 [
$WebAppContextWithReload$WebAppClassLoaderExtension] does NOT provide
an 'addTransformer(ClassFileTransformer)' method. Specify a custom
LoadTimeWeaver or start your Java virtual machine with Spring's agent:

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


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

Apr 15, 2009, 9:58:57 PM4/15/09
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


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)

so my beans.xml has changed to:

<bean id="entityManagerFactory"
<property name="persistenceUnitName" value="StocksPU"/>

<!-- no longer used
<bean id="entityManagerFactory"
<property name="dataSource" ref="dataSource" />
<property name="jpaVendorAdapter">
<property name="showSql" value="false" />
<property name="generateDdl" value="false" />
<property name="databasePlatform"
value="oracle.toplink.essentials.platform.database.MySQL4Platform" />
<property name="loadTimeWeaver">
class="org.springframework.instrument.classloading.InstrumentationLoadTimeWeaver" /

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"
<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 id="testDataSource"
<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}" />

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=""
version="1.0" >
<persistence-unit name="StocksPU" transaction-

<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" />

although, I guess I could create several PUs and have a similar
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
0 new messages