FileNotFoundException when creating FileInputStream
When I attempt to open an XSL file to complete a transformation, I get the exception FileNotFound. Steps: [1] Get file location from properties file without problem: String myXsl = getProperties().getProperty("fop.render.article"); String contents: "http://localhost/artimus/pdf/renderPdf.xsl";( verified by logging ) [2] construct FileInputStream from string, and I get exception FileInputStream in = new FileInputStream(myXsl); Err msg: java.io.FileNotFoundException: http:\localhost\artimus\pdf\renderPdf.xsl Note from the message that FileInputStream appears to change the address. How do I force the constructor to accept the whole address? regards, douglas reames rms finance 919 929 3465 _ MSN 8 helps eliminate e-mail viruses. Get 2 months FREE*. http://join.msn.com/?page=features/virus - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: FileNotFoundException when creating FileInputStream
hi, May be you are trying to get HTTP file using File Stream, that's why ;-) navjot |-Original Message- |From: douglas reames [mailto:[EMAIL PROTECTED] |Sent: Thursday, June 19, 2003 6:14 PM |To: [EMAIL PROTECTED] |Cc: [EMAIL PROTECTED] |Subject: FileNotFoundException when creating FileInputStream | | |When I attempt to open an XSL file to complete a transformation, I get the |exception FileNotFound. Steps: | | [1] Get file location from properties file without problem: |String myXsl = |getProperties().getProperty("fop.render.article"); | |String contents: |"http://localhost/artimus/pdf/renderPdf.xsl";( verified by logging ) | | [2] construct FileInputStream from string, and I get exception |FileInputStream in = new FileInputStream(myXsl); | |Err msg: java.io.FileNotFoundException: |http:\localhost\artimus\pdf\renderPdf.xsl | |Note from the message that FileInputStream appears to change the address. | |How do I force the constructor to accept the whole address? | |regards, |douglas reames |rms finance |919 929 3465 | |_ |MSN 8 helps eliminate e-mail viruses. Get 2 months FREE*. |http://join.msn.com/?page=features/virus | | |- |To unsubscribe, e-mail: [EMAIL PROTECTED] |For additional commands, e-mail: [EMAIL PROTECTED] | | - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: FileNotFoundException when creating FileInputStream
FileInputStream expects a filename, but you fed it a URL. Is the XSL file within your webapp? If so, don't use a URL to reference it. If it is not within your web app but it is under your control, consider moving it into your web app. If you cannot move it, you will need to make an HTTP request to go get it. This code will go get it and give you an InputStream to read from (there may be better ways -- I just hobbled this together): InputStream in = new StringBufferInputStream( new URLConnection(new URL(myXsl)).getResponseMessage() ); This is expensive, so if you need to get this often and it doesn't change much, you should cache it within your app. Be sure to consider what a reasonable cache strategy would be, though. If you just get it once and hold onto it forever, your app will need to be restarted every time the xsl file changes, which would not be acceptable in a production environment in most cases. -Max - Original Message - From: "douglas reames" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Cc: <[EMAIL PROTECTED]> Sent: Thursday, June 19, 2003 5:43 AM Subject: FileNotFoundException when creating FileInputStream > When I attempt to open an XSL file to complete a transformation, I get the > exception FileNotFound. Steps: > > [1] Get file location from properties file without problem: > String myXsl = > getProperties().getProperty("fop.render.article"); > > String contents: > "http://localhost/artimus/pdf/renderPdf.xsl";( verified by logging ) > > [2] construct FileInputStream from string, and I get exception > FileInputStream in = new FileInputStream(myXsl); > > Err msg: java.io.FileNotFoundException: > http:\localhost\artimus\pdf\renderPdf.xsl > > Note from the message that FileInputStream appears to change the address. > > How do I force the constructor to accept the whole address? > > regards, > douglas reames > rms finance > 919 929 3465 > > _ > MSN 8 helps eliminate e-mail viruses. Get 2 months FREE*. > http://join.msn.com/?page=features/virus > > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: FileNotFoundException when creating FileInputStream
you are absolutely correct. I have inserted a temporary workaround. thanks for responding. best regards, douglas reames From: "Navjot Singh" <[EMAIL PROTECTED]> Reply-To: "Struts Users Mailing List" <[EMAIL PROTECTED]> To: "Struts Users Mailing List" <[EMAIL PROTECTED]> Subject: RE: FileNotFoundException when creating FileInputStream Date: Thu, 19 Jun 2003 20:29:56 +0530 hi, May be you are trying to get HTTP file using File Stream, that's why ;-) navjot |-Original Message- |From: douglas reames [mailto:[EMAIL PROTECTED] |Sent: Thursday, June 19, 2003 6:14 PM |To: [EMAIL PROTECTED] |Cc: [EMAIL PROTECTED] |Subject: FileNotFoundException when creating FileInputStream | | |When I attempt to open an XSL file to complete a transformation, I get the |exception FileNotFound. Steps: | | [1] Get file location from properties file without problem: |String myXsl = |getProperties().getProperty("fop.render.article"); | |String contents: |"http://localhost/artimus/pdf/renderPdf.xsl";( verified by logging ) | | [2] construct FileInputStream from string, and I get exception |FileInputStream in = new FileInputStream(myXsl); | |Err msg: java.io.FileNotFoundException: |http:\localhost\artimus\pdf\renderPdf.xsl | |Note from the message that FileInputStream appears to change the address. | |How do I force the constructor to accept the whole address? | |regards, |douglas reames |rms finance |919 929 3465 | |_ |MSN 8 helps eliminate e-mail viruses. Get 2 months FREE*. |http://join.msn.com/?page=features/virus | | |- |To unsubscribe, e-mail: [EMAIL PROTECTED] |For additional commands, e-mail: [EMAIL PROTECTED] | | - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] _ Protect your PC - get McAfee.com VirusScan Online http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: FileNotFoundException when creating FileInputStream
Is the XSL file within your webapp? If so, don't use a URL to reference it. It is within the webapp. I began using the absolute reference - "http://localhost:8080/artimus..."; - because I was getting FileNotFound when I tried using a relative reference. I need to refer to the above static xsl file to perform a PDF transformation on the fly. I am obvoiusly a newbie - how do I do it? Take the reference out of the Properties File and put it in Struts-Config? I would prefer not to hard-code the reference. thanks for responding to me earlier. To temporarily workaround this issue, I have inserted an absolute file reference in the Properties File. This will obviously not work once I move the war file to a remote server that I don't control. best regards, douglas reames From: "Max Cooper" <[EMAIL PROTECTED]> Reply-To: "Struts Users Mailing List" <[EMAIL PROTECTED]> To: "Struts Users Mailing List" <[EMAIL PROTECTED]> CC: <[EMAIL PROTECTED]> Subject: Re: FileNotFoundException when creating FileInputStream Date: Thu, 19 Jun 2003 08:46:10 -0700 FileInputStream expects a filename, but you fed it a URL. Is the XSL file within your webapp? If so, don't use a URL to reference it. If it is not within your web app but it is under your control, consider moving it into your web app. If you cannot move it, you will need to make an HTTP request to go get it. This code will go get it and give you an InputStream to read from (there may be better ways -- I just hobbled this together): InputStream in = new StringBufferInputStream( new URLConnection(new URL(myXsl)).getResponseMessage() ); This is expensive, so if you need to get this often and it doesn't change much, you should cache it within your app. Be sure to consider what a reasonable cache strategy would be, though. If you just get it once and hold onto it forever, your app will need to be restarted every time the xsl file changes, which would not be acceptable in a production environment in most cases. -Max - Original Message - From: "douglas reames" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Cc: <[EMAIL PROTECTED]> Sent: Thursday, June 19, 2003 5:43 AM Subject: FileNotFoundException when creating FileInputStream > When I attempt to open an XSL file to complete a transformation, I get the > exception FileNotFound. Steps: > > [1] Get file location from properties file without problem: > String myXsl = > getProperties().getProperty("fop.render.article"); > > String contents: > "http://localhost/artimus/pdf/renderPdf.xsl";( verified by logging ) > > [2] construct FileInputStream from string, and I get exception > FileInputStream in = new FileInputStream(myXsl); > > Err msg: java.io.FileNotFoundException: > http:\localhost\artimus\pdf\renderPdf.xsl > > Note from the message that FileInputStream appears to change the address. > > How do I force the constructor to accept the whole address? > > regards, > douglas reames > rms finance > 919 929 3465 > > _ > MSN 8 helps eliminate e-mail viruses. Get 2 months FREE*. > http://join.msn.com/?page=features/virus > > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] _ MSN 8 with e-mail virus protection service: 2 months FREE* http://join.msn.com/?page=features/virus - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]