Forum: JRuby FileInputStream.new myfile fails??

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
C7aed300a54b96bf2372966ff8aeeeea?d=identicon&s=25 drrs (Guest)
on 2008-11-07 09:44
(Received via mailing list)
Why does this fail on Jruby 1.1.4?
Platform is Windows XP

myfile = 'C:\test.xml'
fis = FileInputStream.new myfile

java.io.FileNotFoundException: <file name>  (The system cannot find the
file
specified)
  at java.io.FileInputStream.open(Native Method)
  at java.io.FileInputStream.<init>(Unknown Source)
  at java.io.FileInputStream.<init>(Unknown Source)
  at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
Method)
--
View this message in context:
http://www.nabble.com/FileInputStream.new-myfile-f...
Sent from the JRuby - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
Ede2aa10c6462f1d825143879be59e38?d=identicon&s=25 Charles Oliver Nutter (Guest)
on 2008-11-07 17:46
(Received via mailing list)
drrs wrote:
>   at java.io.FileInputStream.<init>(Unknown Source)
>   at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

That code appears to work fine with a file that exists. Does C:\test.xml
exist for you?

- Charlie

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
473309c9a62a95bb9b0b3382815cdac6?d=identicon&s=25 Raimon Malatesta (Guest)
on 2008-11-07 18:01
(Received via mailing list)
Should it be 'C:\\test.xml'?

RaY

El 07/11/2008, a las 17:45, Charles Oliver Nutter
escribió:
>>   at java.io.FileInputStream.<init>(Unknown Source)
>
>   http://xircles.codehaus.org/manage_email
>
>


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
C7aed300a54b96bf2372966ff8aeeeea?d=identicon&s=25 drrs (Guest)
on 2008-11-07 20:23
(Received via mailing list)
The file exists. I even tried C:\\test.xml .

Here is the mostly the complete stack trace(below).
set JAVA_HOME=C:\jdk1.5.0_13 is used in _jrubyvars set.
Is there anything with encoding? UTF-8? Is it taking windows drive
letters
correctly.
Its just a simple Windows File read. Any alternatives?

Thanks for the response!
Rohit..


java/io/FileInputStream.java:-2:in `open':
java.io.FileNotFoundException:
testng
xmlparse.xml (The system cannot find the file specified)
(NativeException)
        from java/io/FileInputStream.java:106:in `<init>'
        from java/io/FileInputStream.java:66:in `<init>'
        from sun/reflect/NativeConstructorAccessorImpl.java:-2:in
`newInstance0'

        from sun/reflect/NativeConstructorAccessorImpl.java:39:in
`newInstance'
        from sun/reflect/DelegatingConstructorAccessorImpl.java:27:in
`newInstan
ce'
        from java/lang/reflect/Constructor.java:494:in `newInstance'
        from org/jruby/javasupport/JavaConstructor.java:226:in
`new_instance'
        from org/jruby/java/invokers/ConstructorInvoker.java:100:in
`call'
        from org/jruby/java/invokers/ConstructorInvoker.java:180:in
`call'
        from org/jruby/RubyClass.java:362:in `finvoke'
        from org/jruby/javasupport/util/RuntimeHelpers.java:326:in
`invoke'
        from org/jruby/java/proxies/ConcreteJavaProxy.java:48:in `call'
        from org/jruby/runtime/CallSite.java:168:in `cacheAndCall'
        from org/jruby/runtime/CallSite.java:406:in `call'
        from org/jruby/RubyClass.java:545:in `call'
        from
