1

I'm using GWT 2.4 with gquery-dnd-bundle 1.0.4 so that I can construct trees with drag-and-drop nodes. I've bumped into an annoying bug (http://code.google.com/p/gwtquery-plugins/issues/detail?id=6). The gist of it is I need to guarantee that the file "gquery-dnd-bundle-1.0.4.jar" gets loaded by the classloader at runtime before the gwt-servlet.jar file in my WEB-INF/lib directory.

How can I guarantee this?

I'm using Eclipse Indigo with a GWT Web Application project if that is useful.

Here's the exact error I'm seeing

[ERROR] [draganddroptree] - Errors in 'jar:file:/C:/Documents%20and%20Settings/E18538/workspace/DragAndDropTree/war/WEB-INF/lib/gquery-dnd-bundle-1.0.4.jar!/gwtquery/plugins/droppable/client/gwt/DragAndDropCellTree.java'
        [ERROR] [draganddroptree] - Line 24: The type com.google.gwt.user.cellview.client.CellTreeNodeView is not visible
        [ERROR] [draganddroptree] - Line 86: CellTreeNodeView cannot be resolved to a type
        [ERROR] [draganddroptree] - Line 87: The constructor DragAndDropCellTreeNodeView<T>(DragAndDropCellTree, CellTreeNodeView<?>, TreeViewModel.NodeInfo<T>, Element, T) refers to the missing type CellTreeNodeView
    [ERROR] [draganddroptree] - Unable to load module entry point class com.cme.draganddroptree.client.DragAndDropTree (see associated exception for details)
    [ERROR] [draganddroptree] - Failed to load module 'draganddroptree' from user agent 'Mozilla/5.0 (Windows NT 5.1) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/14.0.835.202 Safari/535.1' at localhost:4490
Dave
  • 15,639
  • 133
  • 442
  • 830

2 Answers2

0

You cannot arrange the loading of your "WEB-INF/lib" JAR's in any kind of deterministic order. The only surefire workaround I can think of is to place the lower-priority JAR file in a directory that is scanned prior to "WEB-INF/lib".

For example, if you are using Tomcat, then you could:

  1. Place the "gwt-servlet.jar" file in the "$CATALINA_BASE/lib" directory.
  2. Keep the "gquery-dnd-bundle-1.0.4.jar" file inside your WAR.

This way, "gwt-servlet.jar" will be loaded into the CLASSPATH first, and "gquery-dnd-bundle-1.0.4.jar" will be loaded second... overwriting any conflicting classes from "gwt-servlet.jar".

If you are using some other app server, then the server-level "lib" directory will be different... but the basic idea is that the lower-priority JAR needs to go into the app server's "lib", while the higher-priority JAR needs to stay in the webapp's "lib".

Not the cleanest situation in the world, but it will guarantee the result you want.

UPDATE: You know, after thinking about it and re-reading the Tomcat docs more carefully, I may actually have this backward. You may need to put "gquery-dnd-bundle-1.0.4.jar" in your app server "lib", and "gwt-servlet.jar" in your webapp's "lib". If you try my suggestion and find that it works for you with one approach over the other, let me know and I'll edit my answer to be more precise.

Steve Perkins
  • 11,520
  • 19
  • 63
  • 95
  • I am using a very old version of tomcat but IIRC it scans the jars in alphabetical order of their name. Maybe that has changed now. – Miserable Variable Oct 06 '11 at 17:17
  • That probably is the case, although you can't guarantee that it will always work. – Steve Perkins Oct 06 '11 at 17:19
  • It doesn't say [here[(http://tomcat.apache.org/tomcat-7.0-doc/class-loader-howto.html) exactly that but I doubt **/WEB-INF/lib/*.jar of your web application** would mean anything but alphabetical order. – Miserable Variable Oct 06 '11 at 17:28
  • It probably depends on the order in which files are returned when the Java process queries a directory. Unless you explicitly tell the "File" class otherwise, then this order is determined by the underlying operating system. On Linux and newer generations of Windows, it will probably always be alphabetical ascending. On older versions of Windows, it might be more random. Anyway, it will *probably* be alphabetic, but you can't "guarantee" that. – Steve Perkins Oct 06 '11 at 17:40
  • Besides, since "gquery-dnd-bundle-1.0.4.jar" comes before "gwt-servlet.jar" alphabetically, he probably wouldn't be seeing this issue in the first place if it were a simple matter of first-alphabetical-wins. – Steve Perkins Oct 06 '11 at 17:40
  • I'm running my GWT app in development mode using the Eclipse GWT plugin. As such, I don't have Tomcat installed. Given this, where would I need to place my JAR files? Also, tried renaming the gquery-dnd-bundle.jar file to z-gquery-dnd-bundle.jar to see if it was an alphabetical problem, but I got the same error (now listed above) – Dave Oct 06 '11 at 18:45
  • The loading of jars by Tomcat is irrelevant in this case. The parts used from gquery-dnd-bundle get compiled to javascript by the GWT compiler, and are not executed on the server side. – Ioan Agopian Oct 06 '11 at 20:39
0

To solve this bug you should have gquery-dnd-bundle-1.0.4.jar set before GWT in your classpath. Using Eclipse in your project properties go to Java Build Path / Order an export and make sure gquery lib is before GWT.

Anyway you may have another problem as gquery-dnd-bundle-1.0.4.jar is compatible with GWT 2.3.x and you are using GWT 2.4. Until a new release of dnd-bundle you can use the enhance-plugin-1.0.2.jar (contains the DND bundle) and gwtquery-1.1.0-SNAPSHOT.jar.

You should look also at the native drag and drop support added in GWT 2.4. Documentation is scarce, but I found this example (you can drag templates from the right and drop them in the task details), and the relevant source code. (info from this post)

Ioan Agopian
  • 788
  • 5
  • 9