My favorites | Sign in
GWT
Project Home Downloads Wiki Issues Source
New issue   Search
for
  Advanced search   Search tips   Subscriptions
Issue 3496: Spring failures in hosted mode in 1.6.2
34 people starred this issue and may be notified of changes. Back to list
Status:  Fixed
Owner:  t.broyer
Closed:  Dec 2012


Sign in to add a comment
 
Reported by flemming...@gmail.com, Mar 23, 2009
Found in GWT Release: 1.6.2RC

Detailed description: Adding spring to the serverside code (web-inf/lib)
make the hosted mode break.
===============================================
loader constraint violation: loader (instance
of com/google/gwt/dev/shell/jetty/JettyLauncher$WebAppContextWithReload
$WebAppClassLoaderExtension) previously initiated loading for a
different type with name "org/apache/commons/logging/Log"
       at java.lang.ClassLoader.defineClass1(Native Method)
       at java.lang.ClassLoader.defineClass(ClassLoader.java:621)
================================================
I add the following jar files to the web-inf/lib folder.
-commons-collections-3.1.jar 
-commons-configuration-1.4.jar 
-commons-logging-1.1.jar 
-gwt-servlet.jar 
-spring-2.5.5.jar 

I have also tried to remove the commons-logging to see if it would work,
but it did not.

Workaround if you have one: If I delete the apache/commons classes in the
gwt-dev-windows.jar and remove the corresponding lines in the
META-INF/INDEX.LIST file, then it seems to work. The app starts up in
hosted mode and my spring bean is being called.


Links to the relevant GWT Developer Forum posts:
http://groups.google.com/group/Google-Web-Toolkit/browse_thread/thread/1b84327226da1233/0aef8cd0635a6c72#0aef8cd0635a6c72
Mar 23, 2009
#1 acc%goog...@gtempaccount.com
Forwarding an 1.6RC issue.
Owner: sco...@google.com
Labels: Type-Defect Category-HostedMode
Mar 23, 2009
#2 joshblin...@gmail.com
I get an error using spring as well when I attempt to extends RemoteServiceServlet:

Caused by: java.lang.LinkageError: Class javax/servlet/http/HttpServletResponse
violates loader constraints

This error didn't occur in 1.6.1 (although I never got everything quite working there
either).  I hope this is related to the above.  

Using Spring 2.5.6, Maven, and GWT 1.6.2.

I attempted to remove HttpServletResponse from the dev library (using osx) as
suggested in the workaround above, but the problem persisted.



Mar 23, 2009
#3 sco...@google.com
(No comment was entered for this change.)
Labels: Milestone-1_6_RC2 Priority-Critical
Mar 23, 2009
#4 sco...@google.com
Can someone verify a fix for me?

Take the attached jar and put it on your classpath ahead of gwt-dev-<platform>.jar.  
See if it fixes the "not and instance of Servlet" problem (and doesn't cause other 
problems).

Lemme know if that works, thanks,
Scott


gwt-dev-patch.jar
18.6 KB   Download
Mar 23, 2009
#5 sco...@google.com
Toby, Bruce-- here's the actual fix (assuming it works).

Basically, the patch is to prioritize the server/system check above loading things 
into the app's classloader.  What was happening is this:

1) User tries to load a class that's not in the WebAppClassLoader, but is in gwt-dev-
windows.jar

2) GWT warns and maps gwt-dev-windows.jar into the WebAppClassLoader.

3) gwt-dev-windows.jar contains javax.servlet.Servlet and lots of other problematic 
classes

4) A subsequent request for javax.servlet.Servlet defines a new copy of the class 
inside the WebAppClassLoader, which is of course unrelated to the one outside of it.

5) Badness ensues.

As far as I can tell, this is fixed by making Jetty ALWAYS load "server" and "system" 
stuff directly from the system classloader and never make copies inside the WebAppClassLoader.  But I'm not 100% confident this patch might not mess something 
else up.

