Skip to content
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

toJava coersion regression when binding to JNDI #2934

Closed
kares opened this issue May 12, 2015 · 2 comments
Closed

toJava coersion regression when binding to JNDI #2934

kares opened this issue May 12, 2015 · 2 comments

Comments

@kares
Copy link
Member

kares commented May 12, 2015

... can't seem to wrap my head around it - for now :

# jruby -Ijdbc-derby/lib -J-cp tomcat-catalina.jar:tomcat-juli.jar 9000_regression.rb

java.lang.System.set_property(
    javax.naming.Context::INITIAL_CONTEXT_FACTORY,
    'org.apache.naming.java.javaURLContextFactory'
)
java.lang.System.set_property(
    javax.naming.Context::URL_PKG_PREFIXES,
    'org.apache.naming'
)

puts init_context = Java::JavaxNaming::InitialContext.new
begin
  init_context.create_subcontext 'jdbc'
rescue javax.naming.NameAlreadyBoundException
end

require 'jdbc/derby'
Jdbc::Derby.load_driver

data_source = org.apache.derby.jdbc.EmbeddedDataSource.new
data_source.database_name = "memory:DerbyDB-JNDI"
data_source.create_database = "create"
data_source.user = "sa"
data_source.password = ""

Java::JavaxNaming::InitialContext.new.bind 'jdbc/DerbyDB', data_source

bound = Java::JavaxNaming::InitialContext.new.lookup 'jdbc/DerbyDB'
puts bound
puts bound.java_class

# jruby 1.7.20 (1.9.3p551) 2015-05-04 3086e6a on Java HotSpot(TM) 64-Bit Server VM 1.7.0_72-b14 +jit [linux-amd64]
#
#  javax.naming.InitialContext@1189857e
#  org.apache.derby.jdbc.EmbeddedDataSource@5683befd
#  org.apache.derby.jdbc.EmbeddedDataSource
#

# jruby 9.0.0.0-SNAPSHOT (2.2.2) 2015-05-11 69147e5 Java HotSpot(TM) 64-Bit Server VM 24.72-b04 on 1.7.0_72-b14 +jit [linux-amd64]
#
# javax.naming.InitialContext@6da9d673
#  Reference Class Name: org.apache.derby.jdbc.EmbeddedDataSource
#  Type: password
#  Content:
#  Type: databaseName
#  Content: memory:DerbyDB-JNDI
#  Type: user
#  Content: sa
#  Type: loginTimeout
#  Content: 0
#  Type: createDatabase
#  Content: create
#  Type: attributesAsPassword
#  Content: false
#  javax.naming.Reference

for some reason under 9K this is no longer bound as a javax.sql.DataSource but instead as a javax.naming.Reference - EmbeddedDataSource implements both ... must be some spooky toJava conversion going around

several .jars are needed to run the script

add'em to class-path e.g. jruby -J-cp tomcat-catalina-7.0.61.jar:tomcat-juli-7.0.61.jar 9000_regression.rb

@mkristian mkristian self-assigned this May 12, 2015
@kares kares changed the title toJava conversion regression when binding to JNDI toJava coersion regression when binding to JNDI May 12, 2015
kares added a commit to jruby/activerecord-jdbc-adapter that referenced this issue May 12, 2015
@kares
Copy link
Member Author

kares commented Aug 15, 2015

@mkristian do you recall if you did actually something about this one ... or now the cause ?

@kares
Copy link
Member Author

kares commented Apr 6, 2016

verified - working fine in 9.0.5

@kares kares closed this as completed Apr 6, 2016
@kares kares added this to the Invalid or Duplicate milestone Apr 6, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants