You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tiles.apache.org by Pistis Valentino <va...@gmail.com> on 2011/07/27 16:47:39 UTC

(Struts1 + Struts2.2.3) + Tiles2.0.6

Hi all,

I'm newbbie in Struts frameworks.
I integrate Struts1 with Struts2, at the moment only 1 page uses
Struts2 and the rest of the web app still using Struts2.
At this points it's ok...
but...
now I want to use tiles2 for the unique page that uses struts2, so I
read this tutorial:
http://www.vaannila.com/struts-2/struts-2-example/struts-2-tiles-example-1.html
and many others, but I have persistently this error:

======================================
Struts Problem Report

Struts has detected an unhandled exception:

Messages:
javax.servlet.jsp.JspException: Error executing tag: Attribute
'header' not found.
File: org/apache/jasper/servlet/JspServletWrapper.java
Line number: 460
________________________________

Stacktraces

org.apache.jasper.JasperException: javax.servlet.jsp.JspException:
Error executing tag: Attribute 'header' not found.

    org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:460)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:355)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:321)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:257)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
    org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
    org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
    org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:659)
    org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:457)
    org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:395)
    org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:311)
    org.apache.struts2.dispatcher.ServletDispatcherResult.doExecute(ServletDispatcherResult.java:157)
    org.apache.struts2.dispatcher.StrutsResultSupport.execute(StrutsResultSupport.java:186)
    com.opensymphony.xwork2.DefaultActionInvocation.executeResult(DefaultActionInvocation.java:373)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:277)
    com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:176)
    com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:263)
    org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:68)
    com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:133)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:207)
    com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:207)
    com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:190)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    org.apache.struts2.interceptor.MultiselectInterceptor.intercept(MultiselectInterceptor.java:75)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:94)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:243)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:100)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:141)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:270)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:145)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:171)
    com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:176)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:190)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:187)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:52)
    org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:498)
    org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)
    org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:91)
    org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)
    org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
    org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
    org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:172)
    org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:558)
    org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
    org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
    org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
    org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:174)
    org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:873)
    org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
    org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
    org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
    org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689)
    java.lang.Thread.run(Unknown Source)

=========================================

I read so many posts, emails, tutorials, etc... but nothing resolve my
problem....
Where I'm wrong??

This are my files...

tiles.xml:

========================================
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE tiles-definitions PUBLIC
"-//Apache Software Foundation//DTD Tiles Configuration 2.0//EN"
"http://tiles.apache.org/dtds/tiles-config_2_0.dtd">

<tiles-definitions>
	<definition name="aboutPage2" template="/pages/struts2/aboutPage2.jsp">
		<put-attribute name="title" value="Template" />
		<put-attribute name="header" value="/pages/struts2/header.jsp" />
		<put-attribute name="body" value="/pages/struts2/body.jsp" />
		<put-attribute name="footer" value="/pages/struts2/footer.jsp" />
	</definition>
<!-- 	<definition name="welcome" extends="baseLayout"> -->
<!-- 		<put-attribute name="title" value="Welcome" /> -->
<!-- 		<put-attribute name="body" value="/pages/welcome.jsp" /> -->
<!-- 	</definition> -->
<!-- 	<definition name="friends" extends="baseLayout"> -->
<!-- 		<put-attribute name="title" value="Friends" /> -->
<!-- 		<put-attribute name="body" value="/pages/friends.jsp" /> -->
<!-- 	</definition> -->
<!-- 	<definition name="office" extends="baseLayout"> -->
<!-- 		<put-attribute name="title" value="Office" /> -->
<!-- 		<put-attribute name="body" value="/pages/office.jsp" /> -->
<!-- 	</definition> -->
</tiles-definitions>
==========================================

part of web.xml, the rest is for struts1:

=========================================
<!-- Struts2 -->

	<context-param>
		<param-name>
			org.apache.tiles.definition.DefinitionsFactory.DEFINITIONS_CONFIG</param-name>
	<!-- org.apache.tiles.impl.BasicTilesContainer.DEFINITIONS_CONFIG
deprecata! -->
		<param-value>/pages/struts2/tiles.xml</param-value>
	</context-param>
	<!-- <listener> -->
	<!-- <listener-class>org.apache.struts2.tiles.StrutsTilesListener
