GWT未解决的类型

时间:2012-07-03 09:34:30

标签: gwt maven compilation pom.xml

情况:

我有两个项目

  • 项目A:本地maven项目“核心”(域名)
  • 项目B:GWT maven项目“应用程序”(GUI)
  • 我使用Eclipse Helios和GWT 2.4

问题:

我不能在A.纠正中使用B.

可以在A中使用我自己的B类,但是我自己的类从其他jar(org.javatuples)中导入类。

当GWT正在编译客户端代码时,它会抛出一条错误消息:

"[ERROR] <no source info>: public abstract class org.javatuples.Tuple
    extends java.lang.Object
    implements : Iterable<java.lang.Object>, java.io.Serializable, Comparable<org.javatuples.Tuple>

这是完整的堆栈跟踪:

Compiling module org.dialoguemaps.dialoguemaps
   Validating newly compiled units
      Ignored 5 units with compilation errors in first pass.
Compile with -strict or with -logLevel set to TRACE or DEBUG to see all errors.
   [ERROR] An internal compiler exception occurred
com.google.gwt.dev.jjs.InternalCompilerException: Failed to get JNode
    at com.google.gwt.dev.jjs.impl.TypeMap.get(TypeMap.java:140)
    at com.google.gwt.dev.jjs.impl.TypeMap.get(TypeMap.java:71)
    at com.google.gwt.dev.jjs.impl.BuildTypeMap.getType(BuildTypeMap.java:730)
    at com.google.gwt.dev.jjs.impl.BuildTypeMap.createField(BuildTypeMap.java:570)
    at com.google.gwt.dev.jjs.impl.BuildTypeMap.access$300(BuildTypeMap.java:99)
    at com.google.gwt.dev.jjs.impl.BuildTypeMap$BuildDeclMapVisitor.visit(BuildTypeMap.java:180)
    at org.eclipse.jdt.internal.compiler.ast.FieldDeclaration.traverse(FieldDeclaration.java:285)
    at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.traverse(TypeDeclaration.java:1232)
    at org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration.traverse(CompilationUnitDeclaration.java:687)
    at com.google.gwt.dev.jjs.impl.BuildTypeMap.createPeersForNonTypeDecls(BuildTypeMap.java:637)
    at com.google.gwt.dev.jjs.impl.BuildTypeMap.exec(BuildTypeMap.java:514)
    at com.google.gwt.dev.jjs.impl.BuildTypeMap.exec(BuildTypeMap.java:523)
    at com.google.gwt.dev.jjs.JavaToJavaScriptCompiler.precompile(JavaToJavaScriptCompiler.java:599)
    at com.google.gwt.dev.jjs.JavaScriptCompiler.precompile(JavaScriptCompiler.java:33)
    at com.google.gwt.dev.Precompile.precompile(Precompile.java:284)
    at com.google.gwt.dev.Precompile.precompile(Precompile.java:233)
    at com.google.gwt.dev.Precompile.precompile(Precompile.java:145)
    at com.google.gwt.dev.Compiler.run(Compiler.java:232)
    at com.google.gwt.dev.Compiler.run(Compiler.java:198)
    at com.google.gwt.dev.Compiler$1.run(Compiler.java:170)
    at com.google.gwt.dev.CompileTaskRunner.doRun(CompileTaskRunner.java:88)
    at com.google.gwt.dev.CompileTaskRunner.runWithAppropriateLogger(CompileTaskRunner.java:82)
    at com.google.gwt.dev.Compiler.main(Compiler.java:177)
      [ERROR] <no source info>: public abstract class org.javatuples.Tuple
    extends java.lang.Object
    implements : Iterable<java.lang.Object>, java.io.Serializable, Comparable<org.javatuples.Tuple>
/*   fields   */
private static final [unresolved] long serialVersionUID
private final [unresolved] java.lang.Object[] valueArray
private final [unresolved] List<java.lang.Object> valueList
/*   methods   */
protected transient void <init>(java.lang.Object[]) 
protected transient void <init>(int, java.lang.Object[]) 
public int compareTo(org.javatuples.Tuple) 
[unresolved] public final boolean contains(java.lang.Object) 
[unresolved] public final boolean containsAll(Collection<?>) 
[unresolved] public final transient boolean containsAll(java.lang.Object[]) 
public final boolean equals(java.lang.Object) 
public abstract int getSize() 
[unresolved] public final java.lang.Object getValue(int) 
public final int hashCode() 
[unresolved] public final int indexOf(java.lang.Object) 
public final Iterator<java.lang.Object> iterator() 
[unresolved] public final int lastIndexOf(java.lang.Object) 
[unresolved] public final java.lang.Object[] toArray() 
[unresolved] public final List<java.lang.Object> toList() 
public final java.lang.String toString() 
org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding
[ERROR] at MultiID.java(17): private final Tuple _value;
 org.eclipse.jdt.internal.compiler.ast.FieldDeclaration

以下是A.的pom.xml和B的pom.xml:

pom.xml A。:

