You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Security Management <li...@secmgmt.com> on 2009/04/21 22:12:58 UTC

Jasper Plugin cannot find file

I'm using the tutorial here:
http://struts.apache.org/2.0.14/docs/jasperreports-tutorial.html

I have put a file here:

/jasper/report.jrxml

I can look in my war file and verify it.

I'm trying to compile and render with it.  Here is my action code:

<action name="saveReport" class="com.secmgmt.struts2.actions.SaveReport">
		<result name="success" type="jasper">
            <param name="location">/jasper/scrounger_report.jasper</param>
            <param name="dataSource">personList</param>
            <param name="format">PDF</param>
        </result>
</action>

I've also tried:
<param name="location">my-webapp/jasper/scrounger_report.jasper</param>

Which is what the tutorial has.

In my action, I have:
try
            {
                JasperCompileManager.compileReportToFile(
                    "my-webapp/jasper/scrounger_report.jrxml",
                    "my-webapp/jasper/scrounger_report.jasper");
            }
            catch (Exception e)
            {
                e.printStackTrace();
                return ERROR;
            }

But I always get a file not found error, I've tried just the
/jasper/...jrxml too, without the appname (which I think is the correct way)
but no luck.

What path should I be using if the file is in /jasper/scrounger_report.jrxml
in my war file?

Thanks
-----Original Message-----
From: stanlick@gmail.com [mailto:stanlick@gmail.com] 
Sent: Tuesday, April 21, 2009 2:29 PM
To: Struts Users Mailing List
Subject: Re: How to do matematical operation in jsp.

Nice reference Wes!  BTW, I noticed you are not using the new cover letter
for the TPS reports, so I'm going to have to go ahead and ask you to read
that memo one more time.

Peace,
the Bob's

On Tue, Apr 21, 2009 at 11:11 AM, Wes Wannemacher <we...@wantii.com> wrote:

> [snip]
> >
> > OTOH, siphoning the $.0000000000000039079850466805510222911834716796875
> into
> > offshore accounts will eventually make you rich.
> >
> > Dave "Expecting his 10% cut" Newton
> >
> [/snip]
>
> But, you have to be careful when moving the money into your own account...
>
> [quote]
> We're not just talking about while-collar, resort prison, we're
> talking Federal Pound Me In the *** Prison!
> [/quote]
>
> You have to be especially careful of mundane details like decimal places.
>
> -Wes
>
> --
> Wes Wannemacher
> Author - Struts 2 In Practice
> Includes coverage of Struts 2.1, Spring, JPA, JQuery, Sitemesh and more
> http://www.manning.com/wannemacher
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


RE: Jasper Plugin cannot find file

Posted by Security Management <li...@secmgmt.com>.
OK, I took a smart pill, and put the following in my action:

JasperCompileManager.compileReportToFile(
 
this.getServletContext().getRealPath("/jasper/scrounger_report.jrxml"),
 
this.getServletContext().getRealPath("/jasper/scrounger_report.jasper"));

I'm logging that location with log4j, and will have to figure out how to put
it in the struts.xml file for the action.

Thanks for all the help.

-----Original Message-----
From: Balwinder Kumar [mailto:balwinder.mca@gmail.com] 
Sent: Tuesday, April 21, 2009 10:51 PM
To: Struts Users Mailing List
Subject: Re: Jasper Plugin cannot find file

I would suggest that first give the complete absolute path and check if 
the program is working fine, just to ensure, there is a problem with 
path only.

Once established problem is with path only, I may help you further.

Regards,
Balwinder Kumar