If this round of changes doesn't seem to fix it, we might just want to bail on that 
warning for 1.6 and go back to the very permissive behavior.


jetty-launcher-1-6.patch
2.4 KB   View   Download
Status: Started
Cc: to...@google.com br...@google.com
Mar 23, 2009
#6 sco...@google.com
Actually, here's a slight variation for consideration, that much more closely follows 
the structure of Jetty's WebAppClassLoader.loadClass().  I think I misunderstood 
before what the purpose of "isServerClass" was.
jetty-launcher-2-1-6.patch
2.4 KB   View   Download
Mar 24, 2009
#7 joshblin...@gmail.com
Scott,

First off, thanks for the really quick turnaround. The patch seems to have solved the
problem, but I think the change you are talking about is still messing with my
configuration.

Not sure if my problem stems from the fact that I am no longer using an eclipse
plugin to manage my launch (both Cypal and gwttooling haven't upgraded to 1.6 yet),
but I get a ton of "[WARN] Server class
'org.springframework.core.NestedRuntimeException' could not be found in the web app,
but was found on the system classpath" - not just for spring classes but my own
libraries as well.  I am also forced to add source paths into my classpath for my
runtime configuration.  Previously, maven took care of it (maven is outputting .java
files as well as .class files into its target directory).

As well, my load-up time in hosted mode is considerably slower, not sure but I hope
this is related.

If you could point me to some documentation as to how to properly configure to avoid
these warnings, that would be great.

Thanks again for the quick patch.


Mar 24, 2009
#8 sco...@google.com
Josh: can you verify you have copies of all your server-side jars in WEB-INF/lib?  
That warning message is supposed to trigger when you're missing necessary server code 
there.

Needing to add source paths is expected, GWT has always worked that way since it 
compiles your code from source.


Mar 24, 2009
#9 joshblin...@gmail.com
Scott: Actually, we're using maven, so the libraries are dynamically linked in to the
launch.

In the Launch configuration, classpath tab, there is a entry under "user entry" for
maven dependencies.  Some of these maven dependencies are libraries in our maven
repository while others refer to other open projects in the workspace.  I think this
is a fairly typical setup using maven.  

Unfortunately, I'm no expert at all this setup, and I don't think the gwt-maven code
has been updated for 1.6.  At least I'm up and running now. 
Mar 24, 2009
#10 sco...@google.com
Ah, okay.  Yeah, maven's not going to put those things into WEB-INF/lib like it ought 
to.  However, we did put in an escape valve.  If you set the system property 
"gwt.nowarn.webapp.classpath", those warnings will be suppressed.  I expect an 
updated Maven plugin will set this property.
Mar 30, 2009
#11 danny.d...@gmail.com
I don't know if this is related but when I switch from version 1.6.1 to 1.6.2, I get
the following error in hosted mode (compiled mode works fine).

[WARN] Nested in java.lang.ExceptionInInitializerError:
org.apache.commons.logging.LogConfigurationException:
org.apache.commons.logging.LogConfigurationException:
org.apache.commons.logging.LogConfigurationException: Invalid class loader hierarchy.
 You have more than one version of 'org.apache.commons.logging.Log' visible, which is
not allowed. (Caused by org.apache.commons.logging.LogConfigurationException: Invalid
class loader hierarchy.  You have more than one version of
'org.apache.commons.logging.Log' visible, which is not allowed.) (Caused by
org.apache.commons.logging.LogConfigurationException:
org.apache.commons.logging.LogConfigurationException: Invalid class loader hierarchy.
 You have more than one version of 'org.apache.commons.logging.Log' visible, which is
not allowed. (Caused by org.apache.commons.logging.LogConfigurationException: Invalid
class loader hierarchy.  You have more than one version of
'org.apache.commons.logging.Log' visible, which is not allowed.))

I'm also using Spring and Maven but I'm not running the hosted mode with the Maven
pluggin, I'm using an Ant script...
Mar 30, 2009
#12 sco...@google.com
Danny: do you get this even when using the gwt-dev-patch.jar from earlier in this 
thread?
Mar 30, 2009
#13 danny.d...@gmail.com
Sorry, I hadn't realized that the patch was right there smiling at me (lazy reader) :-)

So yeah it worked but I couldn't find how to tell maven to put the patch "ahead" in
the classpath so I ended up updating the whole gwt-dev jar...

Anyway, thanks for your help.  As I hoped, the new version solved an issue I had :
http://groups.google.ca/group/Google-Web-Toolkit/browse_thread/thread/6ceee6d2308ec8be/a899b76509e30b91
Mar 30, 2009
#14 sco...@google.com
Fixed in r5077 & r5078.
Status: FixedNotReleased
Mar 30, 2009
#15 sco...@google.com
(No comment was entered for this change.)
Summary: Spring failures in hosted mode in 1.6.2
Apr 3, 2009
#16 joshblin...@gmail.com
Scott, is this fix in the RC2 release, because I get a different problem in RC2 (to do with SLF4J Logger - I'm using 
Spring/Hibernate).  If I apply the dev-patch to the 1.6.3 things work fine.  I'm hoping this fix didn't make it into 
RC2, otherwise it appears there is another issue.
Apr 3, 2009
#17 sco...@google.com
This fix (or a slight variation) is in RC2.  If you're still getting problems in RC2, 
please give me exact details, because what went into RC2 is very slightly different 
from what went into the patch jar.
Apr 6, 2009
#18 joshblin...@gmail.com
Scott,

Not sure how detailed I can go.  I'm using Spring+Hibernate.  From what I can tell,
Hibernate requires org/slf4j/LoggerFactory, which is included in my maven
dependencies.  When I run RC2 with the dev patch, things run fine, without the patch,
I get:

Caused by: java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory
	at org.hibernate.cfg.annotations.Version.<clinit>(Version.java:12)
	at org.hibernate.cfg.AnnotationConfiguration.<clinit>(AnnotationConfiguration.java:78)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
	at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)

