Need Help Packing a GWT Library Module in a JAR

I am trying to pack a GWT library module into a JAR file and use the library in a separate GWT web application by adding a JAR file to my class path.

JAR contains:

  • Java Sources
  • Sources created using RequestFactory.
  • Sources Generated by UiBinder
  • class files
  • library module descriptor
  • UiBinder XML Files

The library module inherits from the web application:

<module> <!-- my web app module descriptor --> ... <inherits name="[path to my library module].Library"/> ... </module> 

However i'm in

 Deferred binding failed for '[path to mylibrary].client.ClientFactory'... 

when trying to start a web application that initializes the library in the onModuleLoad () method. The error is caused by the UiBinder and RequestFactory views that the library module uses. Starting in development mode or compiling a web application leads to errors with messages indicating missing CSS files and illegal links to the generated source in the emul.java.util package (I tried to include this package and all other generated source in the JAR, but it not "t help.)

Can someone tell me what needs to be included in the JAR? Are there any additional resources needed for library modules that use UiBinder and RequestFactory?

Has anyone successfully packaged a GWT library module that uses RequestFactory and UiBinder in a JAR?

Further clarification: we are talking about creating a GWT library module; a module that includes client and server components, RequestFactory and UiBinder. Note that the GWT library module is packaged in a JAR, while the regular GWT module with an entry point is packaged in a WAR. My attempts to package such a library module and the GWT <inherit> from another GWT project failed.

+3
source share
1 answer

Either I misunderstood your question, or you incorrectly copied the GWT compilation with Java byte code compilation.

Traditional Java Development

  • The Java source is compiled into .class files into Java bytecode.
  • Compiled .class files during development as well as during deployment.
  • compiled .class files can be used in the development path and deployment class paths
  • It does not matter if the .class files are banks or hierarchy folders if their location matches their respective package namespace.
  • Java source files cannot be deployed in the deployment class path, but you can deploy JSP source files to war as JSPs.

Not for GWT.

  • GWT is a client-side development.
  • GWT compiled in Javascript.
  • The resulting javascript will be packaged in a war folder.
  • ie, GWT compiled into executables are javascript files.
  • To compile GWT, all Java classes are source files.
  • Any Java library referenced by your Java classes must also be Java source files.

GWT War

  • GWT also facilitates client-side alignment and server-side communications.
  • The server side is typically traditional Java deployed in a JEE military structure.
  • Therefore, in the deployment war, both the GWT client is compiled into javascript and the JEE.class bytecode files.
  • However, GWT JavaScript files are placed in the visible part of the war URL page along with HTML, CSS, and other URLs.
  • Compiled bytecode java files or jars on the server side are placed in class and lib directories that are not addressed to URLs.

Therefore ,

  • Compiled GWT deployment structures cannot be used for development.
  • GWT compiled into javascript deployment war framework.
  • "There is no such thing" as packing GWT compiled resources into a jar for deployment.
  • Compiled GWT resources must be packaged into a URL to the war side.
  • Compiled javascript files have โ€œno such thingโ€ as classpath. Any javascript classpath concept is modeled for JSNI convenience.

Conclusion

Compiled GWT resources are unusable and will not be visible for GWT development, because ... GWT development requires a java source, and deploying a GWT client is javascript in a war, and javascript is not like bans / bytecode files.

Therefore, in GWT there is โ€œno such thingโ€ as can packaging, which can be used for both development and deployment. In some examples and tutorials, package development and deployment files are installed in one jar, but this jar is essentially a zip code that you must first break down the deployment pieces from the development components.

GWT Development jars = source banks,

GWT deployment = war of javascript and resources.

Before you start working in GWT, you must have at least 3-6 months of experience when writing traditional JEE applications with JSP, servlets, HTML and javascript. This will help you instill a strong sense of segregation of the server side against the client side, the war against the bank and, therefore, understand why GWT was invented in the first place. You would understand the deployment process.

+1
source

Source: https://habr.com/ru/post/1387853/


All Articles