Setting the java classpath (for super dev mode)
Asked Answered
H

6

6

I'm trying to run a jar, gwt-codeserver.jar, in OSX.7, with the command

java -cp ".:/sdk/gwt-2.5.0.rc1/gwt-dev.jar" -jar /sdk/gwt-2.5.0.rc1/gwt-codeserver.jar com.activegrade.TeacherView

The command fails with:

Exception in thread "main" java.lang.NoClassDefFoundError: com/google/gwt/core/ext/TreeLogger
Caused by: java.lang.ClassNotFoundException: com.google.gwt.core.ext.TreeLogger
    at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
    ...

But gwt-dev.jar contains the definition for com.google.gwt.core.ext.TreeLogger, so I've concluded that I'm not properly setting the classpath here.

Am I setting the classpath correctly? The jar file is definitely the right jar and it's definitely at that location. How can I diagnose this further?

Harrus answered 29/6, 2012 at 16:18 Comment(0)
C
2

Could this be the source of your problem? "When you use the -jar option, the JAR file is the source of all user classes, and other user class path settings are ignored."

Coquina answered 29/6, 2012 at 17:0 Comment(0)
Z
7

I've got the CodeServer running as an external tool in Eclipse (caveat - you still have to server your html file somehow, which I have not yet done, but this does seem to get the codeserver running). To setup the CodeServer as an external tool in Eclipse,

0) Remember that you should also update your module.gwt.xml file to allow Super Dev Mode book marklets and to enable source maps for debugging. Add these likes to your module.gwt.xml file.

<!-- enable the SuperDevMode book marklets  -->
<add-linker name="xsiframe"/>
<set-configuration-property name="devModeRedirectEnabled" value="true"/>

<!--  enable source maps -->
<set-property name="compiler.useSourceMaps" value="true" />

1) Open the External Tools/External Tools Configurations dialog; this is under the top level 'Run' menu in Windows.

2) Create a new configuration by selecting 'Program' in the list on the left, then press the 'New' button (it looks like a document). Name your configuration in the dialog.

3) The path to your java.exe file goes in the 'Location:' box. You can use the 'Browse File System' button to locate it if you don't know the path.

4) I left working directory blank. I'm not sure if this matters; it seems to work without it. Does anyone out there know for sure if this should be set?

5) The bulk of the work in in the "Arguments:" box. You will provide an argument for the class path which will include the path to gwt-dev.jar, gwt.user.jar, gwt-codeserver.jar and to your source directory. Then you will provide a -jar and argument to the gwt-codeserver.jar and the CodeServer class to run, then you will provide the arguments to CodeServer. I'll break it down;

5a) -cp "comma separated list of class paths, surrounded by double quotes". To make your tool definition more portable, use eclipse "Varaibles' to calculate paths that are relative to your installation. In particular, I used 'workspace_loc' for workspace relative paths (like the src directory) and 'eclipse_home' for paths to gwt SDK stuff like gwt-user.jar (because I installed the SDK in the eclipse plugins folder). Here is my classpath part;

-cp "${eclipse_home}plugins\gwt-2.5.0.rc1\gwt-2.5.0.rc1\gwt-user.jar;${eclipse_home}plugins\gwt-2.5.0.rc1\gwt-2.5.0.rc1\gwt-dev.jar;${workspace_loc:\GWTFractionTest\war\WEB-INF\lib\gwtquery-1.1.0.jar};${eclipse_home}plugins\gwt-2.5.0.rc1\gwt-2.5.0.rc1\gwt-codeserver.jar"

5b) Next is the name of the class that java.exe should run. This is the CodeServer class;

com.google.gwt.dev.codeserver.CodeServer 

5c) Next is the arguments to CodeServer. The first is the path to the src directly. For me, this is a workspace relative path;

-src "${workspace_loc:\GWTFractionTest\src}" 

5d) Finally, the module path (the class path to your gwt.xml file) Here is mine;

com.conceptua.fractiontest.FractionTest

Here is my full argument list;

-cp "${eclipse_home}plugins\gwt-2.5.0.rc1\gwt-2.5.0.rc1\gwt-user.jar;${eclipse_home}plugins\gwt-2.5.0.rc1\gwt-2.5.0.rc1\gwt-dev.jar;${workspace_loc:\GWTFractionTest\war\WEB-INF\lib\gwtquery-1.1.0.jar};${eclipse_home}plugins\gwt-2.5.0.rc1\gwt-2.5.0.rc1\gwt-codeserver.jar" com.google.gwt.dev.codeserver.CodeServer -src "${workspace_loc:\GWTFractionTest\src}" com.conceptua.fractiontest.FractionTest

6) Select the 'Run' button to run the CodeServer. When I execute this in the console;

workDir: C:\Users\Ezward\AppData\Local\Temp\gwt-codeserver-6942784883227417581.tmp
binding: user.agent=safari
binding: compiler.useSourceMaps=true
binding: locale=en
Compiling module com.conceptua.fractiontest.FractionTest
   Validating units:
      Ignored 72 units with compilation errors in first pass.
Compile with -strict or with -logLevel set to TRACE or DEBUG to see all errors.
   Computing all possible rebind results for 'com.google.gwt.useragent.client.UserAgentAsserter'
      Rebinding com.google.gwt.useragent.client.UserAgentAsserter
         Checking rule <generate-with class='com.google.gwt.editor.rebind.SimpleBeanEditorDriverGenerator'/>
            [WARN] Detected warnings related to 'com.google.gwt.editor.client.SimpleBeanEditorDriver'.   Are validation-api-<version>.jar and validation-api-<version>-sources.jar on the classpath?
            Specify -logLevel DEBUG to see all errors.
            [WARN] Unknown type 'com.google.gwt.editor.client.SimpleBeanEditorDriver' specified in deferred binding rule
   Compiling 1 permutation
      Compiling permutation 0...
      Source Maps Enabled
   Compile of permutations succeeded
Linking into C:\Users\Ezward\AppData\Local\Temp\gwt-codeserver-6942784883227417581.tmp\com.conceptua.fractiontest.FractionTest\compile-1\war\fractiontest; Writing extras to C:\Users\Ezward\AppData\Local\Temp\gwt-codeserver-6942784883227417581.tmp\com.conceptua.fractiontest.FractionTest\compile-1\extras\fractiontest
   Link succeeded
   Compilation succeeded -- 58.257s
Compile completed in 60831 ms
2012-07-01 12:37:03.184::INFO:  Logging to STDERR via org.mortbay.log.StdErrLog
2012-07-01 12:37:03.185::INFO:  jetty-6.1.x

The code server is ready.
Next, visit: http://localhxst:9876/
2012-07-01 12:37:03.274::INFO:  Started [email protected]:9876

I'm not sure why I get the initial '72 Units with compilations errors' but it seems to continue to successfully compile and run the server.

7) At this point, you should enter the given CodeServer url into Chrome. You will get a page that indicates the CodeServer is running and you can drag the book marklets to the bookmarks toolbar;

GWT Code Server
Drag these two bookmarklets to your browser's bookmark bar:
Dev Mode On Dev Mode Off
Visit a web page that uses one of these modules:
fractiontest
Click "Dev Mode On" to start development mode.

8) The next step is to get to your html file to run it. It apparently needs to be served by a separate webserver. I'm still working on that part.

Ed

Zinazinah answered 1/7, 2012 at 20:29 Comment(0)
C
2

Could this be the source of your problem? "When you use the -jar option, the JAR file is the source of all user classes, and other user class path settings are ignored."

Coquina answered 29/6, 2012 at 17:0 Comment(0)
H
2

I wasted a lot of time trying to make it work. I tried to follow wonderful Ezward instructions but my setup is probably somewhat different and it didn't work for me. There are many moving pieces and any mistake causes tons of NullPointer, StackOverflow and UnableToComplete exceptions.

The only set of instructions that worked for me I found at http://blog.daniel-kurka.de/2012/07/mgwt-super-dev-mode.html (Daniel Kurka blog). Hope it will help somebody else who is stuck with GWT Super Dev Mode like me.

Hillard answered 11/7, 2012 at 19:32 Comment(0)
K
1

You can use it like following..

java -cp ".:/sdk/gwt-2.5.0.rc1/gwt-dev.jar:/sdk/gwt-2.5.0.rc1/gwt-codeserver.jar" com.activegrade.TeacherView
Kutzenco answered 29/6, 2012 at 17:25 Comment(0)
S
1

Had the same problem. This is what helped me:

java -cp "./gwt-codeserver.jar:./gwt-dev.jar" com.google.gwt.dev.codeserver.CodeServer

You can add the --help as such:

java -cp "./gwt-codeserver.jar:./gwt-dev.jar" com.google.gwt.dev.codeserver.CodeServer --help

Would output:

CodeServer [-bindAddress address] [-port port] [-workDir dir] [-src dir] [module]

where 
  -bindAddress  The ip address of the code server. Defaults to 127.0.0.1.
  -port         The port where the code server will run.
  -workDir      The root of the directory tree where the code server willwrite compiler output. If not supplied, a temporary directorywill be used.
  -src          A directory containing GWT source to be prepended to the classpath for compiling.
and 
  module        The GWT modules that the code server should compile. (Example: com.example.MyApp)

and then just set your -src directory and the name of your module

Sociability answered 20/7, 2012 at 18:35 Comment(0)
H
1

I was able to resolve this by adding gwt-user.jar to the classpath in addition to gwt-dev.jar. The GWT super dev mode instructions say you might need to add gwt-user.jar.

Hierarchy answered 8/8, 2015 at 17:43 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.