gwt app deployment to tomcat doesn't load compiled javascript - eclipse

I use Eclipse GWT Plug-in to build a GWT app. Later on, I'll have to deploy this as a Tomcat webapp. I have read many pages on how to do it and it looks dead simple but it doesn't work here.
If I create a new Web application using the plug-in and that I copy the war directory content to de tomcat_install/webapps folder it works right out the box, I get the application and all the things get loaded correctly.
If I do the same with the application I'm working on for a couple of weeks now, I get nothing, there is just the plain html file I use as welcome page that loads. If I inspect the page I can see it has correctly loaded the .nocache.js but no controls whatsoever show up on my page.
Everything works in development, my servlet are correctly mapped.
Here is my app.gwt.xml :
<?xml version="1.0" encoding="UTF-8"?>
<module rename-to='VirtualLabPortal'>
<inherits name="com.google.gwt.user.User" />
<inherits name='com.google.gwt.user.theme.standard.Standard'/>
<inherits name="com.google.gwt.i18n.I18N"/>
<set-property name="gwt.logging.enabled" value="FALSE"/>
<define-property name="webkitVariant" values="safari, chrome" />
<collapse-all-properties />
<extend-property name="locale" values="en"/>
<extend-property name="locale" values="fr" />
<set-property-fallback name="locale" value="fr"/>
<entry-point
class="com.banctecmtl.ca.vlp.view.webview.client.VirtualLabPortal" />
<source path='view/webview/client' />
<source path='shared' />
<source path='model' />
</module>
My web,xml, where my two servlet are mapped looks like this :
<?xml version="1.0" encoding="utf-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5">
<servlet>
<servlet-name>VlpControllerService</servlet-name>
<servlet-class>com.banctecmtl.ca.vlp.view.webview.server.VlpControllerServiceImpl</servlet-class>
</servlet>
<servlet>
<servlet-name>UserAccessService</servlet-name>
<servlet-class>com.banctecmtl.ca.vlp.view.webview.server.UserAccessServiceImpl</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>VlpControllerService</servlet-name>
<url-pattern>/VirtualLabPortal/VlpController</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>UserAccessService</servlet-name>
<url-pattern>/VirtualLabPortal/UserAccess</url-pattern>
</servlet-mapping>
<!-- Default page to serve -->
<welcome-file-list>
<welcome-file>VirtualLabPortal.html</welcome-file>
</welcome-file-list>
</web-app>
Note that in my services interfaces I use #RemoteServiceRelativePath("VlpController") and #RemoteServiceRelativePath("UserAccess") to ensure a correct mapping.
This is the content of my entrypoint, that I made plain simple just to see if I could get it to work on deployment :
public class VirtualLabPortal implements EntryPoint {
/**
* Entry point method.
*/
public void onModuleLoad() {
RootPanel.get().add(new Label("This"));
}
}
Since the body of my html page is empty, a white page shows up, the javascript should write the test label on that page, but nothing happens. As I said, my VirtualLabPortal.nocache.js is loaded in the html page.
Is there something I'm completely missing here?
EDIT :
I think i just got it, I removed two properties my partner added to the gwt.xml file to reduce the number of permutations and it seems to be fixed so far:
<set-property name="gwt.logging.enabled" value="FALSE"/>
<define-property name="webkitVariant" values="safari, chrome" />
<collapse-all-properties />

Do you compile your project via :
project right clic > google > gwt compile
and then
project right clic > export > WAR file
this is the way I proceed, it works !
check this one:
Deploying GWT app from GAE to Tomcat

After long hours of searching and testing, I understtod how GWT bootstrapping process was working. I looked over my module.gwt.xml file and I found the following line added by one of my partners to reduce the number of permutations :
<collapse-all-properties />
Removing this line brought us back to 18 permutations and deploying the WAR folder to my tomcat webapps directory did the job. Compiling only once was not generating the file used required by my locale. Maybe if my browser language would have been in English it would have worked out the first time.
Well now it works as all the required files are correctly compiled.

Related

GWT error even on official tutorials: Check that your module inherits 'com.google.gwt.core.Core' either directly or indirectly

