Help with Name Collision

Hi,

I’m checking out “Glimmer”, a DSL which provides a simple interface to
the
SWT library for desktop app development. I’m trying to modify a supplied
sample app, a contact manager, so that it loads contacts from a database
(activerecord-jdbcsqlite3) instead of using hard-coded values.

When I run the script (without warnings) I get -

“Processing method: text and args: [“Contact Manager”]
c:/jruby/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/core_ext/string/output_safety.rb:25:in
`add_with_safety’: can’t convert nil into String (TypeError)”

which would seem to indicate that I’m passing a nil object. In irb, the
data
and format look good to me - but I’m a newbie.

When I run it with jruby -w, I get - “Processing method: text and args:
[“Contact Manager”]
java.lang.ClassNotFoundException: org.eclipse.swt.Table” before the
error
above.

There is a Table in swt.jar but it’s in org.eclipse.swt.widgets. Is this
a
name conflict with another Table? and if so how do I resolve it?

BTW, I’ve tried restoring the original (hard-coded) instantiation of
contacts from values and commenting out ALL my code, except for -
require
‘active_record’ - in which case, I still get the errors.

So is this a name collision, a conflict with ActiveRecord or just
something
I’m doing wrong?
Any ideas greatly appreciated!
haden

View this message in context:
http://old.nabble.com/Help-with-Name-Collision-tp27424567p27424567.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

On Tue, Feb 2, 2010 at 11:50 AM, haden [email protected] wrote:

"Processing method: text and args: [“Contact Manager”]

There is a Table in swt.jar but it’s in org.eclipse.swt.widgets. Is this a
name conflict with another Table? and if so how do I resolve it?

BTW, I’ve tried restoring the original (hard-coded) instantiation of
contacts from values and commenting out ALL my code, except for - require
‘active_record’ - in which case, I still get the errors.

So is this a name collision, a conflict with ActiveRecord or just something
I’m doing wrong?
Any ideas greatly appreciated!

Hi,

Nothing rings a bell for me here. So you can get the contacts
application running fine without loading ActiveRecord? Maybe there is
a clash with a class named Table but it’s hard to know for sure. At
any rate, if you could narrow down to a small piece of code that
doesn’t work and share that with us, that would help! Good luck.

/Nick


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

Thanks for your response Nick.

Yeah, Andy initializes a contacts array (shown commented out below). I
added
the db access. To test where it was breaking, I uncommented the
hard-coded
Contacts and commented out the db stuff. If the "require ‘ActiveRecord’
"
line is uncommented, I get the error.

I believe Glimmer is starting to parse the contact_manager when it gives
this error:
Processing method: text and args: [“Contact Manager”]
java.lang.ClassNotFoundException: org.eclipse.swt.Table

If you see some error w/ what I’m doing, I’d appreciate knowing about
it.
Thanks!
haden

Andy’s source is at: http://www.eclipse.org/glimmer/

################################################################################

Copyright © 2008 Annas Al Maleh.

All rights reserved. This program and the accompanying materials

are made available under the terms of the Eclipse Public License v1.0

which accompanies this distribution, and is available at

http://www.eclipse.org/legal/epl-v10.html

Contributors:

Annas Al Maleh - initial API and implementation

################################################################################
require ‘rubygems’
require ‘active_record’
gem ‘activerecord-jdbcsqlite3-adapter’
require ‘yaml’

require File.dirname(FILE) + “/contact”

class ContactRepository

def initialize
@connections = YAML.load_file(“database.yml”)
ActiveRecord::Base.establish_connection(@connections[“development”])
stmt = “select first_name, last_name, email from contacts”
@val = ActiveRecord::Base.connection.select_all(stmt)
@contacts = []

@val.each do |c|
puts “from @val: #{c[“first_name”]} #{c[“last_name”]}
#{c[“email”]}”
@map = {:first_name => c[“first_name”], :last_name =>
c[“last_name”],
:email => c[“email”] }
puts “@map_from_puts #{@map}”
@contacts << Contact.new( @map )
end
end

@contacts = [

Contact.new(:first_name => “Anne”, :last_name => “Sweeney”,

:email =>
[email protected]”),

Contact.new(:first_name => “Beatrice”, :last_name => “Jung”,

:email
=> “[email protected]”),

Contact.new(:first_name => “Frank”, :last_name => “Deelio”,

:email =>
[email protected]”),

Contact.new(:first_name => “franky”, :last_name => “miller”,

:email
=> “[email protected]”),

]

end


View this message in context:
http://old.nabble.com/Help-with-Name-Collision-tp27424567p27430832.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

On Wed, Feb 3, 2010 at 9:57 AM, Thomas E Enebo [email protected]
wrote:

Unfortunately, we are not big fans of include_package and do not
recommend its use (it is slow, cannot be used in top-level namespace,
and it depends on const_missing).

Maybe it’s time we gave the Jython package indexer another shot (or
tried to build a simple one of our own). Ideally, for any JRuby app,
we can populate an index from scanning classpath’s jars, ship an index
for Java 6’s classes, and update our index whenever new jar files are
required in.

We could also rejigger include_package to not install a real
const_missing but to flip some bits inside RubyModule so that it knows
about packages. Basically, if any packages had been added to a module,
some logic would fire that would additionally try to load a class
before moving on to normal module hierarchy searching. The impact
would be a lot less than current logic, and would allow constants and
const_missing hooks in other surrounding scopes to fire properly.

  • Charlie

To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

I would lay 5$ ( :slight_smile: ) that this is because glimmer is using
include_package (heavily?) to include classes and the impl of
include_package depends on const_missing. So some glimmer code is
seeing a reference to a Table constant and perhaps AR is using some
const_missing hook as well and the include_package const_missing is
the winner…kaboom.

At least that would be my working theory…

You could maybe try loading a record or two before initializing any
glimmer GUI code and see if it goes away.

Unfortunately, we are not big fans of include_package and do not
recommend its use (it is slow, cannot be used in top-level namespace,
and it depends on const_missing).

-Tom

On Tue, Feb 2, 2010 at 9:41 PM, haden [email protected] wrote:

Processing method: text and args: [“Contact Manager”]

All rights reserved. This program and the accompanying materials

require ‘yaml’
@contacts = []

Contact.new(:first_name => “Anne”, :last_name => “Sweeney”, :email =>


http://xircles.codehaus.org/manage_email


blog: http://blog.enebo.com twitter: tom_enebo
mail: [email protected]


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

Thomas E Enebo wrote:

I would lay 5$ ( :slight_smile: ) that this is because glimmer is using
include_package (heavily?) to include classes and the impl of
include_package depends on const_missing.

I sent Andy a link to this thread as a possible clue.
He’s posted my some of our exchange about this issue on the Glimmer
Eclipse
Newsgroup:
http://www.eclipse.org/forums/index.php?t=msg&goto=512039&#msg_512039

Thank you all for your responses.
Haden

View this message in context:
http://old.nabble.com/Help-with-Name-Collision-tp27424567p27446697.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

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs