0

While upgrading our application from struts 2.3 to 2.5, we are getting the following error.

package org.apache.tiles.request does not exist

This is the code we have modified for the executed method.

    package com.myeg.ins.web.control.helper;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import org.apache.struts2.ServletActionContext;
import org.apache.tiles.Attribute;
import org.apache.tiles.AttributeContext;
import org.apache.tiles.TilesContainer;
import org.apache.tiles.access.TilesAccess;
import org.apache.tiles.context.TilesRequestContextHolder;
import org.apache.tiles.preparer.PreparerException;
import org.apache.tiles.preparer.ViewPreparer;
import org.apache.tiles.request.Request;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class MenuPreparer implements ViewPreparer 
{
    HttpServletRequest request = ServletActionContext.getRequest();
    HttpSession session = request.getSession();
    protected Logger logger = LoggerFactory.getLogger(this.getClass());
    TilesContainer tileContainer = TilesAccess.getCurrentContainer((Request) request);
    /*-----previous code while using tiles 2.0
    public void execute(TilesRequestContext tilesContext, AttributeContext attributeContext) throws PreparerException 
    {
        String ins=(String)session.getAttribute("insComp");
        logger.info("In Preparer Ins company is::::::"+ins);
        attributeContext.putAttribute("breadcrumbshead", new Attribute(ins));

    }*/
    @Override
    public void execute(Request tileContainer, AttributeContext attributeContext) {
        // TODO Auto-generated method stub

        String ins=(String)session.getAttribute("insComp");
        logger.info("In Preparer Ins company is::::::"+ins);
        attributeContext.putAttribute("breadcrumbshead", new Attribute(ins));
    }
}
Aleksandr M
  • 24,264
  • 12
  • 69
  • 143
raju
  • 1
  • 2
  • Welcome to StackOverflow. Try to make the title of the question as clear as possible, for example starting with the technology you are using and then what the problem is. If I were you I would also write first a line explaing what is the error or the code below, instead of placing first the code followed by a comment explaining what is what we just read. – Ignacio Alorre Aug 15 '17 at 10:26

1 Answers1

0

I have never worked with Apache Tile, but since the error is:

package org.apache.tiles.request does not exist

And since it happened after the update you mentioned. It seems to me you should add a new version for org.apache.tiles.request.

If you are using maven to build your app, you should change in the pom.xml the depency to this one:

<dependency>
  <groupId>org.apache.struts</groupId>
  <artifactId>struts2-tiles3-plugin</artifactId>
  <version>${version.tiles}</version>
  <scope>compile</scope>
</dependency>

You can read more about this in the following link:

https://struts.apache.org/docs/tiles-3-plugin.html

Ignacio Alorre
  • 7,307
  • 8
  • 57
  • 94