Problem on sample "Validation" due to missing class in gwt-servlet

221 views
Skip to first unread message

Cristiano

unread,
Nov 12, 2013, 9:20:43 AM11/12/13
to google-web-tool...@googlegroups.com
Hi All,

I'm making some test on the "validation" example from the gwt source code samples, 
it runs ok from Eclipse, but when I deploy to both Glassfish or Apache Karaf (a OSGi container), I get the following NoClassDefFoundError: 

[In Glassfish]
Exception while dispatching incoming RPC call com.google.gwt.user.server.rpc.UnexpectedException: Service method 'public abstract com.google.gwt.safehtml.shared.SafeHtml com.google.gwt.sample.validation.client.GreetingService.greetServer(com.google.gwt.sample.validation.shared.Person) throws java.lang.IllegalArgumentException,javax.validation.ConstraintViolationException' threw an unexpected exception: java.lang.NoClassDefFoundError: com/google/gwt/thirdparty/streamhtmlparser/ParseException
 at com.google.gwt.user.server.rpc.RPC.encodeResponseForFailure(RPC.java:389)
 at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:579)
 at com.google.gwt.user.server.rpc.RemoteServiceServlet.processCall(RemoteServiceServlet.java:208)
 at com.google.gwt.user.server.rpc.RemoteServiceServlet.processPost(RemoteServiceServlet.java:248)
 at com.google.gwt.user.server.rpc.AbstractRemoteServiceServlet.doPost(AbstractRemoteServiceServlet.java:62) 
 ....


[In Apache Karaf]
Caused by: java.lang.NoClassDefFoundError: com/google/gwt/thirdparty/streamhtmlparser/ParseException 
  at com.google.gwt.safehtml.shared.SafeHtmlBuilder.appendHtmlConstant(SafeHtmlBuilder.java:214)[230:com.google.gwt.gwt-servlet:2.6.0.rc1] 
  at com.google.gwt.sample.validation.server.GreetingServiceImpl.greetServer(GreetingServiceImpl.java:68)[231:gwt-karaf-validation:1.0.0.SNAPSHOT] 
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)[:1.7.0_40]
  ....

The problem is that the class com.google.gwt.thirdparty.streamhtmlparser.ParseException is missing on gwt-servlet.jar
(see below the filters on the classes selected to be included into the jar).

When running into eclipse, the example works as it resolve the class from gwt-user.jar

So, I ask you:
1. should gwt-servlet also include com.google.gwt.thirdparty.streamhtmlparser classes?
2. or should the validation example be adapted to avoid using that class?

I do care to know which one of the two path should be embraced as I'm working on a patch proposal (https://gwt-review.googlesource.com/#/c/5351/) that it will be influenced by this choice.

The ParseException is used by com.google.gwt.safehtml.shared.SafeHtmlHostedModeUtils 
and maybe it should not depend on com.google.gwt.thirdparty.* as these are not available on gwt-servlet, 
but changing this dependency is probably hard and then the package should be then included... but then there could be other issues coming from this modification


For your convenience of inspection, here is the rules for selecting what is included in gwt-servlet.jar:
    <fileset dir="${gwt.dev.bin}">
        <include name="com/google/gwt/dev/asm/**" />
        <include name="com/google/gwt/dev/util/Name*.class" />
        <include name="com/google/gwt/dev/util/StringKey.class" />
        <include name="com/google/gwt/util/tools/shared/**" />
        <include name="com/google/gwt/core/shared/**" />
        <!-- CHECK: do we need to add this rule? <include name="com/google/gwt/thirdparty/streamhtmlparser/**" /> -->
      </fileset>
      <fileset dir="${gwt.user.bin}">
        <exclude name="**/rebind/**" />
        <exclude name="**/tools/**" />
        <exclude name="**/super/**" />
        <exclude name="com/google/gwt/json/**" />
        <exclude name="com/google/gwt/junit/*" />
        <exclude name="com/google/gwt/junit/client/GWTTestCase.*" />
        <exclude name="com/google/gwt/junit/remote/**" />
        <exclude name="com/google/gwt/junit/server/**" />
        <exclude name="com/google/gwt/benchmarks/*" />
        <exclude name="**/*.gwtar" />
      </fileset>


Thank you,
Cristiano


Thomas Broyer

unread,
Nov 12, 2013, 9:54:50 AM11/12/13
to google-web-tool...@googlegroups.com


On Tuesday, November 12, 2013 3:20:43 PM UTC+1, Cristiano wrote:
So, I ask you:
1. should gwt-servlet also include com.google.gwt.thirdparty.streamhtmlparser classes?

