[kepler-users] problem with the URL To Local File actor and a symbol

Christopher Brooks cxh at eecs.berkeley.edu
Sun Jun 14 10:17:10 PDT 2009


Hi Trina,

I can't get this to fail for me, what version of Kepler are you using
(Kepler 1.0.0?  Kepler 1.x from the svn tree?)
and what version of Java?
To get the version of Java: start Kepler and go to Tools -> Check System
Settings and find the the java.runtime.version property.
For example, I have:
java.runtime.version = 1.5.0_16-b06-284

I've attached a model that works for me in the development version
of Kepler.  I did not test it in Kepler-1.0.0.

Does the attached model fail for you?  If not, can you send a test
case that does fail?  The URI issue is fairly tricky, I have
no doubt that there are bugs to be found.

I think the reason the error would occur is because | is probably not
permitted in URIs.  The relationship between URIs and URLs is tricky.
http://java.sun.com/j2se/1.5.0/docs/api/java/net/URI.html says:
"A URI is a uniform resource identifier while a URL is a uniform
resource locator. Hence every URL is a URI, abstractly speaking, but not
  every URI is a URL. This is because there is another subcategory of
  URIs, uniform resource names (URNs), which name resources but do not
  specify how to locate them. The mailto, news, and isbn URIs shown above
  are examples of URNs."

In Java, java.net.URI was introduced after java.net.URL.  The URI class
gives us certain methods not present in the URL class.

The reason you would see the error is because | is not permitted in
Java's URI class.  To replicate this, note that creating a URI fails:

bash-3.2$ java -classpath $PTII:${PTII}/lib/ptjacl.jar tcl.lang.Shell
% java::new java.net.URI 
http://data.aims.gov.au/awsqaqc/XmlDataServlet?fromDate=2008-02-01T00:00:00&thruDate=2008-02-10T00:00:00&stations=4&agperiod=day&agFunct=max|avg&vars=4h&dataLevel=level0&bleach=0&vers=2
java.net.URISyntaxException: Illegal character in query at index 140: 
http://data.aims.gov.au/awsqaqc/XmlDataServlet?fromDate=2008-02-01T00:00:00&thruDate=2008-02-10T00:00:00&stations=4&agperiod=day&agFunct=max|avg&vars=4h&dataLevel=level0&bleach=0&vers=2
%


However, for me, running nameToURL works:
% set a [java::call ptolemy.util.FileUtilities nameToURL 
"http://data.aims.gov.au/awsqaqc/XmlDataServlet?fromDate=2008-02-01T00:00:00&thruDate=2008-02-10T00:00:00&stations=4&agperiod=day&agFunct=max|avg&vars=4h&dataLevel=level0&bleach=0&vers=2" 
[java::null] [java::null]]
java0x3
% $a toString
http://data.aims.gov.au/awsqaqc/XmlDataServlet?fromDate=2008-02-01T00:00:00&thruDate=2008-02-10T00:00:00&stations=4&agperiod=day&agFunct=max|avg&vars=4h&dataLevel=level0&bleach=0&vers=2
%

I tried the above command under Ptolemy II 7.0.1, which is the version
of Ptolemy used by Kepler 1.0.0.  I also tried it under Java 1.5.0_16
and Java 1.6.0_07.

_Christopher