etc...

Let me know if you need more information, thanks again for your help.  I assume this
will be a problem for a lot of other spring/hibernate/maven users.


Apr 6, 2009
#19 danny.d...@gmail.com
Josh : I think you need to include on of the implementation libraries for slf4j.  the
slf4j-api dependency includes only the interfaces of the api but you need to
explicitly define wich implementation you want.

For example, if you're using log4j, you may add :

<dependency>
  <groupId>org.slf4j</groupId>
  <artifactId>slf4j-log4j12</artifactId>
</dependency>

Hope that helps...
Apr 6, 2009
#20 joshblin...@gmail.com
Hey Scott,

I've actually done that (slf4j-log4j13-1.0.1) which implements Logger.  As I said,
with the dev-patch, things work perfectly.  With RC2 -patch, I get the error,

 
Apr 6, 2009
#21 sco...@google.com
Bruce: what I originally pushed out as gwt-dev-patch.jar was based on version 1 of 
the patch above.  What I actually committed was slightly different, version 2 of the 
patch above.  It looks like for most users RC2 (which has patch2) works just fine, 
but a couple of users are reporting patch1 worked but RC2 doesn't.  That's all I know 
if you guys decide to look at this today.
Apr 18, 2009
#22 mlegenha...@gmail.com
Little information. I used GWT 1.6.4 and have the same problems when using spring +
hibernate. I integrate the dev-patch to my maven dependencies and now everything
works fine. I hope this bug will be fixed soon.
Apr 20, 2009
#23 sco...@google.com
If 1.6.4 is broken for you, but 1.6.4 + gwt-dev-patch is working for you, I need a 
small sample demonstrating the exact problem you're having.
May 11, 2009
#24 jlaba...@google.com
1_6_RC2 has been released.
Status: Fixed
May 13, 2009
#25 dragon...@gmail.com
hi, I also get this issue. 
May 19, 2009
#26 christia...@gmail.com
I have the same issue as @mlegenhausen. Compilation of application using GWT 1.6.4
and GXT 2.0M1 crashes (java.lang.StackOverflowError) if the gwt-dev-patch.jar is not
present but works fine otherwise.