IMO yes. It's currently in gwt-servler-deps IIRC, but that one should only contain external deps that can be retrieved from elsewhere (and could therefore cause conflicts if you do use them otherwise, particularly in different versions)

Cristiano

unread,
Nov 12, 2013, 10:20:44 AM11/12/13
to google-web-tool...@googlegroups.com
apparently the package com.google.gwt.thirdparty does not included into gwt-servlet as it is neither in ${gwt.dev.bin} or in ${gwt.user.bin}...

I'm trying to build a GWT that include it to see if then "validation" example could work after that.

thank you Thomas for let me note it is included in gwt-servlet-deps, I'll try a build with:
<zipfileset src="${gwt.tools.lib}/streamhtmlparser/streamhtmlparser-jsilver-r10/streamhtmlparser-jsilver-r10-1.5-rebased.jar" />
added to gwt-servlet (as 'streamhtmlparser' is rebased).

Cristiano

Jens

unread,
Nov 12, 2013, 10:40:08 AM11/12/13
to google-web-tool...@googlegroups.com
Just wanted to throw in that if you use GWT's remote logging along with source maps then the StackTraceDeobfuscator also needs some classes from gwt-servlet-deps. As I think it's a pretty common scenario nowadays to enable source maps where possible you maybe should handle this case as well. IMHO everything in gwt-servlet-deps that is found under the package com.google should go into gwt-servlet. Doesn't really makes sense to me to have these classes in a jar that is not deployed to maven.

-- J.

Cristiano Costantini

unread,
Nov 12, 2013, 11:37:36 AM11/12/13
to google-web-tool...@googlegroups.com
2013/11/12 Jens <jens.ne...@gmail.com>
Just wanted to throw in that if you use GWT's remote logging along with source maps then the StackTraceDeobfuscator also needs some classes from gwt-servlet-deps. As I think it's a pretty common scenario nowadays to enable source maps where possible you maybe should handle this case as well. IMHO everything in gwt-servlet-deps that is found under the package com.google should go into gwt-servlet. Doesn't really makes sense to me to have these classes in a jar that is not deployed to maven.


At first I've read "everything in gwt-servlet-deps should go into gwt-servlet" and I was against that...
...then I've read it better the "that is found under the package com.google" and yes I agree!!

You basically means that if something in gwt-servelt-deps has been rebased then it should go into gwt-servlet and I am okay with this!

Alternatively I think it is better to split gwt-servlet-deps into 2, for example:
- gwt-servlet-deps-external.jar
- gwt-servlet-deps-rebased.jar

Cristiano




Thomas Broyer

unread,
Nov 12, 2013, 1:07:22 PM11/12/13
to google-web-tool...@googlegroups.com
No, if it's been rebased, it's safe to include in gwt-servlet (for Maven, for example), and I don't see any reason for putting it in another JAR. If it's been rebased, it's become an "internal" API of GWT. 

Cristiano

unread,
Nov 12, 2013, 1:34:01 PM11/12/13
to google-web-tool...@googlegroups.com
so, FYI, 
validation example worked on karaf after compiling GWT Servlet with embedded streamhtmlparser-jsilver-r10-1.5-rebased.jar

the examples can be found here: https://github.com/cristcost/gwt-karaf-examples
but they are a little too messy yet... 

I now want to focus on making work on OSGi the "Dynamic Table" sample, so I'm not going to write instruction for running them.

If someone want to try them and have problems, please ask me and I'll be glad to help you.

Cristiano

Cristiano

unread,
Nov 13, 2013, 11:41:12 AM11/13/13
to google-web-tool...@googlegroups.com
Hi All,

I then think that it is needed a patch to include guava-15.0-rebased.jar, sourcemap-rebased.jar, protobuf-java-rebased-2.5.0.jar and streamhtmlparser-jsilver-r10-1.5-rebased.jar in gwt-servlet.jar

The patch should be as easy as moving the following lines in servlet/build.xml up within the <gwt.jar> task of "-servlet" target:
      <zipfileset src="${gwt.tools.lib}/guava/guava-15.0/guava-15.0-rebased.jar" />
      <zipfileset src="${gwt.tools.lib}/jscomp/20131014/sourcemap-rebased.jar" />
      <zipfileset src="${gwt.tools.lib}/protobuf/protobuf-2.5.0/protobuf-java-rebased-2.5.0.jar" />
      <zipfileset src="${gwt.tools.lib}/streamhtmlparser/streamhtmlparser-jsilver-r10/streamhtmlparser-jsilver-r10-1.5-rebased.jar" />

else, people may be deploying GWT web application without being able to make them work.