Trina Myers wrote:
> Hi All,
> 
> I have a workflow that extracts xml files from a servlet and transforms the
> data within using the XPATH actor. It has been working very well until I
> have tried to import 2 elements from the site. The only difference between
> the URL in question and the working URL is the use of "|" (separating
> max|avg). 
> If I download the xml file with both elements and use the absolute address
> to the file on the local machine the workflow works fine (extracting both
> the avg and max data as required), so I am sure the problem is at the URL to
> local file actor.
> 
> I would appreciate any guidance
> Cheers
> Trina
> 
> The error message:
> 
> ptolemy.kernel.util.IllegalActionException: Cannot read file
> 'http://data.aims.gov.au/awsqaqc/XmlDataServlet?fromDate=2008-02-01T00:00:00
> &thruDate=2008-02-10T00:00:00&stations=4&agperiod=day&agFunct=max|avg&vars=4
> h&dataLevel=level0&bleach=0&vers=2'
>   in .test_url.URL To Local File.fileOrURL
> Because:
> Problem with URI format in
> 'http://data.aims.gov.au/awsqaqc/XmlDataServlet?fromDate=2008-02-01T00:00:00
> &thruDate=2008-02-10T00:00:00&stations=4&agperiod=day&agFunct=max|avg&vars=4
> h&dataLevel=level0&bleach=0&vers=2'. and
> 'http://data.aims.gov.au/awsqaqc/XmlDataServlet?fromDate=2008-02-01T00:00:00
> &thruDate=2008-02-10T00:00:00&stations=4&agperiod=day&agFunct=max|avg&vars=4
> h&dataLevel=level0&bleach=0&vers=2' This can happen if the file name is not
> absoluteand is not present relative to the directory in which the specified
> model was read (which was
> 'file:/C:/Documents%20and%20Settings/Trina/Desktop/THESIS_wORKFLOWS/Hypothes
> isTest_Reef/AIMS_REALTIME/test_url.xml')
> 	at ptolemy.data.expr.FileParameter.asURL(FileParameter.java:216)
> 	at util.URLToLocalFile._openAndReadBytes(URLToLocalFile.java:226)
> 	at util.URLToLocalFile.fire(URLToLocalFile.java:166)
> 	at ptolemy.actor.AtomicActor.iterate(AtomicActor.java:398)
> 	at
> ptolemy.actor.sched.StaticSchedulingDirector.fire(StaticSchedulingDirector.j
> ava:170)
> 	at ptolemy.actor.CompositeActor.fire(CompositeActor.java:400)
> 	at ptolemy.actor.Manager.iterate(Manager.java:688)
> 	at ptolemy.actor.Manager.execute(Manager.java:332)
> 	at ptolemy.actor.Manager.run(Manager.java:1071)
> 	at ptolemy.actor.Manager$3.run(Manager.java:1112)
> Caused by: java.io.IOException: Problem with URI format in
> 'http://data.aims.gov.au/awsqaqc/XmlDataServlet?fromDate=2008-02-01T00:00:00
> &thruDate=2008-02-10T00:00:00&stations=4&agperiod=day&agFunct=max|avg&vars=4
> h&dataLevel=level0&bleach=0&vers=2'. and
> 'http://data.aims.gov.au/awsqaqc/XmlDataServlet?fromDate=2008-02-01T00:00:00
> &thruDate=2008-02-10T00:00:00&stations=4&agperiod=day&agFunct=max|avg&vars=4
> h&dataLevel=level0&bleach=0&vers=2' This can happen if the file name is not
> absoluteand is not present relative to the directory in which the specified
> model was read (which was
> 'file:/C:/Documents%20and%20Settings/Trina/Desktop/THESIS_wORKFLOWS/Hypothes
> isTest_Reef/AIMS_REALTIME/test_url.xml')
> 	at ptolemy.util.FileUtilities.nameToURL(FileUtilities.java:356)
> 	at ptolemy.data.expr.FileParameter.asURL(FileParameter.java:213)
> 	... 9 more
> Caused by: java.lang.IllegalArgumentException
> 	at java.net.URI.create(Unknown Source)
> 	at java.net.URI.resolve(Unknown Source)
> 	at ptolemy.util.FileUtilities.nameToURL(FileUtilities.java:353)
> 	... 10 more
> Caused by: java.net.URISyntaxException: Illegal character in query at index
> 140:
> http://data.aims.gov.au/awsqaqc/XmlDataServlet?fromDate=2008-02-01T00:00:00&
> thruDate=2008-02-10T00:00:00&stations=4&agperiod=day&agFunct=max|avg&vars=4h
> &dataLevel=level0&bleach=0&vers=2
> 	at java.net.URI$Parser.fail(Unknown Source)
> 	at java.net.URI$Parser.checkChars(Unknown Source)
> 	at java.net.URI$Parser.parseHierarchical(Unknown Source)
> 	at java.net.URI$Parser.parse(Unknown Source)
> 	at java.net.URI.<init>(Unknown Source)
> 	... 13 more
> Caused by: java.io.IOException: Problem with URI format in
> 'http://data.aims.gov.au/awsqaqc/XmlDataServlet?fromDate=2008-02-01T00:00:00
> &thruDate=2008-02-10T00:00:00&stations=4&agperiod=day&agFunct=max|avg&vars=4
> h&dataLevel=level0&bleach=0&vers=2'. and
> 'http://data.aims.gov.au/awsqaqc/XmlDataServlet?fromDate=2008-02-01T00:00:00
> &thruDate=2008-02-10T00:00:00&stations=4&agperiod=day&agFunct=max|avg&vars=4
> h&dataLevel=level0&bleach=0&vers=2' This can happen if the file name is not
> absoluteand is not present relative to the directory in which the specified
> model was read (which was
> 'file:/C:/Documents%20and%20Settings/Trina/Desktop/THESIS_wORKFLOWS/Hypothes
> isTest_Reef/AIMS_REALTIME/test_url.xml')
> 	at ptolemy.util.FileUtilities.nameToURL(FileUtilities.java:356)
> 	at ptolemy.data.expr.FileParameter.asURL(FileParameter.java:213)
> 	at util.URLToLocalFile._openAndReadBytes(URLToLocalFile.java:226)
> 	at util.URLToLocalFile.fire(URLToLocalFile.java:166)
> 	at ptolemy.actor.AtomicActor.iterate(AtomicActor.java:398)
> 	at
> ptolemy.actor.sched.StaticSchedulingDirector.fire(StaticSchedulingDirector.j
> ava:170)
> 	at ptolemy.actor.CompositeActor.fire(CompositeActor.java:400)
> 	at ptolemy.actor.Manager.iterate(Manager.java:688)
> 	at ptolemy.actor.Manager.execute(Manager.java:332)
> 	at ptolemy.actor.Manager.run(Manager.java:1071)
> 	at ptolemy.actor.Manager$3.run(Manager.java:1112)
> Caused by: java.lang.IllegalArgumentException
> 	at java.net.URI.create(Unknown Source)
> 	at java.net.URI.resolve(Unknown Source)
> 	at ptolemy.util.FileUtilities.nameToURL(FileUtilities.java:353)
> 	... 10 more
> Caused by: java.net.URISyntaxException: Illegal character in query at index
> 140:
> http://data.aims.gov.au/awsqaqc/XmlDataServlet?fromDate=2008-02-01T00:00:00&
> thruDate=2008-02-10T00:00:00&stations=4&agperiod=day&agFunct=max|avg&vars=4h
> &dataLevel=level0&bleach=0&vers=2
> 	at java.net.URI$Parser.fail(Unknown Source)
> 	at java.net.URI$Parser.checkChars(Unknown Source)
> 	at java.net.URI$Parser.parseHierarchical(Unknown Source)
> 	at java.net.URI$Parser.parse(Unknown Source)
> 	at java.net.URI.<init>(Unknown Source)
> 	... 13 more
> 
> _______________________________________________
> Kepler-users mailing list
> Kepler-users at kepler-project.org
> http://mercury.nceas.ucsb.edu/kepler/mailman/listinfo/kepler-users

-- 
Christopher Brooks (cxh at eecs berkeley edu) University of California
CHESS Executive Director                      US Mail: 337 Cory Hall
Programmer/Analyst CHESS/Ptolemy/Trust        Berkeley, CA 94720-1774
ph: 510.643.9841 fax:510.642.2718	      (Office: 545Q Cory)
home: (F-Tu) 707.665.0131 (W-F) 510.655.5480
-------------- next part --------------
A non-text attachment was scrubbed...
Name: URLToLocalFileTest.xml
Type: text/xml
Size: 23217 bytes
Desc: not available
URL: <http://lists.nceas.ucsb.edu/kepler/pipermail/kepler-users/attachments/20090614/92a49767/attachment.xml>


More information about the Kepler-users mailing list