Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/google-app-engine/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 在appspot中部署应用程序后出错_Java_Google App Engine - Fatal编程技术网

Java 在appspot中部署应用程序后出错

Java 在appspot中部署应用程序后出错,java,google-app-engine,Java,Google App Engine,尝试在appspot中访问Java应用程序时,我在浏览器中遇到以下错误 Error: NOT_FOUND 但是,当我从Eclipse或ant运行时,它工作得很好。我已经检查了GAE管理控制台中的日志,但找不到任何错误消息 我还尝试在构建之前删除所有*.class文件 应用程序使用appengine-java-sdk-1.5.3中提供的appcfg脚本进行部署。这种行为有什么具体原因吗 以下是来自GAE日志控制台的调试消息: 2011-10-02 22:11:39.306 / 302 14950

尝试在appspot中访问Java应用程序时,我在浏览器中遇到以下错误

Error: NOT_FOUND
但是,当我从Eclipse或ant运行时,它工作得很好。我已经检查了GAE管理控制台中的日志,但找不到任何错误消息

我还尝试在构建之前删除所有*.class文件

应用程序使用appengine-java-sdk-1.5.3中提供的appcfg脚本进行部署。这种行为有什么具体原因吗

以下是来自GAE日志控制台的调试消息:

2011-10-02 22:11:39.306 / 302 14950ms 10348cpu_ms 315api_cpu_ms 0kb Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/14.0.835.186 Safari/535.1
115.119.214.18 - - [02/Oct/2011:22:11:39 -0700] "GET / HTTP/1.1" 302 191 - "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/14.0.835.186 Safari/535.1" "xxxxxxxx-test.appspot.com" ms=14950 cpu_ms=10348 api_cpu_ms=315 cpm_usd=0.287514 loading_request=1 throttle_code=1 instance=00c61b117c46324075b13d0c2ce04f5678c813
I 2011-10-02 22:11:26.447
javax.servlet.ServletContext log: Initializing Spring root WebApplicationContext
W 2011-10-02 22:11:26.728
[s~xxxxxxxx-test/8.353561328003056299].<stderr>: log4j:WARN No appenders could be found for logger (org.springframework.web.context.ContextLoader).

W 2011-10-02 22:11:26.728
[s~xxxxxxxx-test/8.353561328003056299].<stderr>: log4j:WARN Please initialize the log4j system properly.

I 2011-10-02 22:11:37.075
javax.servlet.ServletContext log: Initializing Spring FrameworkServlet 'dispatcher'
I 2011-10-02 22:11:39.306
This request caused a new process to be started for your application, and thus caused your application code to be loaded for the first time. This request may thus take longer and use more CPU than a typical request for your application.
2011-10-02 22:11:39.306/302 14950ms 10348cpu_ms 315api_cpu_ms 0kb Mozilla/5.0(X11;Linux x86_64)AppleWebKit/535.1(KHTML,类似Gecko)Chrome/14.0.835.186 Safari/535.1
115.119.214.18--[02/Oct/2011:22:11:39-0700]“GET/HTTP/1.1”302 191-“Mozilla/5.0(X11;Linux x86_64)AppleWebKit/535.1(KHTML,像Gecko)Chrome/14.0.835.186 Safari/535.1”“xxxxxxxxxxxxx-test.appspot.com”ms=14950 cpu_ms=10348 api_cpu_-ms=315 cpm_usd=0.28751BU=0.28751BU加载请求=1油门代码=1实例=638c408c408c674;
I 2011-10-02 22:11:26.447
javax.servlet.ServletContext日志:初始化Spring根WebApplicationContext
W 2011-10-02 22:11:26.728
[s~xxxxxxxx-test/8.353561328003056299]:log4j:WARN找不到记录器(org.springframework.web.context.ContextLoader)的任何附加程序。
W 2011-10-02 22:11:26.728
[s~xxxxxxxx-test/8.353561328003056299]:log4j:WARN请正确初始化log4j系统。
I 2011-10-02 22:11:37.075
javax.servlet.ServletContext日志:初始化Spring FrameworkServlet“dispatcher”
I 2011-10-02 22:11:39.306
此请求导致为应用程序启动一个新进程,从而导致首次加载应用程序代码。因此,与应用程序的典型请求相比,此请求可能需要更长的时间并使用更多的CPU。
web.xml:

<?xml version="1.0" encoding="utf-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
        xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
        version="2.5">

<filter>
                <filter-name>springSecurityFilterChain</filter-name>
                <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
        </filter>

        <filter-mapping>
                <filter-name>springSecurityFilterChain</filter-name>
                <url-pattern>/*</url-pattern>
        </filter-mapping>

        <context-param>
                <param-name>contextConfigLocation</param-name>
                <param-value>/WEB-INF/spring/*.xml</param-value>
        </context-param>
        <listener>
                <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
        </listener>
        <servlet>
                <servlet-name>dispatcher</servlet-name>
                <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
                <init-param>
                        <param-name>contextConfigLocation</param-name>
                        <param-value>/WEB-INF/spring/servlet-config.xml</param-value>
                </init-param>
                <load-on-startup>1</load-on-startup>
        </servlet>
        <servlet-mapping>
                <servlet-name>dispatcher</servlet-name>
                <url-pattern>/ExampleApp/*</url-pattern>
        </servlet-mapping>
        <welcome-file-list>
                <welcome-file>index.jsp</welcome-file>
        </welcome-file-list>
</web-app>

springSecurityFilterChain
org.springframework.web.filter.DelegatingFilterProxy
springSecurityFilterChain
/*
上下文配置位置
/WEB-INF/spring/*.xml
org.springframework.web.context.ContextLoaderListener
调度员
org.springframework.web.servlet.DispatcherServlet
上下文配置位置
/WEB-INF/spring/servlet-config.xml
1.
调度员
/示例应用程序/*
index.jsp
index.jsp(欢迎文件)的内容


以下是build.xml文件:

<project>
    <property name="sdk.dir" location="../appengine-java-sdk-1.5.3" />
    <import file="${sdk.dir}/config/user/ant-macros.xml" />

    <path id="project.classpath">
        <pathelement path="war/WEB-INF/classes" />
        <fileset dir="war/WEB-INF/lib">
            <include name="**/*.jar" />
        </fileset>
        <fileset dir="${sdk.dir}/lib">
            <include name="shared/**/*.jar" />
        </fileset>
    </path>
