Your src appears not to live underneath a subpackage called 'client',but you'll need to use the <src> directive in your module to make it accessible - gwt

I am using GWT 2.9.0 + GXT 4.1.0 + Java 11 combination. I am getting below error
[ERROR] Hint: Your source appears not to live underneath a subpackage called 'client'; no problem, but you'll need to use the directive in your module to make it accessible
ProjectName. Below is my project structure in package explorer in eclipse. I am getting the error when trying to run my application in super dev mode through gwt eclipse plugin in eclipse IDE. Can you help me in resolving the issue
MavenProjectName
src/main/java ----> This is empty
src/main/src-client
com.cname.proj
Main.java
Main.gwt.xml
com.cname.proj.client.centerpanelscreens
com.cname.proj.client.command
com.cname.proj.service
src/main/src-common
com.cname.proj
Common.gwt.xml
com.cname.proj.model
com.cname.proj.model.to
com.cname.proj.service
com.cname.proj.util
src/main/webapp
index.html
src/main/webapp/WEB-INF
web.xml
Content below in Main.gwt.xml
<module rename-to="js">
<inherits name='com.google.gwt.user.User'/>
<inherits name='com.google.gwt.user.theme.clean.Clean'/>
<inherits name='com.cname.proj.Common' />
<inherits name='com.sencha.gxt.ui.GXT'/>
<entry-point class='com.cname.proj.Main' />
<source path="client" />
<source path="service"/>
</module>
Content below in Common.gwt.xml
<module>
<inherits name='com.sencha.gxt.ui.GXT'/>
<source path="model"/>
<source path="service" />
<source path="util">
</source>
GWT Logs
Resolving javax.validation.constraints.Pattern
Resolving javax.validation.constraints.Pattern.Flag
Found type 'javax.validation.constraints.Pattern.Flag'
Resolving method <clinit>
Resolving method <init>
Resolving method getValue
Resolving method values
Resolving method valueOf
Resolving field UNIX_LINES
Resolving field CASE_INSENSITIVE
Resolving field COMMENTS
Resolving field MULTILINE
Resolving field DOTALL
Resolving field UNICODE_CASE
Resolving field CANON_EQ
Resolving field value
Resolving javax.validation.constraints.Pattern.List
Found type 'javax.validation.constraints.Pattern.List'
Resolving annotation for java.lang.annotation.Target
Resolving annotation for java.lang.annotation.Retention
Resolving annotation for java.lang.annotation.Documented
Resolving method value
Resolving javax.validation.spi.ConfigurationState
Finding entry point classes
Tracing compile failure path for type 'com.cname.proj.Main'
Checked 0 dependencies for errors.
[ERROR] Hint: Your source appears not to live underneath a subpackage called 'client'; no problem, but you'll need to use the <source> directive in your module to make it accessible
Closing cache file: C:\gwt-unitCache\gwt-unitCache-b9eb8fcc22822eac5087fcda1c6dcb20c0796e62-18CAE75E829AF224BF18DEE97AC379EF-00000181BAD760BD (0 units written)
Deleting empty file: C:\gwt-unitCache\gwt-unitCache-b9eb8fcc22822eac5087fcda1c6dcb20c0796e62-18CAE75E829AF224BF18DEE97AC379EF-00000181BAD760BD
Shutting down PersistentUnitCache thread
Shutting down PersistentUnitCache thread
POM.xml with the required legacy plugin
<plugins>
<!-- GWT Maven Plugin -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>gwt-maven-plugin</artifactId>
<version>2.9.0</version>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>test</goal>
<!-- goal>generateAsync</goal> -->
</goals>
</execution>
</executions>
<!-- Plugin configuration. There are many available options, see gwt-maven-plugin
documentation at codehaus.org -->
<configuration>
<!-- module>com.msci.dm.gis.gwt.Main</module-->
<runTarget>Main.html</runTarget>
<debugPort>8998</debugPort>
<hostedWebapp>${webappDirectory}</hostedWebapp>
<extraJvmArgs>-Xmx512M -Xss1024k</extraJvmArgs>
</configuration>`enter code here`
</plugin>

Tracing compile failure path for type 'com.cname.proj.Main'
Checked 0 dependencies for errors.
[ERROR] Hint: Your source appears not to live underneath a subpackage called 'client'; no problem, but you'll need to use the <source> directive in your module to make it accessible
Your .gwt.xml files both live in com/cname/proj/, and only lists these sub-packages as sources:
<source path="client" />
<source path="service" />
...
<source path="model" />
<source path="service" />
<source path="util" />
(note that you have "service" listed twice, both .gwt.xml files claim that the server package is part of its own module).
Since no module is claiming the top-level package of com.cname.proj, that source file will not be available at compile time.
The expected pattern is to only list packages that are expected for the compiler to transform all of their contents into JS. Typically, this is the client sub-package, but convention often suggests that a shared sub-package may exist too, consisting of code shared between the server and client. There is no problem with listing others like service, model, util, and you technically can also just list the empty string to indicate the entire current package and all subpackages:
<source path="" />
With all of that said, the best option is to move Main into com.cname.proj.client, since it is almost certainly exclusively a client class.

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.

Build Path in eclipse

After importing my existing GWT project to Eclipse getting the following error.
Project 'TestUI' is missing required source folder: 'TestMgr/nocache/js.gwt.xml'.
Please help.
Please post your module gwt.xml. You should ensure the entry point classpath is correct
<!-- Specify the app entry point class. -->
<entry-point class="com.me.myproject.client.TestUI" />
And check that you added the appropriate packages to your module
<!-- Adding package to this gwt module -->
<source path="client" />
<source path="shared" />
If everything is fine with the module, could you be more specific about where that error happens ? When launching your project ? In Eclipse warnings ?

Check the inheritance chain from module; it may not be inheriting a required module or a module may not be adding its source path entries properly

I want to create a gwt maven project with multiple gwt modules. some of them are just utility modules means they have no entry point. Basically I have already a gwt project with multiple gwt modules in it and I have converted it to maven but while compilation its giving me following exception :
[ERROR] Unable to find type
'in.appops.showcase.web.gwt.uploadservice.client.UploadService' [INFO]
[ERROR] Hint: Previous compiler errors may have made this type
unavailable [INFO] [ERROR] Hint: Check the inheritance chain
from your module; it may not be inheriting a required module or a
module may not be adding its source path entries properly
My project has core and dispath modules which are utility modules without entry point and other uploadservice module which has entry point which is inheriting the core module .
So I put core.gwt.xml ,dispatch.get.xml in their packages i.e in src/main/java itself and uploadservice.gwt.xml in resources folder of maven.
also in pom.xml I am providing the modules to compile:
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.codehaus.mojo</groupId>
<artifactId>gwt-maven-plugin</artifactId>
<version>2.4.0</version>
<goals>
<goal>clean</goal>
<goal>resources</goal>
<goal>compile</goal>
<goal>i18n</goal>
<goal>generateAsync</goal>
</goals>
<configuration>
<runTarget>Index.html</runTarget>
<hostedWebapp>${webappDirectory}</hostedWebapp>
<modules>
<!-- <module>platform.bindings.web.gwt.dispatch.Dispatch</module>
<module>platform.core.Core</module> -->
<module>showcase.web.gwt.addressbook.AddressBook</module>
<module>showcase.web.gwt.uploadservice.UploadService</module>
</modules>
</configuration>
</pluginExecutionFilter>
<action>
<execute />
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
can anybody help me to get out of this exception. Is it neccessary that I need to provide the order to compile the modules or anything else?
Note 1 -
When using gwt standard approach your folder structure
src/main/java/showcase/web/gwt/yourmodule/yourmodule.gwt.xml
src/main/java/showcase/web/gwt/yourmodule/client
src/main/java/showcase/web/gwt/yourmodule/public
Your pom references
<module>showcase.web.gwt.addressbook.AddressBook</module>
<module>showcase.web.gwt.uploadservice.UploadService</module>
Your .gwt.xml file location
src/main/java/showcase/web/gwt/addressbook/AddressBook.gwt.xml
src/main/java/showcase/web/gwt/uploadservice/UploadService.gwt.xml
Note 2 - <lifecycleMappingMetadata> is for your m2e = maven eclipse plugin. For clear example of GWT MAVEN POM example - http://code.google.com/p/google-web-toolkit/source/browse/trunk/samples/validation/pom.xml
Note 3 - Exactly follow the extremely simple example of gwt maven sample project - http://code.google.com/p/google-web-toolkit/source/browse/trunk/samples/validation/
DO NOT CHANGE FOLDER LOCATION. *FOLLOW THE NAMING CONVENTION.* even folder names like public, client are picked by "name" in GWT.
If this error occurs upon loading the entry point, you may need to change the tags in your *.gwt.xml file.
After changing my package structure, I was able to successfully fix the error, "Check the inheritance chain from your module; it may not be inheriting a required module or a module may not be adding its source path entries properly".
In your .gwt.xml file, find the source tags near the bottom of the file.
revert to an earlier working commit, or open a known working project
take note of the pattern that the working source tags follow relative to the package structure of your working project.
roll forward to the broken commit
modify your source tag(s) to correspond to the current package structure, following the same pattern.
In addition, you should check to make sure you have the appropriate inherits tags in your .gwt.xml file. For example, you will get a similar error if you attempt to use SmartGWT without the tag inherits name="com.smartgwt.SmartGWt"
Your UploadService.gwt.xml file should be in src/main/resources/in/appops/showcase/web/gwt/uploadservice. Others GWT module descriptors should be in their packages as well.

