struts 2 and jasper reports integration - struts2

I want to integrate jasper report to my struts 2 application.
But I am getting this exception:
java.lang.NullPointerException
net.sf.jasperreports.engine.fill.JRFiller.fillReport(JRFiller.java:89)
net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:601)
org.apache.struts2.views.jasperreports.JasperReportsResult.doExecute(JasperReportsResult.java:325)
org.apache.struts2.dispatcher.StrutsResultSupport.execute(StrutsResultSupport.java:186)
com.opensymphony.xwork2.DefaultActionInvocation.executeResult(DefaultActionInvocation.java:371)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:275)
org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:256)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:167)
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:265)
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:246)
com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:138)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:239)
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:239)
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:191)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
org.apache.struts2.interceptor.MultiselectInterceptor.intercept(MultiselectInterceptor.java:73)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:91)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:252)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:100)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:141)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:145)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
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:246)
com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:161)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:193)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:189)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
interceptor.LoginInterceptor.intercept(LoginInterceptor.java:40)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:54)
org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:563)
org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:99)
jars I have added:
struts 2 core 2.3.15
jasper reports 3.1.2
commons lang 3.2
commons digester 1.7
commons beanutils 1.7.0
commons collections 2.1
common logging 1.0
struts2 jasper report plugin 2.3.15
joda time 2.1.0
Here is report file.
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd"
pageWidth="595" pageHeight="842" columnWidth="555"
leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20"
name="our_jasper_template">
<property name="ireport.zoom" value="1.0" />
<property name="ireport.x" value="0" />
<property name="ireport.y" value="0" />
<field name="customerName" class="java.lang.String"/>
<field name="customerId" class="java.lang.String"/>
<background>
<band splitType="Stretch"/>
</background>
<title>
<band height="79" >
</band>
</title>
<pageHeader>
<band height="50">
<staticText>
<reportElement mode="Opaque" x="0" y="0" width="552"
height="35" backcolor="#CCCCCC" />
<textElement textAlignment="Center">
<font size="26" />
</textElement>
<text><![CDATA[user Report]]></text>
</staticText>
</band>
</pageHeader>
<columnHeader>
<band/>
</columnHeader>
<detail>
<band height="20">
<textField>
<reportElement x="0" y="0" width="100" height="20"/>
<textFieldExpression><![CDATA[$F{customerName}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="100" y="0" width="100" height="20"/>
<textFieldExpression><![CDATA[$F{customerId}]]></textFieldExpression>
</textField>
</band>
</detail>
<columnFooter>
<band/>
</columnFooter>
<pageFooter>
<band height="15">
<staticText>
<reportElement x="0" y="0" width="40" height="15"/>
<textElement/>
<text><![CDATA[Page:]]></text>
</staticText>
<textField>
<reportElement x="40" y="0" width="100" height="15"/>
<textElement/>
<textFieldExpression class="java.lang.Integer"><![CDATA[$V{PAGE_NUMBER}]]></textFieldExpression>
</textField>
</band>
</pageFooter>
<summary>
<band/>
</summary>
</jasperReport>
Action class
public class TestJasperAction extends ActionSupport {
List<PolicyBean> beanCollection=new ArrayList();
#Override
public String execute() {
ResultSet rs = PolicyDao.getPolicyRsTest();
try {
while (rs.next()) {
PolicyBean p = new PolicyBean();
p.setCustomerName(rs.getString("customer_first_name") + " " + rs.getString("customer_last_name"));
p.setCustomerId(rs.getString("customer_no"));
beanCollection.add(p);
}
} catch (SQLException ex) {
Logger.getLogger(TestJasperAction.class.getName()).log(Level.SEVERE, null, ex);
}
System.out.println("Bean size:"+beanCollection.size());
return SUCCESS;
}
public List<PolicyBean> getBeanCollection() {
return beanCollection;
}
public void setBeanCollection(List<PolicyBean> beanCollection) {
this.beanCollection = beanCollection;
}
}
struts.xml
<action name="JasperTesting" class="action.TestJasperAction">
<result name="success" type="jasper">
<param name="location">/iacms/jaspers/our_jasper_template.jasper</param>
<param name="dataSource">beanCollection</param>
<param name="format">PDF</param>
</result>
JSP code:
<div class="form-group row" style="margin-left: 250px">
<s:form action="JasperTesting">
<s:submit cssClass="btn btn-success" value="Generate Report"/>
</s:form>
</div>
Any help or direction will be much appreciated.

Related

Unable to manually set the intervals for Y axis

I have a HTML5 column chart in my jasper report. I need to configure the y axis and be able to set the intervals manually
I have used,
<property name="net.sf.jasperreports.chart.range.axis.tick.count" value="false"/>
<property name="net.sf.jasperreports.chart.range.axis.tick.interval" value="2"/>
It has no effect on the chart
The source code is as follows
<?xml version="1.0" encoding="UTF-8"?>
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="customizechart" pageWidth="1000" pageHeight="1000" columnWidth="960" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="23a00417-b19d-4f98-aa59-dc6422d51386">
<property name="net.sf.jasperreports.chart.range.axis.tick.count" value="false"/>
<property name="net.sf.jasperreports.chart.range.axis.tick.interval" value="2"/>
<queryString>
<![CDATA[Select * from some_table]]>
</queryString>
<field name="Name" class="java.lang.String"/>
<field name="AppliedQuantity" class="java.lang.Float"/>
<summary>
<band height="959" splitType="Stretch">
<componentElement>
<reportElement x="0" y="0" width="960" height="500" uuid="774dd6b9-b5b9-4d3c-b518-6f7c7ca40043"/>
<hc:chart xmlns:hc="http://jaspersoft.com/highcharts" xsi:schemaLocation="http://jaspersoft.com/highcharts http://jaspersoft.com/schema/highcharts.xsd" type="Column">
<hc:chartSetting name="default">
<hc:chartProperty name="chart.zoomType">
<hc:propertyExpression><![CDATA["xy"]]></hc:propertyExpression>
</hc:chartProperty>
<hc:chartProperty name="credits.enabled">
<hc:propertyExpression><![CDATA[false]]></hc:propertyExpression>
</hc:chartProperty>
<hc:chartProperty name="credits.href">
<hc:propertyExpression><![CDATA[""]]></hc:propertyExpression>
</hc:chartProperty>
<hc:chartProperty name="credits.text">
<hc:propertyExpression><![CDATA[""]]></hc:propertyExpression>
</hc:chartProperty>
<hc:chartProperty name="title.text">
<hc:propertyExpression><![CDATA[""]]></hc:propertyExpression>
</hc:chartProperty>
<hc:chartProperty name="yAxis.title.text">
<hc:propertyExpression><![CDATA[""]]></hc:propertyExpression>
</hc:chartProperty>
</hc:chartSetting>
<multiAxisData>
<multiAxisDataset/>
<dataAxis axis="Rows">
<axisLevel name="Name">
<labelExpression><![CDATA["Level Label expression"]]></labelExpression>
<axisLevelBucket class="java.lang.String">
<bucketExpression><![CDATA[$F{Name}]]></bucketExpression>
</axisLevelBucket>
</axisLevel>
</dataAxis>
<dataAxis axis="Columns"/>
<multiAxisMeasure name="Measure1" class="java.lang.Integer" calculation="Nothing">
<labelExpression><![CDATA["f"]]></labelExpression>
<valueExpression><![CDATA[$F{AppliedQuantity}]]></valueExpression>
</multiAxisMeasure>
</multiAxisData>
<hc:series name="Measure1"/>
</hc:chart>
</componentElement>
</band>
</summary>
</jasperReport>
Any ideas on this?
net.sf.jasperreports.chart.* properties apply to the charts built into the community/open source JasperReports library (which are based on JFreeChart).
For HTML5 charts - part of JasperReports Professional - what you have to do is set the yAxis.tickInterval property in the chart:
<hc:chartProperty name="yAxis.tickInterval">
<hc:propertyExpression><![CDATA[500]]></hc:propertyExpression>
</hc:chartProperty>

jasper report how to print data as per users time zone

Could someone please help me out on printing data as per user timezone. We have a scenario where the user will pass the timezone and based upon that the value should return. I found the way to modify the date parameters as per user passed time zone and get the result from database. But after that how should I write the data in there time zone. Do I need to convert individual date columns to be printed on there time zone or any other way is there to convert once as per there time zone and print all values.
Let me tell you we trying to implement this on existing reports, so we are looking for a process for least changes.
Please find the source code for a sample report.
<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.2.0.final using JasperReports Library version 6.2.0 -->
<!-- 2017-02-27T18:40:31 -->
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="TimeZoneQuery" pageWidth="842" pageHeight="595" orientation="Landscape" whenNoDataType="NoDataSection" columnWidth="842" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0" isIgnorePagination="true" uuid="6af36fbc-520f-436a-a8b5-1510d55e7474">
<property name="ireport.zoom" value="1.0"/>
<property name="ireport.x" value="0"/>
<property name="ireport.y" value="0"/>
<property name="com.jaspersoft.studio.data.sql.tables" value=""/>
<style name="column header" mode="Opaque" forecolor="#000000" backcolor="#D2D2D2" fill="Solid" vTextAlign="Middle" vImageAlign="Middle" fontName="Tahoma" fontSize="11" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false">
<box>
<topPen lineWidth="0.25" lineStyle="Solid" lineColor="#979991"/>
<leftPen lineWidth="0.25" lineStyle="Solid" lineColor="#979991"/>
<bottomPen lineWidth="0.25" lineStyle="Solid" lineColor="#979991"/>
<rightPen lineWidth="0.25" lineStyle="Solid" lineColor="#979991"/>
</box>
</style>
<style name="detail" forecolor="#000000" fill="Solid" vTextAlign="Middle" vImageAlign="Middle" fontName="Tahoma" fontSize="11" isBold="false" isItalic="false" isUnderline="false" isStrikeThrough="false">
<box>
<pen lineWidth="0.25" lineColor="#666666"/>
<topPen lineWidth="0.25" lineColor="#979991"/>
<leftPen lineWidth="0.25" lineColor="#979991"/>
<bottomPen lineWidth="0.25" lineColor="#979991"/>
<rightPen lineWidth="0.25" lineColor="#979991"/>
</box>
</style>
<parameter name="FromDate" class="java.lang.String">
<parameterDescription><![CDATA[]]></parameterDescription>
</parameter>
<parameter name="ToDate" class="java.lang.String">
<parameterDescription><![CDATA[]]></parameterDescription>
</parameter>
<parameter name="userTimezone" class="java.lang.String"/>
<parameter name="FromDateTZ" class="java.lang.String" isForPrompting="false">
<defaultValueExpression><![CDATA["'"+$P{REPORT_FORMAT_FACTORY}.createDateFormat("yyyy-MM-dd HH:mm:ss",$P{REPORT_LOCALE}, java.util.TimeZone.getTimeZone($P{userTimezone})).format(new SimpleDateFormat("MM/dd/yyyy HH:mm:ss").parse($P{FromDate}+" 00:00:00'"))+"'"]]></defaultValueExpression>
</parameter>
<parameter name="ToDateTZ" class="java.lang.String" isForPrompting="false">
<defaultValueExpression><![CDATA["'"+$P{REPORT_FORMAT_FACTORY}.createDateFormat("yyyy-MM-dd HH:mm:ss",$P{REPORT_LOCALE}, java.util.TimeZone.getTimeZone($P{userTimezone})).format(new SimpleDateFormat("MM/dd/yyyy HH:mm:ss").parse($P{ToDate}+" 00:00:00'"))+"'"]]></defaultValueExpression>
</parameter>
<parameter name="PrintTZ" class="java.lang.String" isForPrompting="false">
<defaultValueExpression><![CDATA[$P{REPORT_TIME_ZONE}.getTimeZone($P{userTimezone})]]></defaultValueExpression>
</parameter>
<queryString>
<![CDATA[select job.transcribed_date::text,job.created_Date::text, job.delivered_date::text,job.JOB_ID, job.client_facility_iD,job.DICTATION_LENGTH
from DW.job_f job
where job.transcribed_date between to_timestamp( $P!{FromDateTZ} ,'YYYY-MM-DD HH24:MI:SS') and to_timestamp( $P!{ToDateTZ} ,'YYYY-MM-DD HH24:MI:SS')]]>
</queryString>
<field name="transcribed_date" class="java.lang.String"/>
<field name="created_date" class="java.lang.String"/>
<field name="delivered_date" class="java.lang.String"/>
<field name="job_id" class="java.math.BigDecimal"/>
<field name="client_facility_id" class="java.math.BigDecimal"/>
<field name="dictation_length" class="java.math.BigDecimal"/>
<background>
<band splitType="Stretch"/>
</background>
<title>
<band height="120" splitType="Stretch">
<property name="com.jaspersoft.studio.unit.height" value="pixel"/>
<textField>
<reportElement x="0" y="0" width="842" height="30" uuid="68bf2fd7-6d2a-4101-aa84-2f1dc73aa782"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="Tahoma" size="11" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA["Report Header Section"]]></textFieldExpression>
</textField>
<textField>
<reportElement x="0" y="50" width="842" height="20" uuid="7e08b87a-bfd3-4c97-85c2-0495253e1ee9"/>
<textElement verticalAlignment="Middle">
<font fontName="Tahoma" size="10" isItalic="true"/>
</textElement>
<textFieldExpression><![CDATA["Time Run : "+new SimpleDateFormat("MM-dd-YYYY HH:mm:ss").format(new Date())]]></textFieldExpression>
</textField>
<textField>
<reportElement x="0" y="30" width="842" height="20" uuid="d6500562-18ff-4426-b997-c928ea4fac7f"/>
<textElement textAlignment="Center">
<font fontName="Tahoma" size="11"/>
</textElement>
<textFieldExpression><![CDATA["Report Description"]]></textFieldExpression>
</textField>
<textField>
<reportElement x="0" y="100" width="842" height="20" uuid="5ac7e312-67d6-4cb5-b140-db61aec3a23e"/>
<box>
<topPen lineWidth="0.5" lineColor="#999999"/>
</box>
<textFieldExpression><![CDATA[""]]></textFieldExpression>
</textField>
<textField>
<reportElement x="0" y="70" width="422" height="30" uuid="9c55c0f6-3bdd-4a6e-89ea-c68f35afde77"/>
<textElement textAlignment="Left" verticalAlignment="Middle"/>
<textFieldExpression><![CDATA["Date Between "+$P{FromDateTZ} +" and "+$P{ToDateTZ}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="422" y="70" width="420" height="30" uuid="a3f557b3-cd79-42b6-b5b4-ab1d959edb3f"/>
</textField>
<textField>
<reportElement x="422" y="70" width="280" height="30" uuid="a6716a87-4ac6-469a-9340-808348561b83"/>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$P{REPORT_TIME_ZONE}.toString()]]></textFieldExpression>
</textField>
<textField>
<reportElement x="0" y="0" width="0" height="0" uuid="8f70b2ad-ad64-4bef-8d7e-fd35dcf761dc">
<property name="com.jaspersoft.studio.unit.width" value="pixel"/>
<property name="com.jaspersoft.studio.unit.height" value="pixel"/>
</reportElement>
<textFieldExpression><![CDATA[$P{REPORT_TIME_ZONE}.getTimeZone($P{userTimezone})]]></textFieldExpression>
</textField>
</band>
</title>
<pageHeader>
<band splitType="Stretch"/>
</pageHeader>
<columnHeader>
<band height="30" splitType="Stretch">
<property name="com.jaspersoft.studio.unit.height" value="pixel"/>
<textField>
<reportElement style="column header" stretchType="RelativeToTallestObject" x="0" y="0" width="142" height="30" uuid="47351e64-0eed-4b3f-8e65-bbd4aa71707b"/>
<textFieldExpression><![CDATA["transcribed_date"]]></textFieldExpression>
</textField>
<textField>
<reportElement style="column header" stretchType="RelativeToTallestObject" x="142" y="0" width="140" height="30" uuid="5b44c994-90f9-4861-9dbd-37b0f2a4325f"/>
<textFieldExpression><![CDATA["created_date"]]></textFieldExpression>
</textField>
<textField>
<reportElement style="column header" stretchType="RelativeToTallestObject" x="282" y="0" width="140" height="30" uuid="118a7ea2-1a87-46ad-887b-9258ac5b39f5"/>
<textFieldExpression><![CDATA["delivered_date"]]></textFieldExpression>
</textField>
<textField>
<reportElement style="column header" stretchType="RelativeToTallestObject" x="422" y="0" width="140" height="30" uuid="16275c85-468f-4f0f-bc11-56741eca0c01"/>
<textFieldExpression><![CDATA["job_id"]]></textFieldExpression>
</textField>
<textField>
<reportElement style="column header" stretchType="RelativeToTallestObject" x="562" y="0" width="140" height="30" uuid="60ba0fee-da2a-40d1-9a15-c7dd6a699e6d"/>
<textFieldExpression><![CDATA["client_facility_id"]]></textFieldExpression>
</textField>
<textField>
<reportElement style="column header" stretchType="RelativeToTallestObject" x="702" y="0" width="140" height="30" uuid="7e7b7403-55d3-4414-b9a5-f55e9a4503c3"/>
<textFieldExpression><![CDATA["dictation_length"]]></textFieldExpression>
</textField>
</band>
</columnHeader>
<detail>
<band height="30" splitType="Stretch">
<property name="com.jaspersoft.studio.unit.height" value="pixel"/>
<textField>
<reportElement style="detail" stretchType="RelativeToTallestObject" x="0" y="0" width="142" height="30" uuid="ac7dc00e-7886-4ada-84f2-a626739b4390">
<property name="com.jaspersoft.studio.unit.y" value="pixel"/>
</reportElement>
<textFieldExpression><![CDATA[$F{transcribed_date}]]></textFieldExpression>
</textField>
<textField>
<reportElement style="detail" stretchType="RelativeToTallestObject" x="142" y="0" width="140" height="30" uuid="58f2d24f-451d-429b-a6ba-adf3b6095093"/>
<textFieldExpression><![CDATA[$F{created_date}]]></textFieldExpression>
</textField>
<textField>
<reportElement style="detail" stretchType="RelativeToTallestObject" x="282" y="0" width="140" height="30" uuid="256ad4fb-2886-4368-8097-635c2991064d"/>
<textFieldExpression><![CDATA[$F{delivered_date}]]></textFieldExpression>
</textField>
<textField>
<reportElement style="detail" stretchType="RelativeToTallestObject" x="422" y="0" width="140" height="30" uuid="2beac647-69e2-4fb6-bbe2-9a9730038a56"/>
<textFieldExpression><![CDATA[$F{job_id}]]></textFieldExpression>
</textField>
<textField>
<reportElement style="detail" stretchType="RelativeToTallestObject" x="562" y="0" width="140" height="30" uuid="a88d32dd-1cc3-4bdc-9ef9-540b022377c9"/>
<textFieldExpression><![CDATA[$F{client_facility_id}]]></textFieldExpression>
</textField>
<textField>
<reportElement style="detail" stretchType="RelativeToTallestObject" x="702" y="0" width="140" height="30" uuid="82fb777d-e46f-448f-a4c5-dab3b9ca0b3f"/>
<textFieldExpression><![CDATA[$F{dictation_length}]]></textFieldExpression>
</textField>
</band>
</detail>
<columnFooter>
<band splitType="Stretch"/>
</columnFooter>
<pageFooter>
<band splitType="Stretch"/>
</pageFooter>
<summary>
<band splitType="Stretch">
<property name="com.jaspersoft.studio.unit.height" value="pixel"/>
</band>
</summary>
<noData>
<band height="40">
<staticText>
<reportElement x="0" y="0" width="842" height="40" uuid="2de331a1-b95b-4154-99f7-095e5cade32c"/>
<textElement verticalAlignment="Middle">
<font fontName="Tahoma" size="11" isBold="false"/>
</textElement>
<text><![CDATA[No Results
The specified criteria didn't result in any data. This is often caused by applying filters and/or selections that are too restrictive or that contain incorrect values. Please check your Analysis Filters and try again. ]]></text>
</staticText>
</band>
</noData>
</jasperReport>
If you see this is build for accepting three parameters. Two date fields and one users timezone prompt. Based upon the date filter provided I'm converting the those to users time zone format and passing that to the database. The issue is while printing the result on there timezone. As my report has three date time fields which should display the result also as per there user timezone.
My question is there any way I can fix the timezone at the top of the report instead of converting all the three date time fields individually. Let me know if you need more clarification on this. Thanks

java.lang.NoSuchMethodError:In jaspereports in struts2

Trying to integrate jasperreports with struts2....and i am very new to jasperreports ....designed reports using eclipse report designer
here is my jrmxlЖ
<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.1.0.final using JasperReports Library version 6.1.0 -->
<!-- 2015-08-24T16:05:04 -->
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="Coffee_Landscape" pageWidth="842" pageHeight="595" orientation="Landscape" columnWidth="802" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="df013db5-f76e-44d3-b0df-bcbc46d93160">
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="One Empty Record"/>
<style name="Title" fontName="Times New Roman" fontSize="50" isBold="true"/>
<style name="SubTitle" forecolor="#736343" fontName="Arial" fontSize="18"/>
<style name="Column header" forecolor="#666666" fontName="Arial" fontSize="12" isBold="true"/>
<style name="Detail" fontName="Arial" fontSize="12"/>
<style name="Row" mode="Transparent">
<conditionalStyle>
<conditionExpression><![CDATA[$V{REPORT_COUNT}%2 == 0]]></conditionExpression>
<style backcolor="#E6DAC3"/>
</conditionalStyle>
</style>
<field name="transaction_Date" class="java.sql.Timestamp">
<fieldDescription><![CDATA[]]></fieldDescription>
</field>
<field name="amount_Of_Sale" class="java.math.BigDecimal">
<fieldDescription><![CDATA[]]></fieldDescription>
</field>
<field name="discount_Amount" class="java.math.BigDecimal">
<fieldDescription><![CDATA[]]></fieldDescription>
</field>
<background>
<band splitType="Stretch"/>
</background>
<title>
<band height="136" splitType="Stretch">
<image>
<reportElement x="0" y="0" width="164" height="126" uuid="1c003177-754c-448f-8ce1-16868856f545"/>
<imageExpression><![CDATA["pctv-blue-rect.png"]]></imageExpression>
</image>
<staticText>
<reportElement style="Title" x="190" y="0" width="443" height="62" uuid="bc1ce1da-8232-46ea-be55-cec4abb986dd"/>
<textElement verticalAlignment="Middle"/>
<text><![CDATA[MyFirstJasper]]></text>
</staticText>
<staticText>
<reportElement style="SubTitle" x="303" y="62" width="196" height="22" uuid="f6a78448-8260-4445-a9e0-e3fb53b080d9"/>
<textElement>
<font fontName="Times New Roman"/>
</textElement>
<text><![CDATA[Coffee SubTitle]]></text>
</staticText>
<staticText>
<reportElement x="172" y="94" width="383" height="42" uuid="8240065e-64b6-4170-b5d9-6341598e7b35"/>
<textElement textAlignment="Right">
<font size="10"/>
</textElement>
<text><![CDATA[Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce auctor purus gravida arcu aliquam mattis. Donec et nulla libero, ut varius massa. Nulla sed turpis elit. Etiam aliquet mauris a ligula hendrerit in auctor leo lobortis.]]></text>
</staticText>
</band>
</title>
<pageHeader>
<band splitType="Stretch"/>
</pageHeader>
<columnHeader>
<band height="16" splitType="Stretch">
<line>
<reportElement positionType="FixRelativeToBottom" x="0" y="15" width="802" height="1" uuid="e9d2002a-c8ee-4649-a258-640dad29110c"/>
<graphicElement>
<pen lineWidth="0.5" lineColor="#999999"/>
</graphicElement>
</line>
<staticText>
<reportElement style="Column header" x="0" y="0" width="267" height="15" forecolor="#736343" uuid="732f1c0f-9a82-40f6-a3ec-adc1a7974b20"/>
<text><![CDATA[TRANSACTION DATE]]></text>
</staticText>
<staticText>
<reportElement style="Column header" x="267" y="0" width="267" height="15" forecolor="#736343" uuid="3d530dc4-b1f1-4fc8-97a9-caf5e9880788"/>
<text><![CDATA[AMOUNT OF SALE]]></text>
</staticText>
<staticText>
<reportElement style="Column header" x="534" y="0" width="267" height="15" forecolor="#736343" uuid="79cddcd9-d19c-4737-bef4-4f5913c70e06"/>
<text><![CDATA[DISCOUNT AMOUNT]]></text>
</staticText>
</band>
</columnHeader>
<detail>
<band height="15" splitType="Stretch">
<frame>
<reportElement style="Row" mode="Opaque" x="0" y="0" width="802" height="15" uuid="fa7cec56-4ec1-48e6-a26e-7266a995d174"/>
<textField isStretchWithOverflow="true">
<reportElement style="Detail" x="0" y="0" width="267" height="15" uuid="8af81006-b893-4305-b756-5393650dbe47"/>
<textFieldExpression><![CDATA[$F{transaction_Date}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true">
<reportElement style="Detail" x="267" y="0" width="267" height="15" uuid="0b740c0b-0299-4454-b6d1-98fba48bd8d1"/>
<textFieldExpression><![CDATA[$F{amount_Of_Sale}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true">
<reportElement style="Detail" x="534" y="0" width="267" height="15" uuid="135c7c39-45d3-4b00-a67e-58caf29dc186"/>
<textFieldExpression><![CDATA[$F{discount_Amount}]]></textFieldExpression>
</textField>
</frame>
</band>
</detail>
<columnFooter>
<band height="6" splitType="Stretch">
<line>
<reportElement positionType="FixRelativeToBottom" x="0" y="3" width="802" height="1" uuid="fa5e88d5-a011-4e32-8f12-ce923f903111"/>
<graphicElement>
<pen lineWidth="0.5" lineColor="#999999"/>
</graphicElement>
</line>
</band>
</columnFooter>
<pageFooter>
<band height="25" splitType="Stretch">
<frame>
<reportElement mode="Opaque" x="-21" y="1" width="843" height="24" forecolor="#D0B48E" backcolor="#F2EBDF" uuid="5d8169bd-4a75-48c8-8a68-6d3ad5ba9402"/>
<textField evaluationTime="Report">
<reportElement style="Column header" x="783" y="1" width="40" height="20" forecolor="#736343" uuid="e5e27efa-b599-499b-9ca3-848cb511cb7b"/>
<textElement verticalAlignment="Middle">
<font size="10" isBold="false"/>
</textElement>
<textFieldExpression><![CDATA[" " + $V{PAGE_NUMBER}]]></textFieldExpression>
</textField>
<textField>
<reportElement style="Column header" x="703" y="1" width="80" height="20" forecolor="#736343" uuid="18cfe1ca-f7d6-48b0-9827-28578b42a5e0"/>
<textElement textAlignment="Right" verticalAlignment="Middle">
<font size="10" isBold="false"/>
</textElement>
<textFieldExpression><![CDATA["Page "+$V{PAGE_NUMBER}+" of"]]></textFieldExpression>
</textField>
<textField pattern="EEEEE dd MMMMM yyyy">
<reportElement style="Column header" x="1" y="1" width="197" height="20" forecolor="#736343" uuid="fbce24bb-3cb1-44a3-8eec-8c067ddbe5b5"/>
<textElement verticalAlignment="Middle">
<font size="10" isBold="false"/>
</textElement>
<textFieldExpression><![CDATA[new java.util.Date()]]></textFieldExpression>
</textField>
</frame>
</band>
</pageFooter>
<summary>
<band splitType="Stretch"/>
</summary>
</jasperReport>
And Struts.xml
<action name="myJasperTest" class="com.pincodetv.jasper.JasperAction">
<result name="success" type="jasper">
<param name="location">/jasper/our_compiled_template.jasper</param>
<param name="dataSource">myList</param>
<param name="format">PDF</param>
</result>
</action>
Jars which i have in lib
struts2-jasperreports-plugin-2.2.3.jar
jasperreports-6.1.0.jar
jasperreports-fonts-6.1.0.jar
jasperreports-javaflow-6.1.0.jar
The error logs...
java.lang.NoSuchMethodError: net.sf.jasperreports.engine.util.JRLoader.loadObject(Ljava/lang/String;)Ljava/lang/Object;
at org.apache.struts2.views.jasperreports.JasperReportsResult.doExecute(JasperReportsResult.java:321)
at org.apache.struts2.dispatcher.StrutsResultSupport.execute(StrutsResultSupport.java:186)
at com.opensymphony.xwork2.DefaultActionInvocation.executeResult(DefaultActionInvocation.java:371)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:275)
at org.apache.struts2.interceptor.DeprecationInterceptor.intercept(DeprecationInterceptor.java:41)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:256)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:167)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:265)
at org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:68)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:138)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:254)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:254)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:191)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at org.apache.struts2.interceptor.MultiselectInterceptor.intercept(MultiselectInterceptor.java:73)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:91)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:252)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:100)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:141)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:145)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:171)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:139)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:193)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:189)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:54)
at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:562)
at org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)
at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:99)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:501)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1070)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:611)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:745)
i got the same problem, i used struts2, jasper-report 5.6.0, japer report library 5.6.0. how i solved my problem is just added class JRLoader download here:
http://grepcode.com/file/repo1.maven.org/maven2/net.sf.jasperreports/jasperreports/4.5.0/net/sf/jasperreports/engine/util/JRLoader.java
add the joda library in you project library,
joda download here:
https://github.com/JodaOrg/joda-time/releases/download/v2.9.4/joda-time-2.9.4-dist.tar.gz
create package in you project net.sf.jasperreports.engine.util
and put the JRLoader.java in that package, then run your project
viola.... it's work....

