在intellij中运行GWT时出错

时间:2014-06-19 16:02:38

标签: maven tomcat gwt intellij-idea

我正在尝试在Tomcat服务器上运行GWT,我的构建框架是Maven。但是我一直收到以下错误

 java: Unable to find RequestFactory built-in type. Is requestfactory-[client|server].jar on the classpath?

知道为什么会这样吗?

由于

1 个答案:

答案 0 :(得分:0)

读取此错误,似乎缺少lib。检查请求工厂服务器是否在您的pom.xml中,以及您的配置是否正常。

我也在使用maven和GWT-requestfactory。以下是我的maven配置示例:

<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">
    <modelVersion>4.0.0</modelVersion>
    <parent>
<!-- -->
    </parent>
    <artifactId>docentryeditor</artifactId>
    <packaging>war</packaging>

    <name>doc-entry-editor</name>

    <properties>
        <!-- Convenience property to set the GWT version -->
        <gwtVersion>2.5.1</gwtVersion>
        <webappDirectory>${project.build.directory}/${project.build.finalName}</webappDirectory>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    </properties>

    <url>http://maven.apache.org</url>
    <repositories>
        <repository>
            <id>gwt-maven</id>
            <url>http://gwt-maven.googlecode.com/svn/trunk/mavenrepo/</url>
        </repository>
    </repositories>


    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>com.google.gwt</groupId>
            <artifactId>gwt-servlet</artifactId>
            <version>${gwtVersion}</version>
        </dependency>
        <dependency>
            <groupId>com.google.gwt</groupId>
            <artifactId>gwt-dev</artifactId>
            <version>${gwtVersion}</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>com.google.gwt</groupId>
            <artifactId>gwt-user</artifactId>
            <version>${gwtVersion}</version>
            <scope>provided</scope>
            <exclusions>
                <exclusion>
                    <groupId>javax.validation</groupId>
                    <artifactId>validation-api</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>com.google.web.bindery</groupId>
            <artifactId>requestfactory-server</artifactId>
            <version>${gwtVersion}</version>
        </dependency>
        <dependency>
            <groupId>com.google.web.bindery</groupId>
            <artifactId>requestfactory-apt</artifactId>
            <version>${gwtVersion}</version>
        </dependency>
        <dependency>
            <groupId>aopalliance</groupId>
            <artifactId>aopalliance</artifactId>
            <version>1.0</version>
        </dependency>
        <dependency>
            <groupId>com.google.gwt.inject</groupId>
            <artifactId>gin</artifactId>
            <version>1.5.0</version>
        </dependency>
        <dependency>
            <groupId>com.google.inject</groupId>
            <artifactId>guice</artifactId>
            <version>3.0</version>
        </dependency>
        <dependency>
            <groupId>com.google.inject.extensions</groupId>
            <artifactId>guice-servlet</artifactId>
            <version>3.0</version>
        </dependency>
        <dependency>
            <groupId>com.google.inject.extensions</groupId>
            <artifactId>guice-assistedinject</artifactId>
            <version>3.0</version>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-validator</artifactId>
            <version>4.1.0.Final</version>
        </dependency>
        <dependency>
            <groupId>javax.validation</groupId>
            <artifactId>validation-api</artifactId>
            <version>1.0.0.GA</version>
        </dependency>
        <dependency>
            <groupId>javax.validation</groupId>
            <artifactId>validation-api</artifactId>
            <version>1.0.0.GA</version>
            <classifier>sources</classifier>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>1.7.7</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
            <version>1.7.7</version>
        </dependency>
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.17</version>
        </dependency>

    </dependencies>
    <build>
        <finalName>docentryeditor</finalName>
        <outputDirectory>${webappDirectory}/WEB-INF/classes</outputDirectory>
        <!-- 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>${gwtVersion}</version>
                <dependencies>
                    <dependency>
                        <groupId>com.google.gwt</groupId>
                        <artifactId>gwt-user</artifactId>
                        <version>${gwtVersion}</version>
                    </dependency>
                    <dependency>
                        <groupId>com.google.gwt</groupId>
                        <artifactId>gwt-dev</artifactId>
                        <version>${gwtVersion}</version>
                    </dependency>
                    <dependency>
                        <groupId>com.google.gwt</groupId>
                        <artifactId>gwt-servlet</artifactId>
                        <version>${gwtVersion}</version>
                    </dependency>
                </dependencies>
                <!-- JS is only needed in the package phase, this speeds up testing -->
                <executions>
                    <execution>
                        <phase>prepare-package</phase>
                        <goals>
                            <goal>compile</goal>
                        </goals>
                    </execution>
                </executions>
                <!-- Plugin configuration. There are many available options,
                     see gwt-maven-plugin documentation at codehaus.org -->
                <configuration>
                    <!-- URL that should be automatically opened in the GWT shell (gwt:run). -->
                    <runTarget>XDS-MetadataEditor.html</runTarget>
                    <!-- Ask GWT to create the Story of Your Compile (SOYC) (gwt:compile) -->
                    <compileReport>true</compileReport>
                    <module>edu.tn.xds.metadata.editor</module>
                    <hostedWebapp>${webappDirectory}</hostedWebapp><!--makes file download work in dev mode-->
                    <logLevel>INFO</logLevel>
                    <style>${gwtVersion}</style>

                    <copyWebapp>true</copyWebapp>
                </configuration>
            </plugin>

            <!-- Maven WAR plugin -->
            <plugin>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.4</version>
                <configuration>
                    <!-- configured to be the same as for the gwt plugin -->
                    <webappDirectory>${webappDirectory}</webappDirectory>
                </configuration>
                <executions>
                    <execution>
                        <phase>compile</phase>
                        <goals>
                            <!-- create an exploded version of the war in webappDirectory. Ideal
                                for development -->
                            <goal>exploded</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <!-- Copy static web files before executing gwt:run -->
            <plugin>
                <artifactId>maven-resources-plugin</artifactId>
                <version>2.4.2</version>
                <executions>
                    <execution>
                        <phase>compile</phase>
                        <goals>
                            <goal>copy-resources</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${webappDirectory}/WEB-INF/</outputDirectory>
                            <resources>
                                <resource>
                                    <directory>src/main/webapp</directory>
                                </resource>
                            </resources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <!-- RequestFactory Validation jar -->
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.5.1</version>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                    <annotationProcessors>
                        <annotationProcessor>com.google.web.bindery.requestfactory.apt.RfValidator</annotationProcessor>
                    </annotationProcessors>
                </configuration>
                <dependencies>
                    <dependency>
                        <groupId>com.google.web.bindery</groupId>
                        <artifactId>requestfactory-apt</artifactId>
                        <version>${gwtVersion}</version>
                    </dependency>
                </dependencies>
            </plugin>
        </plugins>
            <!--This plugin's configuration is used to store Eclipse m2e settings
                                only. It has no influence on the Maven build itself. -->


        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.eclipse.m2e</groupId>
                    <artifactId>lifecycle-mapping</artifactId>
                    <version>1.0.0</version>
                    <configuration>
                        <lifecycleMappingMetadata>
                            <pluginExecutions>
                                <pluginExecution>
                                    <pluginExecutionFilter>
                                        <groupId>org.codehaus.mojo</groupId>
                                        <artifactId>
                                            gwt-maven-plugin
                                        </artifactId>
                                        <versionRange>
                                            [2.5.1,)
                                        </versionRange>
                                        <goals>
                                            <goal>i18n</goal>
                                        </goals>
                                    </pluginExecutionFilter>
                                </pluginExecution>
                            </pluginExecutions>
                        </lifecycleMappingMetadata>
                    </configuration>
                </plugin>
            </plugins>
        </pluginManagement>

    </build>
</project>

如果您有任何疑问,或者有什么事情您不明白,请不要犹豫。 否则,如果你真的没有设法做到这一点,给我你的maven配置,我会看看它,并试着告诉你有什么问题。

请注意我的配置没有tomcat配置,因为我不需要它,但我真的不认为这可能是你的问题。