I am learning GWT and was trying to run this tutorial by Vogella and also the official GWT tutorial.
Using the Eclipse GWT plugin 3.0 on Windows 10 and JDK 11
I marked the Maven Project checkbox.
When I right-click and Run As
Turning off precompile in incremental mode.
Super Dev Mode starting up
workDir: C:\Users\My\AppData\Local\Temp\gwt-codeserver-8137229043727681777.tmp
2021-04-29 12:03:13.494:INFO::main: Logging initialized #718ms
Loading Java files in de.vogella.gwt.helloworld.De_vogella_gwt_helloworld.
[ERROR] Hint: Check that your module inherits 'com.google.gwt.core.Core' either directly or indirectly (most often by inheriting module 'com.google.gwt.user.User')
I see that it is inheriting User
<?xml version="1.0" encoding="UTF-8"?>
<!--
When updating your version of GWT, you should also update this DTD reference,
so that your app can take advantage of the latest GWT module capabilities.
-->
<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 2.8.1//EN"
"http://www.gwtproject.org/doctype/2.8.1/gwt-module.dtd">
<module rename-to='de_vogella_gwt_helloworld'>
<!-- Inherit the core Web Toolkit stuff. -->
<inherits name='com.google.gwt.user.User'/>
<!-- Inherit the default GWT style sheet. You can change -->
<!-- the theme of your GWT application by uncommenting -->
<!-- any one of the following lines. -->
<inherits name='com.google.gwt.user.theme.clean.Clean'/>
<!-- <inherits name='com.google.gwt.user.theme.standard.Standard'/> -->
<!-- <inherits name='com.google.gwt.user.theme.chrome.Chrome'/> -->
<!-- <inherits name='com.google.gwt.user.theme.dark.Dark'/> -->
<!-- Other module inherits -->
<!-- Specify the app entry point class. -->
<entry-point class='de.vogella.gwt.helloworld.client.De_vogella_gwt_helloworld'/>
<!-- Specify the paths for translatable code -->
<source path='client'/>
<source path='shared'/>
<!-- allow Super Dev Mode -->
<add-linker name="xsiframe"/>
</module>
This SO question was not relevant to my issue.
Almost certainly you are either missing gwt-user.jar from your classpath, or somehow the gwt-user.jar version doesn't match the gwt-dev.jar, which will cause problems. Every module automatically inherits com.google.gwt.core.Core (despite the error message), and as your .gwt.xml shows, you already have User added.
--
Additionally, from your linked SO post, do check the comments - there are some better, more modern tutorials listed.

GWT: CSS file defined in module definition file (gwt.xml) doesn't work?

