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

Commit 25b8f73

Browse files
committed
Add repro project for SPR-15842
1 parent 5837376 commit 25b8f73

File tree

9 files changed

+443
-0
lines changed

9 files changed

+443
-0
lines changed

SPR-15842/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-15842/pom.xml

Lines changed: 260 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,260 @@
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-15842</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.8</java.version>
13+
<spring.version>3.2.18.RELEASE</spring.version>
14+
<!--<spring.version>4.3.10.RELEASE</spring.version>-->
15+
<slf4j.version>1.7.22</slf4j.version>
16+
<tomcat.version>8.5.9</tomcat.version>
17+
</properties>
18+
19+
<dependencies>
20+
<!-- Spring Framework -->
21+
<dependency>
22+
<groupId>org.springframework</groupId>
23+
<artifactId>spring-context</artifactId>
24+
<version>${spring.version}</version>
25+
<exclusions>
26+
<!-- Exclude Commons Logging in favor of SLF4j -->
27+
<exclusion>
28+
<groupId>commons-logging</groupId>
29+
<artifactId>commons-logging</artifactId>
30+
</exclusion>
31+
</exclusions>
32+
</dependency>
33+
<dependency>
34+
<groupId>org.springframework</groupId>
35+
<artifactId>spring-webmvc</artifactId>
36+
<version>${spring.version}</version>
37+
</dependency>
38+
39+
<!-- Logging -->
40+
<dependency>
41+
<groupId>org.slf4j</groupId>
42+
<artifactId>slf4j-api</artifactId>
43+
<version>${slf4j.version}</version>
44+
</dependency>
45+
<dependency>
46+
<groupId>org.slf4j</groupId>
47+
<artifactId>jcl-over-slf4j</artifactId>
48+
<version>${slf4j.version}</version>
49+
<scope>runtime</scope>
50+
</dependency>
51+
<dependency>
52+
<groupId>org.slf4j</groupId>
53+
<artifactId>slf4j-log4j12</artifactId>
54+
<version>${slf4j.version}</version>
55+
<scope>runtime</scope>
56+
</dependency>
57+
<dependency>
58+
<groupId>log4j</groupId>
59+
<artifactId>log4j</artifactId>
60+
<version>1.2.17</version>
61+
<scope>runtime</scope>
62+
</dependency>
63+
64+
<!-- Servlet API -->
65+
<dependency>
66+
<groupId>javax.servlet</groupId>
67+
<artifactId>javax.servlet-api</artifactId>
68+
<version>3.1.0</version>
69+
<scope>provided</scope>
70+
</dependency>
71+
72+
<!-- JSP API and JSTL
73+
<dependency>
74+
<groupId>javax.servlet.jsp</groupId>
75+
<artifactId>jsp-api</artifactId>
76+
<version>2.1</version>
77+
<scope>provided</scope>
78+
</dependency>
79+
<dependency>
80+
<groupId>javax.servlet</groupId>
81+
<artifactId>jstl</artifactId>
82+
<version>1.2</version>
83+
</dependency>
84+
-->
85+
86+
<!-- Apache Tiles
87+
<dependency>
88+
<groupId>org.apache.tiles</groupId>
89+
<artifactId>tiles-jsp</artifactId>
90+
<version>2.1.3</version>
91+
<exclusions>
92+
<exclusion>
93+
<groupId>commons-logging</groupId>
94+
<artifactId>commons-logging-api</artifactId>
95+
</exclusion>
96+
</exclusions>
97+
</dependency>
98+
-->
99+
100+
<!-- JSR 303 with Hibernate Validator
101+
<dependency>
102+
<groupId>javax.validation</groupId>
103+
<artifactId>validation-api</artifactId>
104+
<version>1.0.0.GA</version>
105+
</dependency>
106+
<dependency>
107+
<groupId>org.hibernate</groupId>
108+
<artifactId>hibernate-validator</artifactId>
109+
<version>4.1.0.Final</version>
110+
</dependency>
111+
-->
112+
113+
<!-- Joda Time Library
114+
<dependency>
115+
<groupId>joda-time</groupId>
116+
<artifactId>joda-time</artifactId>
117+
<version>1.6.2</version>
118+
</dependency>
119+
<dependency>
120+
<groupId>joda-time</groupId>
121+
<artifactId>joda-time-jsptags</artifactId>
122+
<version>1.0.2</version>
123+
<scope>runtime</scope>
124+
</dependency>
125+
-->
126+
127+
<!-- Apache Commons File Upload
128+
<dependency>
129+
<groupId>commons-fileupload</groupId>
130+
<artifactId>commons-fileupload</artifactId>
131+
<version>1.2.2</version>
132+
</dependency>
133+
<dependency>
134+
<groupId>commons-io</groupId>
135+
<artifactId>commons-io</artifactId>
136+
<version>2.0.1</version>
137+
</dependency>
138+
-->
139+
140+
<dependency>
141+
<groupId>com.fasterxml.jackson.core</groupId>
142+
<artifactId>jackson-databind</artifactId>
143+
<version>2.6.2</version>
144+
</dependency>
145+
146+
<!-- Rome Atom+RSS
147+
<dependency>
148+
<groupId>rome</groupId>
149+
<artifactId>rome</artifactId>
150+
<version>1.0</version>
151+
</dependency>
152+
-->
153+
154+
<!-- Test -->
155+
<dependency>
156+
<groupId>junit</groupId>
157+
<artifactId>junit</artifactId>
158+
<version>4.12</version>
159+
<scope>test</scope>
160+
</dependency>
161+
</dependencies>
162+
163+
<build>
164+
<plugins>
165+
<plugin>
166+
<groupId>org.apache.maven.plugins</groupId>
167+
<artifactId>maven-compiler-plugin</artifactId>
168+
<version>2.5.1</version>
169+
<configuration>
170+
<source>${java.version}</source>
171+
<target>${java.version}</target>
172+
</configuration>
173+
</plugin>
174+
<plugin>
175+
<groupId>org.apache.maven.plugins</groupId>
176+
<artifactId>maven-dependency-plugin</artifactId>
177+
<version>2.8</version>
178+
<executions>
179+
<execution>
180+
<id>install</id>
181+
<phase>install</phase>
182+
<goals>
183+
<goal>sources</goal>
184+
</goals>
185+
</execution>
186+
</executions>
187+
</plugin>
188+
<plugin>
189+
<groupId>org.apache.maven.plugins</groupId>
190+
<artifactId>maven-eclipse-plugin</artifactId>
191+
<version>2.8</version>
192+
<configuration>
193+
<downloadSources>true</downloadSources>
194+
<downloadJavadocs>false</downloadJavadocs>
195+
<wtpversion>2.0</wtpversion>
196+
</configuration>
197+
</plugin>
198+
<plugin>
199+
<groupId>org.apache.maven.plugins</groupId>
200+
<artifactId>maven-surefire-plugin</artifactId>
201+
<version>2.12.4</version>
202+
<configuration>
203+
<includes>
204+
<include>**/*Tests.java</include>
205+
<include>**/*Test.java</include>
206+
</includes>
207+
<excludes>
208+
<exclude>**/*Abstract*.java</exclude>
209+
</excludes>
210+
</configuration>
211+
</plugin>
212+
<plugin>
213+
<groupId>org.eclipse.jetty</groupId>
214+
<artifactId>jetty-maven-plugin</artifactId>
215+
<version>9.3.3.v20150827</version>
216+
</plugin>
217+
<plugin>
218+
<groupId>org.codehaus.cargo</groupId>
219+
<artifactId>cargo-maven2-plugin</artifactId>
220+
<version>1.6.2</version>
221+
<configuration>
222+
<configuration>
223+
<properties>
224+
<cargo.servlet.port>8080</cargo.servlet.port>
225+
<cargo.logging>medium</cargo.logging>
226+
<cargo.jvmargs>-Xms96m -Xmx512m -Djava.awt.headless=true</cargo.jvmargs>
227+
<!--
228+
<cargo.jvmargs>
229+
-Xdebug
230+
-Xrunjdwp:transport=dt_socket,address=8000,suspend=n,server=y
231+
-Xnoagent
232+
-Djava.compiler=NONE
233+
</cargo.jvmargs>
234+
-->
235+
</properties>
236+
</configuration>
237+
<container>
238+
<containerId>tomcat8x</containerId>
239+
<zipUrlInstaller>
240+
<url>http://archive.apache.org/dist/tomcat/tomcat-8/v${tomcat.version}/bin/apache-tomcat-${tomcat.version}.zip</url>
241+
</zipUrlInstaller>
242+
</container>
243+
</configuration>
244+
</plugin>
245+
</plugins>
246+
</build>
247+
248+
<repositories>
249+
<repository>
250+
<id>spring-maven-snapshot</id>
251+
<name>Springframework Maven Snapshot Repository</name>
252+
<url>http://repo.spring.io/snapshot</url>
253+
<snapshots>
254+
<enabled>true</enabled>
255+
</snapshots>
256+
</repository>
257+
</repositories>
258+
259+
</project>
260+
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/*
2+
* Copyright 2002-2017 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 java.util.HashMap;
19+
import java.util.Map;
20+
21+
import org.springframework.http.HttpStatus;
22+
import org.springframework.http.MediaType;
23+
import org.springframework.http.ResponseEntity;
24+
import org.springframework.stereotype.Controller;
25+
import org.springframework.web.bind.annotation.RequestMapping;
26+
import org.springframework.web.bind.annotation.ResponseBody;
27+
28+
@Controller
29+
@RequestMapping(produces = MediaType.APPLICATION_JSON_VALUE)
30+
class GreetingController {
31+
32+
@ResponseBody
33+
@RequestMapping("/greeting1")
34+
String greeting1() {
35+
return "OK";
36+
}
37+
38+
@ResponseBody
39+
@RequestMapping("/greeting2")
40+
ResponseEntity<String> greeting2() {
41+
return new ResponseEntity("OK", HttpStatus.OK);
42+
}
43+
44+
@ResponseBody
45+
@RequestMapping("/greeting3")
46+
ResponseEntity<Map<String, Object>> greeting3() {
47+
Map<String, Object> map = new HashMap<>(); map.put("key", "value");
48+
return new ResponseEntity(map, HttpStatus.OK);
49+
}
50+
51+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package org.springframework.issues.config;
2+
3+
import org.springframework.context.annotation.Bean;
4+
import org.springframework.context.annotation.ComponentScan;
5+
import org.springframework.context.annotation.Configuration;
6+
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
7+
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
8+
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
9+
import org.springframework.web.servlet.view.InternalResourceViewResolver;
10+
11+
@EnableWebMvc
12+
@ComponentScan(basePackages="org.springframework.issues")
13+
@Configuration
14+
public class WebConfig extends WebMvcConfigurerAdapter {
15+
16+
@Override
17+
public void addViewControllers(ViewControllerRegistry registry) {
18+
registry.addViewController("/").setViewName("home");
19+
}
20+
21+
@Bean
22+
public InternalResourceViewResolver viewResolver() {
23+
InternalResourceViewResolver viewResolver = new InternalResourceViewResolver();
24+
viewResolver.setPrefix("/WEB-INF/views/");
25+
viewResolver.setSuffix(".jsp");
26+
return viewResolver;
27+
}
28+
29+
}
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

0 commit comments

Comments
 (0)