gpt4 book ai didi

java - 可扩展的java web APP openshift - 503错误HAProxy

转载 作者:太空宇宙 更新时间:2023-11-04 14:30:42 24 4
gpt4 key购买 nike

我开始创建一个新的可扩展 Java Web 应用程序,但无法正常工作,因为我收到错误“503 服务不可用 没有服务器可以处理此请求”。我正在使用 RESTful 服务

我的代码是:

测试类

@Path("/test")

public class TestClass {

@GET
public String getName() {
return "John";
}
}

web.xml

<web-app 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"
metadata-complete="false">

<!-- Auto scan REST service -->
<context-param>
<param-name>resteasy.scan</param-name>
<param-value>true</param-value>
</context-param>

<listener>
<listener-class>
org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap
</listener-class>
</listener>

<servlet>
<servlet-name>resteasy-servlet</servlet-name>
<servlet-class>
org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher
</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>resteasy-servlet</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
</web-app>

pom

 <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>
<groupId>myApp</groupId>
<artifactId>myApp</artifactId>
<packaging>war</packaging>
<version>1.0</version>
<name>myApp</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.6</maven.compiler.source>
<maven.compiler.target>1.6</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>org.jboss.spec</groupId>
<artifactId>jboss-javaee-6.0</artifactId>
<version>1.0.0.Final</version>
<type>pom</type>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-jaxrs</artifactId>
<version>2.3.1.GA</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-jackson-provider</artifactId>
<version>2.3.1.GA</version>
<scope>provided</scope>
</dependency>
</dependencies>
<profiles>
<profile>
<!-- When built in OpenShift the 'openshift' profile will be used when
invoking mvn. -->
<!-- Use this profile for any OpenShift specific customization your app
will need. -->
<!-- By default that is to put the resulting archive into the 'deployments'
folder. -->
<!-- http://maven.apache.org/guides/mini/guide-building-for-different-environments.html -->
<id>openshift</id>
<build>
<finalName>myApp</finalName>
<plugins>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.1.1</version>
<configuration>
<outputDirectory>deployments</outputDirectory>
<warName>myApp</warName>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>

在我的 Haproxy.cfg 中,我有此行选项 httpchk GET/myApp有人可以帮忙吗?

最佳答案

如果您的应用程序中没有任何内容监听根上下文 (/),那么 haproxy 会将您的应用程序视为已关闭。您要么需要在根上下文上进行监听,要么更改监控选项以指向在轮询时返回 200(成功)的 url。

您是否将 httpchk GET/更改为 httpchk GET/myApp?

即使您将应用程序更改为部署在/myApp,您仍然需要在该 url 上提供 200 成功的东西。

关于java - 可扩展的java web APP openshift - 503错误HAProxy,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26194321/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com