[jruby-user] NameError: class not found in packages

9 views
Skip to first unread message

Arthur Khachatryan

unread,
Mar 31, 2015, 3:34:03 PM3/31/15
to us...@jruby.codehaus.org
Hi,

I appreciate if somebody will help me to understand and resolve the
problem I have.

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:

....

: 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 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;

public void configureParameters( String firefoxProfileDir )
{
this.firefoxProfileDir = firefoxProfileDir;
java.io.File profilefile = new File(this.firefoxProfileDir);
FirefoxProfile profile = new FirefoxProfile(profilefile);
profile.setAcceptUntrustedCertificates(false);
// webDriver = new FirefoxDriver(profile);
}

public void func1()
{
System.out.println("calling func1 from BaseClass");
}

public void func2()
{
System.out.println("calling func2 from BaseClass");
}
}

--
Posted via http://www.ruby-forum.com/.

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

http://xircles.codehaus.org/manage_email


Kimpton, C (Chris)

unread,
Apr 1, 2015, 2:25:18 AM4/1/15
to us...@jruby.codehaus.org
Hi,

Have you add the selenium jar to the classpath too?

You can change the classpath from within Jruby - didn't realise that was possible. :)

Cheers,
Chris
--------------------------------------------------------------------------------
This email (including any attachments to it) is confidential, legally privileged, subject to copyright and is sent for the personal attention of the intended recipient only. If you have received this email in error, please advise us immediately and delete it. You are notified that disclosing, copying, distributing or taking any action in reliance on the contents of this information is strictly prohibited. Although we have taken reasonable precautions to ensure no viruses are present in this email, we cannot accept responsibility for any loss or damage arising from the viruses in this email or attachments. We exclude any liability for the content of this email, or for the consequences of any actions taken on the basis of the information provided in this email or its attachments, unless that information is subsequently confirmed in writing.
--------------------------------------------------------------------------------

Arthur Khachatryan

unread,
Apr 1, 2015, 3:16:17 AM4/1/15
to us...@jruby.codehaus.org
Yes, I have added selenium jar file as a 'javac' command argument (javac
-cp "G:\selenium_web_driver\*; ... ).

And here is what I have for setting the class path in a Ruby code ( this
is on top of the Ruby script, right after 'require' )
$CLASSPATH << 'G:/thePaths/myclasses.jar'

This is a linking issue in Jruby ( probably a bug in Jruby ), cause the
same code works while I build and run from Eclipse.
Reply all
Reply to author
Forward
0 new messages