502代理服务器错误:代理服务器收到来自上游服务器的无效响应

时间:2017-03-23 15:22:06

标签: java spring maven tomcat proxy

当我尝试部署到服务器时,我正试图让我的第一个Web应用程序工作并遇到一些问题。我做了一些研究,但我似乎无法找到解决方案如何适用于我。我的应用程序在我的本地tomcat服务器上运行正常,但是当我尝试部署到Elastic Beanstalk时,我得到了这个代理错误。以下是所有细节...

的pom.xml

<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/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>FirstSpringMVCProject</groupId>
  <artifactId>FirstSpringMVCProject</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>war</packaging>
  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>

  <build>
    <plugins>
      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.5.1</version>
        <configuration>
          <source>1.8</source>
          <target>1.8</target>
        </configuration>
      </plugin>
      <plugin>
        <artifactId>maven-war-plugin</artifactId>
        <version>3.0.0</version>
        <configuration>
          <warSourceDirectory>WebContent</warSourceDirectory>
        </configuration>
      </plugin>
    </plugins>
  </build>
  <dependencies>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context</artifactId>
        <version>4.3.7.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-core</artifactId>
        <version>4.3.7.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-web</artifactId>
        <version>4.3.7.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-webmvc</artifactId>
        <version>4.3.7.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>jstl</groupId>
        <artifactId>jstl</artifactId>
        <version>1.2</version>
    </dependency>
    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <version>5.1.41</version>
    </dependency>
  </dependencies>
</project>

的web.xml

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

    <display-name>Web projects</display-name>

    <servlet>
        <servlet-name>spring-dispatcher</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    </servlet>

    <welcome-file-list>
        <welcome-file>DisplayMatchup.jsp</welcome-file>
    </welcome-file-list>

    <servlet-mapping>
        <servlet-name>spring-dispatcher</servlet-name>
        <url-pattern>/</url-pattern>
    </servlet-mapping>

</web-app>

弹簧调度-servlet.xml中

<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:mvc="http://www.springframework.org/schema/mvc"
    xsi:schemaLocation="
        http://www.springframework.org/schema/beans     
        http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/context 
        http://www.springframework.org/schema/context/spring-context.xsd
        http://www.springframework.org/schema/mvc
        http://www.springframework.org/schema/mvc/spring-mvc.xsd">


  <context:component-scan base-package="com.gontuseries.hellocontroller" />
 <mvc:annotation-driven/>

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

DisplayMatchup.jsp(view)

<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<style>
ol {
    padding: 12px;
    background-color: #eee;
    display: inline-block;
    list-style-type: none;
    text-align: center;
}
body {
    font-family: Courier;
    text-align: center;
}
button {
    background-color: #4CAF50; /* Green */
    border: none;
    color: white;
    padding: 12px 25px;
    text-align: center;
    font-size: 18px;
    font-family: Courier;
    white-space: normal;
}
</style>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Basketball Player Rater</title>
</head>
<h2>Basketball Player Rater</h2>
<body>
<sql:setDataSource var="snapshot" driver="com.mysql.jdbc.Driver"
     url="jdbc:mysql://results.cae10gzzpyrn.us-west-2.rds.amazonaws.com:3306/results"
     user="yogidmt"  password="bearbpa10"/>
<sql:query dataSource="${snapshot}" var="result">
SELECT * FROM records ORDER BY wins DESC;
</sql:query>
<ol>
<h2>Team 1</h2>
<form:form method="post" action="http://localhost/FirstSpringMVCProject/" modelAttribute="team">
<button type="submit" name="team" value="${matchup.teams[0]}${matchup.teams[1]}"/>${matchup.teams[0]}</button>
</form:form>
</ol>
<ol>
<h2>Team 2</h2>
<form:form method="post" action="http://localhost/FirstSpringMVCProject/" modelAttribute="team">
<button type="submit" name="team" value="${matchup.teams[1]}${matchup.teams[0]}"/>${matchup.teams[1]}</button>
</form:form>
</ol>
<h3>Results:</h3>
<c:forEach var="row" items="${result.rows}">
<c:out value="${row.player}"/> --- <c:out value="${row.winrate}"/>
</br>
</c:forEach>
</body>
</html>

HelloController.java(控制器

package com.gontuseries.hellocontroller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

@Controller
public class HelloController {

    @RequestMapping(value = "/", method = RequestMethod.GET)
    public ModelAndView display() {     

        ModelAndView model = new ModelAndView("DisplayMatchup");
        model.addObject("matchup", new Matchup());

        return model;
    }

    @RequestMapping(value = "/", method = RequestMethod.POST)
    public ModelAndView update(@ModelAttribute("team") String s) {
        Util.updateParse(s);
        ModelAndView model = new ModelAndView("DisplayMatchup");
        model.addObject("matchup", new Matchup());

        return model;
    }
}

我认为其余的我的Java是无关紧要的,在本地工作正常我得到的唯一错误是

INFO: Illegal access: this web application instance has been stopped already.  Could not load .  The eventual following stack trace is caused by an error thrown for debugging purposes as well as to attempt to terminate the thread which caused the illegal access, and has no functional impact.
Mar 23, 2017 10:27:21 AM org.apache.catalina.loader.WebappClassLoader findResourceInternal

但该应用似乎仍能正常运作。

这是我尝试访问应用时获得的全部内容

Proxy Error

The proxy server received an invalid response from an upstream server.
The proxy server could not handle the request GET /.

Reason: Error reading from remote server

另外server logs(最后100行)

0 个答案:

没有答案