<?xml version="1.0"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <modelVersion>4.0.0</modelVersion>
  <groupId>org.dialoguemaps</groupId>
  <artifactId>core</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <name>core</name>
  <url>http://maven.apache.org</url>
  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>
  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.0</version>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>org.javatuples</groupId>
      <artifactId>javatuples</artifactId>
      <version>1.2</version>
      <scope>runtime</scope>
    </dependency>
  </dependencies>
  <repositories>
    <repository>
      <snapshots>
        <enabled>false</enabled>
      </snapshots>
      <id>central</id>
      <name>Maven Repository Switchboard</name>
      <url>http://repo1.maven.org/maven2</url>
    </repository>
  </repositories>
  <pluginRepositories>
    <pluginRepository>
      <releases>
        <updatePolicy>never</updatePolicy>
      </releases>
      <snapshots>
        <enabled>false</enabled>
      </snapshots>
      <id>central</id>
      <name>Maven Plugin Repository</name>
      <url>http://repo1.maven.org/maven2</url>
    </pluginRepository>
  </pluginRepositories>
  <build>
    <sourceDirectory>/home/arno/.workspace/dialoguemaps-core/src/main/java</sourceDirectory>
    <scriptSourceDirectory>/home/arno/.workspace/dialoguemaps-core/src/main/scripts</scriptSourceDirectory>
    <testSourceDirectory>/home/arno/.workspace/dialoguemaps-core/src/test/java</testSourceDirectory>
    <outputDirectory>/home/arno/.workspace/dialoguemaps-core/target/classes</outputDirectory>
    <testOutputDirectory>/home/arno/.workspace/dialoguemaps-core/target/test-classes</testOutputDirectory>
    <resources>
      <resource>
        <directory>/home/arno/.workspace/dialoguemaps-core/src/main/resources</directory>
      </resource>
    </resources>
    <testResources>
      <testResource>
        <directory>/home/arno/.workspace/dialoguemaps-core/src/test/resources</directory>
      </testResource>
    </testResources>
    <directory>/home/arno/.workspace/dialoguemaps-core/target</directory>
    <finalName>core-0.0.1-SNAPSHOT</finalName>
    <pluginManagement>
      <plugins>
        <plugin>
          <artifactId>maven-antrun-plugin</artifactId>
          <version>1.3</version>
        </plugin>
        <plugin>
          <artifactId>maven-assembly-plugin</artifactId>
          <version>2.2-beta-5</version>
        </plugin>
        <plugin>
          <artifactId>maven-dependency-plugin</artifactId>
          <version>2.1</version>
        </plugin>
        <plugin>
          <artifactId>maven-release-plugin</artifactId>
          <version>2.0</version>
        </plugin>
      </plugins>
    </pluginManagement>
    <plugins>
      <plugin>
        <artifactId>maven-clean-plugin</artifactId>
        <version>2.4.1</version>
        <executions>
          <execution>
            <id>default-clean</id>
            <phase>clean</phase>
            <goals>
              <goal>clean</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <artifactId>maven-install-plugin</artifactId>
        <version>2.3.1</version>
        <executions>
          <execution>
            <id>default-install</id>
            <phase>install</phase>
            <goals>
              <goal>install</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <artifactId>maven-resources-plugin</artifactId>
        <version>2.4.3</version>
        <executions>
          <execution>
            <id>default-resources</id>
            <phase>process-resources</phase>
            <goals>
              <goal>resources</goal>
            </goals>
          </execution>
          <execution>
            <id>default-testResources</id>
            <phase>process-test-resources</phase>
            <goals>
              <goal>testResources</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>2.7.1</version>
        <executions>
          <execution>
            <id>default-test</id>
            <phase>test</phase>
            <goals>
              <goal>test</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>2.3.2</version>
        <executions>
          <execution>
            <id>default-testCompile</id>
            <phase>test-compile</phase>
            <goals>
              <goal>testCompile</goal>
            </goals>
          </execution>
          <execution>
            <id>default-compile</id>
            <phase>compile</phase>
            <goals>
              <goal>compile</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <artifactId>maven-jar-plugin</artifactId>
        <version>2.3.1</version>
        <executions>
          <execution>
            <id>default-jar</id>
            <phase>package</phase>
            <goals>
              <goal>jar</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <artifactId>maven-deploy-plugin</artifactId>
        <version>2.5</version>
        <executions>
          <execution>
            <id>default-deploy</id>
            <phase>deploy</phase>
            <goals>
              <goal>deploy</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <artifactId>maven-site-plugin</artifactId>
        <version>2.0.1</version>
        <executions>
          <execution>
            <id>default-site</id>
            <phase>site</phase>
            <goals>
              <goal>site</goal>
            </goals>
            <configuration>
              <outputDirectory>/home/arno/.workspace/dialoguemaps-core/target/site</outputDirectory>
              <reportPlugins>
                <reportPlugin>
                  <groupId>org.apache.maven.plugins</groupId>
                  <artifactId>maven-project-info-reports-plugin</artifactId>
                </reportPlugin>
              </reportPlugins>
            </configuration>
          </execution>
          <execution>
            <id>default-deploy</id>
            <phase>site-deploy</phase>
            <goals>
              <goal>deploy</goal>
            </goals>
            <configuration>
              <outputDirectory>/home/arno/.workspace/dialoguemaps-core/target/site</outputDirectory>
              <reportPlugins>
                <reportPlugin>
                  <groupId>org.apache.maven.plugins</groupId>
                  <artifactId>maven-project-info-reports-plugin</artifactId>
                </reportPlugin>
              </reportPlugins>
            </configuration>
          </execution>
        </executions>
        <configuration>
          <outputDirectory>/home/arno/.workspace/dialoguemaps-core/target/site</outputDirectory>
          <reportPlugins>
            <reportPlugin>
              <groupId>org.apache.maven.plugins</groupId>
              <artifactId>maven-project-info-reports-plugin</artifactId>
            </reportPlugin>
          </reportPlugins>
        </configuration>
      </plugin>
    </plugins>
  </build>
  <reporting>
    <outputDirectory>/home/arno/.workspace/dialoguemaps-core/target/site</outputDirectory>
  </reporting>
</project>

pom.xml B。:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

    <!-- POM file generated with GWT webAppCreator -->
    <modelVersion>4.0.0</modelVersion>
    <groupId>org.dialoguemaps</groupId>
    <artifactId>dialoguemaps</artifactId>
    <packaging>war</packaging>
    <version>1.0-SNAPSHOT</version>
    <name>GWT Maven Archetype</name>

    <properties>
        <!-- Convenience property to set the GWT version -->
        <gwtVersion>2.4.0</gwtVersion>
        <!-- GWT needs at least java 1.5 -->
        <webappDirectory>${project.build.directory}/${project.build.finalName}</webappDirectory>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

    <dependencies>
        <dependency>
            <groupId>com.google.gwt</groupId>
            <artifactId>gwt-servlet</artifactId>
            <version>${gwtVersion}</version>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>com.google.gwt</groupId>
            <artifactId>gwt-user</artifactId>
            <version>${gwtVersion}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.7</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>javax.validation</groupId>
            <artifactId>validation-api</artifactId>
            <version>1.0.0.GA</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>javax.validation</groupId>
            <artifactId>validation-api</artifactId>
            <version>1.0.0.GA</version>
            <classifier>sources</classifier>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.smartgwt</groupId>
            <artifactId>smartgwt</artifactId>
            <version>3.0</version>
        </dependency>
        <dependency>
            <groupId>org.vectomatic</groupId>
            <artifactId>lib-gwt-svg</artifactId>
            <version>0.5.5</version>
        </dependency>
        <dependency>
            <groupId>org.javatuples</groupId>
            <artifactId>javatuples</artifactId>
            <version>1.2</version>
            <scope>runtime</scope>
        </dependency>
    </dependencies>

    <build>
        <!-- Generate compiled stuff in the folder used for developing mode -->
        <outputDirectory>${webappDirectory}/WEB-INF/classes</outputDirectory>

        <plugins>

            <!-- GWT Maven Plugin -->
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>gwt-maven-plugin</artifactId>
                <version>2.4.0</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>compile</goal>
                            <goal>test</goal>
                            <goal>i18n</goal>
                            <goal>generateAsync</goal>
                        </goals>
                    </execution>
                </executions>
                <!-- Plugin configuration. There are many available options, see gwt-maven-plugin 
                    documentation at codehaus.org -->
                <configuration>
                    <runTarget>dialoguemaps.html</runTarget>
                    <hostedWebapp>${webappDirectory}</hostedWebapp>
                    <i18nMessagesBundle>org.dialoguemaps.client.Messages</i18nMessagesBundle>
                </configuration>
            </plugin>

            <!-- Copy static web files before executing gwt:run -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.1.1</version>
                <executions>
                    <execution>
                        <phase>compile</phase>
                        <goals>
                            <goal>exploded</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <webappDirectory>${webappDirectory}</webappDirectory>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.3.2</version>
                <configuration>
                    <source>1.5</source>
                    <target>1.5</target>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <repositories>
        <repository>
            <id>smartclient</id>
            <name>smartclient.com</name>
            <url>http://www.smartclient.com/maven2</url>
        </repository>
    </repositories>


</project>

问题:

  • 这是一个maven依赖性问题吗?
  • 这是一个GWT问题,因为GWT无法编译类类型Tuple?
  • 您是否有解决方案或想法如何解决此问题?

此致 阿诺

2 个答案:

答案 0 :(得分:0)

项目如果您不想将其用于另一个GWT项目,则必须使用源代码提供jar。 在它的pom构建部分中添加它:

<resources>
  <resource>
    <directory>src/main/java</directory>
    <includes>
      <include>**/client/**</include>
      <include>**/*.gwt.xml</include>
    </includes>
  </resource>   
</resources>

将“client”包含模式调整到项目源路径并重建。一旦.java类可用于子项目,它就会编译。

答案 1 :(得分:0)

您不能在GWT客户端代码中使用或引用javatuples,因为该库使用无法编译为javascript代码的java功能。