Security Management wrote:
> I'm using the tutorial here:
> http://struts.apache.org/2.0.14/docs/jasperreports-tutorial.html
>
> I have put a file here:
>
> /jasper/report.jrxml
>
> I can look in my war file and verify it.
>
> I'm trying to compile and render with it.  Here is my action code:
>
> <action name="saveReport" class="com.secmgmt.struts2.actions.SaveReport">
> 		<result name="success" type="jasper">
>             <param name="location">/jasper/scrounger_report.jasper</param>
>             <param name="dataSource">personList</param>
>             <param name="format">PDF</param>
>         </result>
> </action>
>
> I've also tried:
> <param name="location">my-webapp/jasper/scrounger_report.jasper</param>
>
> Which is what the tutorial has.
>
> In my action, I have:
> try
>             {
>                 JasperCompileManager.compileReportToFile(
>                     "my-webapp/jasper/scrounger_report.jrxml",
>                     "my-webapp/jasper/scrounger_report.jasper");
>             }
>             catch (Exception e)
>             {
>                 e.printStackTrace();
>                 return ERROR;
>             }
>
> But I always get a file not found error, I've tried just the
> /jasper/...jrxml too, without the appname (which I think is the correct
way)
> but no luck.
>
> What path should I be using if the file is in
/jasper/scrounger_report.jrxml
> in my war file?
>
> Thanks
> -----Original Message-----
> From: stanlick@gmail.com [mailto:stanlick@gmail.com] 
> Sent: Tuesday, April 21, 2009 2:29 PM
> To: Struts Users Mailing List
> Subject: Re: How to do matematical operation in jsp.
>
> Nice reference Wes!  BTW, I noticed you are not using the new cover letter
> for the TPS reports, so I'm going to have to go ahead and ask you to read
> that memo one more time.
>
> Peace,
> the Bob's
>
> On Tue, Apr 21, 2009 at 11:11 AM, Wes Wannemacher <we...@wantii.com> wrote:
>
>   
>> [snip]
>>     
>>> OTOH, siphoning the $.0000000000000039079850466805510222911834716796875
>>>       
>> into
>>     
>>> offshore accounts will eventually make you rich.
>>>
>>> Dave "Expecting his 10% cut" Newton
>>>
>>>       
>> [/snip]
>>
>> But, you have to be careful when moving the money into your own
account...
>>
>> [quote]
>> We're not just talking about while-collar, resort prison, we're
>> talking Federal Pound Me In the *** Prison!
>> [/quote]
>>
>> You have to be especially careful of mundane details like decimal places.
>>
>> -Wes
>>
>> --
>> Wes Wannemacher
>> Author - Struts 2 In Practice
>> Includes coverage of Struts 2.1, Spring, JPA, JQuery, Sitemesh and more
>> http://www.manning.com/wannemacher
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
>>     
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
>   



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Jasper Plugin cannot find file

Posted by Balwinder Kumar <ba...@gmail.com>.
I would suggest that first give the complete absolute path and check if 
the program is working fine, just to ensure, there is a problem with 
path only.

Once established problem is with path only, I may help you further.

Regards,
Balwinder Kumar

Security Management wrote:
> I'm using the tutorial here:
> http://struts.apache.org/2.0.14/docs/jasperreports-tutorial.html
>
> I have put a file here:
>
> /jasper/report.jrxml
>
> I can look in my war file and verify it.
>
> I'm trying to compile and render with it.  Here is my action code:
>
> <action name="saveReport" class="com.secmgmt.struts2.actions.SaveReport">
> 		<result name="success" type="jasper">
>             <param name="location">/jasper/scrounger_report.jasper</param>
>             <param name="dataSource">personList</param>
>             <param name="format">PDF</param>
>         </result>
> </action>
>
> I've also tried:
> <param name="location">my-webapp/jasper/scrounger_report.jasper</param>
>
> Which is what the tutorial has.
>
> In my action, I have:
> try
>             {
>                 JasperCompileManager.compileReportToFile(
>                     "my-webapp/jasper/scrounger_report.jrxml",
>                     "my-webapp/jasper/scrounger_report.jasper");
>             }
>             catch (Exception e)
>             {
>                 e.printStackTrace();
>                 return ERROR;
>             }
>
> But I always get a file not found error, I've tried just the
> /jasper/...jrxml too, without the appname (which I think is the correct way)
> but no luck.
>
> What path should I be using if the file is in /jasper/scrounger_report.jrxml
> in my war file?
>
> Thanks
> -----Original Message-----
> From: stanlick@gmail.com [mailto:stanlick@gmail.com] 
> Sent: Tuesday, April 21, 2009 2:29 PM
> To: Struts Users Mailing List
> Subject: Re: How to do matematical operation in jsp.
>
> Nice reference Wes!  BTW, I noticed you are not using the new cover letter
> for the TPS reports, so I'm going to have to go ahead and ask you to read
> that memo one more time.
>
> Peace,
> the Bob's
>
> On Tue, Apr 21, 2009 at 11:11 AM, Wes Wannemacher <we...@wantii.com> wrote:
>
>   
>> [snip]
>>     
>>> OTOH, siphoning the $.0000000000000039079850466805510222911834716796875
>>>       
>> into
>>     
>>> offshore accounts will eventually make you rich.
>>>
>>> Dave "Expecting his 10% cut" Newton
>>>
>>>       
>> [/snip]
>>
>> But, you have to be careful when moving the money into your own account...
>>
>> [quote]
>> We're not just talking about while-collar, resort prison, we're
>> talking Federal Pound Me In the *** Prison!
>> [/quote]
>>
>> You have to be especially careful of mundane details like decimal places.
>>
>> -Wes
>>
>> --
>> Wes Wannemacher
>> Author - Struts 2 In Practice
>> Includes coverage of Struts 2.1, Spring, JPA, JQuery, Sitemesh and more
>> http://www.manning.com/wannemacher
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
>>     
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
>   