GWT. Maven. GWT Module <module_name> not found in project sources or resources

I have a maven multi-module project. One of this modules (compiled as .jar) contains only domain objects, which will be used at client and server sides (I add this .jar as dependency to other my modules).
I know that GWT module, where will be used objects from shared .jar, must also have source files for successful compilation. So I tried to add to my pom.xml both:
<resources>
<resource>
<directory>src/main/java/<path></directory>
<includes>
<include>**/*.java</include>
<include>**/*.gwt.xml</include>
</includes>
</resource>
</resources>
and
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>gwt-maven-plugin</artifactId>
<versionRange>[${gwt.version}]</versionRange>
<goals>
<goal>resources</goal>
</goals>
<plugin>
But resulting .jar don't contain GWT module source (i.e gwt.xml). All sources of domain classes are added as well (at root directory of .jar), but ModuleName.gwt.xml not.
Where is problem? Thanks.
If your .gwt.xml file is in src/main/resources/ then it won't get copied if you specify src/main/java/ as the resource path...
You should probably omit the <resource> section and let the GWT plugin include the source in the jar or at least have two sections, one for the .gwt.xml file (src/main/resources or where you put it) and one for the source code (as you have it now).
Cheers,
I was troubleshooting this error today so I'm just posting my fix:
Multi-module gwt project being build with the maven gwt plugin needs an entry in the pom.xml like:
<modules>
<module>../theothermodule</module>
</modules>
In order to compile.
This error have multiple explanations. Check list:
if you are referencing a gwt module you need to point to the *.gwt.xml file in dot notation without the file extension. E.g. com.example.ThirdParty refers to com/example/ThirdParty.gwt.xml module
to import the 3rd party module, add <inherits name="com.example.ThirdParty" /> to your *.gwt.xml file
the ThirdParty.gwt.xml should contain one or more source elements pointing to translatable code. E.g. <source path='shared' />.
all translatable code in ThirdParty.jar needs to include plaintext *.java sources. E.g. com/example/shared/Widget.class and com/example/shared/Widget.java are both present
the ThirdParty.jar is on your classpath
Notes:
if the ThirdParty gwt module does not have entry point it does not need to be compiled with gwt compiler
the gwt compiler does not require extra configuration to include the ThirdParty module as long as its jar is on classpath and your *.gwt.xml inherits ThirdParty.gwt.xml; the same applies to the gwt maven plugin

Complie issue with Custom GWT project strcuture

I am working on a gwt module that is built using maven build system. I
had a working module that had the following project structure.
project-name/src/main/java/pkg1/pkg2/pkg3/EntryPoingClass
project-name/src/man/resources/pkg1/pkg2/ModuleDef.gwt.xml
The module definition was looking like this (I have put only this
project specific settings here...normal inherits are not specified for
the sake of brevity)
... <entry-point class='pkg1.pkg2.pkg3.EntryPointClass'/>
<source path='pkg3'/>...
I am not a big fan of having sub packages in the resources folder.
Hence I am trying to change it to something like the following
project-name/src/main/java/pkg1/pkg2/pkg3/EntryPoingClass project-name/src/man/resources/ModuleDef.gwt.xml
Also changed the module definition to
... <entry-point class='pkg1.pkg2.pkg3.EntryPointClass'/>
<source path='pkg1.pkg2.pkg3'/> <!-- Since the module def is not
inside any package I am specifying the entire 'client' package here --> ...
After this, invoking gwt compile fails with the following error
Unable to find type "pkg1.pkg2.pkg3.EntryPointClass"
Can anybody tell me if there is any relation between the package
structure of the EntryPointClass and the module definition package
structure apart from the fact that the EntryPointClass should be
inside the 'client' package specified in the module definition (which
is satisfied here)?
Btw, I could see that the compiled classes are available in the
classpath when invoking the gwt compiler.
Any help in this regard is greatly appreciated.
GWT compiler needs sources of client side classes, not only compiled bytecode. Is it in classpath?
In my company we always set pom.xml to copy sources to target as resources:
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
</resource>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/client/**/*.java</include>
<include>**/*.gwt.xml</include>
</includes>
</resource>
</resources>
</build>
Change **/client/**/*.java to anything satisfies your needs (probably pkg1/pkg2/pkg3/**/*.java). This way sources of client part are always in classpath.