Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add gwt-dev-help documentation #386

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/main/markdown/doc/latest/gwt-dev-help/WebAppClassPath.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Web App Classpath Problem

You were directed to this help topic because your server code needed a class or resource that was not found on the *web app classpath*, but **was** found on the *system classpath*. The *system classpath* is the classpath you specify when launching the Java VM to run hosted mode. The *web app classpath* is different — it consists of classes that live in your web application's *war directory*. All server classes and dependencies should be placed in your war directory: libraries (jars) should be placed in `war/WEB-INF/lib/` and classes that don't live in jars should be placed in `war/WEB-INF/classes/`.

GWT hosted mode helpfully works around this problem by mapping these outside resources into your web app classpath. This warning reminds you that failing to address the issue can lead to problems when you actually deploy your web app to a real server.

## Tips

- The most common reason to encounter this problem with a new project is using RPC, which tries to load `com.google.gwt.user.client.rpc.RemoteService`. The solution is to copy `gwt-servlet.jar` from the GWT install directory into your web app's `war/WEB-INF/lib/` directory.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we remove 'with a new project'? So, we would not limit it to new projects.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, these definitely need to be updated - this is just the first step at migrating them out of gwtproject/gwt itself, we'll want to refine them and possibly add more (jsinterop errors and warnings could use some help sections, or anchors on existing pages)


- If you have a good reason for not following the recommended configuration, you can suppress the warning by setting the Java system property `gwt.nowarn.webapp.classpath`. Specify `-Dgwt.nowarn.webapp.classpath` as a JVM argument when launching hosted mode.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we say: 'If you have good reasons for ...'?

11 changes: 11 additions & 0 deletions src/main/markdown/doc/latest/gwt-dev-help/longJsniRestriction.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Restrictions on Long Values with JSNI

The Java `long` type cannot be represented in JavaScript as a numeric type, so GWT emulates it using an opaque data structure. This means that JSNI methods cannot process a `long` as a numeric type. The compiler, therefore, disallows, by default, directly accessing a `long` from JSNI: JSNI methods cannot have `long` as a parameter type or a return type, and they cannot access a `long` using a JSNI reference. If you find yourself wanting to pass a `long` into or out of a JSNI method, here are some options:

1. **For numbers that fit into type `double`**, use type `double` instead of type `long`.

2. **For computations that require the full `long` semantics**, rearrange the code so that the computations happen in Java instead of in JavaScript. That way, they will use the `long` emulation.

3. **For values meant to be passed through unchanged to Java code**, wrap the value in a `Long`. There are no restrictions on type `Long` with JSNI methods.

4. **If you are sure you know what you are doing**, you can add the annotation `com.google.gwt.core.client.UnsafeNativeLong` to the method. The compiler will then allow you to pass a `long` into and out of JavaScript. It will still be an opaque data type, however, so the only thing you will be able to do with it will be to pass it back to Java.
7 changes: 7 additions & 0 deletions src/main/markdown/doc/latest/gwt-dev-help/servletMappings.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Servlet Mappings, GWT Modules, and web.xml

GWT modules may declare one or more `<servlet>` tags. These define Java Servlets that implement the server-side component of a GWT-enabled web application.

In modern GWT applications, these are only used for testing, and it is discouraged to use them in application code.

During hosted mode startup, the set of *expected* servlets (from GWT module `<servlet>` tags) is validated against the set of actual servlets (from the `WEB-INF/web.xml`) and a warning is issued for each *expected* servlet which does not match an actual servlet.
Loading