如何将 .war 文件部署到 AWS EC2 实例中的 jboss 服务器 运行?
How to deploy a .war file into jboss server running in AWS EC2 instance?
我在 AWS-EC2 上创建了一个 JBoss EAP 实例(遵循 this 指南),现在我正在尝试将一个简单的 hello-world 应用程序部署到其中。
我已经将 .war 文件复制到 /opt/rh/eap7/root/usr/share/wildfly/standalone/deployments 文件夹中,然后我 运行 standalone.sh 在 /opt/rh/eap7/root/usr/share/wildfly/bin 文件夹中,然后得到这个日志:
=========================================================================
JBoss Bootstrap Environment
JBOSS_HOME: /opt/rh/eap7/root/usr/share/wildfly
JAVA: java
JAVA_OPTS: -server -verbose:gc -Xloggc:/opt/rh/eap7/root/usr/share/wildfly/standalone/log/gc.log -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=5 -XX:GCLogFileSize=3M -XX:-TraceClassUnloading -Xms1303m -Xmx1303m -XX:MetaspaceSize=96M -XX:MaxMetaspaceSize=256m -Djava.net.preferIPv4Stack=true -Djboss.modules.system.pkgs=org.jboss.byteman -Djava.awt.headless=true
=========================================================================
15:11:14,196 INFO [org.jboss.modules] (main) JBoss Modules version 1.8.6.Final-redhat-00001
15:11:14,830 INFO [org.jboss.msc] (main) JBoss MSC version 1.4.5.Final-redhat-00001
15:11:14,854 INFO [org.jboss.threads] (main) JBoss Threads version 2.3.2.Final-redhat-1
15:11:15,170 INFO [org.jboss.as] (MSC service thread 1-2) WFLYSRV0049: JBoss EAP 7.2.0.GA (WildFly Core 6.0.11.Final-redhat-00001) starting
15:11:17,070 INFO [org.wildfly.security] (ServerService Thread Pool -- 20) ELY00001: WildFly Elytron version 1.6.1.Final-redhat-00001
15:11:18,572 INFO [org.jboss.as.controller.management-deprecated] (Controller Boot Thread) WFLYCTL0028: Attribute 'security-realm' in the resource at address '/core-service=management/management-interface=http-interface' is deprecated, and may be removed in a future version. See the attribute description in the output of the read-resource-description operation to learn more about the deprecation.
15:11:18,692 INFO [org.jboss.as.controller.management-deprecated] (ServerService Thread Pool -- 34) WFLYCTL0028: Attribute 'security-realm' in the resource at address '/subsystem=undertow/server=default-server/https-listener=https' is deprecated, and may be removed in a future version. See the attribute description in the output of the read-resource-description operation to learn more about the deprecation.
15:11:18,852 INFO [org.jboss.as.server] (Controller Boot Thread) WFLYSRV0039: Creating http management service using socket-binding (management-http)
15:11:18,905 INFO [org.xnio] (MSC service thread 1-2) XNIO version 3.6.5.Final-redhat-00001
15:11:18,930 INFO [org.xnio.nio] (MSC service thread 1-2) XNIO NIO Implementation Version 3.6.5.Final-redhat-00001
15:11:19,070 INFO [org.jboss.as.connector.subsystems.datasources] (ServerService Thread Pool -- 41) WFLYJCA0004: Deploying JDBC-compliant driver class org.h2.Driver (version 1.4)
15:11:19,126 INFO [org.jboss.as.naming] (ServerService Thread Pool -- 60) WFLYNAM0001: Activating Naming Subsystem
15:11:19,114 INFO [org.wildfly.extension.microprofile.config.smallrye._private] (ServerService Thread Pool -- 57) WFLYCONF0001: Activating WildFly MicroProfile Config Subsystem
15:11:19,123 WARN [org.jboss.as.txn] (ServerService Thread Pool -- 68) WFLYTX0013: The node-identifier attribute on the /subsystem=transactions is set to the default value. This is a danger for environments running multiple servers. Please make sure the attribute value is unique.
15:11:19,177 INFO [org.wildfly.extension.microprofile.opentracing] (ServerService Thread Pool -- 59) WFLYTRACEXT0001: Activating MicroProfile OpenTracing Subsystem
15:11:19,201 INFO [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 48) WFLYCLINF0001: Activating Infinispan subsystem.
15:11:19,218 INFO [org.jboss.as.webservices] (ServerService Thread Pool -- 70) WFLYWS0002: Activating WebServices Extension
15:11:19,225 INFO [org.wildfly.extension.io] (ServerService Thread Pool -- 49) WFLYIO001: Worker 'default' has auto-configured to 2 core threads with 16 task threads based on your 1 available processors
15:11:19,209 INFO [org.jboss.as.security] (ServerService Thread Pool -- 66) WFLYSEC0002: Activating Security Subsystem
15:11:19,263 INFO [org.wildfly.extension.microprofile.health.smallrye] (ServerService Thread Pool -- 58) WFLYHEALTH0001: Activating Eclipse MicroProfile Health Subsystem
15:11:19,243 INFO [org.jboss.as.jsf] (ServerService Thread Pool -- 55) WFLYJSF0007: Activated the following JSF Implementations: [main]
15:11:19,316 INFO [org.jboss.as.jaxrs] (ServerService Thread Pool -- 50) WFLYRS0016: RESTEasy version 3.6.1.SP2-redhat-00001
15:11:19,359 INFO [org.jboss.as.mail.extension] (MSC service thread 1-1) WFLYMAIL0002: Unbound mail session [java:jboss/mail/Default]
15:11:19,435 INFO [org.jboss.remoting] (MSC service thread 1-2) JBoss Remoting version 5.0.8.Final-redhat-1
15:11:19,569 INFO [org.wildfly.extension.undertow] (MSC service thread 1-1) WFLYUT0003: Undertow 2.0.15.Final-redhat-00001 starting
15:11:19,571 INFO [org.jboss.as.connector] (MSC service thread 1-1) WFLYJCA0009: Starting JCA Subsystem (WildFly/IronJacamar 1.4.11.Final-redhat-00001)
15:11:19,571 INFO [org.jboss.as.security] (MSC service thread 1-1) WFLYSEC0001: Current PicketBox version=5.0.3.Final-redhat-3
15:11:19,787 INFO [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-2) WFLYJCA0010: Unbound data source [java:jboss/datasources/ExampleDS]
15:11:19,878 INFO [org.jboss.as.naming] (MSC service thread 1-2) WFLYNAM0003: Starting Naming Service
15:11:19,908 INFO [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-1) WFLYJCA0018: Started Driver service with driver-name = h2
15:11:19,958 INFO [org.jboss.as.mail.extension] (MSC service thread 1-1) WFLYMAIL0001: Bound mail session [java:jboss/mail/Default]
15:11:19,947 INFO [org.wildfly.extension.undertow] (ServerService Thread Pool -- 69) WFLYUT0014: Creating file handler for path '/opt/rh/eap7/root/usr/share/wildfly/welcome-content' with options [directory-listing: 'false', follow-symlink: 'false', case-sensitive: 'true', safe-symlink-paths: '[]']
15:11:20,062 INFO [org.jboss.as.ejb3] (MSC service thread 1-2) WFLYEJB0481: Strict pool slsb-strict-max-pool is using a max instance size of 16 (per class), which is derived from thread worker pool sizing.
15:11:20,082 INFO [org.jboss.as.ejb3] (MSC service thread 1-1) WFLYEJB0482: Strict pool mdb-strict-max-pool is using a max instance size of 4 (per class), which is derived from the number of CPUs on this host.
15:11:20,601 INFO [org.wildfly.extension.undertow] (MSC service thread 1-1) WFLYUT0012: Started server default-server.
15:11:20,708 INFO [org.wildfly.extension.undertow] (MSC service thread 1-1) WFLYUT0018: Host default-host starting
15:11:20,916 INFO [org.wildfly.extension.undertow] (MSC service thread 1-2) WFLYUT0006: Undertow HTTP listener default listening on 127.0.0.1:8080
15:11:20,966 INFO [org.jboss.as.ejb3] (MSC service thread 1-1) WFLYEJB0493: EJB subsystem suspension complete
15:11:21,208 WARN [org.jboss.as.domain.management.security] (MSC service thread 1-2) WFLYDM0111: Keystore /opt/rh/eap7/root/usr/share/wildfly/standalone/configuration/application.keystore not found, it will be auto generated on first use with a self signed certificate for host localhost
15:11:21,218 INFO [org.jboss.as.server.deployment.scanner] (MSC service thread 1-1) WFLYDS0013: Started FileSystemDeploymentService for directory /opt/rh/eap7/root/usr/share/wildfly/standalone/deployments
15:11:21,228 INFO [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-1) WFLYJCA0001: Bound data source [java:jboss/datasources/ExampleDS]
15:11:21,236 INFO [org.jboss.as.server.deployment] (MSC service thread 1-2) WFLYSRV0027: Starting deployment of "hello-world.war" (runtime-name: "hello-world.war")
15:11:21,471 INFO [org.wildfly.extension.undertow] (MSC service thread 1-2) WFLYUT0006: Undertow HTTPS listener https listening on 127.0.0.1:8443
15:11:21,630 INFO [org.jboss.ws.common.management] (MSC service thread 1-1) JBWS022052: Starting JBossWS 5.2.4.Final-redhat-00001 (Apache CXF 3.2.5.redhat-00001)
15:11:23,358 INFO [org.infinispan.factories.GlobalComponentRegistry] (MSC service thread 1-2) ISPN000128: Infinispan version: Infinispan 'Estrella Galicia' 9.3.3.Final-redhat-00001
15:11:23,971 INFO [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 72) WFLYCLINF0002: Started client-mappings cache from ejb container
15:11:24,233 INFO [org.wildfly.extension.undertow] (ServerService Thread Pool -- 72) WFLYUT0021: Registered web context: '/hello-world' for server 'default-server'
15:11:24,271 INFO [org.jboss.as.server] (ServerService Thread Pool -- 42) WFLYSRV0010: Deployed "hello-world.war" (runtime-name : "hello-world.war")
15:11:24,413 INFO [org.jboss.as.server] (Controller Boot Thread) WFLYSRV0212: Resuming server
15:11:24,418 INFO [org.jboss.as] (Controller Boot Thread) WFLYSRV0060: Http management interface listening on http://127.0.0.1:9990/management
15:11:24,418 INFO [org.jboss.as] (Controller Boot Thread) WFLYSRV0051: Admin console listening on http://127.0.0.1:9990
15:11:24,418 INFO [org.jboss.as] (Controller Boot Thread) WFLYSRV0025: JBoss EAP 7.2.0.GA (WildFly Core 6.0.11.Final-redhat-00001) started in 10933ms - Started 404 of 589 services (326 services are lazy, passive or on-demand)
由于我没有看到任何错误,我认为一切正常,我的应用已准备好 运行。虽然当我卷曲时,这就是我得到的
卷曲 http://127.0.0.1:9990/hello-world
Error404 - 未找到
如果我只是卷曲 http://127.0.0.1:9990,那么什么也不会发生。
此外,当我尝试使用实例的 public DNS 时,喜欢 publicDNS.compute.amazonaws.com/hello-world 页面给了我 ERR_CONNECTION_REFUSED.
我是不是漏掉了一些步骤?
谢谢!
您试图在错误的端口上访问您的网络应用程序。 9990是管理端口,部署管理控制台。 wildfly 中 web 应用程序的默认端口是 8080。所以尝试在 ec2 实例上做一个 curl
此外,我遇到的第二个问题是无法通过 public DNS 访问实例,我执行了以下操作并且有效:
由于应用程序服务器是 JBoss 7.1 独立版,我不得不编辑 standalone.xml 并替换它:
<interface name="public">
<inet-address value="${jboss.bind.address:127.0.0.1}"/>
</interface>
有了这个:
<interface name="public">
<any-address/>
</interface>
我在 AWS-EC2 上创建了一个 JBoss EAP 实例(遵循 this 指南),现在我正在尝试将一个简单的 hello-world 应用程序部署到其中。
我已经将 .war 文件复制到 /opt/rh/eap7/root/usr/share/wildfly/standalone/deployments 文件夹中,然后我 运行 standalone.sh 在 /opt/rh/eap7/root/usr/share/wildfly/bin 文件夹中,然后得到这个日志:
=========================================================================
JBoss Bootstrap Environment
JBOSS_HOME: /opt/rh/eap7/root/usr/share/wildfly
JAVA: java
JAVA_OPTS: -server -verbose:gc -Xloggc:/opt/rh/eap7/root/usr/share/wildfly/standalone/log/gc.log -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=5 -XX:GCLogFileSize=3M -XX:-TraceClassUnloading -Xms1303m -Xmx1303m -XX:MetaspaceSize=96M -XX:MaxMetaspaceSize=256m -Djava.net.preferIPv4Stack=true -Djboss.modules.system.pkgs=org.jboss.byteman -Djava.awt.headless=true
=========================================================================
15:11:14,196 INFO [org.jboss.modules] (main) JBoss Modules version 1.8.6.Final-redhat-00001
15:11:14,830 INFO [org.jboss.msc] (main) JBoss MSC version 1.4.5.Final-redhat-00001
15:11:14,854 INFO [org.jboss.threads] (main) JBoss Threads version 2.3.2.Final-redhat-1
15:11:15,170 INFO [org.jboss.as] (MSC service thread 1-2) WFLYSRV0049: JBoss EAP 7.2.0.GA (WildFly Core 6.0.11.Final-redhat-00001) starting
15:11:17,070 INFO [org.wildfly.security] (ServerService Thread Pool -- 20) ELY00001: WildFly Elytron version 1.6.1.Final-redhat-00001
15:11:18,572 INFO [org.jboss.as.controller.management-deprecated] (Controller Boot Thread) WFLYCTL0028: Attribute 'security-realm' in the resource at address '/core-service=management/management-interface=http-interface' is deprecated, and may be removed in a future version. See the attribute description in the output of the read-resource-description operation to learn more about the deprecation.
15:11:18,692 INFO [org.jboss.as.controller.management-deprecated] (ServerService Thread Pool -- 34) WFLYCTL0028: Attribute 'security-realm' in the resource at address '/subsystem=undertow/server=default-server/https-listener=https' is deprecated, and may be removed in a future version. See the attribute description in the output of the read-resource-description operation to learn more about the deprecation.
15:11:18,852 INFO [org.jboss.as.server] (Controller Boot Thread) WFLYSRV0039: Creating http management service using socket-binding (management-http)
15:11:18,905 INFO [org.xnio] (MSC service thread 1-2) XNIO version 3.6.5.Final-redhat-00001
15:11:18,930 INFO [org.xnio.nio] (MSC service thread 1-2) XNIO NIO Implementation Version 3.6.5.Final-redhat-00001
15:11:19,070 INFO [org.jboss.as.connector.subsystems.datasources] (ServerService Thread Pool -- 41) WFLYJCA0004: Deploying JDBC-compliant driver class org.h2.Driver (version 1.4)
15:11:19,126 INFO [org.jboss.as.naming] (ServerService Thread Pool -- 60) WFLYNAM0001: Activating Naming Subsystem
15:11:19,114 INFO [org.wildfly.extension.microprofile.config.smallrye._private] (ServerService Thread Pool -- 57) WFLYCONF0001: Activating WildFly MicroProfile Config Subsystem
15:11:19,123 WARN [org.jboss.as.txn] (ServerService Thread Pool -- 68) WFLYTX0013: The node-identifier attribute on the /subsystem=transactions is set to the default value. This is a danger for environments running multiple servers. Please make sure the attribute value is unique.
15:11:19,177 INFO [org.wildfly.extension.microprofile.opentracing] (ServerService Thread Pool -- 59) WFLYTRACEXT0001: Activating MicroProfile OpenTracing Subsystem
15:11:19,201 INFO [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 48) WFLYCLINF0001: Activating Infinispan subsystem.
15:11:19,218 INFO [org.jboss.as.webservices] (ServerService Thread Pool -- 70) WFLYWS0002: Activating WebServices Extension
15:11:19,225 INFO [org.wildfly.extension.io] (ServerService Thread Pool -- 49) WFLYIO001: Worker 'default' has auto-configured to 2 core threads with 16 task threads based on your 1 available processors
15:11:19,209 INFO [org.jboss.as.security] (ServerService Thread Pool -- 66) WFLYSEC0002: Activating Security Subsystem
15:11:19,263 INFO [org.wildfly.extension.microprofile.health.smallrye] (ServerService Thread Pool -- 58) WFLYHEALTH0001: Activating Eclipse MicroProfile Health Subsystem
15:11:19,243 INFO [org.jboss.as.jsf] (ServerService Thread Pool -- 55) WFLYJSF0007: Activated the following JSF Implementations: [main]
15:11:19,316 INFO [org.jboss.as.jaxrs] (ServerService Thread Pool -- 50) WFLYRS0016: RESTEasy version 3.6.1.SP2-redhat-00001
15:11:19,359 INFO [org.jboss.as.mail.extension] (MSC service thread 1-1) WFLYMAIL0002: Unbound mail session [java:jboss/mail/Default]
15:11:19,435 INFO [org.jboss.remoting] (MSC service thread 1-2) JBoss Remoting version 5.0.8.Final-redhat-1
15:11:19,569 INFO [org.wildfly.extension.undertow] (MSC service thread 1-1) WFLYUT0003: Undertow 2.0.15.Final-redhat-00001 starting
15:11:19,571 INFO [org.jboss.as.connector] (MSC service thread 1-1) WFLYJCA0009: Starting JCA Subsystem (WildFly/IronJacamar 1.4.11.Final-redhat-00001)
15:11:19,571 INFO [org.jboss.as.security] (MSC service thread 1-1) WFLYSEC0001: Current PicketBox version=5.0.3.Final-redhat-3
15:11:19,787 INFO [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-2) WFLYJCA0010: Unbound data source [java:jboss/datasources/ExampleDS]
15:11:19,878 INFO [org.jboss.as.naming] (MSC service thread 1-2) WFLYNAM0003: Starting Naming Service
15:11:19,908 INFO [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-1) WFLYJCA0018: Started Driver service with driver-name = h2
15:11:19,958 INFO [org.jboss.as.mail.extension] (MSC service thread 1-1) WFLYMAIL0001: Bound mail session [java:jboss/mail/Default]
15:11:19,947 INFO [org.wildfly.extension.undertow] (ServerService Thread Pool -- 69) WFLYUT0014: Creating file handler for path '/opt/rh/eap7/root/usr/share/wildfly/welcome-content' with options [directory-listing: 'false', follow-symlink: 'false', case-sensitive: 'true', safe-symlink-paths: '[]']
15:11:20,062 INFO [org.jboss.as.ejb3] (MSC service thread 1-2) WFLYEJB0481: Strict pool slsb-strict-max-pool is using a max instance size of 16 (per class), which is derived from thread worker pool sizing.
15:11:20,082 INFO [org.jboss.as.ejb3] (MSC service thread 1-1) WFLYEJB0482: Strict pool mdb-strict-max-pool is using a max instance size of 4 (per class), which is derived from the number of CPUs on this host.
15:11:20,601 INFO [org.wildfly.extension.undertow] (MSC service thread 1-1) WFLYUT0012: Started server default-server.
15:11:20,708 INFO [org.wildfly.extension.undertow] (MSC service thread 1-1) WFLYUT0018: Host default-host starting
15:11:20,916 INFO [org.wildfly.extension.undertow] (MSC service thread 1-2) WFLYUT0006: Undertow HTTP listener default listening on 127.0.0.1:8080
15:11:20,966 INFO [org.jboss.as.ejb3] (MSC service thread 1-1) WFLYEJB0493: EJB subsystem suspension complete
15:11:21,208 WARN [org.jboss.as.domain.management.security] (MSC service thread 1-2) WFLYDM0111: Keystore /opt/rh/eap7/root/usr/share/wildfly/standalone/configuration/application.keystore not found, it will be auto generated on first use with a self signed certificate for host localhost
15:11:21,218 INFO [org.jboss.as.server.deployment.scanner] (MSC service thread 1-1) WFLYDS0013: Started FileSystemDeploymentService for directory /opt/rh/eap7/root/usr/share/wildfly/standalone/deployments
15:11:21,228 INFO [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-1) WFLYJCA0001: Bound data source [java:jboss/datasources/ExampleDS]
15:11:21,236 INFO [org.jboss.as.server.deployment] (MSC service thread 1-2) WFLYSRV0027: Starting deployment of "hello-world.war" (runtime-name: "hello-world.war")
15:11:21,471 INFO [org.wildfly.extension.undertow] (MSC service thread 1-2) WFLYUT0006: Undertow HTTPS listener https listening on 127.0.0.1:8443
15:11:21,630 INFO [org.jboss.ws.common.management] (MSC service thread 1-1) JBWS022052: Starting JBossWS 5.2.4.Final-redhat-00001 (Apache CXF 3.2.5.redhat-00001)
15:11:23,358 INFO [org.infinispan.factories.GlobalComponentRegistry] (MSC service thread 1-2) ISPN000128: Infinispan version: Infinispan 'Estrella Galicia' 9.3.3.Final-redhat-00001
15:11:23,971 INFO [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 72) WFLYCLINF0002: Started client-mappings cache from ejb container
15:11:24,233 INFO [org.wildfly.extension.undertow] (ServerService Thread Pool -- 72) WFLYUT0021: Registered web context: '/hello-world' for server 'default-server'
15:11:24,271 INFO [org.jboss.as.server] (ServerService Thread Pool -- 42) WFLYSRV0010: Deployed "hello-world.war" (runtime-name : "hello-world.war")
15:11:24,413 INFO [org.jboss.as.server] (Controller Boot Thread) WFLYSRV0212: Resuming server
15:11:24,418 INFO [org.jboss.as] (Controller Boot Thread) WFLYSRV0060: Http management interface listening on http://127.0.0.1:9990/management
15:11:24,418 INFO [org.jboss.as] (Controller Boot Thread) WFLYSRV0051: Admin console listening on http://127.0.0.1:9990
15:11:24,418 INFO [org.jboss.as] (Controller Boot Thread) WFLYSRV0025: JBoss EAP 7.2.0.GA (WildFly Core 6.0.11.Final-redhat-00001) started in 10933ms - Started 404 of 589 services (326 services are lazy, passive or on-demand)
由于我没有看到任何错误,我认为一切正常,我的应用已准备好 运行。虽然当我卷曲时,这就是我得到的
卷曲 http://127.0.0.1:9990/hello-world Error404 - 未找到
如果我只是卷曲 http://127.0.0.1:9990,那么什么也不会发生。
此外,当我尝试使用实例的 public DNS 时,喜欢 publicDNS.compute.amazonaws.com/hello-world 页面给了我 ERR_CONNECTION_REFUSED.
我是不是漏掉了一些步骤?
谢谢!
您试图在错误的端口上访问您的网络应用程序。 9990是管理端口,部署管理控制台。 wildfly 中 web 应用程序的默认端口是 8080。所以尝试在 ec2 实例上做一个 curl
此外,我遇到的第二个问题是无法通过 public DNS 访问实例,我执行了以下操作并且有效:
由于应用程序服务器是 JBoss 7.1 独立版,我不得不编辑 standalone.xml 并替换它:
<interface name="public">
<inet-address value="${jboss.bind.address:127.0.0.1}"/>
</interface>
有了这个:
<interface name="public">
<any-address/>
</interface>