Make the patch is easy, get the contributors to take a final decision is harder:
but I think that the problem should be solved for 2.6.0 as Validation is a feature described in the GWT dev guide (http://www.gwtproject.org/doc/latest/DevGuideValidation.html) and the problem is there since gwt 2.5 (I would not be surprised if no one use that feature).

So, what you do think?

Cristiano




Thomas Broyer

unread,
Nov 13, 2013, 12:33:43 PM11/13/13
to google-web-tool...@googlegroups.com


On Wednesday, November 13, 2013 5:41:12 PM UTC+1, Cristiano wrote:
Hi All,

I then think that it is needed a patch to include guava-15.0-rebased.jar, sourcemap-rebased.jar, protobuf-java-rebased-2.5.0.jar and streamhtmlparser-jsilver-r10-1.5-rebased.jar in gwt-servlet.jar

No, not protobuf, it's only used for DevMode's "remote UI" (what makes the Dev Mode view in Eclipse possible)

Guava is only needed for SafeHtml and SafeUri, so it'd be better to provide guava-less implementation of the two classes that use it; except if it's also needed for sourcemap, in which case it's OK to put it into gwt-servlet.
 
The patch should be as easy as moving the following lines in servlet/build.xml up within the <gwt.jar> task of "-servlet" target:
      <zipfileset src="${gwt.tools.lib}/guava/guava-15.0/guava-15.0-rebased.jar" />
      <zipfileset src="${gwt.tools.lib}/jscomp/20131014/sourcemap-rebased.jar" />
      <zipfileset src="${gwt.tools.lib}/protobuf/protobuf-2.5.0/protobuf-java-rebased-2.5.0.jar" />
      <zipfileset src="${gwt.tools.lib}/streamhtmlparser/streamhtmlparser-jsilver-r10/streamhtmlparser-jsilver-r10-1.5-rebased.jar" />

else, people may be deploying GWT web application without being able to make them work.

Make the patch is easy, get the contributors to take a final decision is harder:
but I think that the problem should be solved for 2.6.0 as Validation is a feature described in the GWT dev guide (http://www.gwtproject.org/doc/latest/DevGuideValidation.html) and the problem is there since gwt 2.5 (I would not be surprised if no one use that feature).

So, what you do think?

I'd support such a change, and cherry-picking it to the release/2.6 branch!

Matthew Dempsky

unread,
Nov 13, 2013, 3:00:17 PM11/13/13
to google-web-toolkit-contributors
Sounds like a reasonable proposal to me.


--
http://groups.google.com/group/Google-Web-Toolkit-Contributors
---
You received this message because you are subscribed to the Google Groups "GWT Contributors" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit-co...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Roberto Lublinerman

unread,
Nov 13, 2013, 3:14:19 PM11/13/13
to google-web-tool...@googlegroups.com
On Wed, Nov 13, 2013 at 9:33 AM, Thomas Broyer <t.br...@gmail.com> wrote:


On Wednesday, November 13, 2013 5:41:12 PM UTC+1, Cristiano wrote:
Hi All,

I then think that it is needed a patch to include guava-15.0-rebased.jar, sourcemap-rebased.jar, protobuf-java-rebased-2.5.0.jar and streamhtmlparser-jsilver-r10-1.5-rebased.jar in gwt-servlet.jar

No, not protobuf, it's only used for DevMode's "remote UI" (what makes the Dev Mode view in Eclipse possible)

Guava is only needed for SafeHtml and SafeUri, so it'd be better to provide guava-less implementation of the two classes that use it; except if it's also needed for sourcemap, in which case it's OK to put it into gwt-servlet.

Guava is used by sourcemap so it must be provided as well.

@Cristiano would you want to make the patch yourserf? If so just add me as a reviewer.... 
 

Cristiano Costantini

unread,
Nov 13, 2013, 3:32:42 PM11/13/13
to google-web-tool...@googlegroups.com
Ok,
I'll follow your indications,
I'll give it a try before pushing it and in case of surprises I'll come back here to discuss.

Do you want me also to create an issue associated to this, for tracking purposes

Cristiano

Jens

unread,
Nov 13, 2013, 3:58:30 PM11/13/13
to google-web-tool...@googlegroups.com

Make the patch is easy, get the contributors to take a final decision is harder:

Given the patch is correct you get an instant +1 from me because I always forget adding gwt-servlet-deps.jar until I see (the already well known) exceptions ;-)

-- J.

Cristiano

unread,
Nov 13, 2013, 6:40:33 PM11/13/13
to google-web-tool...@googlegroups.com
Uploaded the patch: https://gwt-review.googlesource.com/#/c/5400

I've tested it with "validation" sample, that now works with only gwt-servlet,jar on the classpath, 
and on "dynatable" examples plus 3 applications from my own with no visible change.

Cristiano
Reply all
Reply to author
Forward
0 new messages