-
-
Notifications
You must be signed in to change notification settings - Fork 925
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NameError: class not found in packages #2891
Comments
C:>java -version C:\jruby-9.0.0.0.pre1\bin\jruby.exe selenium-server-standalone-2.45.0.jar was located in projec_directory Here is the Java compile command: |
please try the 9.0.0.0.pre2 since there are some changes on the classloader hierarchy of jruby. |
ok, I'll try that and update the bug details. you also can try at your end. require 'java' $CLASSPATH << 'selenium-server-standalone-2.45.0.jar' module TheMainClasses puts "classpath = #{$CLASSPATH}" and here is what I get with commented string: Process finished with exit code 0 and here is what I get if I remove the comments: Process finished with exit code 1 |
C:\jruby-9.0.0.0.pre2\bin\jruby.exe --1.8 -e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift) C:/bug_in_jruby/calling_java.rb Process finished with exit code 1 |
It worked ! C:\jruby-9.0.0.0.pre1\bin\jruby.exe --1.8 -e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift) C:/bug_in_jruby/calling_java.rb Process finished with exit code 0 |
I have in BaseClass.java file the following class and while I create a
class object in a Ruby file it gets into an error if I have not
commented the instantiating of 'webDriver' ( see below ).
With the commented 'webDriver' I can call func1() and func2() Java
methods from Ruby code ( jruby test.rb ===> calling Java methods from
test.rb )
Please note that Java compilation passes with no errors and I create
then put the classes JAR file in $CLASSPATH in my Ruby file ( $CLASSPATH
<< "the_classes_jar_file" )
Without commented the 'webDriver' I am getting the following error.
This is a linking issue in Jruby ( probably a bug in Jruby ), cause the
same code works while I build and run from Eclipse.
....
: NameError: BaseClass not found in packages p1; last error: cannot link
Java class p1.BaseClass,probable missing dependency:
org/openqa/selenium/WebDriver
....
Here is the Java class:
package p1;
import java.io.File;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.;
import org.openqa.selenium.chrome.;
import org.openqa.selenium.ie.*;
public class BaseClass
{
protected static WebDriver webDriver = null;
protected static String firefoxProfileDir = "";
public void func1()
{
System.out.println("calling func1 from BaseClass");
}
public void func2()
{
System.out.println("calling func2 from BaseClass");
}
}
and here is the Jruby code ( test.rb ) calling the Java class method:
require 'java'
include Java
module TheMainClasses
include_package "p1"
end
obj_base = TheMainClasses::BaseClass.new()
obj_base.func1()
obj_base.func2()
The text was updated successfully, but these errors were encountered: