Solution for no effect when integrating Spring3 MVC with Tiles 2.2.1

by kpkmd54461 on 2012-02-25 10:08:52

The Spring MVC project built with STS 2.6 has the following configuration added in the `pom.xml`:

```xml

org.apache.tiles

tiles-extras

2.2.1

```

In the `applicationContext.xml`, the following configuration is added:

```xml

/WEB-INF/tiles.xml

```

A new file named `tiles.xml` is created under `/WEB-INF/` with appropriate content, and all the necessary JSP files are present.

After deploying to Tomcat 6.0.29, when accessing `http://localhost:8080/springmvctiles/contact` in the browser, the result appears as if Tiles 2 integration did not work properly. Only `contact.jsp` is displayed, along with an error of type `org.springframework.core.ConstantException`. The other pages are not rendered. What could be the issue? The project uses Spring 3.0.5 and Tiles 2.2.1.

---

### Possible Solution

This problem might occur due to one or more of the following reasons:

1. **Incorrect Configuration in `tiles.xml`:**

Ensure that the `tiles.xml` file is correctly configured. It should define layouts and views properly. For example:

```xml

```

2. **Tiles Resolver Not Configured Properly:**

Verify that the `TilesViewResolver` bean is correctly defined in the Spring configuration file (e.g., `applicationContext.xml`). It should look like this:

```xml

```

3. **Jar File Compatibility Issues:**

Ensure there are no conflicts between the versions of Spring (3.0.5) and Tiles (2.2.1). Sometimes, mismatched versions can cause runtime issues. Check the dependency tree using Maven's `dependency:tree` command to ensure no conflicting versions exist.

4. **Controller Mapping Issue:**

Confirm that the controller mapping for `/contact` returns the correct view name (`contact`) that matches the definition in `tiles.xml`.

Example Controller Code:

```java

@Controller

public class ContactController {

@RequestMapping("/contact")

public String showContactPage() {

return "contact"; // This should match the name in tiles.xml

}

}

```

5. **Tomcat Classloader Issues:**

If you have multiple versions of the same library in your application or Tomcat's `lib` folder, it might lead to classloading conflicts. Ensure that only the required versions of libraries are present.

6. **Error Handling:**

The `org.springframework.core.ConstantException` suggests that there might be a constant-related issue in your code or configuration. Double-check any constants used in your controllers or configurations.

---

### Additional References

For further troubleshooting, consider the following resources:

- **File.delete() not working:** [Link](http://www.myexception.cn/java-web/43660.html)

- **JTable image display issue:** Why does clicking on an image in a JTable make it blank? [Solution](#)

- **Reducing JS method parameters:** Techniques to minimize the number of parameters in JavaScript functions. [Solution](#)

- **Blocking Servlet Threads:** How to pause servlet threads and delay client response. [Solution](#)

By carefully reviewing the above points, you should be able to identify and resolve the issue with Tiles integration in your Spring MVC project.