生成服务时出现错误请求错误

时间:2014-03-01 20:11:20

标签: java google-app-engine rest maven

我正在使用Google端点构建REST API。当我使用maven构建时,我收到以下错误。

Google App Engine Java SDK - get endpoints discovery doc...
Using Class Name:se.deverything.webapi.endpoints.BloodPressureReadingEndpoint
Using Class Name:se.deverything.webapi.endpoints.EventEndpoint
Executing endpoints Command=[get-discovery-doc, -cp, C:\Git\monium\webapi\webapi-war\target\webapi-war-0-snapshot\WEB-INF\classes;C:\Git\monium\webapi\webapi-war\target/classes;C:\Git\monium\webapi\services\target\services-0-snapshot.jar;C:\Git\monium\webapi\model\target\model-0-snapshot.jar;C:\Users\Marthin\.m2\repository\jstl\jstl\1.2\jstl-1.2.jar;C:\Users\Marthin\.m2\repository\com\google\appengine\appengine-endpoints\1.8.7\appengine-endpoints-1.8.7.jar;C:\Users\Marthin\.m2\repository\javax\jdo\jdo-api\3.0.1\jdo-api-3.0.1.jar;C:\Users\Marthin\.m2\repository\javax\transaction\jta\1.1\jta-1.1.jar;C:\Users\Marthin\.m2\repository\org\eclipse\persistence\javax.persistence\2.1.0\javax.persistence-2.1.0.jar;C:\Users\Marthin\.m2\repository\org\datanucleus\datanucleus-core\3.2.12\datanucleus-core-3.2.12.jar;C:\Users\Marthin\.m2\repository\org\datanucleus\datanucleus-api-jpa\3.3.7\datanucleus-api-jpa-3.3.7.jar;C:\Users\Marthin\.m2\repository\org\datanucleus\datanucleus-rdbms\3.2.11\datanucleus-rdbms-3.2.11.jar;C:\Users\Marthin\.m2\repository\org\datanucleus\datanucleus-api-jdo\3.1.3\datanucleus-api-jdo-3.1.3.jar;C:\Users\Marthin\.m2\repository\com\google\appengine\appengine-api-1.0-sdk\1.8.7\appengine-api-1.0-sdk-1.8.7.jar, -o, C:\Git\monium\webapi\webapi-war\target/generated-sources/appengine-endpoints/WEB-INF, -w, C:\Git\monium\webapi\webapi-war\target/generated-sources/appengine-endpoints, -f, rest, se.deverything.webapi.endpoints.BloodPressureReadingEndpoint, se.deverything.webapi.endpoints.EventEndpoint]
mar 01, 2014 9:05:28 EM com.google.apphosting.utils.config.AppEngineWebXmlReader readAppEngineWebXml
INFO: Successfully processed C:\Git\monium\webapi\webapi-war\target/generated-sources/appengine-endpoints\WEB-INF/appengine-web.xml
Error: 400 Bad Request
{
 "error": {
  "errors": [
   {
    "domain": "global",
    "reason": "invalid",
    "message": "Invalid Value"
   }
  ],
  "code": 400,
  "message": "Invalid Value"
 }
}