<!--
    <target name="copyjars" description="Copies the App Engine JARs to the WAR.">
        <copy todir="war/WEB-INF/lib" flatten="true">
        <fileset dir="${sdk.dir}/lib/user">
            <include name="**/*.jar" />
        </fileset>
        </copy>
    </target>
-->
    <target name="compile" description="Compiles Java source and copies other source files to the WAR.">
        <mkdir dir="war/WEB-INF/classes" />
        <copy todir="war/WEB-INF/classes">
            <fileset dir="src">
            <exclude name="**/*.java" />
            </fileset>
        </copy>
        <javac srcdir="src" destdir="war/WEB-INF/classes" classpathref="project.classpath" debug="on" />
    </target>

    <target name="datanucleusenhance" depends="compile" description="Performs JDO enhancement on compiled data classes.">
        <enhance_war war="war" />
    </target>

    <target name="runserver" depends="datanucleusenhance" description="Starts the development server.">
        <dev_appserver war="war" />
    </target>

    <target name="update" depends="datanucleusenhance" description="Uploads the application to App Engine.">
        <appcfg action="update" war="war" />
    </target>

    <target name="update_indexes" depends="datanucleusenhance" description="Uploads just the datastore index configuration to App Engine.">
        <appcfg action="update_indexes" war="war" />
    </target>

    <target name="rollback" depends="datanucleusenhance" description="Rolls back an interrupted application update.">
        <appcfg action="rollback" war="war" />
    </target>

    <target name="request_logs" description="Downloads log data from App Engine for the application.">
        <appcfg action="request_logs" war="war">
        <options>
            <arg value="--num_days=5"/>
        </options>
        <args>
            <arg value="logs.txt"/>
        </args>
        </appcfg>
    </target>
</project>

经过几天的测试和实验,我在appspot.com上找到了问题的解决方案。JSP配置有一个问题,其中前缀有一个额外的斜杠

旧配置:

<bean
     class="org.springframework.web.servlet.view.InternalResourceViewResolver">
                <property name="order" value="2" />
                <property name="prefix" value="/WEB-INF/views/" />
                <property name="suffix" value=".jsp" />
</bean>
<bean
     class="org.springframework.web.servlet.view.InternalResourceViewResolver">
                <property name="order" value="2" />
                <property name="prefix" value="/WEB-INF/views" />
                <property name="suffix" value=".jsp" />
</bean>

新配置:

<bean
     class="org.springframework.web.servlet.view.InternalResourceViewResolver">
                <property name="order" value="2" />
                <property name="prefix" value="/WEB-INF/views/" />
                <property name="suffix" value=".jsp" />
</bean>
<bean
     class="org.springframework.web.servlet.view.InternalResourceViewResolver">
                <property name="order" value="2" />
                <property name="prefix" value="/WEB-INF/views" />
                <property name="suffix" value=".jsp" />
</bean>

在控制器中,返回路径是“/Login/LoginPage.jsp”。(由于返回jsp文件位置的控制器方法太多,所以xml文件中没有更改)

在启用log4j记录调试问题之前,我无法跟踪问题。识别问题的关键是日志中的以下行:

2011-10-10 21:38:14.644
[s~exampleapp-test/8.353868453989422042].<stdout>: 16:08:14,644 DEBUG [org.springframework.web.servlet.view.JstlView] - Forwarding to resource [/WEB-INF/views//Login/LoginPage.jsp] in InternalResourceView '/Login/LoginPage'
2011-10-1021:38:14.644
[s~exampleapp test/8.353868453989422042]:16:08:14644调试[org.springframework.web.servlet.view.JstlView]-转发到InternalResourceView'/Login/LoginPage'中的资源[/web-INF/views//Login/LoginPage.jsp]

感谢@Dave的耐心和指导。

我想当你尝试应用程序的URL时,你会在浏览器中看到这一点。你看到的就这些吗?是否存在任何类型的堆栈跟踪?是的,未找到是我在浏览器中看到的唯一错误消息。我已经从GAE日志控制台添加了调试消息。应用程序在Eclipse和ant中运行时没有任何问题。我很确定这个错误不是AppEngine的错误之一。您的
war
文件夹中是否可能没有Spring的一些配置位?也许您是对的,但我想知道它如何与Eclipse一起工作。如果配置中存在问题,那么它也不应该与Eclipse一起工作。Eclipse可以看到的内容可能与部署的内容不匹配。发生这种情况的原因有几个:Eclipse可能有一个更宽的类路径,一些应该是资源的东西意外地被放入
静态文件中,一些应该安装的东西意外地被包含在
排除中。