</listener-class> -->
	<!-- </listener> -->

	<listener>
		<listener-class>
			org.apache.tiles.web.startup.TilesListener
		</listener-class>
	</listener>


	<filter>
		<filter-name>struts2</filter-name>
		<filter-class>
			<!-- org.apache.struts2.dispatcher.FilterDispatcher -->
			org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
		</filter-class>
	</filter>

	<filter-mapping>
		<filter-name>struts2</filter-name>
		<url-pattern>*.action</url-pattern>
	</filter-mapping>
	<filter-mapping>
		<filter-name>struts2</filter-name>
		<url-pattern>/struts/*</url-pattern>
	</filter-mapping>
===========================================

struts.xml:

===========================================
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
	"-//Apache Software Foundation//DTD Struts Configuration 2.1.7//EN"
	"http://struts.apache.org/dtds/struts-2.1.7.dtd">


<struts>

	
	<constant name="struts.enable.DynamicMethodInvocation" value="false" />
	<constant name="struts.devMode" value="true" />
	<constant name="struts.i18n.reload" value="true"></constant>
	<constant name="struts.devMode" value="true"></constant>
	<constant name="struts.configuration.xml.reload" value="true"></constant>
	<constant name="struts.url.http.port" value="8080"></constant>
	<constant name="struts.serve.static" value="true"></constant>
	<constant name="struts.serve.static.browserCache" value="false"></constant>
	<!-- __________________________________________________________________________________________
-->
	<include file="struts-default.xml"></include>

	
	<constant name="struts.enable.DynamicMethodInvocation" value="false" />
	<!-- <constant name="struts.devMode" value="false" /> -->
	<constant name="struts.convention.result.path" value="/pages" />
	<constant name="struts.convention.action.packages"
value="it.dom.app.struts2" />
	<!-- <constant name="struts.custom.i18n.resources" value="messages" /> -->
	<constant name="struts.convention.classes.reload" value="true" />
	<constant name="struts.convention.action.disableJarScanning"
		value="true"></constant>
	<!-- <constant name="struts.convention.package.locators.basePackage"
value="it.dom.app.struts2"></constant> -->
	<!-- <constant name="struts.convention.default.parent.package"
value="struts2"></constant> -->
	<constant name="struts.convention.exclude.packages"
		value="org.apache.struts.*, org.apache.struts2.*,
org.springframework.web.struts.*, org.springframework.web.struts2.*,
org.hibernate.*"></constant>
	<constant name="struts.convention.package.locators" value="struts2"></constant>


	<package name="app" namespace="/protected" extends="struts-default">
		
		<!-- <action name="about2" class="it.dom.app.struts2.AboutPage2Action"> -->
		<!-- <result name="success">/pages/struts2/aboutPage2.jsp</result> -->
		<!-- <result name="error">/error.jsp</result> -->
		<!-- <result name="input">/error.jsp</result> -->
		<!-- <interceptor-ref name="paramsPrepareParamsStack" /> -->
		<!-- <result type="stream"> -->
		<!-- <param name="contentType">text/html</param> -->
		<!-- <param name="inputName">inputStream</param> -->
		<!-- </result> -->
		<!-- </action> -->

		<!-- Add actions here -->
	</package>

	<!-- Add packages here -->

</struts>
===========================================

aboutPage2.jsp:

===========================================
<%@ taglib
	uri="http://tiles.apache.org/tags-tiles"
	prefix="tiles"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta
	http-equiv="Content-Type"
	content="text/html; charset=UTF-8">
<title><tiles:insertAttribute
		name="title"
		ignore="true" ></tiles:insertAttribute></title>
</head>
<body>
	<table
		border="1"
		cellpadding="2"
		cellspacing="2"
		align="center">
		<tr>
			<td
				height="30"
				colspan="2"><tiles:insertAttribute name="header"
></tiles:insertAttribute></td>
		</tr>
		<tr>
			<td width="350"><tiles:insertAttribute name="body"
></tiles:insertAttribute></td>
		</tr>
		<tr>
			<td
				height="30"
				colspan="2"><tiles:insertAttribute name="footer"
></tiles:insertAttribute></td>
		</tr>
	</table>
</body>
</html>
=============================

The other jsp's are standard html...
The libs are the standard dependencies included for Struts2.2.3 (tiles
libs included) plus the others for struts1...

If possible help me, please...

Tx in advance
Ciao
Vale

Re: (Struts1 + Struts2.2.3) + Tiles2.0.6

Posted by Antonio Petrelli <an...@gmail.com>.
2011/7/27 Pistis Valentino <va...@gmail.com>

> I'm newbbie in Struts frameworks.
> I integrate Struts1 with Struts2, at the moment only 1 page uses
> Struts2 and the rest of the web app still using Struts2.
> At this points it's ok...
> but...
> now I want to use tiles2 for the unique page that uses struts2, so I
> read this tutorial:
>
> http://www.vaannila.com/struts-2/struts-2-example/struts-2-tiles-example-1.html
> and many others, but I have persistently this error:
>
> ======================================
> Struts Problem Report
>
> Struts has detected an unhandled exception:
>
> Messages:
> javax.servlet.jsp.JspException: Error executing tag: Attribute
> 'header' not found.
>

How are you invoking the "aboutPage2" definition? I don't see any action at
all in your struts.xml, nor a result type for Tiles.

Antonio

Re: (Struts1 + Struts2.2.3) + Tiles2.0.6

Posted by Pistis Valentino <va...@gmail.com>.
:)
don't worry, i perfectly understand... :) that you don't say RTFM to me.
I want to say that i must study better for better understand the Struts2
world...

My mistake was banal...from newbbie :)

========================================================
Italian Translation

Tranquillo, ho cpaito perfettamente, non pensavo tu mi stessi dicendo RTFM.
Io volevo dire che devo studiare meglio Struts2 per capire meglio e
ovviamente per imparare ad usarlo.

Il mio errore era molto banale...da newbbie :)
========================================================

Thanks a lot!

Ciao
Valentino

2011/7/29 Antonio Petrelli <an...@gmail.com>

> 2011/7/29 Pistis Valentino <va...@gmail.com>
>
> > Ooops!....
> > I'm very very sorry...but i'm very new using this programming
> paradigms...
> > I must study better Struts2, and Tiles2 ....
> >
> > Many many thanks...
> >
>
> No wait, I did not mean to say RTFM or something like that. A mistake that
> appears obvious to me (one of Tiles developes) might not seem obvious to
> another (a simple Tiles user), so don't worry :-)
>
> Antonio
>

Re: (Struts1 + Struts2.2.3) + Tiles2.0.6

Posted by Antonio Petrelli <an...@gmail.com>.
2011/7/29 Pistis Valentino <va...@gmail.com>

> Ooops!....
> I'm very very sorry...but i'm very new using this programming paradigms...
> I must study better Struts2, and Tiles2 ....
>
> Many many thanks...
>

No wait, I did not mean to say RTFM or something like that. A mistake that
appears obvious to me (one of Tiles developes) might not seem obvious to
another (a simple Tiles user), so don't worry :-)

Antonio

Re: (Struts1 + Struts2.2.3) + Tiles2.0.6

Posted by Pistis Valentino <va...@gmail.com>.
Ooops!....
I'm very very sorry...but i'm very new using this programming paradigms...
I must study better Struts2, and Tiles2 ....

Many many thanks...

Ciao
Valentino


2011/7/28 Antonio Petrelli <an...@gmail.com>

> 2011/7/28 Pistis Valentino <va...@gmail.com>
>
> > @Action(value = "/protected/about2", results = {
> > @Result(location = "/pages/struts2/aboutPage2.jsp", name = "success")
> > })
> >
>
> You are invoking JSP template page without the intervention of Tiles. Sorry
> but the exception says it all.
>
> Antonio
>

Re: (Struts1 + Struts2.2.3) + Tiles2.0.6

Posted by Antonio Petrelli <an...@gmail.com>.
2011/7/28 Pistis Valentino <va...@gmail.com>

> @Action(value = "/protected/about2", results = {
> @Result(location = "/pages/struts2/aboutPage2.jsp", name = "success")
> })
>

You are invoking JSP template page without the intervention of Tiles. Sorry
but the exception says it all.

Antonio

Re: (Struts1 + Struts2.2.3) + Tiles2.0.6

Posted by Pistis Valentino <va...@gmail.com>.
2011/7/27 Pistis Valentino <va...@gmail.com>

> I'm newbbie in Struts frameworks.
> I integrate Struts1 with Struts2, at the moment only 1 page uses
> Struts2 and the rest of the web app still using Struts2.
> At this points it's ok...
> but...
> now I want to use tiles2 for the unique page that uses struts2, so I
> read this tutorial:
>
>
http://www.vaannila.com/struts-2/struts-2-example/struts-2-tiles-example-1.html
> and many others, but I have persistently this error:
>
> ======================================
> Struts Problem Report
>
> Struts has detected an unhandled exception:
>
> Messages:
> javax.servlet.jsp.JspException: Error executing tag: Attribute
> 'header' not found.
>

How are you invoking the "aboutPage2" definition? I don't see any action at
all in your struts.xml, nor a result type for Tiles.


Antonio

Ciao Antonio,

thank you for the response, only today i'm subscribed to the maillist...and
i read the response fortunately viewing the archive mail list...

For invoking the action I used a Convention Plugin for Struts2, i use the
tags into the action.
And I'm sure, before using tiles, the aboutPage2 without using tiles it's
ok, and the jsp was writing entirely into 1 page jsp without any other
"tile", except javascript and css.

This is the code for the action with convention plugin tags:

-----------------------------------------------------------------
package it.dom.app.struts2;

import it.dom.app.businessObjects.base.HibernateSession;

import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.SQLException;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Result;
import org.hibernate.Session;
import org.hibernate.cfg.Settings;
import org.hibernate.connection.ConnectionProvider;
import org.hibernate.engine.SessionFactoryImplementor;

import com.opensymphony.xwork2.ActionSupport;

//@ParentPackage(value = "struts2")
public class AboutPage2Action extends ActionSupport {

/**
* A generated Serial Version ID
*/
 private static final long serialVersionUID = 1L;