From GWT tutorial (http://www.gwtproject.org/doc/latest/DevGuideUiCss.html), we know there are multiple approaches for associating CSS files with your module. Therein, one way is using the <stylesheet> element in the module XML file.
When I used the way to do it, I got the warning message below. It seems the way doesn't work.
Here's the contents of module1.gwt.xml:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 2.7.0//EN" "http://google-web-toolkit.googlecode.com/svn/tags/2.7.0/distro-source/core/src/gwt-module.dtd">
<module rename-to="entry1">
<inherits name="com.google.gwt.user.User" />
<inherits name='com.google.gwt.user.theme.clean.Clean'/>
<source path="client" />
<entry-point class="com.jst.gwt2.client.Entry1"></entry-point>
<stylesheet src="../entry1.css" />
<source path='client' />
<source path='rpc' />
</module>
Here's the warning message:
GET /entry1.css
[WARN] ignored get request: /entry1.css
[WARN] not handled: /entry1.css
quoting #Thomas Broyer:
to get the full explanation click here
You'll have to change either
the path to your CSS (e.g. /entry1.css, but that won't necessarily work once deployed in production)
the location of your CSS (e.g. put it in your module's public path and reference it as <stylesheet src="entry1.css"/>)
the way you load it (e.g. inject it from your onModuleLoad, either as a StyleElement added to the Document; or possibly as a TextResource
that you inject using StyleInjector –and use one less request to the
server)

Spring/REST Application with HOT Deployment: Groovy script does not load dynamically from applicationContext.xml on tomcat startup at runtime

I am in the process of converting an already exisiting Java Web application into a RESTful web application using Spring MVC and Groovy.
One of the main features I wanted to achieve was HOT DEPLOYMENT.
I chose groovy because I did not want to make changes to the already implemented Business logic(handlers) and also if I had to ever make changes to the groovy code after deployment, I could easily do that without restarting the server(ie. at runtime).
This can be done because Spring supports Dynamic reloading of groovy scripts(beans). It reloads classes of dynamic languages if they are changed.
I am using Spring annotations to map request URL's to controller methods and the application is deployed in tomcat 6.0.35.
This is the web.xml file
//web.xml
<?xml version = "1.0" encoding = "UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5">
<!-- Spring Dispatcher -->
<servlet>
<servlet-name>rest</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>rest</servlet-name>
<url-pattern>/service/*</url-pattern>
</servlet-mapping>
<!-- Loads application context files in addition to ${contextConfigLocation} -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<!-- Set session timeout to 30 minutes -->
<session-config>
<session-timeout>30</session-timeout>
</session-config>
</web-app>
This groovy file is the controller to which the DispatcherServlet maps the request.
// UserController.groovy
#Controller
class UserController
{
// This is the method to which the HTTP request is submitted to based on the mapping of the
// action field of the form ie. /service/user/login/auth.json
#RequestMapping(value="/user/login/auth.{extension:[a-zA-Z]+}", method=RequestMethod.POST)
#ResponseBody
public String authenticate(
#PathVariable String extension,
#RequestParam(value="username", required=true) String username,
#RequestParam(value="password", required=true) String password)
{
// UserResource makes the backend calls, authenticates a user and returns the result.
def user = new UserResource()
def result = user.login(name:username, userPassword:password)
// Output the result of the query. Method makeView makes a JSON response of the result
// and sends to the client(browser)
def builder = makeView(extension)
{
it.login(action:result.action, message:result.message)
}
}
}
The Spring configuration file is as follows where I have used the "lang:groovy" tag which supports dynamic languages. I have also mentioned the refresh time to be 5 seconds, so that any changes made to those groovy files at runtime can be seen every 1 second and the classes are reloaded.
//applicationContext.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:lang="http://www.springframework.org/schema/lang"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:c="http://www.springframework.org/schema/c"
xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.1.xsd
http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util-3.1.xsd
http://www.springframework.org/schema/lang
http://www.springframework.org/schema/lang/spring-lang-3.1.xsd">
<context:annotation-config/>
<context:component-scan base-package="app.controller,app.resource" />
<lang:groovy id="user" script-source="classpath:controller/UserController.groovy" refresh-check-delay="1000"></lang:groovy>
<!-- To enable #RequestMapping process on type level and method level -->
<bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping" />
<bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter" />
<!-- Resolves view names to template resources within the directory -->
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/"/>
<property name="suffix" value=".html"/>
</bean>
</beans>
I have configured my Buildpath and groovy compiler accordingly, so that all the groovy scripts directly get copied to the target folder instead of getting compiled to class files.
THE MAIN PROBLEM
When I deploy this project in a tomcat server, it loads all the Spring beans required including the ScriptProcessor. Now, when I go to my browser, load the form, and try to submit the authentication form, I get the following error in Tomcat log:
15:20:09 WARN - No mapping found for HTTP request with URI [/service/user/login/auth.json] in DispatcherServlet with name 'rest'
I have also made changes in $TOMCAT_DIR/conf/context.xml to antilock resources and JARS
<Context antiResourceLocking="true" antiJARLocking="true" reloadable="true" privileged="true">
.
.
.</Context>
However, if I configure my project to compile those groovy scripts into bytecode classes, comment out the "lang:groovy" tag in applicationContext.xml, and then restart the server, the groovy scripts get compiled into class files and the request is serviced perfectly. Authentication takes place.
Also, if I configure the dynamic beans in my applicationContet.xml using the following two lines instead of the tag, my beans DO get created dynamically at runtime and the URLs do get mapped to the respective controller methods because of the annotations.
<bean class="org.springframework.scripting.support.ScriptFactoryPostProcessor" />
<bean id ="User" class="org.springframework.scripting.groovy.GroovyScriptFactory">
<constructor-arg value="classpath:controller/UserController.groovy" />
</bean>
But I do not know how to create the bean refreshing functionality with this style. So I guess there is an issue with the way the tag processes the groovy scripts.
I would really appreciate some help on this. I have searched all over the internet and read an infinite number of tutorials, and followed the exact procedure mentioned there. But I cant find out whats going wrong.
Please help me solve this problem.
Thank you.
Try creating the controller with Java/Groovy that is compiled and let it get injected the Groovy 'script' as a dependency to do the actual work. I seem to remember doing this before and it might be the annotations or the way Spring loads controllers that makes the 'script' not work for you properly.

gwt logs are not generated

Using gwt logs jar I am able to display logs on my console. But now I wanted to add logs in my olgs file from cient side, as we do using log4j on server side. So i reffered to http://code.google.com/p/gwt-log/wiki/GettingStarted this link but i dont see any client side logs getting generated in my log file.
Following is my gwt.xml file
<inherits name="com.allen_sauer.gwt.log.gwt-log-DEBUG" />
<set-property name="log_DivLogger" value="DISABLED" />
<!-- In gwt-log-3.0.3 or later -->
<inherits name="com.allen_sauer.gwt.log.gwt-log-RemoteLogger" />
<set-configuration-property name="log_pattern" value="%d [%t] %p - %m
%n" />
Following is my web.xml file
<servlet>
<servlet-name>gwt-log-remote-logger-servlet</servlet-name>
<servlet-class>com.allen_sauer.gwt.log.server.RemoteLoggerServiceImpl</servlet-class>
<!--
The `symbolMaps` parameter specifies the server directory
containing the GWT compiler symbol maps output, which is used
for stack trace deobfuscation
-->
<init-param>
<!-- This value assumes a GWT compile with '-deploy war/WEB-INF/deploy/' -->
<param-name>symbolMaps</param-name>
<!--
Modify the param-value based on your server environment. Some web servers
use your `war` directory as the 'current working dir', while other
vendors will do something different. You may use trial and error. Specify the
relative path you think should work, then check the server log after forwarding
the first client log message to the server. If the directory cannot be found,
gwt-log will report the full path which it tried.
-->
<param-value>WEB-INF/deploy/detectfiles/symbolMaps/</param-value>
</init-param>
<!--
Additional or alternate directories may be specified via additional parameter
which also begin with `symbolMaps`. This may be useful if you deploy to multiple
server environments which use different directory structures or have a different
notion of what the 'current working directory' is.
-->
<init-param>
<param-name>symbolMaps_2</param-name>
<param-value>WEB-INF/deploy/detectfiles/symbolMaps/</param-value>
</init-param>
<!-- Optionally enable CORS (http://www.w3.org/TR/cors/)
<init-param>
<param-name>Access-Control-Allow-Origin</param-name>
<param-value>http://your-applications-origin</param-value>
</init-param>
-->
</servlet>
<servlet-mapping>
<servlet-name>gwt-log-remote-logger-servlet</servlet-name>
<url-pattern>/com.renault.detectfiles/gwt-log</url-pattern>
</servlet-mapping>
I have added log on clinet side as follows
Log.debug("Hi this is a debug log");
First of all, make sure that you compile your GWT application with the additional parameter -deploy war/WEB-INF/deploy/.
Second, make sure that symbol maps exist in the directory
WEB-INF/deploy/detectfiles/symbolMaps/. I observed that symbolMaps go to the directory WEB-INF/deploy/<module-name>/symbolMaps/ when I compiled. Here, detectfiles does not look like your module name. Because, in the url-pattern, you have specified com.renault.detectfiles as the module name.
These might be the possible cause of not seeing the log.

Servlet not found once hosted on a web server

The main problem is that the servlet is basically not found on the web server once I upload it to some webhosting server I got, while it finds it all fine and dandy in hosted mode with the embedded jetty
I can't really check the full tomcat setup on the host, but it's actually there as some .jsp test files run fine there, unless there's something missing that I'm not sure of
When going directly to the path of the servlet, when in hosted mode it does the
HTTP method GET is not supported by this URL,
while just 404 on the webserver
web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
version="2.5"
xmlns="http://java.sun.com/xml/ns/javaee">
<!-- Servlets -->
<servlet>
<servlet-name>retailQuery</servlet-name>
<servlet-class>com.retail.report.server.DBConnectionServiceImpl</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>retailQuery</servlet-name>
<url-pattern>/retailreport/retailQuery</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>RetailReport.html</welcome-file>
</welcome-file-list>
</web-app>
RetailReport.gwt.xml:
<?xml version="1.0" encoding="UTF-8"?>
<module rename-to='retailreport'>
<inherits name='com.google.gwt.user.User'/>
<inherits name='com.google.gwt.user.theme.clean.Clean'/>
<!-- Specify the app entry point class. -->
<entry-point class='com.retail.report.client.RetailReport'/>
<servlet class="com.retail.report.server.DBConnectionServiceImpl"
path="/retailQuery" />
DBConnectionServiceImpl:
package com.retail.report.client;
import java.util.ArrayList;
import com.google.gwt.user.client.rpc.RemoteService;
import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
#RemoteServiceRelativePath("retailQuery")
public interface DBConnectionService extends RemoteService {
public ArrayList<SalesEntry> dayOfWeekQuery(String hier);
public ArrayList<SalesEntry> weekQuery(String hier);
}
As far as I can see, everything seems to be normal when looking at similar problems with servlets not being found, the only thing I cant check 100% for sure is any tomcat settings that I don't know about that need to be set, since it's some shared tomcat server on the webhost that I cant change anything with myself (although can probably ask the hosting if there's actually something that needs to change)
What is inside your tomcat/lib folder on the host? It is possible that GWT assumes some libraries are available on the hosted mode, but they are missing from your deployed version's host libraries. Just make sure all needed .jar files are in the war file in classes or lib.