Menu
  • HOME
  • TAGS

Ruby : TypeError: can't convert String into Integer

ruby,json,parsing,jruby

A small change in your code should get the right data: @jdoc = JSON.parse(result) @uid = @json['owner']['uid'] #=> "bb4123ac7950435eb516e2a47940b675" Also, you're trying to convert a string: "bb4123ac7950435eb516e2a47940b675" into integer: to_i() in your code. Which would be 0 as uid is a string of alphanumeric characters, and not a combination of...

Can't launch simple Sinatra app using rackup and jRuby (no response from web server)

ruby,sinatra,jruby,rackup

Well, this is hardly sufficient to explain what is going on, but I can make it work if in config.ru I replace run Sinatra::Application with Sinatra::Application.run! In fact, knowing that makes me even more confused. Some sort of bug in Rack?...

Rails, jRuby, ArgumentError: wrong number of arguments calling `to_sql` (2 for 1)

ruby-on-rails,ruby,postgresql,rails-activerecord,jruby

Simply fixed the issue by updating database related gems, using the bundle update command.

How to configure ruby puts logs to show up in Java-JRuby log file

java,ruby,logging,jax-rs,jruby

I just noticed that I was able to use slf4j too log = org.slf4j.LoggerFactory.getLogger(self.class.name) The logging level depends on what we set at the root level in config.yaml. Only if that is set to DEBUG, we can see log.debug entries. logging: # The default level of all loggers. Can be...

Shoes cannot find its own backend

ruby,jruby,shoes,shoes-4

project maintainer here. That's a clear sheos4 bug/regression - thanks for finding it. This should go to the bug tracker of the project - I opened an issue for it and set it for the next release. In the meantime, please use the shoes launcher :) Feel free to report...

Foreground or background image manipulations in Rails (Jruby, Torquebox)

ruby-on-rails,amazon-s3,jruby,jrubyonrails,torquebox

It is generally considered bad practice to block a web request handler on a network request to a third party service. If that service should become slow or unavailable, this can clog up all your web processes, regardless of what ruby you are using. This is what you are referring...

How to set log4j logging levels for Java jars called from JRuby

log4j,jruby,catalina

I got this to work by setting JVM options JRuby-style: export JRUBY_OPTS="-J-Dlog4j.debug=true -J-Dlog4j.configuration=file:/absolute/path/to/log4j.properties" trinidad This overwrote log4j.properties specified in my Java jar and I was able to manipulate log levels of Java classes in (and called by classes explicitly in) the jar file....

Calling Java code snippet from JRuby?

java,jruby

Explained here on how to call existing Java code from JRuby. The most basic usage: require 'java' java.lang.System.out.println("Hello, world!") As a bit more complex example, if you want to import your arbitrary package (say, 'foo.bar.baz') from a JAR, you can do this: require 'java' require 'foobarbaz.jar' def foo Java::Foo end...

Passing JRuby objects to Java methods?

java,jruby

simply specify an Object or IRubyObject argument signature in the method and it will work just fine when you call the Java method from your Ruby script ... UPDATE: assuming a LogStash::Event you can either make the Java signature accept (IRubyObject event) and than use event.callMethod("cancelled?").isTrue() and similar on the...

Jboss, setting environment variables for application

jboss,environment-variables,jruby,warbler

You could setup a datasource on the application server https://docs.jboss.org/author/display/WFLY8/DataSource+configuration And in your application you will need to use ActiveRecord-JDBC-Adapter https://github.com/jruby/activerecord-jdbc-adapter Or you can also set environment variables in the application servers's startup script (bin/standalone.sh or bin/domain.sh)...

Issues with parallelizing the creation of key-value pairs in a Ruby hash

ruby,multithreading,hash,parallel-processing,jruby

Hash isn't thread safe. If keep_item? visits the hash, there will be race condition. Even if it doesn't, there are concurrent updates to the hash, which is error prone. If there's no lock or other synchronization, theoretically there's no guarantee that the updates to a non-thread-safe hash on one thread...

Gem::LoadError: can't activate jruby-openssl-0.9.5-java, already activated jruby-openssl-0.9.7-java

ruby-on-rails,jruby,jrubyonrails,jruby-openssl

I ended up uninstalling 0.9.7 version. gem uninstall -i /usr/local/rvm/gems/[email protected] jruby-openssl ...

JRuby and Swing Event Dispatch Thread

java,multithreading,swing,jruby

consider JRuby as any other JVM language ... with no special care for Swing/AWT conventions built-in - only a "new" syntax for writing a Swing GUI. as such do care about EDT just like you would in Java.

Gem install for jruby-complete.jar

java,ruby,rubygems,jruby

I resolved my issue. Here is the updated command I used to install the gems: java -Xmx500M -classpath lib\jcodings.jar;lib\joda-time.jar;lib\jruby-complete.jar org.jruby.Main --command gem install GEM --user-install

Installing ruby-oci8 with jruby

jruby,ruby-c-extension

We can use JDBC, instead of oci8. oci8 needs c extenssions which has been deprecated in jruby. See this for a working example :: https://gist.github.com/rogerleite/217543...

Get column data from HBase via JRuby script

hadoop,hbase,jruby

include Java import org.apache.hadoop.hbase.HBaseConfiguration import org.apache.hadoop.hbase.client.HTable import org.apache.hadoop.hbase.client.Get import org.apache.hadoop.hbase.util.Bytes tableName = 'some_table' conf = HBaseConfiguration.create ht = HTable.new(conf, tableName) key = '7af02800f4c6478cde0f55e8bce34f4a2efa48f2' my_get = Get.new(key.to_java_bytes) result = ht.get(my_get) # This puts Bytes.toStringBinary(result.getValue('foo'.to_java_bytes, 'bar'.to_java_bytes)) ...

Specifying JRuby Version in Bundler

ruby-on-rails,ruby,jruby

as suggested by the comment already linking to RVM reports Gemfile ruby as not installed RVM's support for resolving a Ruby "engine" from the Gemfile is limited and does not match how Heroku is using (parsing) the directive. if you really want to have it both in the Gemfile use...

Jruby thread context instance association

ruby-on-rails,ruby,jruby,threadcontext

finally figured out by reading Mozilla rhino's code: https://github.com/matthieu/rhymeno/blob/master/src/org/mozilla/javascript/Context.java#LC416 static final Context enter(Context cx, ContextFactory factory) Basically the method counts the number of threads that are inside the context ( using it / executing it) and if another thread tries to enter it , it throws an error. To avoid...

How to package the killbill hello-world plugin

ruby,gem,jruby

JRuby 1.7.19 incompatibility (probably related to updated RubyGems), try downgrading JRuby (e.g. 1.7.16 should work fine) for the time being ... or look for a possible resolution of the issue

Serializing a JRuby CompiledScript in Java

java,jruby

As others have said, this is not possible with CompiledScript. However, with JRuby you have another option. You can use the command line tool jrubyc to compile a Ruby script to Java bytecode like so: jrubyc <scriptname.rb> This will produce a class file named scriptname.class. You can run this class...

Jruby Heap Dump Failure

java,jruby,puma,heap-dump

This looks like a JVM bug in jdk 1.8_45 see this link for more info https://bugs.openjdk.java.net/browse/JDK-8065318...

Can't get JRuby to work on AIX machine

jruby,aix

OK, so the server admin and I spent two days trying to figure these things out and I can finally summarize the solution we ended up with to get JRuby working on AIX_64. 1 . First and most important of all, I had to install JRuby 1.7.9 since the 1.7.16...

JRuby source code for org.jruby.javasupport

jruby,source

maybe, just search for the package declaration :) https://github.com/jruby/jruby/tree/master/core/src/main/java/org/jruby/javasupport

Jruby : desktop gui application

ruby,user-interface,jruby,jruby-win32ole

Just one line to add showFactInWindow('fact', 89) ...

Bundle and Running a Jar causes java.lang.reflect.InvocationTargetException

java,jar,bundle,bundler,jruby

This isn't a great answer, but I was having a similar issue on jruby 1.7.3 and using 1.7.10 fixed it. I'd still like to know what the issue with 1.7.3 was though, since that's the version everyone else on my team is using.

Unable to access Scala's Akka libraries in JRuby

scala,akka,jruby

Maybe the << does not add all the individual jars to the classpath? You might have to look for something else to include all jars in lib and lib/akka. Unfortunately I don't know enough JRuby to tell you how to do it. Also: you are importing classes (ActorRegistry, Actors) that...

How do I implement specific interface methods using closure conversion in jruby?

jruby

Looking more closely at https://github.com/jruby/jruby/wiki/CallingJavaFromJRuby#closure-conversion I see this statement: The block is converted to a Proc object, which is then decorated with a java interface proxy that invokes the block for any method called on the interface. I think this means there is no way to tell what method called...

Ruboto horizontal progress bar?

android,ruby,jruby,ruboto

There is no setter for style on ProgressBar, so you have to set it at creation time in the constructor. Note that SplashActivity can conflict with the Ruboto SplashActivity.java, so I use another name (ProgressBarActivity) require 'ruboto/widget' require 'ruboto/util/toast' ruboto_import_widgets :Button, :LinearLayout, :TextView, :ProgressBar class ProgressBarActivity AndroidAttr = JavaUtilities.get_proxy_class('android.R$attr') def...

Swing application closes right away after launch

java,swing,jruby

This question already exists: JRuby script with Rubeus and Swing exiting once packaged into jar using warble Add at the bottom of the main script: event_thread = nil SwingUtilities.invokeAndWait { event_thread = java.lang.Thread.currentThread } event_thread.join ...

Sinatra doesn't know this ditty even when default route is implemented with modular style

ruby,sinatra,jruby,modular

When you use the modular style, the Sinatra::Application app still exists, but usually nothing happens to it. In your config.ru you are running this (empty) app instead of your own. Simply change run Sinatra::Application to run App ...

JRuby gem not available, but JRuby can still run the script

jruby,warbler

Removing the spec.add_development_dependency "optparse" spec.add_runtime_dependency "optparse" did the trick and now the gem compiles into a runnable JAR file. ...

Increasing heap size for JRuby using jruby_opts

ruby-on-rails,rvm,passenger,jruby,jrubyonrails

If you're using Passenger under Apache, you should use SetEnv in your vhost to set the environment variables to use with the process. http://httpd.apache.org/docs/2.4/mod/mod_env.html SetEnv JRUBY_OPTS -J-Xmx1024m ...

cannot load Java class kafka.consumer.ConsumerIterator

java,ruby,gem,rvm,jruby

Problem solved when I removed jruby at all and reinstall by also stating the ruby. rvm install jruby --1.9 This time the gem was installed along with the jar dependencies....

Already initialized constant warnings after Rails 4.2 upgrade

ruby-on-rails,jruby,rails-postgresql

It is caused by the activerecord-jdbc-adapter gem which includes some of the core AR functionality, since it supports multiple AR releases from a single AR-JDBC gem release. Due changes in ActiveRecord's PostgreSQL adapter support it seems to double load ArrayParser. Please note that supporting Rails 4.2 requires work here and/or...

rvm don't use latest jruby version (1.7.12)

rvm,jruby

I do not know why rvm use is not working You can add .rvm/rubies/jruby-1.7.12/bin to your $PATH (try editing .bashrc for linux, .bash_profile for osX), restart console and run 'jruby -v'. It should be 1.7.12. Hope that solves your problem....

Apache Mahout with Ruby on Rails architecture

ruby-on-rails,postgresql,jruby,mahout,jrubyonrails

Have you looked at PredicitonIO? They have several recommenders built on Spark and include a Ruby SDK. Check their template gallery and check their Ruby SDK. Mahout has a new recommender component that is meant to work with a search engine. If you want something extremely flexible you can check...

JRuby & Warbler - Include gem?

ruby,gem,jruby,warbler

Try using bundler gem install bundler Create the file Gemfile at the root of your project and write the dependencies on it: gem 'timers' Now warbler will add the dependencies correctly....

Scripting language to compiled language or pure compiled language, which is faster? [closed]

java,c,ruby,jruby,ruby-c-extension

(Disclaimer: this might not be a complete answer but it was too long for a comment) Although I have next to no experience with JRuby's implementation in particular, dynamic languages implemented on the JVM have their limitations in terms of the speed you can get compared to what you would...

AOT compiling with jRuby to obfuscate Rails code

java,ruby-on-rails,ruby,jruby,.class-file

try Warbler with the compiled feature ... it does ~ the same but creates a dummy .rb file that loads the .class version (it's not clear from your notes or the old AOT wiki whether you tried that explicitly) you should look inside the generated .war file (it's a .zip)...