How to pass list to jasper in grails using JasperService

Here is my Domain class
class User {
String admin
String name
String phoneNumber
String email
String questionSet
}
Here is my view.gsp for Jasper report
<g:jasperReport controller="profile" action="jasperdata" format="PDF"
</g:jasperReport>
And here is my controller
def jasperService
def jasperdata(){
List listDetails = []
Map mapDetails =[:]
Map result = [:]
def number=User.executeQuery('select phoneNumber from User')
mapDetails.put('phnno', number)
listDetails.add(mapDetails)
println listDetails
result.data = []
result.data << [phnno:listDetails]
JasperReportDef rep = jasperService.buildReportDefinition(params,request.locale,result)
ByteArrayOutputStream stream = jasperService.generateReport(rep)
response.setHeader("Content-disposition", "attachment; filename=" + 'transaction' + ".pdf")
response.contentType = "application/pdf"
response.outputStream << stream.toByteArray()
}
I can send a single data item to Jasper But i want to send list of data from controller.
domain is ok but in your controller you can try:
def jasperService
def jasperdata = { User -> user
List<User> listPhoneNumber = User.list() as Object[]
JasperReportDef rep = jasperService.buildReportDefinition(params,request.locale,[data:listPhoneNumber])
ByteArrayOutputStream stream = jasperService.generateReport(rep)
response.setHeader("Content-disposition", "attachment; filename=" + 'transaction' + ".pdf")
response.contentType = "application/pdf"
response.outputStream << stream.toByteArray()
response.outputStream.flush()
}
View you can try too:
<g:jasperReport action="profile" controller="jasperdata" format="PDF" jasper="listPhone">
</g:jasperReport>
And a listPhone.jrxml, just for a simple test.
<?xml version="1.0" encoding="UTF-8"?>
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="relatorio" language="groovy"
pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="5f768b17-5eec-48ad-bfb8-2c500ea4eedb">
<property name="ireport.zoom" value="1.0"/>
<property name="ireport.x" value="0"/>
<property name="ireport.y" value="0"/>
<style name="Title" fontName="Arial" fontSize="26" isBold="true" pdfFontName="Helvetica-Bold"/>
<style name="SubTitle" forecolor="#666666" fontName="Arial" fontSize="18"/>
<style name="Column header" forecolor="#666666" fontName="Arial" fontSize="12" isBold="true"/>
<style name="Detail" fontName="Arial" fontSize="12"/>
<field name="phoneNumber" class="java.lang.String"/>
<background>
<band splitType="Stretch"/>
</background>
<title>
<band height="26" splitType="Stretch">
<staticText>
<reportElement mode="Opaque" x="0" y="0" width="555" height="20" backcolor="#CCCCCC" uuid="3e5957c3-d694-428b-bcd9-173b2b40d517"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="Verdana" isBold="true" isItalic="true"/>
</textElement>
<text><![CDATA[LIST OF PHONE NUMBER]]></text>
</staticText>
</band>
</title>
<pageHeader>
<band splitType="Stretch"/>
</pageHeader>
<columnHeader>
<band height="36" splitType="Stretch">
<staticText>
<reportElement x="0" y="11" width="555" height="20" uuid="467b7009-00d7-48e7-81c4-7037fcddc5ea"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="Verdana" isBold="true"/>
</textElement>
<text><![CDATA[PHONES]]></text>
</staticText>
</band>
</columnHeader>
<detail>
<band height="29" splitType="Stretch">
<textField>
<reportElement x="0" y="0" width="555" height="20" uuid="03b9a4c5-59da-4df7-9435-835eda1e83aa"/>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$F{phoneNumber}]]></textFieldExpression>
</textField>
</band>
</detail>
<columnFooter>
<band height="45" splitType="Stretch"/>
</columnFooter>
<pageFooter>
<band height="20" splitType="Stretch">
<textField>
<reportElement x="455" y="0" width="100" height="20" uuid="b53eb0ee-b2b4-4a82-871b-bd622b308572"/>
<textFieldExpression><![CDATA[$V{PAGE_NUMBER}]]></textFieldExpression>
</textField>
</band>
</pageFooter>
<summary>
<band splitType="Stretch"/>
</summary>
</jasperReport>
Hope it helps.

Struts2 json plugin not working

Following is the jsp wherein i have a struts2 jquery plugin select tag that loads its values asynchronously from an action using json:
<%# taglib prefix="s" uri="/struts-tags"%>
<%# taglib prefix="sj" uri="/struts-jquery-tags"%>
<s:form action="#" theme="css_xhtml" cssClass="form1small" name="reportgenerationform">
<div class="searchHeadersmall">Generate Report</div>
<div id="searchForm1">
<s:url id="remoteurl" action="providerList"/>
<sj:select
href="%{remoteurl}"
id="echo"
name="echo"
list="proList"
emptyOption="true"
headerKey="-1"
headerValue="Select"
/>
</div
</s:form>
Struts.xml is as follows:
<struts>
<constant name="struts.devMode" value="true" />
<package name="package2" extends="struts-default,json-default">
<action name="providerList" class="com.view.AdminAction">
<result name="success" type="json" >
</result>
</action>
</package>
</struts>
Action class AdminAction is as follows:
public class AdminAction extends ActionSupport{
private List<String> proList = new ArrayList<String>();
public List<String> getProList() {
return proList;
}
public void setProList(List<String> proList) {
this.proList = proList;
}
public String execute() {
proList.add("ABC");
proList.add("DEF");
proList.add("agC");
return SUCCESS;
}
public String getJSON(){
return execute();
}
}
When i run this code, my select tag is not getting populated with the values i have set in my action class. Am i missing anything in it. I explored the links available on SO and also struts2 json showcase etc. Any other links and help is welcome. Thanks in advance..
Also i get this exception when i run the code:
java.lang.NoClassDefFoundError: org/apache/commons/lang/xwork/StringUtils
at org.apache.struts2.json.SerializationParams.<init>(SerializationParams.java:57)
at org.apache.struts2.json.JSONResult.writeToResponse(JSONResult.java:214)
at org.apache.struts2.json.JSONResult.execute(JSONResult.java:204)
at com.opensymphony.xwork2.DefaultActionInvocation.executeResult(DefaultActionInvocation.java:371)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:275)
at org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:256)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:167)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:265)
at org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:68)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:138)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:239)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:239)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:191)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at org.apache.struts2.interceptor.MultiselectInterceptor.intercept(MultiselectInterceptor.java:73)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:91)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:252)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:100)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:141)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:145)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:171)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:161)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:193)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:189)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:54)
at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:563)
at org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)
at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:99)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1023)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
If I read it correctly, you are missing dependencies. A quick google gave tons of solutions :
Just Google

Resources