This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 144550 - Cannot find JDBC driver when testing and Error opening script file
Summary: Cannot find JDBC driver when testing and Error opening script file
Status: RESOLVED WONTFIX
Alias: None
Product: serverplugins
Classification: Unclassified
Component: GlassFish (show other bugs)
Version: 6.x
Hardware: All All
: P4 blocker (vote)
Assignee: Nitya Doraisamy
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-08-20 10:23 UTC by hjuskewycz
Modified: 2012-11-27 12:54 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
sample project (97.59 KB, application/x-compressed)
2008-09-07 19:58 UTC, Erno Mononen
Details

Note You need to log in before you can comment on or make changes to this bug.
Description hjuskewycz 2008-08-20 10:23:45 UTC
There are two strange bugs with JRuby on Rails in Netbeans.

1. when I want to start testing with Run-> Test Project I get an error message:

"Error opening script file: C:/Documents and Settings/xxx/My Documents/NetBeansProjects/RailsApplication3/Files/NetBeans
(The system cannot find the path specified)"

2. when I try to run the test with test file or run file, it can't find the mysql driver. However, this error not always
happens. It seems that when I create the project and use Glassfish and then switch to Webrick it happens, but if I use
Webrick from the beginning it doesn't. Just to make it clear, Webrick works, starting up and working with the site is no
problem, only testing doesn't work.

RuntimeError: The driver encountered an error: cannot load Java class com.mysql.jdbc.Driver
C:/Program Files/NetBeans 6.5
Beta/ruby2/jruby-1.1.3/lib/ruby/gems/1.8/gems/activerecord-jdbc-adapter-0.8.2/lib/active_record/connection_adapters/jdbc_adapter.rb:313:in
`initialize'
C:/Program Files/NetBeans 6.5
Beta/ruby2/jruby-1.1.3/lib/ruby/gems/1.8/gems/activerecord-jdbc-adapter-0.8.2/lib/active_record/connection_adapters/jdbc_adapter.rb:46:in
`new'
C:/Program Files/NetBeans 6.5
Beta/ruby2/jruby-1.1.3/lib/ruby/gems/1.8/gems/activerecord-jdbc-adapter-0.8.2/lib/active_record/connection_adapters/jdbc_adapter.rb:46:in
`jdbc_connection'
C:/Program Files/NetBeans 6.5
Beta/ruby2/jruby-1.1.3/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/connection_adapters/abstract/connection_specification.rb:292:in
`connection='
C:/Program Files/NetBeans 6.5
Beta/ruby2/jruby-1.1.3/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/connection_adapters/abstract/connection_specification.rb:260:in
`retrieve_connection'
C:/Program Files/NetBeans 6.5
Beta/ruby2/jruby-1.1.3/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/connection_adapters/abstract/connection_specification.rb:78:in
`connection'
C:/Program Files/NetBeans 6.5
Beta/ruby2/jruby-1.1.3/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/fixtures.rb:503:in `create_fixtures'
C:/Program Files/NetBeans 6.5
Beta/ruby2/jruby-1.1.3/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/fixtures.rb:963:in `load_fixtures'
C:/Program Files/NetBeans 6.5
Beta/ruby2/jruby-1.1.3/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/fixtures.rb:929:in `setup_fixtures'
C:/Program Files/NetBeans 6.5
Beta/ruby2/jruby-1.1.3/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/callbacks.rb:173:in `evaluate_method'
C:/Program Files/NetBeans 6.5
Beta/ruby2/jruby-1.1.3/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/callbacks.rb:161:in `call'
C:/Program Files/NetBeans 6.5
Beta/ruby2/jruby-1.1.3/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/callbacks.rb:90:in `run'
C:/Program Files/NetBeans 6.5
Beta/ruby2/jruby-1.1.3/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/callbacks.rb:90:in `each'
C:/Program Files/NetBeans 6.5
Beta/ruby2/jruby-1.1.3/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/callbacks.rb:90:in `run'
C:/Program Files/NetBeans 6.5
Beta/ruby2/jruby-1.1.3/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/callbacks.rb:272:in `run_callbacks'
C:/Program Files/NetBeans 6.5
Beta/ruby2/jruby-1.1.3/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/testing/setup_and_teardown.rb:31:in
`run_with_callbacks'
C:/Program Files/NetBeans 6.5 Beta/ruby2/jruby-1.1.3/lib/ruby/1.8/test/unit/testsuite.rb:34:in `run'
C:/Program Files/NetBeans 6.5 Beta/ruby2/jruby-1.1.3/lib/ruby/1.8/test/unit/testsuite.rb:33:in `each'
C:/Program Files/NetBeans 6.5 Beta/ruby2/jruby-1.1.3/lib/ruby/1.8/test/unit/testsuite.rb:33:in `run'
C:/Program Files/NetBeans 6.5 Beta/ruby2/jruby-1.1.3/lib/ruby/1.8/test/unit/ui/testrunnermediator.rb:46:in `run_suite'
Comment 1 Erno Mononen 2008-08-20 11:46:52 UTC
The first problem you're encountering seems like issue 143941, which is fixed in dev builds (if you'd like to try it, 
please see http://wiki.netbeans.org/RubyInstallation#section-RubyInstallation-HowDoIGetTheContinuousBuilds for 
instructions). 

