java - 访问网页时出现问题(在 Wildfly 上上传)

标签 java docker spring-boot wildfly war

使用以下命令创建 docker 容器:

docker run -p 8080:8080 -p 9990:9990 --name wildfly -d -it jboss/wildfly `/opt/jboss/wildfly/bin/standalone.sh -bmanagement 0.0.0.0`

当我创建 docker 容器时,我通过管理页面上传一个 war 文件,我可以在端口 9990 上访问该文件。从日志文件中可以看到,war文件的上传 成功结束,上下文路径为 /TestProject,但是当我尝试访问浏览器 ( http://localhost:8080/TestProject/.../ ) 时,我收到的消息是 “此页面无法正常工作” 。 .war 文件在本地安装的 Wildfly 上进行了测试,并且可以正常工作。

日志文件:

 12:24:01,974 WARN  [org.jboss.as.ee] (MSC service thread 1-1) WFLYEE0007: Not installing optional component org.springframework.web.context.request.async.StandardServletAsyncWebRequest due to an exception (enable DEBUG log level to see the cause)
12:24:02,135 INFO  [org.infinispan.factories.GlobalComponentRegistry] (MSC service thread 1-4) ISPN000128: Infinispan version: Infinispan 'Chakra' 8.2.8.Final
12:24:02,464 INFO  [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 62) WFLYCLINF0002: Started client-mappings cache from ejb container
12:24:02,580 INFO  [io.undertow.servlet] (ServerService Thread Pool -- 66) 2 Spring WebApplicationInitializers detected on classpath
12:24:03,175 INFO  [stdout] (ServerService Thread Pool -- 66)
12:24:03,176 INFO  [stdout] (ServerService Thread Pool -- 66)   .   ____          _            __ _ _
12:24:03,176 INFO  [stdout] (ServerService Thread Pool -- 66)  /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
12:24:03,176 INFO  [stdout] (ServerService Thread Pool -- 66) ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
12:24:03,176 INFO  [stdout] (ServerService Thread Pool -- 66)  \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
12:24:03,177 INFO  [stdout] (ServerService Thread Pool -- 66)   '  |____| .__|_| |_|_| |_\__, | / / / /
12:24:03,177 INFO  [stdout] (ServerService Thread Pool -- 66)  =========|_|==============|___/=/_/_/_/
12:24:03,179 INFO  [stdout] (ServerService Thread Pool -- 66)  :: Spring Boot ::        (v1.4.2.RELEASE)
12:24:03,180 INFO  [stdout] (ServerService Thread Pool -- 66)
12:24:03,252 INFO  [com.musala.test.project.TestProjectApplication] (ServerService Thread Pool -- 66) Starting TestProjectApplication on 18aafab37ce1 with PID 53 (started by jboss in /opt/jboss)
12:24:03,253 INFO  [com.musala.test.project.TestProjectApplication] (ServerService Thread Pool -- 66) No active profile set, falling back to default profiles: default
12:24:03,296 INFO  [org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext] (ServerService Thread Pool -- 66) Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@4750038e: startup date [Wed Nov 08 12:24:03 UTC 2017]; root of context hierarchy
12:24:04,106 INFO  [org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor] (ServerService Thread Pool -- 66) JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
12:24:04,134 INFO  [io.undertow.servlet] (ServerService Thread Pool -- 66) Initializing Spring embedded WebApplicationContext
12:24:04,135 INFO  [org.springframework.web.context.ContextLoader] (ServerService Thread Pool -- 66) Root WebApplicationContext: initialization completed in 840 ms
12:24:04,581 INFO  [org.springframework.boot.web.servlet.ServletRegistrationBean] (ServerService Thread Pool -- 66) Mapping servlet: 'dispatcherServlet' to [/]
12:24:04,585 INFO  [org.springframework.boot.web.servlet.FilterRegistrationBean] (ServerService Thread Pool -- 66) Mapping filter: 'errorPageFilter' to: [/*]
12:24:04,588 INFO  [org.springframework.boot.web.servlet.FilterRegistrationBean] (ServerService Thread Pool -- 66) Mapping filter: 'characterEncodingFilter' to: [/*]
12:24:04,588 INFO  [org.springframework.boot.web.servlet.FilterRegistrationBean] (ServerService Thread Pool -- 66) Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
12:24:04,589 INFO  [org.springframework.boot.web.servlet.FilterRegistrationBean] (ServerService Thread Pool -- 66) Mapping filter: 'httpPutFormContentFilter' to: [/*]
12:24:04,589 INFO  [org.springframework.boot.web.servlet.FilterRegistrationBean] (ServerService Thread Pool -- 66) Mapping filter: 'requestContextFilter' to: [/*]
12:24:04,766 INFO  [org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter] (ServerService Thread Pool -- 66) Looking for @ControllerAdvice: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@4750038e: startup date [Wed Nov 08 12:24:03 UTC 2017]; root of context hierarchy
12:24:04,808 INFO  [org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping] (ServerService Thread Pool -- 66) Mapped "{[/hello]}" onto public java.lang.String com.musala.test.project.TestController.test()
12:24:04,813 INFO  [org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping] (ServerService Thread Pool -- 66) Mapped "{[/error],produces=[text/html]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
12:24:04,813 INFO  [org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping] (ServerService Thread Pool -- 66) Mapped "{[/error]}" onto public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframework.boot.autoconfigure.web.BasicErrorController.error(javax.servlet.http.HttpServletRequest)
12:24:04,853 INFO  [org.springframework.web.servlet.handler.SimpleUrlHandlerMapping] (ServerService Thread Pool -- 66) Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
12:24:04,853 INFO  [org.springframework.web.servlet.handler.SimpleUrlHandlerMapping] (ServerService Thread Pool -- 66) Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
12:24:04,877 INFO  [org.springframework.web.servlet.handler.SimpleUrlHandlerMapping] (ServerService Thread Pool -- 66) Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
12:24:04,986 INFO  [org.springframework.jmx.export.annotation.AnnotationMBeanExporter] (ServerService Thread Pool -- 66) Registering beans for JMX exposure on startup
12:24:04,997 INFO  [com.musala.test.project.TestProjectApplication] (ServerService Thread Pool -- 66) Started TestProjectApplication in 2.33 seconds (JVM running for 1132.907)
12:24:05,044 INFO  [javax.enterprise.resource.webcontainer.jsf.config] (ServerService Thread Pool -- 66) Initializing Mojarra 2.2.13.SP4  for context '/TestProject'
12:24:05,911 INFO  [org.wildfly.extension.undertow] (ServerService Thread Pool -- 66) WFLYUT0021: Registered web context: '/TestProject' for server 'default-server'
12:24:05,986 INFO  [org.jboss.as.server] (External Management Request Threads -- 6) WFLYSRV0010: Deployed "TestProject.war" (runtime-name : "TestProject.war")

已创建 docker 容器(显示端口已打开) Created docker container 任何帮助将非常感激!

最佳答案

问题在于运行容器。尝试从所有界面添加对应用程序的访问:

docker run -p 8080:8080 -p 9990:9990 --name wildfly -d -it jboss/wildfly `/opt/jboss/wildfly/bin/standalone.sh -b 0.0.0.0 -bmanagement 0.0.0.0`

您唯一缺少的是:-b 0.0.0.0

关于java - 访问网页时出现问题(在 Wildfly 上上传),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47180412/

相关文章:

bash - bash无法使用Docker的SHELL指令工作

nginx - 运行 Nginx Docker 或 cat 日志时无法使用 -lt

java - tomcat上部署后视频格式和MIME类型错误

docker - 如何通过某些 API 测量容器的启动和结束时间?

spring - Maven 和 Spring Boot - 不可解析的父 pom - repo.spring.io(未知主机)

java - SpringBoot @SqsListener - 不工作 - 异常 - TaskRejectedException

java - 这就是您在服务层中调用 Dao 的方式吗?

java - 如果它在 jar 文件中,则基于 Spring Annotation 的 Controller 不起作用

Java Collections - 查找两个集合之间是否存在公共(public)元素的最快方法

java - 初始化浮点值时出错