headius / jruby-pg Goto Github PK
View Code? Open in Web Editor NEWA JRuby version of the "pg" gem.
License: Other
A JRuby version of the "pg" gem.
License: Other
Hello @headius! I'm working on the next version of Subledger and am trying to keep my runtime options open. The system is built around Reel web server and the Celluloid ecosystem and mindset.
I'm having a hard time getting it running on JRuby. I'm using the pg gem and found jruby-pg and it appeared to cover my needs as a pg replacement.
However, upon booting on JRuby, the app crashes with the following exception. It's worth noting that it doesn't crash when I send it a request, but simply upon booting.
I tried to re-create a minimum crash example, but came up short. When isolated from the rest of the system, my DbConnection cell behaved just fine on JRuby using jruby-pg.
Can you tell from the backtrace what might be happening?
v3 $ ./api.rb
E, [2014-04-06T22:11:57.729000 #62114] ERROR -- : Subledger::Operations::Utilities::Aws::DbConnection crashed!
Java::JavaLang::NullPointerException:
org.jruby.pg.PostgresHelpers.stringify(PostgresHelpers.java:9)
org.jruby.pg.Connection.parse_args(Connection.java:352)
org.jruby.pg.Connection.initialize(Connection.java:397)
org.jruby.pg.Connection$INVOKER$i$0$0$initialize.call(Connection$INVOKER$i$0$0$initialize.gen)
org.jruby.internal.runtime.methods.JavaMethod$JavaMethodN.call(JavaMethod.java:665)
org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:336)
org.jruby.runtime.callsite.CachingCallSite.callBlock(CachingCallSite.java:179)
org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:183)
org.jruby.RubyClass.newInstance(RubyClass.java:804)
org.jruby.RubyClass$INVOKER$i$newInstance.call(RubyClass$INVOKER$i$newInstance.gen)
org.jruby.internal.runtime.methods.JavaMethod$JavaMethodZeroOrOneOrNBlock.call(JavaMethod.java:297)
org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:326)
org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:170)
org.jruby.ast.CallSpecialArgNode.interpret(CallSpecialArgNode.java:67)
org.jruby.ast.ReturnNode.interpret(ReturnNode.java:92)
org.jruby.ast.NewlineNode.interpret(NewlineNode.java:105)
org.jruby.evaluator.ASTInterpreter.INTERPRET_METHOD(ASTInterpreter.java:74)
org.jruby.internal.runtime.methods.InterpretedMethod.call(InterpretedMethod.java:182)
org.jruby.internal.runtime.methods.DefaultMethod.call(DefaultMethod.java:198)
org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:326)
org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:170)
org.jruby.ast.CallOneArgNode.interpret(CallOneArgNode.java:57)
org.jruby.ast.InstAsgnNode.interpret(InstAsgnNode.java:95)
org.jruby.ast.OpAsgnOrNode.interpret(OpAsgnOrNode.java:102)
org.jruby.ast.NewlineNode.interpret(NewlineNode.java:105)
org.jruby.ast.BlockNode.interpret(BlockNode.java:71)
org.jruby.evaluator.ASTInterpreter.INTERPRET_METHOD(ASTInterpreter.java:74)
org.jruby.internal.runtime.methods.InterpretedMethod.call(InterpretedMethod.java:112)
org.jruby.internal.runtime.methods.DefaultMethod.call(DefaultMethod.java:164)
org.jruby.RubyClass.finvoke(RubyClass.java:548)
org.jruby.RubyBasicObject.send19(RubyBasicObject.java:1531)
org.jruby.RubyBasicObject$INVOKER$i$send19.call(RubyBasicObject$INVOKER$i$send19.gen)
org.jruby.RubyKernel.public_send(RubyKernel.java:1965)
org.jruby.RubyKernel$INVOKER$s$0$0$public_send.call(RubyKernel$INVOKER$s$0$0$public_send.gen)
org.jruby.internal.runtime.methods.DynamicMethod.call(DynamicMethod.java:218)
org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:356)
org.jruby.runtime.callsite.CachingCallSite.callBlock(CachingCallSite.java:213)
org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:217)
org.jruby.ast.CallSpecialArgBlockPassNode.interpret(CallSpecialArgBlockPassNode.java:66)
org.jruby.ast.NewlineNode.interpret(NewlineNode.java:105)
org.jruby.ast.BlockNode.interpret(BlockNode.java:71)
org.jruby.ast.RescueNode.executeBody(RescueNode.java:221)
org.jruby.ast.RescueNode.interpret(RescueNode.java:116)
org.jruby.evaluator.ASTInterpreter.INTERPRET_METHOD(ASTInterpreter.java:74)
org.jruby.internal.runtime.methods.InterpretedMethod.call(InterpretedMethod.java:204)
org.jruby.internal.runtime.methods.DefaultMethod.call(DefaultMethod.java:206)
org.jruby.runtime.callsite.SuperCallSite.callBlock(SuperCallSite.java:190)
org.jruby.runtime.callsite.SuperCallSite.call(SuperCallSite.java:197)
org.jruby.runtime.callsite.SuperCallSite.callVarargs(SuperCallSite.java:108)
org.jruby.ast.SuperNode.interpret(SuperNode.java:115)
org.jruby.ast.LocalAsgnNode.interpret(LocalAsgnNode.java:123)
org.jruby.ast.NewlineNode.interpret(NewlineNode.java:105)
org.jruby.ast.BlockNode.interpret(BlockNode.java:71)
org.jruby.ast.RescueNode.executeBody(RescueNode.java:221)
org.jruby.ast.RescueNode.interpret(RescueNode.java:116)
org.jruby.ast.EnsureNode.interpret(EnsureNode.java:96)
org.jruby.evaluator.ASTInterpreter.INTERPRET_METHOD(ASTInterpreter.java:74)
org.jruby.internal.runtime.methods.InterpretedMethod.call(InterpretedMethod.java:182)
org.jruby.internal.runtime.methods.DefaultMethod.call(DefaultMethod.java:198)
org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:168)
org.jruby.ast.CallOneArgNode.interpret(CallOneArgNode.java:57)
org.jruby.ast.NewlineNode.interpret(NewlineNode.java:105)
org.jruby.evaluator.ASTInterpreter.INTERPRET_BLOCK(ASTInterpreter.java:112)
org.jruby.runtime.Interpreted19Block.evalBlockBody(Interpreted19Block.java:206)
org.jruby.runtime.Interpreted19Block.yield(Interpreted19Block.java:157)
org.jruby.runtime.Interpreted19Block.yieldSpecific(Interpreted19Block.java:130)
org.jruby.runtime.Block.yieldSpecific(Block.java:111)
org.jruby.ast.ZYieldNode.interpret(ZYieldNode.java:25)
org.jruby.ast.NewlineNode.interpret(NewlineNode.java:105)
org.jruby.ast.IfNode.interpret(IfNode.java:118)
org.jruby.ast.NewlineNode.interpret(NewlineNode.java:105)
org.jruby.evaluator.ASTInterpreter.INTERPRET_BLOCK(ASTInterpreter.java:112)
org.jruby.runtime.Interpreted19Block.evalBlockBody(Interpreted19Block.java:206)
org.jruby.runtime.Interpreted19Block.yield(Interpreted19Block.java:157)
org.jruby.runtime.Interpreted19Block.yieldSpecific(Interpreted19Block.java:130)
org.jruby.runtime.Block.yieldSpecific(Block.java:111)
org.jruby.ast.ZYieldNode.interpret(ZYieldNode.java:25)
org.jruby.ast.NewlineNode.interpret(NewlineNode.java:105)
org.jruby.ast.BlockNode.interpret(BlockNode.java:71)
org.jruby.ast.RescueNode.executeBody(RescueNode.java:221)
org.jruby.ast.RescueNode.interpret(RescueNode.java:116)
org.jruby.ast.EnsureNode.interpret(EnsureNode.java:96)
org.jruby.ast.BeginNode.interpret(BeginNode.java:83)
org.jruby.ast.NewlineNode.interpret(NewlineNode.java:105)
org.jruby.evaluator.ASTInterpreter.INTERPRET_BLOCK(ASTInterpreter.java:112)
org.jruby.runtime.Interpreted19Block.evalBlockBody(Interpreted19Block.java:206)
org.jruby.runtime.Interpreted19Block.yield(Interpreted19Block.java:157)
org.jruby.runtime.Interpreted19Block.yieldSpecific(Interpreted19Block.java:130)
org.jruby.runtime.Block.yieldSpecific(Block.java:111)
org.jruby.ast.ZYieldNode.interpret(ZYieldNode.java:25)
org.jruby.ast.NewlineNode.interpret(NewlineNode.java:105)
org.jruby.ast.BlockNode.interpret(BlockNode.java:71)
org.jruby.evaluator.ASTInterpreter.INTERPRET_BLOCK(ASTInterpreter.java:112)
org.jruby.runtime.Interpreted19Block.evalBlockBody(Interpreted19Block.java:206)
org.jruby.runtime.Interpreted19Block.yield(Interpreted19Block.java:194)
org.jruby.runtime.Interpreted19Block.yield(Interpreted19Block.java:177)
org.jruby.runtime.Block.yieldArray(Block.java:158)
org.jruby.ext.fiber.ThreadFiber$1.run(ThreadFiber.java:222)
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
java.lang.Thread.run(Thread.java:695)
RubyGems.org doesn't report a license for your gem. This is because it is not specified in the gemspec of your last release.
via e.g.
spec.license = 'MIT'
# or
spec.licenses = ['MIT', 'GPL-2']
Including a license in your gemspec is an easy way for rubygems.org and other tools to check how your gem is licensed. As you can imagine, scanning your repository for a LICENSE file or parsing the README, and then attempting to identify the license or licenses is much more difficult and more error prone. So, even for projects that already specify a license, including a license in your gemspec is a good practice. See, for example, how rubygems.org uses the gemspec to display the rails gem license.
There is even a License Finder gem to help companies/individuals ensure all gems they use meet their licensing needs. This tool depends on license information being available in the gemspec. This is an important enough issue that even Bundler now generates gems with a default 'MIT' license.
I hope you'll consider specifying a license in your gemspec. If not, please just close the issue with a nice message. In either case, I'll follow up. Thanks for your time!
Appendix:
If you need help choosing a license (sorry, I haven't checked your readme or looked for a license file), GitHub has created a license picker tool. Code without a license specified defaults to 'All rights reserved'-- denying others all rights to use of the code.
Here's a list of the license names I've found and their frequencies
p.s. In case you're wondering how I found you and why I made this issue, it's because I'm collecting stats on gems (I was originally looking for download data) and decided to collect license metadata,too, and make issues for gemspecs not specifying a license as a public service :). See the previous link or my blog post about this project for more information.
Environment:
When running the rake
command, I get a weird git checkout
error.
When running the test_all.sh
script, it runs quite a few more things, but also gives plenty of errors. In the linked gist:
There is a superuser account in my Postgres installation with my system login name and no password (I can run a bare psql
command and start typing SQL commands).
I have the following error when issuing a regexp match operation in pg connection:
model.where("? ~* #{field}", value.text).order(code: :desc).to_sql
# => "SELECT \"purchases\".* FROM \"purchases\" WHERE ('c2b32596-c0cc-4157-b007-1c3dbcf5f4be' ~* source_guid) ORDER BY \"purchases\".\"code\" DESC"
the error text:
output error: java.lang.NoSuchMethodError: org.jruby.RubyEncoding.newEncoding(Lorg/jruby/Ruby;Lorg/jcodings/Encoding;)Lorg/jruby/RubyEncoding;
The readme says...
# Please note that the 1.0 is necessary to let bundler do its dependency management, as there is no .gemspec in the source.
gem 'pg', '0.17.1', :platform => :jruby, :git => 'git://github.com/headius/jruby-pg.git', :branch => :master
I see no "1.0" in that line. Is it meant to say "installing from git is necessary"?
require 'pg'
pg = PG::Connection.open :dbname => 'scrap'
pg.wait_for_notify(0.1) # Never returns
The .jar
seems to be outdated.
I get a message described in #31 for any Postgres error.
I tried using this gem as a drop-in replacement for pg
while attempting to get Discourse to run on JRuby.
Due to this line, the ActiveRecord Postgresql adapter is unable to recognize this gem as satisfying its requirements. I always get:
Gem::LoadError: Specified 'postgresql' for database adapter, but the gem is not loaded. Add `gem 'pg'` to your Gemfile.
I was able to get things to work by forking the gem and editing the gemspec.
I'm not sure what the correct long-term approach is. Either ActiveRecord should be fixed (ideal?), or the gem
method itself needs to be patched (ugly?).
using jruby-pg in a multithreaded way gives the following errors
PG::Error:
Cannot consume input while connection is in SendingDescribe state
PG::Error:
message is incomplete
I'm trying get jruby-pg running with RDBI. RDBI makes heavy use of the fname function on the result object. Unfortunately, this results in the jruby-pg gem not working entirely.
I noticed that in the jruby-pg source code fname is set to nil. I believe that functionally it is equivalent to result.fields[i], so my guess is that it is not a big deal to implement because fields is working correctly.
@JRubyMethod
public IRubyObject fname(ThreadContext context, IRubyObject arg0) {
return context.nil;
}
gem install jruby-pg
ERROR: Could not find a valid gem 'jruby-pg' (>= 0) in any repository
(switched to jruby-9.0.0.0 recently)
I'm getting the following error when running a pretty simple migration in sequel:
Connection.java:1434:in `newPgErrorCommon': java.lang.NoSuchMethodError: org.jruby.RubyEncoding.newEncoding(Lorg/jruby/Ruby;Lorg/jcodings/Encoding;
)Lorg/jruby/RubyEncoding;
from Connection.java:1450:in `newPgError'
from Result.java:107:in `check'
from Connection.java:549:in `exec'
from Connection$INVOKER$i$0$2$exec.gen:-1:in `call'
from DynamicMethod.java:205:in `call'
from DynamicMethod.java:201:in `call'
from AliasMethod.java:61:in `call'
from CachingCallSite.java:161:in `call'
from InterpreterEngine.java:289:in `processCall'
from StartupInterpreterEngine.java:77:in `interpret'
from Interpreter.java:136:in `INTERPRET_BLOCK'
from InterpretedIRBlockBody.java:118:in `commonYieldPath'
from IRBlockBody.java:66:in `yieldSpecific'
from Block.java:116:in `yieldSpecific'
from IRRuntimeHelpers.java:457:in `yieldSpecific'
from YieldInstr.java:72:in `interpret'
from StartupInterpreterEngine.java:183:in `processOtherOp'
from StartupInterpreterEngine.java:107:in `interpret'
from MixedModeIRMethod.java:128:in `INTERPRET_METHOD'
from MixedModeIRMethod.java:114:in `call'
from CachingCallSite.java:273:in `cacheAndCall'
from CachingCallSite.java:79:in `callBlock'
from CachingCallSite.java:83:in `call'
from CallBase.java:419:in `interpret'
from InterpreterEngine.java:321:in `processCall'
from StartupInterpreterEngine.java:77:in `interpret'
from MixedModeIRMethod.java:128:in `INTERPRET_METHOD'
from MixedModeIRMethod.java:114:in `call'
from CachingCallSite.java:77:in `callBlock'
from CachingCallSite.java:83:in `call'
from CallBase.java:419:in `interpret'
from InterpreterEngine.java:321:in `processCall'
from StartupInterpreterEngine.java:77:in `interpret'
from Interpreter.java:136:in `INTERPRET_BLOCK'
from InterpretedIRBlockBody.java:118:in `commonYieldPath'
The migration is:
Sequel.migration do
change do
alter_table(:offers) do
add_column(:size, Integer)
add_column(:title, String)
add_column(:description, String)
add_column(:construction_year, String)
add_column(:insertion_date, String)
add_column(:lat, Float)
add_column(:lng, Float)
add_column(:street, String)
add_column(:price, Integer)
add_column(:price_per_meter, Float)
add_column(:rooms, Integer)
add_column(:floor_number, Integer)
add_column(:max_floor, Integer)
add_column(:insertion_date, DateTime)
add_column(:is_active, TrueClass)
end
end
end
I have the following error when issuing group by operation in pg connection:
> self.all.group(:inn)
=> (pry) output error: java.lang.NoSuchMethodError: org.jruby.RubyEncoding.newEncoding(Lorg/jruby/Ruby;Lorg/jcodings/Encoding;)Lorg/jruby/RubyEncoding;
That is the SQL query:
> self.all.group(:inn).to_sql
=> "SELECT \"organizations\".* FROM \"organizations\" GROUP BY \"organizations\".\"inn\""
and also I've tried it with plain sql call with the same result:
> self.connection.execute( "SELECT \"organizations\".* FROM \"organizations\" GROUP BY \"organizations\".\"inn\"")
Java::JavaLang::NoSuchMethodError: org.jruby.RubyEncoding.newEncoding(Lorg/jruby/Ruby;Lorg/jcodings/Encoding;)Lorg/jruby/RubyEncoding;
from org.jruby.pg.Connection.newPgErrorCommon(Connection.java:1434)
The following examples work as expected on the pg gem, but throw errors on jruby-pg 0.14.1.rc2-java:
require 'pg'
pg = PG::Connection.open :dbname => 'scrap'
pg.async_exec("select now()", nil)
PG::Error: org.jruby.RubyNil cannot be cast to org.jruby.RubyArray
from org/jruby/pg/Connection.java:560:in `exec'
from (irb):4:in `evaluate'
from org/jruby/RubyKernel.java:1121:in `eval'
from org/jruby/RubyKernel.java:1517:in `loop'
from org/jruby/RubyKernel.java:1282:in `catch'
from org/jruby/RubyKernel.java:1282:in `catch'
from /home/chris/.rvm/rubies/jruby-1.7.5/bin/irb:13:in `(root)'
pg.async_exec("select $1::boolean", [false])
PG::Error: invalid input syntax for type boolean: "#<FalseClass:0x54fe71ff>"
from org/jruby/pg/Connection.java:558:in `exec'
from (irb):6:in `evaluate'
from org/jruby/RubyKernel.java:1121:in `eval'
from org/jruby/RubyKernel.java:1517:in `loop'
from org/jruby/RubyKernel.java:1282:in `catch'
from org/jruby/RubyKernel.java:1282:in `catch'
from /home/chris/.rvm/rubies/jruby-1.7.5/bin/irb:13:in `(root)'
Thank you!
the gemspec references non-existing files
bundler gives the following warning:
This prevents bundler from installing bins or native extensions, but that may not affect its functionality.
The validation message from Rubygems was:
["lib/pg_ext.jar", ".gemtest"] are not files
I think we're at or close to a point where we could release this as a -java version of the pg gem. There are still many libraries and applications that depend on functions the pg library provides that JDBC does not.
@ged Are you interested in working with us to get a -java version of the pg gem made? As I see it, the only requirements are the following:
We would obviously continue to support the Java version of the gem, and we do not expect you to take that over.
@jvshahid What remains before you would be comfortable releasing this? I know you had been looking into ActiveRecord tests when we paused a few months ago.
Hi @headius !
I'd like to do a refresh of this gem as an alternative to ARJDBC.
Specifically, I would like to refresh the gem build system to a straight gem build
without Hoe, and release a new stable version.
What name should the gem have? it is called pg
, jruby-pg
, and pg_jruby
in the Rakefile
, the GitHub project, and in RubyGems.org. I guess pg_jruby
is the right name since it has already been released with that name.
getting this:
Gem::LoadError: Specified 'postgresql' for database adapter, but the gem is not loaded. Add gem 'pg'
to your Gemfile (and ensure its version is at the minimum required by ActiveRecord).
What is the adapter type I should have?
The issue is related to pg_jruby (0.17.1 java)
Tested with JRuby 9.0.5.0 and ...
java version "1.8.0_144"
Java(TM) SE Runtime Environment (build 1.8.0_144-b01)
Java HotSpot(TM) 64-Bit Server VM (build 25.144-b01, mixed mode)
Terminating the Postgres connection result in (encoding) error type different from the one obtained in ruby pg
.(first time).
Re-Running the SQL statement on already terminated connection result in indefinite blocking again a behaviour much different from ruby pg
.
Ruby PG behaviour
require 'pg'
conn = PG.connect(dbname: 'postgres', user: 'postgres')
## Use either `pg_terminate_backend` or `kill` command to terminate the connection.
conn.exec('select 1') ## 1 st time
PG::UnableToSend: erver closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
conn.exec('select 1`) ## 2nd time same error type no blocking.
PG::UnableToSend: no connection to the server
Jruby pg behaviour
require 'pg'
conn = PG.connect(dbname: 'postgres', user: 'postgres')
## Use either `pg_terminate_backend` or `kill` command to terminate the connection.
conn.exec('select 1') ## 1 st time
Java::JavaLang::NoSuchMethodError: org.jruby.RubyEncoding.newEncoding(Lorg/jruby/Ruby;Lorg/jcodings/Encoding;)Lorg/jruby/RubyEncoding;
from org.jruby.pg.Connection.newPgErrorCommon(Connection.java:1434)
from org.jruby.pg.Connection.newPgError(Connection.java:1450)
from org.jruby.pg.Connection.exec(Connection.java:544)
from org.jruby.pg.Connection$INVOKER$i$0$2$exec_DBG.call(Connection$INVOKER$i$0$2$exec_DBG.gen)
from org.jruby.internal.runtime.methods.DynamicMethod.call(DynamicMethod.java:201)
from org.jruby.internal.runtime.methods.DynamicMethod.call(DynamicMethod.java:197)
from org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:313)
from org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:163)
from org.jruby.ir.interpreter.InterpreterEngine.processCall(InterpreterEngine.java:316)
from org.jruby.ir.interpreter.StartupInterpreterEngine.interpret(StartupInterpreterEngine.java:77)
from org.jruby.ir.interpreter.Interpreter.INTERPRET_EVAL(Interpreter.java:122)
from org.jruby.ir.interpreter.Interpreter.evalCommon(Interpreter.java:177)
from org.jruby.ir.interpreter.Interpreter.evalWithBinding(Interpreter.java:202)
from org.jruby.RubyKernel.evalCommon(RubyKernel.java:1009)
from org.jruby.RubyKernel.eval19(RubyKernel.java:976)
from org.jruby.RubyKernel$INVOKER$s$0$3$eval19_DBG.call(RubyKernel$INVOKER$s$0$3$eval19_DBG.gen)
... 104 levels...
from org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:313)
from org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:163)
from org.jruby.ir.interpreter.InterpreterEngine.processCall(InterpreterEngine.java:316)
from org.jruby.ir.interpreter.StartupInterpreterEngine.interpret(StartupInterpreterEngine.java:77)
from org.jruby.ir.interpreter.Interpreter.INTERPRET_ROOT(Interpreter.java:112)
from org.jruby.ir.interpreter.Interpreter.execute(Interpreter.java:99)
from org.jruby.ir.interpreter.Interpreter.execute(Interpreter.java:35)
from org.jruby.ir.IRTranslator.execute(IRTranslator.java:42)
from org.jruby.Ruby.runInterpreter(Ruby.java:848)
from org.jruby.Ruby.runInterpreter(Ruby.java:853)
from org.jruby.Ruby.runNormally(Ruby.java:752)
from org.jruby.Ruby.runFromMain(Ruby.java:569)
from org.jruby.Main.doRunFromMain(Main.java:415)
from org.jruby.Main.internalRun(Main.java:310)
from org.jruby.Main.run(Main.java:239)
from org.jruby.Main.main(Main.java:201)
Running the SQL statement 2nd time result indefinite block of the running program.
conn.execute('select 1')
## the code block no timeout happens.
If the connection is closed by the client then the JRuby pg End result is same as Ruby pg.
Posting it because others may have the same issue. Haven't found a fix.
Built using bundler
NameError: uninitialized constant PG
from org/jruby/RubyModule.java:2726:in `const_missing'
What is the purpose of this project? What's wrong with using the pg gem with jruby?
I'll make a PR to explain this in the readme.
Thanks!
John
Rails 5 already switched to pg 0.18.
I'll keep this issue as a reminder that we will need 0.18 version of this gem in the future.
Right now this version fails with when used with Rails 5.0:
uninitialized constant PG::TypeMapByClass
Howdy, this is great stuff! I got initially stuck in Result.getvalue when a NULL value was returned from a SELECT. Not sure if this is the right fix, but I got around it by adding:
ByteBuffer buffer = columns[column];
if ( buffer == null) {
return context.nil;
}
I have a Rails app that we converted to use jRuby, along with this gem.
I have a simple migration:
class AddSummarizedOnWithOffsetToTwitterEngagements < ActiveRecord::Migration def change add_column :twitter_post_engagements, :summarized_on_with_offset, :date, null: false add_column :twitter_daily_post_engagements, :summarized_on_with_offset, :date, null: false end end
When running the migration, I get the following convoluted error:
== 20160128152848 AddSummarizedOnWithOffsetToTwitterEngagements: migrating ==== -- add_column(:twitter_post_engagements, :summarized_on_with_offset, :date, {:null=>false}) /Users/eric.berry/.rbenv/versions/jruby-9.0.4.0/lib/ruby/gems/shared/gems/rake-10.5.0/lib/rake/task.rb:189: warning: singleton on non-persistent Java type Java::JavaLang::NoSuchMethodError (http://wiki.jruby.org/Persistence) rake aborted! Java::JavaLang::NoSuchMethodError: org.jruby.RubyEncoding.newEncoding(Lorg/jruby/Ruby;Lorg/jcodings/Encoding;)Lorg/jruby/RubyEncoding; org.jruby.pg.Connection.newPgErrorCommon(Connection.java:1434) org.jruby.pg.Connection.newPgError(Connection.java:1450) org.jruby.pg.Result.check(Result.java:107) org.jruby.pg.Connection.exec(Connection.java:549) org.jruby.pg.Connection$INVOKER$i$0$2$exec_DBG.call(Connection$INVOKER$i$0$2$exec_DBG.gen) org.jruby.internal.runtime.methods.DynamicMethod.call(DynamicMethod.java:201) org.jruby.internal.runtime.methods.DynamicMethod.call(DynamicMethod.java:197) org.jruby.internal.runtime.methods.AliasMethod.call(AliasMethod.java:61) org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:161) org.jruby.ir.interpreter.InterpreterEngine.processCall(InterpreterEngine.java:290) org.jruby.ir.interpreter.StartupInterpreterEngine.interpret(StartupInterpreterEngine.java:77) org.jruby.ir.interpreter.Interpreter.INTERPRET_BLOCK(Interpreter.java:122) org.jruby.runtime.MixedModeIRBlockBody.commonYieldPath(MixedModeIRBlockBody.java:136) org.jruby.runtime.IRBlockBody.yieldSpecific(IRBlockBody.java:67) org.jruby.runtime.Block.yieldSpecific(Block.java:116) org.jruby.ir.runtime.IRRuntimeHelpers.yieldSpecific(IRRuntimeHelpers.java:457) org.jruby.ir.instructions.YieldInstr.interpret(YieldInstr.java:72) org.jruby.ir.interpreter.StartupInterpreterEngine.processOtherOp(StartupInterpreterEngine.java:191) org.jruby.ir.interpreter.StartupInterpreterEngine.interpret(StartupInterpreterEngine.java:115) org.jruby.ir.interpreter.Interpreter.INTERPRET_BLOCK(Interpreter.java:122) org.jruby.runtime.MixedModeIRBlockBody.commonYieldPath(MixedModeIRBlockBody.java:136) org.jruby.runtime.IRBlockBody.doYield(IRBlockBody.java:152) org.jruby.runtime.BlockBody.yield(BlockBody.java:78) org.jruby.runtime.Block.yield(Block.java:147) ...
I am currently running postgres 9.5 on my local machine, however this error also happens on our prod server, which is running 9.4.
Thank you for your help!
Trying to add JRuby support to Perpetuity::Postgres. The good news is that almost 200 of the 214 specs pass. About 6 of the failures are due to a JRuby bug but the rest are due to missing exceptions:
PG::ConnectionBad
: I'm assuming this is a generic "we couldn't connect" exception, but I'm seeing it raised if the specified database doesn't exist.PG::UndefinedFunction
: If you use a SQL function that isn't loaded or doesn't exist.PG::UndefinedTable
: CRUD on a nonexistent table.PG::UndefinedColumn
: Raised any time Postgres says column "foo" does not exist
.I think those are the only exceptions I'm missing in Perpetuity::Postgres. I'll update if I notice more.
Hey there!
Ruby 2.2.1
v3 $ rbenv shell 2.2.1
ruby: 2.2.1 | master *%
v3 $ bin/sledger
Welcome to the Subledger CLI!
irb(main):001:0>
irb(main):002:0* require 'pg'
=> true
irb(main):004:0> PG.connect host: '0.0.0.0',
irb(main):005:0* user: 'subledger',
irb(main):006:0* dbname: 'subledger',
irb(main):007:0* sslmode: 'prefer'
=> #<PG::Connection:0x007fa9eb5318c0>
JRuby 1.7.19
v3 $ rbenv shell jruby-1.7.19
ruby: jruby-1.7.19 | master *%
v3 $ bin/sledger
Welcome to the Subledger CLI!
irb(main):001:0>
irb(main):002:0* require 'pg'
=> true
irb(main):004:0> PG.connect host: '0.0.0.0',
irb(main):005:0* user: 'subledger',
irb(main):006:0* dbname: 'subledger',
irb(main):007:0* sslmode: 'prefer'
PG::Error: Connection refused
from org/jruby/pg/Connection.java:398:in `initialize'
from /Users/tmornini/.rbenv/versions/jruby-1.7.19/lib/ruby/gems/shared/gems/pg_jruby-0.14.1.rc2-java/lib/pg.rb:44:in `connect'
from (irb):4:in `evaluate'
from org/jruby/RubyKernel.java:1107:in `eval'
from org/jruby/RubyKernel.java:1507:in `loop'
from org/jruby/RubyKernel.java:1270:in `catch'
from org/jruby/RubyKernel.java:1270:in `catch'
from /Users/tmornini/.rbenv/versions/jruby-1.7.19/bin/irb:13:in `(root)'
Let me know how I can help!
I was trying to test Sequel with pg_jruby, but kept getting this same encoding error. I was able to reduce it to an extremely simple test case:
$ jruby -vr pg -e 'p PGconn.connect(:user=>"sequel_test")'
jruby 1.7.6 (1.9.3p392) 2013-10-22 6004147 on OpenJDK Server VM 1.7.0_21-b11 [OpenBSD-i386]
PG::Error: (Error) Invalid encoding: US-ASCII
initialize at org/jruby/pg/Connection.java:398
(root) at -e:1
$ ruby -vr pg -e 'p PGconn.connect(:user=>"sequel_test")'
ruby 1.9.3p448 (2013-06-27 revision 41675) [i386-openbsd]
#<PG::Connection:0x84a2e2dc>
Getting this error back when trying to connect to PG 9.6.8:
Java::JavaLang::IllegalArgumentException: Unexpected message NoticeResponse
org.jruby.pg.internal.PostgresqlConnection.finishConnecting(PostgresqlConnection.java:1605)
org.jruby.pg.internal.PostgresqlConnection.connectPollInternal(PostgresqlConnection.java:1222)
org.jruby.pg.internal.PostgresqlConnection.connectPoll(PostgresqlConnection.java:170)
org.jruby.pg.internal.PostgresqlConnection.connectDbCommon(PostgresqlConnection.java:1388)
org.jruby.pg.internal.PostgresqlConnection.connectDb(PostgresqlConnection.java:157)
org.jruby.pg.Connection.connectSync(Connection.java:1465)
org.jruby.pg.Connection.initialize(Connection.java:365)
org.jruby.pg.Connection$INVOKER$i$0$0$initialize.call(Connection$INVOKER$i$0$0$initialize.gen)
(lots of non-PG related stack trace available on request)
Not seeing this when connecting to a 9.5 database.
edit As a comparison, I've had no problems connecting with postgres-pr
Postgres' 26000 INVALID SQL STATEMENT NAME
exception is not implemented. I have:
uninitialized constant PG::InvalidSqlStatementName
trying to rescue this.
Any ideas?
In pg
I can do this:
PG::Connection.open('postgres://postgres:password@localhost/test')
However in jruby-pg
if the argument is a string, it expects it to be pairs of key=value and fails with error indicating wrong number of arguments.
Connecting via URI is useful when you share configuration between PG and, for example, Sequel.
Hey there. A bug in my code is the root cause of this error, but this appears to be a slight issue in the jruby-pg code:
NameError: uninitialized constant PG::ConnectionBad
org/jruby/RubyModule.java:2690:in `const_missing'
/Users/tmornini/subledger/v3/lib/subledger/operations/utilities/aws/db_connector.rb:17:in `initialize'
org/jruby/RubyKernel.java:1965:in `public_send'
/Users/tmornini/.rbenv/versions/jruby-1.7.11/lib/ruby/gems/shared/gems/celluloid-0.15.2/lib/celluloid/calls.rb:25:in `dispatch'
/Users/tmornini/.rbenv/versions/jruby-1.7.11/lib/ruby/gems/shared/gems/celluloid-0.15.2/lib/celluloid/calls.rb:67:in `dispatch'
/Users/tmornini/.rbenv/versions/jruby-1.7.11/lib/ruby/gems/shared/gems/celluloid-0.15.2/lib/celluloid/actor.rb:322:in `handle_message'
/Users/tmornini/.rbenv/versions/jruby-1.7.11/lib/ruby/gems/shared/gems/celluloid-0.15.2/lib/celluloid/actor.rb:416:in `task'
/Users/tmornini/.rbenv/versions/jruby-1.7.11/lib/ruby/gems/shared/gems/celluloid-0.15.2/lib/celluloid/tasks.rb:55:in `initialize'
/Users/tmornini/.rbenv/versions/jruby-1.7.11/lib/ruby/gems/shared/gems/celluloid-0.15.2/lib/celluloid/tasks.rb:47:in `initialize'
/Users/tmornini/.rbenv/versions/jruby-1.7.11/lib/ruby/gems/shared/gems/celluloid-0.15.2/lib/celluloid/tasks/task_fiber.rb:13:in `create']
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.