Question

I am trying to use the myType class declared in the package com.mycompany.myproject in a class that lives in com.mycompany.myproject.client but I am getting the following errors when compiling:

[ERROR] Line [X]: The import com.mycompany.myproject.myType cannot be resolved

If I try to run the hosted browser I get:

[ERROR] Line [X]: No source code is available for type com.mycompany.myproject.myType; did you forget to inherit a required module?

Any idea?

Was it helpful?

Solution

This error means that the GWT compiler cannot find your class. The GWT compiler can only find classes referenced by the .gwt.xml file for your project.

It's all explained here: http://code.google.com/webtoolkit/doc/latest/DevGuideOrganizingProjects.html

OTHER TIPS

The compiler firstly scans for the app's module.gwt.XML. The module XML can then or inherit other module xml. Modules can also declare which packages they wish to make visible to the compiler.

One doesn't just place •.java files on the compile path but must the module XML mechanism. This because not all sub packages should be translable eg a servlet component that compliments a client side intended component.

project structure:

  • com.mycompany.service
  • com.mycompany.myproject
    • client
    • service
    • myproject.gwt.xml

the source package by default is "client" that is placed in the same directory with gwt.xml file. If you want to add or change source directory - you have to edit gwt.xml.

1) for instance, you want make available for gwt package "com.my~ny.p~ct.service". In gwt.xml file add < source path="service"/>.

path-attribute values like "../", "." - will not work.

2) if you want to make available "com.my~ny.service" package.

create module (gwt.xml file) in com.mycompany,
where you have point source directory
and inherit default gwt User module.

I was having a similar problem and I managed to figure out a workaround which might help you in this situation.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top