tags:

views:

782

answers:

4

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?

+4  A: 

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/1.6/DevGuideOrganizingProjects.htm

rustyshelf
the link seems to be broken
JohnIdol
The correct link is http://code.google.com/webtoolkit/doc/1.6/DevGuideOrganizingProjects.html
Templar
rustyshelf is correct. As an example, if you want to use the gwt-gears API, you need to add the following to your .gwt.xml file:<inherits name="com.google.gwt.gears.Gears" />
Templar
+1  A: 

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.

mP
+1  A: 

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.

signalpillar
A: 

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

Templar