I'll have a look at the other issue.
Comment 2 Erno Mononen 2008-09-01 10:39:45 UTC
Seems that javac.classpath specifed in project.properties does not get passed to GF. When you choose to use JDBC, the 
Rails project wizard automatically creates an entry to project.properties for the target driver jar file, e.g.:

javac.classpath=${file.reference.mysql-connector-java-5.1.6-bin.jar}

In RailsServerManager, it looks like the classPath variable is not used when starting GF (in the glassfishEnsureRunning 
method). Peter, could you check this please?

Comment 3 _ pcw 2008-09-01 17:57:24 UTC
Yes, I know about this.  One workaround is to (manually) copy the JDBC driver into the JRuby lib folder (of the JRuby
distribution selected for the project, such as the one that comes with NetBeans)

I've been mulling & poking around for the GlassFish specific solution for a while now.  [glassfish_root]/lib didn't work
when I checked it out (might have been a GF bug).  I've just discovered this past weekend that [glassfish_domain]/lib
may work, and if true, we can wrap this up.
Comment 4 _ pcw 2008-09-04 02:34:36 UTC
Driver jar is not required when adapter is set to "jdbc[dbtype]' in database.yml -- and in fact, gets in the way for
GlassFish, I don't know why yet.

Driver jar is being added because NetBeans is still generating the old "adapter:jdbc" format (isn't that a bug?  It
doesn't seem to work, even for MySQL, why are we still using it?  Has anyone ever made it work?)

If you update database.yml to use the first format, i.e. 

  adapter: jdbcpostgresql # or correct for your db
  encoding: utf8
  database: [database name]
  username: [username]
  password: [password]
  host: localhost
  port: 5432 # or correct for your db

install the correct gem for above (activerecord-jdbcpostgresql-adapter for the above) and make sure that the JDBC driver
jar *IS NOT* in the library list on the Project Properties > Java page, then things appear to work -- this works because
the driver jar is included with the aforementioned gem.

It will work *WITH* the specified if you run in DEBUG mode or run against the V3 GEM.

I'm still investigating why the presence of the jar seems to screw things up in RUN mode.  I thought we ignored it.
Comment 5 Erno Mononen 2008-09-07 17:43:08 UTC
> Driver jar is being added because NetBeans is still generating the old "adapter:jdbc" format (isn't that a bug?  

There is issue 138316 for bundling jdbc<dbms> adapters with the IDE. We need to find out how to make them use the MySQL 
and PostgreSQL drivers already bundled with the IDE so that the distribution wouldn't have two copies of the drivers. 
I'll speak to Nick Sieger about that, but likely the issue needs to be addressed post 6.5.

> It
> doesn't seem to work, even for MySQL, why are we still using it?  Has anyone ever made it work?)

I haven't experienced any problems with the generic 'jdbc' adapter; works fine for me both with MySQL 5.0 and 
PostgreSQL 8.3.3, for example with the following IDE generated configuration:

development:
      host: localhost
      adapter: jdbc
      driver: org.postgresql.Driver
      url: jdbc:postgresql://localhost:5432/<db_name>
      username: ...
      password: ...

(With WEBrick/Mongrel). I've tried MySQL on Win/Linux and PostgreSQL on Linux.
Comment 6 _ pcw 2008-09-07 18:19:15 UTC
It doesn't work on Solaris 10/PostgreSQL (my box).

I asked Vivek to test against MySQL (I think this was on Ubuntu) and he was having the same problems (jar loading issues).

Can you tell me the OS, DB, JDK, AppServer, and NetBeans versions that you used in which it does work and attach the
project you used?  Clearly I'm doing something different (possibly totally wrong).  I've never had this working.
Comment 7 Erno Mononen 2008-09-07 19:58:57 UTC
Created attachment 69252 [details]
sample project
Comment 8 Erno Mononen 2008-09-07 19:59:51 UTC
Attached is a project created with:
 
Product Version: NetBeans IDE Dev (Build 080905)
Java: 1.5.0_15; Java HotSpot(TM) 64-Bit Server VM 1.5.0_15-b04
System: Linux version 2.6.24-19-generic running on amd64; UTF-8; en_US (nb)
 
it uses WEBrick,the built-in JRuby 1.1.4 and Rails 2.1.0. OS is Ubuntu 8.04 (64bit) and DB PostgreSQL 8.3.3.
Comment 9 _ pcw 2008-10-13 19:09:52 UTC
This issue ended up a casualty of my unexpected absence in mid September.  I'll consider it for a patch release I guess.
 I don't see it being resolved for release, way too late.
Comment 10 Vince Kraemer 2009-09-16 23:55:33 UTC
Assigned engineer: please correct the tm value.  nb 6.7 has shipped, so a tm of
6.7  is invalid at this point
Comment 11 Vince Kraemer 2009-09-16 23:59:53 UTC
assign outher half of pcw's issues
Comment 12 Vince Kraemer 2010-04-23 04:55:36 UTC
scripting support (JRuby and Rails) is not a high priority for the GF team at this point.  Lowering to p4.
Comment 13 TomasKraus 2012-11-27 12:54:39 UTC
We do not support JRuby on Rails in current GlassFish plugin releases.
Closing this bug.