Using Class Name:se.deverything.webapi.endpoints.BloodPressureReadingEndpoint
Using Class Name:se.deverything.webapi.endpoints.EventEndpoint
Executing endpoints Command=[get-discovery-doc, -cp, C:\Git\monium\webapi\webapi-war\target\webapi-war-0-snapshot\WEB-INF\classes;C:\Git\monium\webapi\webapi-war\target/classes;C:\Git\monium\webapi\services\target\services-0-snapshot.jar;C:\Git\monium\webapi\model\target\model-0-snapshot.jar;C:\Users\Marthin\.m2\repository\jstl\jstl\1.2\jstl-1.2.jar;C:\Users\Marthin\.m2\repository\com\google\appengine\appengine-endpoints\1.8.7\appengine-endpoints-1.8.7.jar;C:\Users\Marthin\.m2\repository\javax\jdo\jdo-api\3.0.1\jdo-api-3.0.1.jar;C:\Users\Marthin\.m2\repository\javax\transaction\jta\1.1\jta-1.1.jar;C:\Users\Marthin\.m2\repository\org\eclipse\persistence\javax.persistence\2.1.0\javax.persistence-2.1.0.jar;C:\Users\Marthin\.m2\repository\org\datanucleus\datanucleus-core\3.2.12\datanucleus-core-3.2.12.jar;C:\Users\Marthin\.m2\repository\org\datanucleus\datanucleus-api-jpa\3.3.7\datanucleus-api-jpa-3.3.7.jar;C:\Users\Marthin\.m2\repository\org\datanucleus\datanucleus-rdbms\3.2.11\datanucleus-rdbms-3.2.11.jar;C:\Users\Marthin\.m2\repository\org\datanucleus\datanucleus-api-jdo\3.1.3\datanucleus-api-jdo-3.1.3.jar;C:\Users\Marthin\.m2\repository\com\google\appengine\appengine-api-1.0-sdk\1.8.7\appengine-api-1.0-sdk-1.8.7.jar, -o, C:\Git\monium\webapi\webapi-war\target/generated-sources/appengine-endpoints/WEB-INF, -w, C:\Git\monium\webapi\webapi-war\target/generated-sources/appengine-endpoints, -f, rpc, se.deverything.webapi.endpoints.BloodPressureReadingEndpoint, se.deverything.webapi.endpoints.EventEndpoint]
mar 01, 2014 9:05:29 EM com.google.apphosting.utils.config.AppEngineWebXmlReader readAppEngineWebXml
INFO: Successfully processed C:\Git\monium\webapi\webapi-war\target/generated-sources/appengine-endpoints\WEB-INF/appengine-web.xml
Error: 400 Bad Request
{
 "error": {
  "errors": [
   {
    "domain": "global",
    "reason": "invalid",
    "message": "Invalid Value"
   }
  ],
  "code": 400,
  "message": "Invalid Value"
 }
}

Endpoints discovery doc generation done.

POM.xml(构建部分)

   <build>
        <outputDirectory>target/${project.artifactId}-${project.version}/WEB-INF/classes</outputDirectory> 

        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.3</version>
                <configuration>
                    <webXml>${project.build.directory}/generated-sources/appengine-endpoints/WEB-INF/web.xml</webXml>
                    <archiveClasses>true</archiveClasses>
                    <webResources>
                        <resource>
                            <directory>${basedir}/src/main/webapp/WEB-INF</directory>
                            <filtering>true</filtering>
                            <targetPath>WEB-INF</targetPath>
                            <excludes>
                                <exclude>web.xml</exclude>
                            </excludes>
                        </resource>
                        <resource>
                            <directory>${project.build.directory}/generated-sources/appengine-endpoints</directory>
                            <includes>
                                <include>WEB-INF/*.discovery</include>
                                <include>WEB-INF/*.api</include>
                            </includes>
                        </resource>
                    </webResources>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.3.2</version>
                <configuration>
                    <source>1.7</source>
                    <target>1.7</target>
                </configuration>
            </plugin>

            <plugin>
                <groupId>com.google.appengine</groupId>
                <artifactId>appengine-maven-plugin</artifactId>
                <version>${appengine.target.version}</version>
                <configuration>
                    <enableJarClasses>false</enableJarClasses>
                    <oauth2>false</oauth2>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>endpoints_get_discovery_doc</goal>
                        </goals>
                    </execution>                 
                </executions>
            </plugin>
        </plugins>
    </build>

任何人都知道这是为什么?

2 个答案:

答案 0 :(得分:1)

我们遇到了同样的问题。我们解决了从@ApiMethod名称参数中删除下划线的问题。

答案 1 :(得分:0)

我的错误的解决方案是更改api annotion上的版本。

我有这个

@Api(name="event", version="v1-0")

并更改为此

@Api(name="event", version="v1")

因此,我没有遵循的版本有一些命名约定。如果有人知道确切的约定并且有链接,请分享评论。