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

Add repro project for SPR-16461 #175

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions SPR-16461/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
## Spring MVC project with Java config

This is a simple template for creating issue reproduction projects per
the [README in the root of this repository](https://github.com/spring-projects/spring-framework-issues#readme).
Please review that document before starting.

As described at the link above, do not edit this project directly! Rather
use the `./create-repro-project.sh` script to create a fresh copy to
a new directory having the same name as the JIRA issue you're trying
to reproduce and edit from there.

## Deploying

It is possible to deploy your application directly from the command-line
using maven. See the next two sections on Cargo and Jetty.

### Cargo

You can deploy with the [Cargo Maven plugin](http://cargo.codehaus.org/) which
supports a wide [range of servers](http://cargo.codehaus.org/Containers).
The required command is `mvn package cargo:run`.

By default Cargo is configured to start with `Tomcat 8` but you can easily
edit the plugin settings in `pom.xml` to switch to a different server
and version. The pom.xml or to switch to debug settings.

### Jetty

You can also deploy with the
[Jetty Maven plugin](http://www.eclipse.org/jetty/documentation/current/jetty-maven-plugin.html).
The required command is `mvn jetty:run` or `mvnDebug jetty:run`.

## Logging

This project contains a `log4j.properties` file in `src/main/resources` that you
may wish to configure to emit more detailed logging. The root logger is set to
`INFO` and a custom `org.springframework.web` logger is set to `DEBUG`.
268 changes: 268 additions & 0 deletions SPR-16461/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,268 @@
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.springframework.issues</groupId>
<artifactId>SPR-16461</artifactId>
<version>1.0-SNAPSHOT</version>
<name>Spring MVC Issue Reproduction Project</name>
<packaging>war</packaging>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.6</java.version>
<spring.version>4.3.5.RELEASE</spring.version>
<slf4j.version>1.7.22</slf4j.version>
<tomcat.version>8.5.9</tomcat.version>
</properties>

<dependencies>
<!-- Spring Framework -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${spring.version}</version>
<exclusions>
<!-- Exclude Commons Logging in favor of SLF4j -->
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${spring.version}</version>
</dependency>

<!-- Logging -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
<version>${slf4j.version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>${slf4j.version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
<scope>runtime</scope>
</dependency>

<!-- Servlet API -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
<scope>provided</scope>
</dependency>

<!-- JSP API and JSTL
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>jsp-api</artifactId>
<version>2.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
-->

<!-- Apache Tiles
<dependency>
<groupId>org.apache.tiles</groupId>
<artifactId>tiles-jsp</artifactId>
<version>2.1.3</version>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging-api</artifactId>
</exclusion>
</exclusions>
</dependency>
-->

<!-- JSR 303 with Hibernate Validator
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>1.0.0.GA</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>4.1.0.Final</version>
</dependency>
-->

<!-- Joda Time Library
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>1.6.2</version>
</dependency>
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time-jsptags</artifactId>
<version>1.0.2</version>
<scope>runtime</scope>
</dependency>
-->

<!-- Apache Commons File Upload
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>1.2.2</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.0.1</version>
</dependency>
-->

<!-- Jackson JSON Processor
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.6.2</version>
</dependency>
-->

<!-- Google GSON -->
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.6</version>
</dependency>

<!-- Rome Atom+RSS
<dependency>
<groupId>rome</groupId>
<artifactId>rome</artifactId>
<version>1.0</version>
</dependency>
-->

<!-- Test -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.5.1</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.8</version>
<executions>
<execution>
<id>install</id>
<phase>install</phase>
<goals>
<goal>sources</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-eclipse-plugin</artifactId>
<version>2.8</version>
<configuration>
<downloadSources>true</downloadSources>
<downloadJavadocs>false</downloadJavadocs>
<wtpversion>2.0</wtpversion>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.12.4</version>
<configuration>
<includes>
<include>**/*Tests.java</include>
<include>**/*Test.java</include>
</includes>
<excludes>
<exclude>**/*Abstract*.java</exclude>
</excludes>
</configuration>
</plugin>
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>9.3.3.v20150827</version>
</plugin>
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<version>1.6.2</version>
<configuration>
<configuration>
<properties>
<cargo.servlet.port>8080</cargo.servlet.port>
<cargo.logging>medium</cargo.logging>
<cargo.jvmargs>-Xms96m -Xmx512m -Djava.awt.headless=true</cargo.jvmargs>
<!--
<cargo.jvmargs>
-Xdebug
-Xrunjdwp:transport=dt_socket,address=8000,suspend=n,server=y
-Xnoagent
-Djava.compiler=NONE
</cargo.jvmargs>
-->
</properties>
</configuration>
<container>
<containerId>tomcat8x</containerId>
<zipUrlInstaller>
<url>http://archive.apache.org/dist/tomcat/tomcat-8/v${tomcat.version}/bin/apache-tomcat-${tomcat.version}.zip</url>
</zipUrlInstaller>
</container>
</configuration>
</plugin>
</plugins>
</build>

<repositories>
<repository>
<id>spring-maven-snapshot</id>
<name>Springframework Maven Snapshot Repository</name>
<url>http://repo.spring.io/snapshot</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>

</project>

Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package org.springframework.issues;

import org.springframework.issues.model.Animal;
import org.springframework.issues.model.Cat;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import static org.springframework.web.bind.annotation.RequestMethod.GET;

@RestController
public class AnimalController
{
private final Cat bizzy = new Cat("Bizzy", 10);

@RequestMapping(method = GET, value = "/animal")
public Animal getAnimal()
{
return bizzy;
}

@RequestMapping(method = GET, value = "/cat")
public Cat getCat()
{
return bizzy;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package org.springframework.issues.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
import org.springframework.web.servlet.view.InternalResourceViewResolver;

@EnableWebMvc
@ComponentScan(basePackages="org.springframework.issues")
@Configuration
public class WebConfig extends WebMvcConfigurerAdapter {

@Override
public void addViewControllers(ViewControllerRegistry registry) {
registry.addViewController("/").setViewName("home");
}

@Bean
public InternalResourceViewResolver viewResolver() {
InternalResourceViewResolver viewResolver = new InternalResourceViewResolver();
viewResolver.setPrefix("/WEB-INF/views/");
viewResolver.setSuffix(".jsp");
return viewResolver;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package org.springframework.issues.model;

public class Animal
{
private final String name;

public Animal(String name)
{
this.name = name;
}

public String getName()
{
return name;
}
}
17 changes: 17 additions & 0 deletions SPR-16461/src/main/java/org/springframework/issues/model/Cat.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package org.springframework.issues.model;

public class Cat extends Animal
{
private final int whiskers;

public Cat(String name, int whiskers)
{
super(name);
this.whiskers = whiskers;
}

public int getWhiskers()
{
return whiskers;
}
}
Loading