Skip to content
This repository was archived by the owner on Dec 15, 2021. It is now read-only.

Commit b281f0e

Browse files
committed
Add project for SPR-17521
1 parent 1ed6aff commit b281f0e

File tree

10 files changed

+437
-0
lines changed

10 files changed

+437
-0
lines changed

SPR-17521/README.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
## Spring MVC project with Java config
2+
3+
This is a simple template for creating issue reproduction projects per
4+
the [README in the root of this repository](https://github.com/spring-projects/spring-framework-issues#readme).
5+
Please review that document before starting.
6+
7+
As described at the link above, do not edit this project directly! Rather
8+
use the `./create-repro-project.sh` script to create a fresh copy to
9+
a new directory having the same name as the JIRA issue you're trying
10+
to reproduce and edit from there.
11+
12+
## Deploying
13+
14+
It is possible to deploy your application directly from the command-line
15+
using maven. See the next two sections on Cargo and Jetty.
16+
17+
### Cargo
18+
19+
You can deploy with the [Cargo Maven plugin](http://cargo.codehaus.org/) which
20+
supports a wide [range of servers](http://cargo.codehaus.org/Containers).
21+
The required command is `mvn package cargo:run`.
22+
23+
By default Cargo is configured to start with `Tomcat 8` but you can easily
24+
edit the plugin settings in `pom.xml` to switch to a different server
25+
and version. The pom.xml or to switch to debug settings.
26+
27+
### Jetty
28+
29+
You can also deploy with the
30+
[Jetty Maven plugin](http://www.eclipse.org/jetty/documentation/current/jetty-maven-plugin.html).
31+
The required command is `mvn jetty:run` or `mvnDebug jetty:run`.
32+
33+
## Logging
34+
35+
This project contains a `log4j.properties` file in `src/main/resources` that you
36+
may wish to configure to emit more detailed logging. The root logger is set to
37+
`INFO` and a custom `org.springframework.web` logger is set to `DEBUG`.

SPR-17521/pom.xml

Lines changed: 261 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,261 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
<groupId>org.springframework.issues</groupId>
5+
<artifactId>SPR-17521</artifactId>
6+
<version>1.0-SNAPSHOT</version>
7+
<name>Spring MVC Issue Reproduction Project</name>
8+
<packaging>war</packaging>
9+
10+
<properties>
11+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
12+
<java.version>1.6</java.version>
13+
<spring.version>5.0.9.RELEASE</spring.version>
14+
<slf4j.version>1.7.22</slf4j.version>
15+
<tomcat.version>8.5.9</tomcat.version>
16+
</properties>
17+
18+
<dependencies>
19+
<!-- Spring Framework -->
20+
<dependency>
21+
<groupId>org.springframework</groupId>
22+
<artifactId>spring-context</artifactId>
23+
<version>${spring.version}</version>
24+
<exclusions>
25+
<!-- Exclude Commons Logging in favor of SLF4j -->
26+
<exclusion>
27+
<groupId>commons-logging</groupId>
28+
<artifactId>commons-logging</artifactId>
29+
</exclusion>
30+
</exclusions>
31+
</dependency>
32+
<dependency>
33+
<groupId>org.springframework</groupId>
34+
<artifactId>spring-webmvc</artifactId>
35+
<version>${spring.version}</version>
36+
</dependency>
37+
38+
<!-- Logging -->
39+
<dependency>
40+
<groupId>org.slf4j</groupId>
41+
<artifactId>slf4j-api</artifactId>
42+
<version>${slf4j.version}</version>
43+
</dependency>
44+
<dependency>
45+
<groupId>org.slf4j</groupId>
46+
<artifactId>jcl-over-slf4j</artifactId>
47+
<version>${slf4j.version}</version>
48+
<scope>runtime</scope>
49+
</dependency>
50+
<dependency>
51+
<groupId>org.slf4j</groupId>
52+
<artifactId>slf4j-log4j12</artifactId>
53+
<version>${slf4j.version}</version>
54+
<scope>runtime</scope>
55+
</dependency>
56+
<dependency>
57+
<groupId>log4j</groupId>
58+
<artifactId>log4j</artifactId>
59+
<version>1.2.17</version>
60+
<scope>runtime</scope>
61+
</dependency>
62+
63+
<!-- Servlet API -->
64+
<dependency>
65+
<groupId>javax.servlet</groupId>
66+
<artifactId>javax.servlet-api</artifactId>
67+
<version>3.1.0</version>
68+
<scope>provided</scope>
69+
</dependency>
70+
71+
<!-- JSP API and JSTL
72+
<dependency>
73+
<groupId>javax.servlet.jsp</groupId>
74+
<artifactId>jsp-api</artifactId>
75+
<version>2.1</version>
76+
<scope>provided</scope>
77+
</dependency>
78+
<dependency>
79+
<groupId>javax.servlet</groupId>
80+
<artifactId>jstl</artifactId>
81+
<version>1.2</version>
82+
</dependency>
83+
-->
84+
85+
<!-- Apache Tiles
86+
<dependency>
87+
<groupId>org.apache.tiles</groupId>
88+
<artifactId>tiles-jsp</artifactId>
89+
<version>2.1.3</version>
90+
<exclusions>
91+
<exclusion>
92+
<groupId>commons-logging</groupId>
93+
<artifactId>commons-logging-api</artifactId>
94+
</exclusion>
95+
</exclusions>
96+
</dependency>
97+
-->
98+
99+
<!-- JSR 303 with Hibernate Validator
100+
<dependency>
101+
<groupId>javax.validation</groupId>
102+
<artifactId>validation-api</artifactId>
103+
<version>1.0.0.GA</version>
104+
</dependency>
105+
<dependency>
106+
<groupId>org.hibernate</groupId>
107+
<artifactId>hibernate-validator</artifactId>
108+
<version>4.1.0.Final</version>
109+
</dependency>
110+
-->
111+
112+
<!-- Joda Time Library
113+
<dependency>
114+
<groupId>joda-time</groupId>
115+
<artifactId>joda-time</artifactId>
116+
<version>1.6.2</version>
117+
</dependency>
118+
<dependency>
119+
<groupId>joda-time</groupId>
120+
<artifactId>joda-time-jsptags</artifactId>
121+
<version>1.0.2</version>
122+
<scope>runtime</scope>
123+
</dependency>
124+
-->
125+
126+
<!-- Apache Commons File Upload
127+
<dependency>
128+
<groupId>commons-fileupload</groupId>
129+
<artifactId>commons-fileupload</artifactId>
130+
<version>1.2.2</version>
131+
</dependency>
132+
<dependency>
133+
<groupId>commons-io</groupId>
134+
<artifactId>commons-io</artifactId>
135+
<version>2.0.1</version>
136+
</dependency>
137+
-->
138+
139+
<!-- Jackson JSON Processor
140+
<dependency>
141+
<groupId>com.fasterxml.jackson.core</groupId>
142+
<artifactId>jackson-databind</artifactId>
143+
<version>2.6.2</version>
144+
</dependency>
145+
-->
146+
147+
<!-- Rome Atom+RSS
148+
<dependency>
149+
<groupId>rome</groupId>
150+
<artifactId>rome</artifactId>
151+
<version>1.0</version>
152+
</dependency>
153+
-->
154+
155+
<!-- Test -->
156+
<dependency>
157+
<groupId>junit</groupId>
158+
<artifactId>junit</artifactId>
159+
<version>4.12</version>
160+
<scope>test</scope>
161+
</dependency>
162+
</dependencies>
163+
164+
<build>
165+
<plugins>
166+
<plugin>
167+
<groupId>org.apache.maven.plugins</groupId>
168+
<artifactId>maven-compiler-plugin</artifactId>
169+
<version>2.5.1</version>
170+
<configuration>
171+
<source>${java.version}</source>
172+
<target>${java.version}</target>
173+
</configuration>
174+
</plugin>
175+
<plugin>
176+
<groupId>org.apache.maven.plugins</groupId>
177+
<artifactId>maven-dependency-plugin</artifactId>
178+
<version>2.8</version>
179+
<executions>
180+
<execution>
181+
<id>install</id>
182+
<phase>install</phase>
183+
<goals>
184+
<goal>sources</goal>
185+
</goals>
186+
</execution>
187+
</executions>
188+
</plugin>
189+
<plugin>
190+
<groupId>org.apache.maven.plugins</groupId>
191+
<artifactId>maven-eclipse-plugin</artifactId>
192+
<version>2.8</version>
193+
<configuration>
194+
<downloadSources>true</downloadSources>
195+
<downloadJavadocs>false</downloadJavadocs>
196+
<wtpversion>2.0</wtpversion>
197+
</configuration>
198+
</plugin>
199+
<plugin>
200+
<groupId>org.apache.maven.plugins</groupId>
201+
<artifactId>maven-surefire-plugin</artifactId>
202+
<version>2.12.4</version>
203+
<configuration>
204+
<includes>
205+
<include>**/*Tests.java</include>
206+
<include>**/*Test.java</include>
207+
</includes>
208+
<excludes>
209+
<exclude>**/*Abstract*.java</exclude>
210+
</excludes>
211+
</configuration>
212+
</plugin>
213+
<plugin>
214+
<groupId>org.eclipse.jetty</groupId>
215+
<artifactId>jetty-maven-plugin</artifactId>
216+
<version>9.3.3.v20150827</version>
217+
</plugin>
218+
<plugin>
219+
<groupId>org.codehaus.cargo</groupId>
220+
<artifactId>cargo-maven2-plugin</artifactId>
221+
<version>1.6.2</version>
222+
<configuration>
223+
<configuration>
224+
<properties>
225+
<cargo.servlet.port>8080</cargo.servlet.port>
226+
<cargo.logging>medium</cargo.logging>
227+
<cargo.jvmargs>-Xms96m -Xmx512m -Djava.awt.headless=true</cargo.jvmargs>
228+
<!--
229+
<cargo.jvmargs>
230+
-Xdebug
231+
-Xrunjdwp:transport=dt_socket,address=8000,suspend=n,server=y
232+
-Xnoagent
233+
-Djava.compiler=NONE
234+
</cargo.jvmargs>
235+
-->
236+
</properties>
237+
</configuration>
238+
<container>
239+
<containerId>tomcat8x</containerId>
240+
<zipUrlInstaller>
241+
<url>http://archive.apache.org/dist/tomcat/tomcat-8/v${tomcat.version}/bin/apache-tomcat-${tomcat.version}.zip</url>
242+
</zipUrlInstaller>
243+
</container>
244+
</configuration>
245+
</plugin>
246+
</plugins>
247+
</build>
248+
249+
<repositories>
250+
<repository>
251+
<id>spring-maven-snapshot</id>
252+
<name>Springframework Maven Snapshot Repository</name>
253+
<url>http://repo.spring.io/snapshot</url>
254+
<snapshots>
255+
<enabled>true</enabled>
256+
</snapshots>
257+
</repository>
258+
</repositories>
259+
260+
</project>
261+
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
* Copyright 2002-2018 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package org.springframework.issues.config;
17+
18+
import org.springframework.http.ResponseEntity;
19+
import org.springframework.web.bind.annotation.ControllerAdvice;
20+
import org.springframework.web.bind.annotation.ExceptionHandler;
21+
import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler;
22+
23+
@ControllerAdvice
24+
public class RestExceptionHandler extends ResponseEntityExceptionHandler {
25+
26+
@ExceptionHandler
27+
public ResponseEntity<String> handle(IllegalArgumentException ex) {
28+
return ResponseEntity.badRequest().body("Handled: " + ex.toString());
29+
}
30+
31+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*
2+
* Copyright 2002-2018 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package org.springframework.issues.config;
17+
18+
import org.springframework.web.bind.annotation.GetMapping;
19+
import org.springframework.web.bind.annotation.RestController;
20+
21+
@RestController
22+
public class TestController {
23+
24+
@GetMapping("/test")
25+
public void handle() {
26+
throw new IllegalArgumentException("argument error");
27+
}
28+
29+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package org.springframework.issues.config;
2+
3+
import org.springframework.context.annotation.ComponentScan;
4+
import org.springframework.context.annotation.Configuration;
5+
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
6+
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
7+
8+
@EnableWebMvc
9+
@ComponentScan(basePackages="org.springframework.issues")
10+
@Configuration
11+
public class WebConfig implements WebMvcConfigurer {
12+
13+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
log4j.rootCategory=INFO, stdout
2+
3+
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
4+
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
5+
log4j.appender.stdout.layout.ConversionPattern=%d %p [%c] - <%m>%n
6+
7+
log4j.category.org.springframework.web=DEBUG
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
2+
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
3+
<html>
4+
<head>
5+
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
6+
<title>Home</title>
7+
</head>
8+
<body>
9+
<h1>Home</h1>
10+
</body>
11+
</html>

0 commit comments

Comments
 (0)