RE: Jasper Plugin cannot find file

Posted by Security Management <li...@secmgmt.com>.
Doh, I must have replied to a topic, my bad.

>>What is "my-webapp"? A directory? Your web app's context? If the latter, 
>>that certainly won't work, you'd need to get the path relative to your 
>>webapp's deployment.

Yes, it's the context directory, I've also just tried it with
/jasper/scrounger_report.jasper.

> I have put a file here:
> 
> /jasper/report.jrxml

>>Without any context I have no idea where that file is: is it on the 
>>classpath? Is it in the webapp root?

The webapp root, that is, if I do a listing of my war file, it's in the root
of it, at /jasper/scrounger_report.jasper

>>If compileReportToFile is expecting a physical file you may have issues 
>>if you're deploying a war file, since files contained in it may not be 
>>accessible in this manner.

I've looked in my webapps directory, the war gets expanded and the file
exists on the filesystem.  Are you saying I may still have issues?

>>Are you actually compiling the report each time the action is hit?

No, I'm just testing to make sure I can figure this out.


-----Original Message-----
From: Dave Newton [mailto:newton.dave@yahoo.com] 
Sent: Tuesday, April 21, 2009 4:37 PM
To: Struts Users Mailing List
Subject: Re: Jasper Plugin cannot find file

Please start new threads for new topics.

Security Management wrote:
> I have put a file here:
> 
> /jasper/report.jrxml

Without any context I have no idea where that file is: is it on the 
classpath? Is it in the webapp root?

> <action name="saveReport" class="com.secmgmt.struts2.actions.SaveReport">
> 		<result name="success" type="jasper">
>             <param name="location">/jasper/scrounger_report.jasper</param>
>             <param name="dataSource">personList</param>
>             <param name="format">PDF</param>
>         </result>
> </action>
> 
> I've also tried:
> <param name="location">my-webapp/jasper/scrounger_report.jasper</param>
> 
> Which is what the tutorial has.
> 
> In my action, I have:
> try
>             {
>                 JasperCompileManager.compileReportToFile(
>                     "my-webapp/jasper/scrounger_report.jrxml",
>                     "my-webapp/jasper/scrounger_report.jasper");

What is "my-webapp"? A directory? Your web app's context? If the latter, 
that certainly won't work, you'd need to get the path relative to your 
webapp's deployment.

If compileReportToFile is expecting a physical file you may have issues 
if you're deploying a war file, since files contained in it may not be 
accessible in this manner.

Are you actually compiling the report each time the action is hit?

Dave


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Jasper Plugin cannot find file

Posted by Dave Newton <ne...@yahoo.com>.
Please start new threads for new topics.

Security Management wrote:
> I have put a file here:
> 
> /jasper/report.jrxml

Without any context I have no idea where that file is: is it on the 
classpath? Is it in the webapp root?

> <action name="saveReport" class="com.secmgmt.struts2.actions.SaveReport">
> 		<result name="success" type="jasper">
>             <param name="location">/jasper/scrounger_report.jasper</param>
>             <param name="dataSource">personList</param>
>             <param name="format">PDF</param>
>         </result>
> </action>
> 
> I've also tried:
> <param name="location">my-webapp/jasper/scrounger_report.jasper</param>
> 
> Which is what the tutorial has.
> 
> In my action, I have:
> try
>             {
>                 JasperCompileManager.compileReportToFile(
>                     "my-webapp/jasper/scrounger_report.jrxml",
>                     "my-webapp/jasper/scrounger_report.jasper");

What is "my-webapp"? A directory? Your web app's context? If the latter, 
that certainly won't work, you'd need to get the path relative to your 
webapp's deployment.

If compileReportToFile is expecting a physical file you may have issues 
if you're deploying a war file, since files contained in it may not be 
accessible in this manner.

Are you actually compiling the report each time the action is hit?

Dave


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org