org/jruby/internal/runtime/methods/DynamicMethod.java:151:in
`call'

        from org/jruby/java/proxies/ConcreteJavaProxy.java:191:in `call'
        from org/jruby/runtime/CallSite.java:156:in `cacheAndCall'
        from org/jruby/runtime/CallSite.java:394:in `call'
        from C_3a_/mywork/trunk/jmdi.rb:37:in `__file__'
        from C_3a_/mywork/trunk/jmdi.rb:-1:in `__file__'
        from C_3a_/mywork/trunk/jmdi.rb:-1:in `load'
        from org/jruby/Ruby.java:544:in `runScript'
        from org/jruby/Ruby.java:457:in `runNormally'
        from org/jruby/Ruby.java:330:in `runFromMain'
        from org/jruby/Main.java:214:in `run'
        from org/jruby/Main.java:100:in `run'
        from org/jruby/Main.java:84:in `main'
Complete Java stackTrace
java.io.FileNotFoundException: testngxmlparse.xml (The system cannot
find
the fi
le specified)
        at java.io.FileInputStream.open(Native Method)
        at java.io.FileInputStream.<init>(FileInputStream.java:106)
        at java.io.FileInputStream.<init>(FileInputStream.java:66)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
Method)

        at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstruct
orAccessorImpl.java:39)
        at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingC
onstructorAccessorImpl.java:27)
        at
java.lang.reflect.Constructor.newInstance(Constructor.java:494)
        at
org.jruby.javasupport.JavaConstructor.new_instance(JavaConstructor.ja
va:226)
        at
org.jruby.java.invokers.ConstructorInvoker.call(ConstructorInvoker.ja
va:100)
        at
org.jruby.java.invokers.ConstructorInvoker.call(ConstructorInvoker.ja
va:180)
        at org.jruby.RubyClass.finvoke(RubyClass.java:362)
        at
org.jruby.javasupport.util.RuntimeHelpers.invoke(RuntimeHelpers.java:
326)
        at
org.jruby.java.proxies.ConcreteJavaProxy$2.call(ConcreteJavaProxy.jav
a:48)
        at
org.jruby.runtime.CallSite$InlineCachingCallSite.cacheAndCall(CallSit
e.java:168)
        at
org.jruby.runtime.CallSite$InlineCachingCallSite.call(CallSite.java:4
06)
        at org.jruby.RubyClass$SpecificArityNew.call(RubyClass.java:545)
        at
org.jruby.internal.runtime.methods.DynamicMethod.call(DynamicMethod.j
ava:151)
        at
org.jruby.java.proxies.ConcreteJavaProxy$ConcreteNewMethod.call(Concr
eteJavaProxy.java:191)
        at
org.jruby.runtime.CallSite$InlineCachingCallSite.cacheAndCall(CallSit
e.java:156)
        at
org.jruby.runtime.CallSite$InlineCachingCallSite.call(CallSite.java:3
94)
        at C_3a_.mywork.jruby_jmdi.jmdi.__file__



        at org.jruby.Ruby.runScript(Ruby.java:544)
        at org.jruby.Ruby.runNormally(Ruby.java:457)
        at org.jruby.Ruby.runFromMain(Ruby.java:330)
        at org.jruby.Main.run(Main.java:214)
        at org.jruby.Main.run(Main.java:100)
        at org.jruby.Main.main(Main.java:84)


Charles Oliver Nutter-2 wrote:
>> specified)
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>     http://xircles.codehaus.org/manage_email
>
>
>
>

--
View this message in context:
http://www.nabble.com/FileInputStream.new-myfile-f...
Sent from the JRuby - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
C7aed300a54b96bf2372966ff8aeeeea?d=identicon&s=25 drrs (Guest)
on 2008-11-07 21:49
(Received via mailing list)
Trying something like this at the Ruby File class level is better for
me:

myfile = 'c:\test.xml'
f = File.open(myfile, 'r')
contents = f.read
java_bytes = contents.to_java_bytes
puts ' java bytes got '

Thanks!

--
View this message in context:
http://www.nabble.com/FileInputStream.new-myfile-f...
Sent from the JRuby - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
C7aed300a54b96bf2372966ff8aeeeea?d=identicon&s=25 drrs (Guest)
on 2008-11-07 23:36
(Received via mailing list)
Even Java code running inside with
FileInputStream fis = new FileInputStream(path);

doesn't work in JRuby????

This statement is used in a lot of places in the Java code....

Please let me know????

--
View this message in context:
http://www.nabble.com/FileInputStream.new-myfile-f...
Sent from the JRuby - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
5f19a61c59692713f86abf93c5cfe9c1?d=identicon&s=25 Ray Krueger (Guest)
on 2008-11-07 23:38
(Received via mailing list)
> Even Java code running inside with
> FileInputStream fis = new FileInputStream(path);
>
> doesn't work in JRuby????
>
> This statement is used in a lot of places in the Java code....
>
> Please let me know????
>
> --

Try using "/test.xml", or "c:/test.xml" instead of the "\"

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
C7aed300a54b96bf2372966ff8aeeeea?d=identicon&s=25 drrs (Guest)
on 2008-11-08 02:30
(Received via mailing list)
>>>>Try using "/test.xml", or "c:/test.xml" instead of the "\"

Nope. That didn't help.

I am trying to think of possible ways I can debug it.
Cannot attach Eclipse debugger to Java code.

And trying to think what could be possible causes for it.
In fact, the absolute path is printed with the File not found message,
but
the path is correct.
May be knowing the exact mechanism like LOAD_PATH JRuby uses.
But then why would it not work with the absolute path.


This would have been great......as I have really started to like
JRuby......but...:-(

Can you test and confirm it works on your system? I will try to test on
another machine then.....

Thanks.

--
View this message in context:
http://www.nabble.com/FileInputStream.new-myfile-f...
Sent from the JRuby - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
Ede2aa10c6462f1d825143879be59e38?d=identicon&s=25 Charles Oliver Nutter (Guest)
on 2008-11-08 07:02
(Received via mailing list)
drrs wrote:
> Can you test and confirm it works on your system? I will try to test on
> another machine then.....

Can you just try this code and make sure it works:

File.open('C:\test.xml')

or

File.open('C:/test.xml')

That's the Ruby File class, and if it doesn't work there's something
else wrong on your system.

- Charlie

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
C7aed300a54b96bf2372966ff8aeeeea?d=identicon&s=25 drrs (Guest)
on 2008-11-08 23:02
(Received via mailing list)
Charles Oliver Nutter-2 wrote:
> stream.
> Anyways, I could run the test using JRuby once the ruby did the directory
>
>
--
View this message in context:
http://www.nabble.com/FileInputStream.new-myfile-f...
Sent from the JRuby - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
Ede2aa10c6462f1d825143879be59e38?d=identicon&s=25 Charles Oliver Nutter (Guest)
on 2008-11-14 05:20
(Received via mailing list)
Glad you figured it all out :) If you feel like your experience would be
interesting to others, please add something to the wiki :)

drrs wrote:
>> Problem was the Error reporting here said the file path not found, where
>>
>> <eom>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe from this list, please visit:
>>
>>     http://xircles.codehaus.org/manage_email
>>
>>
>>
>>
>


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
This topic is locked and can not be replied to.