使用 Spring 引导项目时,JSP 个文件未部署到 Pivotal Web 服务
JSP files not deployed to Pivotal Web Services when using Spring Boot project
我有一个简单的 Spring Boot webmvc 应用程序,其中有一个 JSP 页面在本地工作,但是当我部署到 Pivotal Web Services(由 Pivotal.io 托管)时,我收到一个错误查看 JSP 页面时。该应用程序打包为 WAR:
2015-02-11 12:22:30.381 ERROR 31 --- [io-61338-exec-4] o.s.boot.context.web.ErrorPageFilter : Cannot forward to error page for request [/] as the response has already been committed. As a result, the response may have the wrong status code. If your application is running on WebSphere Application Server you may be able to resolve this problem by setting com.ibm.ws.webcontainer.invokeFlushAfterService to false
仔细查看远程系统上的文件,我的 JSP 文件似乎没有部署。他们被删除了。它们在我部署之前 WAR。
我已经尝试从 STS 3.6.3 SR1 和使用 CF 从命令行进行部署。
当我创建一个常规 Spring MVC 项目(不使用 Spring 引导)时,一切似乎都在本地和关键的 Web 服务云上工作。
我做错了什么?我错过了配置设置吗?请帮忙。谢谢。
这是我的 Spring 引导项目设置:
HomeController.java的代码:
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
public class HomeController {
@RequestMapping("/")
public String viewHomePage() {
return "home";
}
}
主要class:
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class SpringBootHWorldApplication {
public static void main(String[] args) {
SpringApplication.run(SpringBootHWorldApplication.class, args);
}
}
ServletInitializer:
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.context.web.SpringBootServletInitializer;
public class ServletInitializer extends SpringBootServletInitializer {
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(SpringBootHWorldApplication.class);
}
}
Application.Properties 文件:
spring.view.prefix: /WEB-INF/views/
spring.view.suffix: .jsp
我的 jsp 页面位于 src/main/webapp/WEB-INF/views
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<h1>Hello World!!</h1>
</body>
</html>
Pom.xml 文件:
<?xml version="1.0" encoding="UTF-8"?>
<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>com.somecompany</groupId>
<artifactId>SpringBootHWorldExample</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>SpringBootHWorld</name>
<description>Demo project for Spring Boot</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.2.1.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<start-class>demo.SpringBootHWorldApplication</start-class>
<java.version>1.7</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
远程系统上的文件。请注意文件夹 /WEB-INF/views 丢失。我尝试将文件移动到不同的位置,但每次文件丢失,即使它在本地工作。
https://www.dropbox.com/s/nz8p7su2ksboc2o/RemoteFiles.png
最后是部署日志:
Checking application - SpringBootHWorld
Generating application archive
Creating application
Pushing application
Application successfully pushed
Starting and staging application
Got staging request for app with id 3e09036b-1575-42ac-9642-f667506f7c53
Updated app with guid 3e09036b-1575-42ac-9642-f667506f7c53 ({"state"=>"STARTED"})
-----> Downloaded app package (7.6M)
-----> Java Buildpack Version: v2.6.1 | https://github.com/cloudfoundry/java-buildpack.git#2d92e70
-----> Downloading Open Jdk JRE 1.8.0_31 from https://download.run.pivotal.io/openjdk/lucid/x86_64/openjdk-1.8.0_31.tar.gz (1.8s)
Expanding Open Jdk JRE to .java-buildpack/open_jdk_jre (1.2s)
-----> Downloading Spring Auto Reconfiguration 1.7.0_RELEASE from https://download.run.pivotal.io/auto-reconfiguration/auto-reconfiguration-1.7.0_RELEASE.jar (0.1s)
-----> Downloading Tomcat Instance 8.0.18 from https://download.run.pivotal.io/tomcat/tomcat-8.0.18.tar.gz (0.4s)
Expanding Tomcat to .java-buildpack/tomcat (0.1s)
-----> Downloading Tomcat Lifecycle Support 2.4.0_RELEASE from https://download.run.pivotal.io/tomcat-lifecycle-support/tomcat-lifecycle-support-2.4.0_RELEASE.jar (0.0s)
-----> Downloading Tomcat Logging Support 2.4.0_RELEASE from https://download.run.pivotal.io/tomcat-logging-support/tomcat-logging-support-2.4.0_RELEASE.jar (0.0s)
-----> Uploading droplet (54M)
Starting app instance (index 0) with guid 3e09036b-1575-42ac-9642-f667506f7c53
[CONTAINER] org.apache.coyote.http11.Http11NioProtocol INFO Initializing ProtocolHandler ["http-nio-61338"]
[CONTAINER] org.apache.catalina.startup.Catalina INFO Initialization processed in 511 ms
[CONTAINER] org.apache.catalina.core.StandardService INFO Starting service Catalina
[CONTAINER] org.apache.catalina.core.StandardEngine INFO Starting Servlet Engine: Apache Tomcat/8.0.18
[CONTAINER] org.apache.catalina.startup.HostConfig INFO Deploying web application directory /home/vcap/app/.java-buildpack/tomcat/webapps/ROOT
[CONTAINER] ing.AutoReconfigurationServletContainerInitializer INFO Initializing ServletContext with Auto-reconfiguration ApplicationContextInitializers
[CONTAINER] lina.core.ContainerBase.[Catalina].[localhost].[/] INFO Spring WebApplicationInitializers detected on classpath: [org.springframework.boot.autoconfigure.jersey.JerseyAutoConfiguration@68430648, demo.ServletInitializer@6459b75d]
. ____ _ __ _ _
/\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v1.2.1.RELEASE)
2015-02-11 12:22:27.338 INFO 31 --- [ost-startStop-1] pertySourceApplicationContextInitializer : Adding 'cloud' PropertySource to ApplicationContext
2015-02-11 12:22:27.397 INFO 31 --- [ost-startStop-1] nfigurationApplicationContextInitializer : Adding cloud service auto-reconfiguration to ApplicationContext
2015-02-11 12:22:27.417 INFO 31 --- [ost-startStop-1] o.s.boot.SpringApplication : Starting application on 18eod7e1vho with PID 31 (/home/vcap/app/.java-buildpack/tomcat/webapps/ROOT/WEB-INF/lib/spring-boot-1.2.1.RELEASE.jar started by vcap in /home/vcap/app)
2015-02-11 12:22:27.453 INFO 31 --- [ost-startStop-1] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@1a2c932: startup date [Wed Feb 11 12:22:27 UTC 2015]; root of context hierarchy
2015-02-11 12:22:27.997 INFO 31 --- [ost-startStop-1] o.s.b.f.s.DefaultListableBeanFactory : Overriding bean definition for bean 'beanNameViewResolver': replacing [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.boot.autoconfigure.web.ErrorMvcAutoConfiguration$WhitelabelErrorViewConfiguration; factoryMethodName=beanNameViewResolver; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/boot/autoconfigure/web/ErrorMvcAutoConfiguration$WhitelabelErrorViewConfiguration.class]] with [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration$WebMvcAutoConfigurationAdapter; factoryMethodName=beanNameViewResolver; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/boot/autoconfigure/web/WebMvcAutoConfiguration$WebMvcAutoConfigurationAdapter.class]]
2015-02-11 12:22:28.192 INFO 31 --- [ost-startStop-1] urceCloudServiceBeanFactoryPostProcessor : Auto-reconfiguring beans of type javax.sql.DataSource
2015-02-11 12:22:28.198 INFO 31 --- [ost-startStop-1] urceCloudServiceBeanFactoryPostProcessor : No beans of type javax.sql.DataSource found. Skipping auto-reconfiguration.
2015-02-11 12:22:28.362 INFO 31 --- [ost-startStop-1] o.a.c.c.C.[Catalina].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2015-02-11 12:22:28.362 INFO 31 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 909 ms
2015-02-11 12:22:29.170 INFO 31 --- [ost-startStop-1] o.s.b.c.e.ServletRegistrationBean : Mapping servlet: 'dispatcherServlet' to [/]
2015-02-11 12:22:29.172 INFO 31 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*]
2015-02-11 12:22:29.172 INFO 31 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean : Mapping filter: 'errorPageFilter' to: [/*]
2015-02-11 12:22:29.172 INFO 31 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2015-02-11 12:22:29.413 INFO 31 --- [ost-startStop-1] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for @ControllerAdvice: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@1a2c932: startup date [Wed Feb 11 12:22:27 UTC 2015]; root of context hierarchy
2015-02-11 12:22:29.494 INFO 31 --- [ost-startStop-1] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/],methods=[],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public java.lang.String demo.HomeController.viewHomePage()
2015-02-11 12:22:29.497 INFO 31 --- [ost-startStop-1] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error],methods=[],params=[],headers=[],consumes=[],produces=[],custom=[]}" 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)
2015-02-11 12:22:29.497 INFO 31 --- [ost-startStop-1] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error],methods=[],params=[],headers=[],consumes=[],produces=[text/html],custom=[]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest)
2015-02-11 12:22:29.523 INFO 31 --- [ost-startStop-1] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2015-02-11 12:22:29.524 INFO 31 --- [ost-startStop-1] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2015-02-11 12:22:29.561 INFO 31 --- [ost-startStop-1] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2015-02-11 12:22:29.636 INFO 31 --- [ost-startStop-1] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup
2015-02-11 12:22:29.646 INFO 31 --- [ost-startStop-1] o.s.boot.SpringApplication : Started application in 3.053 seconds (JVM running for 5.418)
[CONTAINER] org.apache.catalina.startup.HostConfig INFO Deployment of web application directory /home/vcap/app/.java-buildpack/tomcat/webapps/ROOT has finished in 4,709 ms
[CONTAINER] org.apache.coyote.http11.Http11NioProtocol INFO Starting ProtocolHandler ["http-nio-61338"]
[CONTAINER] org.apache.tomcat.util.net.NioSelectorPool INFO Using a shared selector for servlet write/read
[CONTAINER] org.apache.catalina.startup.Catalina INFO Server startup in 4766 ms
2015-02-11 12:22:30.055 INFO 31 --- [io-61338-exec-2] o.a.c.c.C.[Catalina].[localhost].[/] : Initializing Spring FrameworkServlet 'dispatcherServlet'
2015-02-11 12:22:30.056 INFO 31 --- [io-61338-exec-2] o.s.web.servlet.DispatcherServlet : FrameworkServlet 'dispatcherServlet': initialization started
2015-02-11 12:22:30.072 INFO 31 --- [io-61338-exec-2] o.s.web.servlet.DispatcherServlet : FrameworkServlet 'dispatcherServlet': initialization completed in 16 ms
SpringBootHWorld.cfapps.io - [11/02/2015:12:22:30 +0000] "GET / HTTP/1.1" 200 0 "-" "Java/1.7.0_45" 10.10.2.122:36854 x_forwarded_for:"50.187.174.41" vcap_request_id:e3177b90-5b1b-4325-6268-3f23c3b85d34 response_time:0.099450479 app_id:3e09036b-1575-42ac-9642-f667506f7c53
2015-02-11 12:22:30.116 ERROR 31 --- [io-61338-exec-2] o.s.boot.context.web.ErrorPageFilter : Cannot forward to error page for request [/] as the response has already been committed. As a result, the response may have the wrong status code. If your application is running on WebSphere Application Server you may be able to resolve this problem by setting com.ibm.ws.webcontainer.invokeFlushAfterService to false
2015-02-11 12:22:30.381 ERROR 31 --- [io-61338-exec-4] o.s.boot.context.web.ErrorPageFilter : Cannot forward to error page for request [/] as the response has already been committed. As a result, the response may have the wrong status code. If your application is running on WebSphere Application Server you may be able to resolve this problem by setting com.ibm.ws.webcontainer.invokeFlushAfterService to false
springboothworld.cfapps.io - [11/02/2015:12:22:30 +0000] "GET / HTTP/1.1" 200 0 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/40.0.2214.111 Safari/537.36" 10.10.2.122:36858 x_forwarded_for:"50.187.174.41" vcap_request_id:ce3100c1-c592-452f-7174-06c4c28bcc2e response_time:0.015669152 app_id:3e09036b-1575-42ac-9642-f667506f7c53
经过多次故障排除,我相信我已经解决了我的问题。为了让事情正常进行,我做了以下事情:
- 右键单击项目并选择属性。
- Select 项目方面。
- 取消选中动态 Web 模块并退出对话框。
- 返回项目方面
- 选中动态 Web 模块并选择 link "Further configuration available..."
- 在内容目录中输入路径 "src/main/webapp"。
- 退出对话框。
这做了两件事。
首先,这在我的 webapp 目录中添加了带有清单文件的 META-INF 文件夹。
其次,它更新了 .settings 文件夹中的文件 org.eclipse.wst.common.component。
在进行上述更改之前,存在以下行:
<wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/>
org.eclipse.wst.common.component
的内容
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
<wb-module deploy-name="SpringBootHelloWorld-06">
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
<wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/>
<property name="context-root" value="demo"/>
<property name="java-output-path" value="/SpringBootHelloWorld-06/target/classes"/>
</wb-module>
</project-modules>
我也尝试过使用清单文件手动添加 META-INF 文件夹,但没有成功。所以我怀疑,这个文件的变化可能是原因,虽然我不确定。也许在这方面有更深入了解的人可以阐明一些问题。
我最初在这里的回答被某人删除了,所以 OP 和我正在互动 elsewhere. In summary, it is found that using STS for the deployment isn't working, and using the cf
command line tool (say, as described here) 代替。想在这里报告它,以便它可能对偶然发现此问题的人有用post。
我有一个简单的 Spring Boot webmvc 应用程序,其中有一个 JSP 页面在本地工作,但是当我部署到 Pivotal Web Services(由 Pivotal.io 托管)时,我收到一个错误查看 JSP 页面时。该应用程序打包为 WAR:
2015-02-11 12:22:30.381 ERROR 31 --- [io-61338-exec-4] o.s.boot.context.web.ErrorPageFilter : Cannot forward to error page for request [/] as the response has already been committed. As a result, the response may have the wrong status code. If your application is running on WebSphere Application Server you may be able to resolve this problem by setting com.ibm.ws.webcontainer.invokeFlushAfterService to false
仔细查看远程系统上的文件,我的 JSP 文件似乎没有部署。他们被删除了。它们在我部署之前 WAR。
我已经尝试从 STS 3.6.3 SR1 和使用 CF 从命令行进行部署。
当我创建一个常规 Spring MVC 项目(不使用 Spring 引导)时,一切似乎都在本地和关键的 Web 服务云上工作。
我做错了什么?我错过了配置设置吗?请帮忙。谢谢。
这是我的 Spring 引导项目设置:
HomeController.java的代码:
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
public class HomeController {
@RequestMapping("/")
public String viewHomePage() {
return "home";
}
}
主要class:
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class SpringBootHWorldApplication {
public static void main(String[] args) {
SpringApplication.run(SpringBootHWorldApplication.class, args);
}
}
ServletInitializer:
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.context.web.SpringBootServletInitializer;
public class ServletInitializer extends SpringBootServletInitializer {
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(SpringBootHWorldApplication.class);
}
}
Application.Properties 文件:
spring.view.prefix: /WEB-INF/views/
spring.view.suffix: .jsp
我的 jsp 页面位于 src/main/webapp/WEB-INF/views
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<h1>Hello World!!</h1>
</body>
</html>
Pom.xml 文件:
<?xml version="1.0" encoding="UTF-8"?>
<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>com.somecompany</groupId>
<artifactId>SpringBootHWorldExample</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>SpringBootHWorld</name>
<description>Demo project for Spring Boot</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.2.1.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<start-class>demo.SpringBootHWorldApplication</start-class>
<java.version>1.7</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
远程系统上的文件。请注意文件夹 /WEB-INF/views 丢失。我尝试将文件移动到不同的位置,但每次文件丢失,即使它在本地工作。
https://www.dropbox.com/s/nz8p7su2ksboc2o/RemoteFiles.png
最后是部署日志:
Checking application - SpringBootHWorld
Generating application archive
Creating application
Pushing application
Application successfully pushed
Starting and staging application
Got staging request for app with id 3e09036b-1575-42ac-9642-f667506f7c53
Updated app with guid 3e09036b-1575-42ac-9642-f667506f7c53 ({"state"=>"STARTED"})
-----> Downloaded app package (7.6M)
-----> Java Buildpack Version: v2.6.1 | https://github.com/cloudfoundry/java-buildpack.git#2d92e70
-----> Downloading Open Jdk JRE 1.8.0_31 from https://download.run.pivotal.io/openjdk/lucid/x86_64/openjdk-1.8.0_31.tar.gz (1.8s)
Expanding Open Jdk JRE to .java-buildpack/open_jdk_jre (1.2s)
-----> Downloading Spring Auto Reconfiguration 1.7.0_RELEASE from https://download.run.pivotal.io/auto-reconfiguration/auto-reconfiguration-1.7.0_RELEASE.jar (0.1s)
-----> Downloading Tomcat Instance 8.0.18 from https://download.run.pivotal.io/tomcat/tomcat-8.0.18.tar.gz (0.4s)
Expanding Tomcat to .java-buildpack/tomcat (0.1s)
-----> Downloading Tomcat Lifecycle Support 2.4.0_RELEASE from https://download.run.pivotal.io/tomcat-lifecycle-support/tomcat-lifecycle-support-2.4.0_RELEASE.jar (0.0s)
-----> Downloading Tomcat Logging Support 2.4.0_RELEASE from https://download.run.pivotal.io/tomcat-logging-support/tomcat-logging-support-2.4.0_RELEASE.jar (0.0s)
-----> Uploading droplet (54M)
Starting app instance (index 0) with guid 3e09036b-1575-42ac-9642-f667506f7c53
[CONTAINER] org.apache.coyote.http11.Http11NioProtocol INFO Initializing ProtocolHandler ["http-nio-61338"]
[CONTAINER] org.apache.catalina.startup.Catalina INFO Initialization processed in 511 ms
[CONTAINER] org.apache.catalina.core.StandardService INFO Starting service Catalina
[CONTAINER] org.apache.catalina.core.StandardEngine INFO Starting Servlet Engine: Apache Tomcat/8.0.18
[CONTAINER] org.apache.catalina.startup.HostConfig INFO Deploying web application directory /home/vcap/app/.java-buildpack/tomcat/webapps/ROOT
[CONTAINER] ing.AutoReconfigurationServletContainerInitializer INFO Initializing ServletContext with Auto-reconfiguration ApplicationContextInitializers
[CONTAINER] lina.core.ContainerBase.[Catalina].[localhost].[/] INFO Spring WebApplicationInitializers detected on classpath: [org.springframework.boot.autoconfigure.jersey.JerseyAutoConfiguration@68430648, demo.ServletInitializer@6459b75d]
. ____ _ __ _ _
/\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v1.2.1.RELEASE)
2015-02-11 12:22:27.338 INFO 31 --- [ost-startStop-1] pertySourceApplicationContextInitializer : Adding 'cloud' PropertySource to ApplicationContext
2015-02-11 12:22:27.397 INFO 31 --- [ost-startStop-1] nfigurationApplicationContextInitializer : Adding cloud service auto-reconfiguration to ApplicationContext
2015-02-11 12:22:27.417 INFO 31 --- [ost-startStop-1] o.s.boot.SpringApplication : Starting application on 18eod7e1vho with PID 31 (/home/vcap/app/.java-buildpack/tomcat/webapps/ROOT/WEB-INF/lib/spring-boot-1.2.1.RELEASE.jar started by vcap in /home/vcap/app)
2015-02-11 12:22:27.453 INFO 31 --- [ost-startStop-1] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@1a2c932: startup date [Wed Feb 11 12:22:27 UTC 2015]; root of context hierarchy
2015-02-11 12:22:27.997 INFO 31 --- [ost-startStop-1] o.s.b.f.s.DefaultListableBeanFactory : Overriding bean definition for bean 'beanNameViewResolver': replacing [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.boot.autoconfigure.web.ErrorMvcAutoConfiguration$WhitelabelErrorViewConfiguration; factoryMethodName=beanNameViewResolver; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/boot/autoconfigure/web/ErrorMvcAutoConfiguration$WhitelabelErrorViewConfiguration.class]] with [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration$WebMvcAutoConfigurationAdapter; factoryMethodName=beanNameViewResolver; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/boot/autoconfigure/web/WebMvcAutoConfiguration$WebMvcAutoConfigurationAdapter.class]]
2015-02-11 12:22:28.192 INFO 31 --- [ost-startStop-1] urceCloudServiceBeanFactoryPostProcessor : Auto-reconfiguring beans of type javax.sql.DataSource
2015-02-11 12:22:28.198 INFO 31 --- [ost-startStop-1] urceCloudServiceBeanFactoryPostProcessor : No beans of type javax.sql.DataSource found. Skipping auto-reconfiguration.
2015-02-11 12:22:28.362 INFO 31 --- [ost-startStop-1] o.a.c.c.C.[Catalina].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2015-02-11 12:22:28.362 INFO 31 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 909 ms
2015-02-11 12:22:29.170 INFO 31 --- [ost-startStop-1] o.s.b.c.e.ServletRegistrationBean : Mapping servlet: 'dispatcherServlet' to [/]
2015-02-11 12:22:29.172 INFO 31 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*]
2015-02-11 12:22:29.172 INFO 31 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean : Mapping filter: 'errorPageFilter' to: [/*]
2015-02-11 12:22:29.172 INFO 31 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2015-02-11 12:22:29.413 INFO 31 --- [ost-startStop-1] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for @ControllerAdvice: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@1a2c932: startup date [Wed Feb 11 12:22:27 UTC 2015]; root of context hierarchy
2015-02-11 12:22:29.494 INFO 31 --- [ost-startStop-1] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/],methods=[],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public java.lang.String demo.HomeController.viewHomePage()
2015-02-11 12:22:29.497 INFO 31 --- [ost-startStop-1] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error],methods=[],params=[],headers=[],consumes=[],produces=[],custom=[]}" 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)
2015-02-11 12:22:29.497 INFO 31 --- [ost-startStop-1] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error],methods=[],params=[],headers=[],consumes=[],produces=[text/html],custom=[]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest)
2015-02-11 12:22:29.523 INFO 31 --- [ost-startStop-1] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2015-02-11 12:22:29.524 INFO 31 --- [ost-startStop-1] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2015-02-11 12:22:29.561 INFO 31 --- [ost-startStop-1] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2015-02-11 12:22:29.636 INFO 31 --- [ost-startStop-1] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup
2015-02-11 12:22:29.646 INFO 31 --- [ost-startStop-1] o.s.boot.SpringApplication : Started application in 3.053 seconds (JVM running for 5.418)
[CONTAINER] org.apache.catalina.startup.HostConfig INFO Deployment of web application directory /home/vcap/app/.java-buildpack/tomcat/webapps/ROOT has finished in 4,709 ms
[CONTAINER] org.apache.coyote.http11.Http11NioProtocol INFO Starting ProtocolHandler ["http-nio-61338"]
[CONTAINER] org.apache.tomcat.util.net.NioSelectorPool INFO Using a shared selector for servlet write/read
[CONTAINER] org.apache.catalina.startup.Catalina INFO Server startup in 4766 ms
2015-02-11 12:22:30.055 INFO 31 --- [io-61338-exec-2] o.a.c.c.C.[Catalina].[localhost].[/] : Initializing Spring FrameworkServlet 'dispatcherServlet'
2015-02-11 12:22:30.056 INFO 31 --- [io-61338-exec-2] o.s.web.servlet.DispatcherServlet : FrameworkServlet 'dispatcherServlet': initialization started
2015-02-11 12:22:30.072 INFO 31 --- [io-61338-exec-2] o.s.web.servlet.DispatcherServlet : FrameworkServlet 'dispatcherServlet': initialization completed in 16 ms
SpringBootHWorld.cfapps.io - [11/02/2015:12:22:30 +0000] "GET / HTTP/1.1" 200 0 "-" "Java/1.7.0_45" 10.10.2.122:36854 x_forwarded_for:"50.187.174.41" vcap_request_id:e3177b90-5b1b-4325-6268-3f23c3b85d34 response_time:0.099450479 app_id:3e09036b-1575-42ac-9642-f667506f7c53
2015-02-11 12:22:30.116 ERROR 31 --- [io-61338-exec-2] o.s.boot.context.web.ErrorPageFilter : Cannot forward to error page for request [/] as the response has already been committed. As a result, the response may have the wrong status code. If your application is running on WebSphere Application Server you may be able to resolve this problem by setting com.ibm.ws.webcontainer.invokeFlushAfterService to false
2015-02-11 12:22:30.381 ERROR 31 --- [io-61338-exec-4] o.s.boot.context.web.ErrorPageFilter : Cannot forward to error page for request [/] as the response has already been committed. As a result, the response may have the wrong status code. If your application is running on WebSphere Application Server you may be able to resolve this problem by setting com.ibm.ws.webcontainer.invokeFlushAfterService to false
springboothworld.cfapps.io - [11/02/2015:12:22:30 +0000] "GET / HTTP/1.1" 200 0 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/40.0.2214.111 Safari/537.36" 10.10.2.122:36858 x_forwarded_for:"50.187.174.41" vcap_request_id:ce3100c1-c592-452f-7174-06c4c28bcc2e response_time:0.015669152 app_id:3e09036b-1575-42ac-9642-f667506f7c53
经过多次故障排除,我相信我已经解决了我的问题。为了让事情正常进行,我做了以下事情:
- 右键单击项目并选择属性。
- Select 项目方面。
- 取消选中动态 Web 模块并退出对话框。
- 返回项目方面
- 选中动态 Web 模块并选择 link "Further configuration available..."
- 在内容目录中输入路径 "src/main/webapp"。
- 退出对话框。
这做了两件事。
首先,这在我的 webapp 目录中添加了带有清单文件的 META-INF 文件夹。
其次,它更新了 .settings 文件夹中的文件 org.eclipse.wst.common.component。
在进行上述更改之前,存在以下行:
<wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/>
org.eclipse.wst.common.component
的内容<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
<wb-module deploy-name="SpringBootHelloWorld-06">
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
<wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/>
<property name="context-root" value="demo"/>
<property name="java-output-path" value="/SpringBootHelloWorld-06/target/classes"/>
</wb-module>
</project-modules>
我也尝试过使用清单文件手动添加 META-INF 文件夹,但没有成功。所以我怀疑,这个文件的变化可能是原因,虽然我不确定。也许在这方面有更深入了解的人可以阐明一些问题。
我最初在这里的回答被某人删除了,所以 OP 和我正在互动 elsewhere. In summary, it is found that using STS for the deployment isn't working, and using the cf
command line tool (say, as described here) 代替。想在这里报告它,以便它可能对偶然发现此问题的人有用post。