FileInputStream.new myfile fails?

Why does this fail on Jruby 1.1.4?
Platform is Windows XP

myfile = ‘C:\test.xml’
fis = FileInputStream.new myfile

java.io.FileNotFoundException: (The system cannot find the
file
specified)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.(Unknown Source)
at java.io.FileInputStream.(Unknown Source)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
Method)

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


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

drrs wrote:

at java.io.FileInputStream.(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

Should it be ‘C:\test.xml’?

RaY

El 07/11/2008, a las 17:45, Charles Oliver N.
escribió:

at java.io.FileInputStream.(Unknown Source)

http://xircles.codehaus.org/manage_email


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

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-fails---tp20376265p20388547.html
Sent from the JRuby - User mailing list archive at Nabble.com.


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

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-fails---tp20376265p20389720.html
Sent from the JRuby - User mailing list archive at Nabble.com.


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

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
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.(FileInputStream.java:106)
at java.io.FileInputStream.(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 N.-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-fails---tp20376265p20387118.html
Sent from the JRuby - User mailing list archive at Nabble.com.


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

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…:frowning:

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-fails---tp20376265p20391022.html
Sent from the JRuby - User mailing list archive at Nabble.com.


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

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

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

Charles Oliver N.-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-fails---tp20376265p20400891.html
Sent from the JRuby - User mailing list archive at Nabble.com.


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

Glad you figured it all out :slight_smile: If you feel like your experience would be
interesting to others, please add something to the wiki :slight_smile:

drrs wrote:

Problem was the Error reporting here said the file path not found, where


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