rubygems IOError: Function not implemented (https://rubygems.org/latest_specs.4.8.gz

ruby,rubygems,jruby,freebsd,rbenv

I found two solutions: Install Oracle Java + JRuby on the FreeBSD host itself, not inside a jail. User Rubinius or MRI instead ...

Package Ruby Library (permailer) as .jar (using JRuby)

java,scala,jar,jruby

seems like the work needed to create an interface (so that you abstract away from JRuby's Java/embed APIs) is done - as you've find out. the project already packages using Maven including the JRuby jar and the ruby dependencies for the premailer gem. while those are not to be found...

java server process not exiting cleanly

java,jruby

The suggestion by Joe to use Runtime.getRuntime().halt(int) works. Thanks

Can SonarQube connect Azure SQL Database?

ruby-on-rails,ruby,azure,jruby,sonarqube

It's possible, I just discovered, after spending 6 pretty frustrating hours on this issue. Here are the issues I encountered and the solutions I came up with for each: Couldn't connect to the Azure SQL Server database -- connection would just time out. The solution was to add ";ssl=require" to...

Find out which gems require native c extensions from a Gemfile?

ruby,gem,jruby,bundler,torquebox

You can use JRuby Lint for that. It will will check for some gems requiring C extension and even list alternative (based on this list).

pass a module and class name as an argument to a ruby function

ruby,cucumber,jruby,factory-girl

If you're on rails, You could use a combination of camelecase/classify and constantize > model = "#{'my_database'.camelcase}::#{'here_is_some_table'.camelcase}".constantize => MyDatabase::HereIsSomeTable # Only work if you actually have such a constant that'll give something like def update_window_for_ctm_staging_extract(target_database, target_table, table_name) model = "#{'target_database'.camelcase}::#{'target_table'.camelcase}".constantize model. where(src_tablename: table_name). update(from_date_dttm: from_date_dttm,...

How to override ActiveRecord::Type::Boolean with JRuby

mysql,ruby-on-rails,ruby,activerecord,jruby

Running with Ruby 2.1.x works and not work with JRuby 1.7.x/Ruby 1.9.x. Thanks @ThomasHaratyk

how to specify native library path in JRuby?

java,linux,jruby,nativelibrary

You can specify -J-Djava.library.path=$LD_LIBRARY_PATH in your jvm server configuration file. Here $LD_LIBRARY_PATH should contain paths to your native libraries.

How to use class declarations using jruby

java,ruby,jruby,minecraft-forge

It looks like these are annotations, so take a look at JRuby's reference on them. It might end up looking something like: java_annotation('Mod(modid="MyModID", name="MyModName")') class MyMod # ... mod stuff end ...

Jruby rails - where should the java code go?

jruby,jrubyonrails

I don't think there's a standard recommended practice, but there are a few options: ruby-maven provides a DSL and a set of Rake plugins to build Java code the Maven way. jruby-gradle-plugin provides similar support for the Gradle build tool. For managing dependency libraries, there's also jar-dependencies. If you're going...

How can I force JRuby to initialize a java ArrayList with java Longs instead of Fixnums?

ruby,jruby,jruby-java-interop

actually, this is far easier than you think and will work fine if you just pass a [] around :) while on the Ruby side JRuby makes sure values are Ruby-like but when it reaches the Java end - in case of a RubyArray instance passed to Java (which actually...

Rails completes in 15 seconds, response received after 2 more minutes

ruby-on-rails-4,jruby,torquebox

Well it turns out it was the bullet gem taking up all the time. It seems that with that many records, detecting whether there is an N+1 query is quite time consuming. Simply disabling bullet reduces the time to exactly what the rails console says it is.

NoMethod Error “join” on JRuby Padrino application on Tomcat 8

tomcat,jruby,padrino,warbler

This is an issue with Rack. Version 1.6.0 at the time of writing is causing errors with Sinatra based applications. Use an older gem until this is confirmed resolved.

jruby call method from super java class

java,jruby

you need make your brain "forget" the Java style super syntax and simply do it the Ruby way e.g. class SortedProperties < java.util.Properties def keys keyList = java.util.Vector.new super.each do |element| keyList.add(element.to_java(:String)) end java.util.Collections.sort(keyList) return keyList.elements() end end props = java.util.Properties.new props.setProperty 'bbb', 'B' props.setProperty 'aaa', 'A' props.setProperty 'ccc', 'C'...

Adding table to JPanel in JRuby

jpanel,jruby

The DefaultTableModel has no visual display component and needs to belong to a JTable. The JTable itself is used to display the data provided by the model. The JTable view can be changed without affecting the model. Any changes to the model affect the JTable. I don't know the Jruby...

How to get application context in Rails

ruby-on-rails,ruby,jruby

You can probably get this by extracting the first part of your path by defining this in your controller: def context_path(url) URI.join('/' + request.fullpath.split('/')[1], url) end helper_method :context_path Then that's easy to incorporate into your URL: <%= link_to "My Link", context_path('three/four') %> ...

Setting JRuby properties within Java code

java,jruby

Use System.setProperty(String key, String value) to set the properties you provide in command line. e.g. System.setProperty("jruby.compat.version","RUBY1_8"); You have to set these properties during start up of your application.so,that there will not be any problem of properties missing...

Need to access Heroku Postgres DB of a JRuby on Rails app in Java

java,postgresql,heroku,jruby,jrubyonrails

Yes, you can do this with the Java APIs in Ruby. It's difficult to provide an exact answer because I do not know what you are trying to do. But here is an example of a method that creates a connection, and manipulates the database in pseudo-JRuby require 'java' java_import...

Is Tail Call optimization all that explains this performance difference

ruby,recursion,jruby,tail-recursion

Tail recursion is not the difference here. In fact, Ruby does not do anything to optimize tail calls. The difference is that the naive algorithm recursively calls itself twice each time it's called, giving O(2n) performance, which means the runtime goes up exponentially as N increases. The tail-call version runs...

Make array of objects from array of strings

ruby,jruby

It may be worth to mention, that File.readlines will read everything into memory, what may cause memory issues with large files. Consider using this code: File.foreach('foo.txt').map do |line| Foo.new(line) end It read file line by line, almost as fast as your code, but more secure....

Print only unique array elements to file in Ruby

ruby,jruby

Consider this (with example array in javalocation): javalocation = %w| 1.5.0/opt/itm/v6.2.2/JRE/lx8266/bin/java 1.5.0/opt/itm/v6.2.2/JRE/lx8266/bin/java 1.5.0/opt/itm/v6.2.2/JRE/lx8266/bin/java 1.5.0/opt/itm/v6.2.2/JRE/lx8266/bin/java 1.5.0/opt/itm/v6.2.2/JRE/lx8266/bin/java 1.5.0/opt/itm/v6.2.2/JRE/lx8266/bin/java 1.5.0/opt/itm/v6.2.2/JRE/lx8266/bin/java 1.7.0_72/u01/java/jdk1.7.0_72/jre/bin/java 1.7.0_72/u01/java/jdk1.7.0_72/jre/bin/java 1.7.0_72/u01/java/jdk1.7.0_72/jre/bin/java...

NullPointerException while using jruby

java,nullpointerexception,jruby

I had created ruby type object in my java code by creating new Ruby object... This causes checking fail in updateARGV because a receiver that register variable in BiVariableMap and another receiver that update variable are different. So, I got a Ruby object from new ScriptingContainer(from it we can always...

Jruby: How to use third party java library?

ruby-on-rails-3,jruby

The trick in this case is to find how to properly import the 3rd party libs. Please download the needed jars using any dependency system (I use ant with ivy). This will download 5 jars based on the qr code library you mentioned: core-2.0.jar core-3.1.0.jar javase-2.0.jar javase-3.1.0.jar jfreesvg-2.1.jar build.xml for...

Does JRuby not have MemoryImageSource in awt.Image?

java,jruby,memoryimagesource

you just did something completely different (watch for proper casing) : java_import java.awt.Image.MemoryImageSource first resolves java.awt.Image which in your case (unfortunately) exists and than tries to call the MemoryImageSource method on the Java class what you're after is java_import java.awt.image.MemoryImageSource thus JRuby assumes java.awt.image is a package and looks for...

syntax error, unexpected kEND [closed]

ruby-on-rails,ruby,jruby

Yes, you add if and miss some end there. Try to use some editor for show you unexpected end. def read_dbf(paste) #Lendo a pasta Dir.foreach(paste) {|name| if File.directory?(name) pasteSub = paste+"/"+name Dir.foreach(pasteSub) {|subname| puts "Pasta: #{pasteSub}" puts subname } end } end ...

Why is my Hash not a Hash?

ruby,jruby

Solved it! Short answer is that you should write # ... when ::Hash # ... instead of # ... when Hash # ... Longer story: Turns out that because my method was in a class that inherited from Virtus::Attribute and because there is a Virtus::Attribute::Hash class, I was unwittingly trying...

JRuby Java Version Compatibility

java,version,jruby,java-7,java-5

From JRuby 1.7.0. Released: Java 5 support dropped (Java 6+ required) Bugs running under Java 8 are actively fixed (e.g. #1899, #1858)....

OS X - How do you stop a bash script from running on startup?

ruby,osx,bash,jruby

It's probably getting called in your profile file. Usually, the file is .bash_profile and is located in your home dir....