Is there a why to merge the gwt-dev-patch.jar with the gwt-dev-window.jar in my maven
repository?
May 19, 2009
#27 sco...@google.com
Sure, just use any zip or jar tool.  You just want all the files in gwt-dev-patch.jar 
to overwrite the existing ones in gwt-dev-windows.jar.  One way to do that might be 
to unpackage them and repackage them.
May 20, 2009
#28 christia...@gmail.com
Thanks for the answer @scottb. I have done this already and it works fine for me. 

I was looking though for a 'cleaner' solution. I've installed the gwt-dev-patch.jar
in my local m2 repository but I'm not sure how to enforce that the patch jar comes
before the dev-windows.jar on the classpath. Is there a way to configure the maven
dependencies so that the gwt-dev-patch.jar comes in the classpath before the
gwt-dev-windows.jar?
May 21, 2009
#29 sco...@google.com
I dunno, but we're going to do a 1.6.5 that will include the fix in not too long.
May 21, 2009
#30 mlegenha...@gmail.com
@christian 
You can get the dev-patch before the gwt jars by using maven 2.0.9 or greater, cause
in this release there determine the classpath order like you have it definied in your
pom.xml.
May 22, 2009
#31 christia...@gmail.com
@scottb
I'm looking forward for the 1.6.5 release. Thx

@mlegenhausen
didn't know that the newt mavens preserve the classpath order. Thanks for the tip
Aug 7, 2009
#32 jason.cl...@gmail.com
This issue is still present in GWT-1.7.0.  The patch jar fixes it, but I would rather 
not have to include a patch.  This is not fixed!!!!  This error occurs for me when I 
include hibernate in my project along with slf4j-log4j12.  I would get a class not 
found exception for slf4j with hibernate tried to load.
Aug 7, 2009
#34 sco...@google.com
Nevermind comment 33 (deleted).  See comment #23... I need a small exemplary sample to 
debug what's different between the original and final patch.
Aug 7, 2009
#35 jason.cl...@gmail.com
Here is a sample project.  We use maven for dependency management so our jars are 
linked in -- not copied to the WEB-INF/lib directory.  To simulate this, I created an 
external-libs folder and linked those jars in.  This is the sample GWT project using 
spring to discover the services (gwtrpcspring).  The problem occurs when spring loads 
hibernate and hibernate trys to load slf4j.  Run the project and look at the error 
message in the jetty console.  I confirmed that the patch jar above fixes the issue in 
this project.
GwtJettyLaunchBug.zip
8.3 MB   Download
Aug 7, 2009
#36 sco...@google.com
Thanks, I'll take a look when I can.
Status: Accepted
Aug 20, 2009
#38 p.fa...@gmail.com
We had a similar problem trying to deploy jpbm on the server side, and tried copying
the slf jars to web-inf/lib by hand - apparently, this fixes the issue at (at least
temporarily).

Any news on a final resolution?
Aug 26, 2009
#39 eske.s...@gmail.com
The SLF4J-classes-not-loaded-in-hosted-mode issue is also discussed in this thread on
the forums:
http://groups.google.com/group/google-web-toolkit/browse_thread/thread/481165b48dbbb2c9

It discusses 2 possible workarounds.

Besides affecting Maven, which links files into WEB-INF/lib, it also affects Gradle
(gradle.org) which does the same thing as Maven.
Nov 9, 2009
#41 war...@gmail.com
I got slf4j issue too like others : 
java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory

Problem tempory fixed if copy past lib in WEB-INF/lib directly... waiting for fix.

GWT version : 1.7.1
Dec 15, 2009
#43 mhaligowski
The problem still exists in GWT 2.0. Using Eclipse, Ant and Hibernate. The web-
jetty.xml solution did not help.
Dec 16, 2009
#44 war...@gmail.com
The fix with jetty-web.xml works for me and I use GWT version 1.7.1. I didn't try
with GWT 2.0.
jetty-web.xml
1.0 KB   View   Download
Feb 3, 2010
Project Member #45 scottb@google.com
(No comment was entered for this change.)
Owner: sco...@google.com
Aug 4, 2010
#46 miha.kad...@gmail.com
Still happens with 2.0.3:

line 357 in com.google.gwt.dev.shell.jetty.JettyLauncher:

    // Don't allow server classes to be loaded from the outside.
    if (isServerPath(name)) {
        throw e;
    }

This should be changed to allow the class in question to be loaded from the outside in case it didn't come from the gwt-dev.jar (e.g. if there's another slf4j jar in the classpath). Jetty allows overriding server classes within a web application, but GWT doesn't (except with jars in WEB-INF/lib).
Aug 4, 2010
Project Member #47 scottb@google.com
John is now the owner of JettyLauncher.
Owner: j...@google.com
Cc: -tobyr+le...@google.com -bruce+pe...@google.com sco...@google.com to...@google.com
Nov 10, 2010
#48 martin.g...@gmail.com
As others said before, it still happens on GWT 2.x. It can be easily reproduced on the Web Application Starter Project (Eclipse plugin). Just modify GreetingServiceImpl.java before running the example project with the following:

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
...
private static final Logger log = LoggerFactory.getLogger(GreetingServiceImpl.class);
...

The workaround that worked for me was adding slf4j jars in WEB-INF\lib

Nov 26, 2010
#50 biard.ro...@gmail.com
I am running GWT 2.1.0 ... Same issues with ClassNotFound Exception org.slf4j.LoggerFactory :(
The trick with jetty-web.xml placed in src/main/webapp works fine for me!

No need to copy/paste lib in WEB-INF/lib folder.
Nov 30, 2010
#51 post2edb...@gmail.com
Yep, also just confirmed (comment 50) that it still happening in 2.1.0 and that the jetty-web.xml workaround works for dev mode.
Jan 13, 2011
Project Member #52 fredsa@google.com
(No comment was entered for this change.)
Labels: -Category-HostedMode Category-DevMode
Feb 8, 2011
#53 rjrjr@google.com
(No comment was entered for this change.)
Labels: -Milestone-1_6_RC2 Milestone-1_6-RC2
Feb 22, 2011
#54 craig...@gmail.com
Still an issue in GWT 2.2.0

Trick with war/WEB-INF/jetty-web.xml still works.  Ref:  https://groups.google.com/group/google-web-toolkit/msg/74f8cf4628f84eda?hl=kyJf8cf4628f84eda
Jul 4, 2011
#55 kdekoo...@gmail.com
And still an issue in GWT 2.3.0.
Feb 14, 2012
#57 matthias...@gmail.com
And still an issue in GWT 2.4.0 ...

Workaround described above still works.
Dec 13, 2012
Project Member #58 jat@jaet.org
Everyone who was on this issue is no longer at Google, so you should probably decide who (if anyone) will work on it.
Owner: skybr...@google.com
Cc: -scottb@google.com -tobyr@google.com
Labels: -Priority-Critical -Milestone-1_6-RC2
Dec 13, 2012
Project Member #59 skybr...@google.com
(No comment was entered for this change.)
Owner: gwt-issu...@googlegroups.com
Dec 14, 2012
Project Member #60 t.broyer
Server-side dependencies should go in WEB-INF/lib, full stop.

gwt-maven-plugin's gwt:run does the right thing (er, it's supposed to at least), and the FAQ for the GPE says you should do an "mvn package" to copy the dependencies before launching the DevMode [1], so it seems everyone agrees.

I therefore set the status back to Fixed.

[1] https://developers.google.com/eclipse/docs/faq#gwt_with_maven
Status: Fixed
Owner: t.broyer
Sign in to add a comment

Powered by Google Project Hosting