private static final Log log = LogFactory.getLog(AboutPage2Action.class);

Session hibSession = HibernateSession.currentSession();

// Per recuperare il nome del database
final SessionFactoryImplementor sessionFactoryImplementor =
(SessionFactoryImplementor) hibSession
.getSessionFactory();

final Settings settings = sessionFactoryImplementor.getSettings();

ConnectionProvider connectionProvider = settings.getConnectionProvider();

Connection connection = null;
DatabaseMetaData databaseMetaData = null;
String dbUserName = null;
String dbVersion = null;
String dbDriverName = null;
String dbDriverVersion = null;

/**
* Il metodo execute e' molto piu' semplice rispetto a Struts, inoltre non
* e' necesario usare un ActionForm per il passaggio dei dati.
*/
@Action(value = "/protected/about2", results = {
@Result(location = "/pages/struts2/aboutPage2.jsp", name = "success")
})
public String execute() {

try {
connection = connectionProvider.getConnection();
databaseMetaData = connection.getMetaData();
dbUserName = databaseMetaData.getUserName();
dbVersion = databaseMetaData.getDatabaseProductVersion();
dbDriverName = databaseMetaData.getDriverName();
dbDriverVersion = databaseMetaData.getDriverVersion();

connection.close();
log.info("Ho appena letto i dati e chiuso la connessione!");
addActionMessage("Ho appena letto i dati e chiuso la connessione!");

return SUCCESS;
} catch (SQLException e) {
log.error("Attenzione!! Problemi con la lettura dei dati dal DB per
AboutPage2!", e);
addActionError("Attenzione!! Problemi con la lettura dei dati dal DB per
AboutPage2!");
return ERROR;
} finally {
HibernateSession.closeSession();
}

}

public String getDbUserName() {
return dbUserName;
}

public void setDbUserName(String dbUserName) {
this.dbUserName = dbUserName;
}

public String getDbVersion() {
return dbVersion;
}

public void setDbVersion(String dbVersion) {
this.dbVersion = dbVersion;
}

public String getDbDriverName() {
return dbDriverName;
}

public void setDbDriverName(String dbDriverName) {
this.dbDriverName = dbDriverName;
}

public String getDbDriverVersion() {
return dbDriverVersion;
}

public void setDbDriverVersion(String dbDriverVersion) {
this.dbDriverVersion = dbDriverVersion;
}
}
--------------------------------------------------------------------------------------

If I'm wrong, please, help me... :)

Thanx a lot!! (Grazie mille!!)