2016年1月7日木曜日

elasticsearch. plugin install failed. SSLException java.security.ProviderException

  • Published Date:Jun. 7, 2016

Article Summary


On Elasticsearch, When I executed bin/plugin command, SSLException java.security.ProviderException occurred.
This article describes how to modify this error.
日本語で読む

Environment


  • vagrant centos6.5
  • elasticsearch2.1.1
  • java(OpenJDK) version 1.7.0_91

Failure of kuromoji plugin installation.


kurimoji is the Japanese Analysis plugin. elasticsearch 2.1 integrates this plugin as official.
So, this plugin can be installed using the plugin manager.

terminal

sudo /usr/share/elasticsearch/bin/plugin install --verbose analysis-kuromoji

Failed: SSLException[java.security.ProviderException: java.security.KeyException]; nested: ProviderException[java.security.KeyException]; nested: KeyException;
ERROR: failed to download out of all possible locations

But, in my environment, plugin installation failed.

Switch Java Version


The cause of the failure is java version.
so, I checked java version.

terminal

// centos
yum search java | grep openjdk
java-1.6.0-openjdk.x86_64 : OpenJDK Runtime Environment
java-1.6.0-openjdk-demo.x86_64 : OpenJDK Demos
java-1.6.0-openjdk-devel.x86_64 : OpenJDK Development Environment
java-1.6.0-openjdk-javadoc.x86_64 : OpenJDK API Documentation
java-1.6.0-openjdk-src.x86_64 : OpenJDK Source Bundle
java-1.7.0-openjdk.x86_64 : OpenJDK Runtime Environment
java-1.7.0-openjdk-demo.x86_64 : OpenJDK Demos
java-1.7.0-openjdk-devel.x86_64 : OpenJDK Development Environment
java-1.7.0-openjdk-javadoc.noarch : OpenJDK API Documentation
java-1.7.0-openjdk-src.x86_64 : OpenJDK Source Bundle
java-1.8.0-openjdk.x86_64 : OpenJDK Runtime Environment
java-1.8.0-openjdk-debug.x86_64 : OpenJDK Runtime Environment with full debug on
java-1.8.0-openjdk-demo.x86_64 : OpenJDK Demos
java-1.8.0-openjdk-demo-debug.x86_64 : OpenJDK Demos with full debug on
java-1.8.0-openjdk-devel.x86_64 : OpenJDK Development Environment
java-1.8.0-openjdk-devel-debug.x86_64 : OpenJDK Development Environment with
java-1.8.0-openjdk-headless.x86_64 : OpenJDK Runtime Environment
java-1.8.0-openjdk-headless-debug.x86_64 : OpenJDK Runtime Environment with full
java-1.8.0-openjdk-javadoc.noarch : OpenJDK API Documentation
java-1.8.0-openjdk-javadoc-debug.noarch : OpenJDK API Documentation for packages
java-1.8.0-openjdk-src.x86_64 : OpenJDK Source Bundle
java-1.8.0-openjdk-src-debug.x86_64 : OpenJDK Source Bundle for packages with

There is java-1.8.0-openjdk.
Next, check using java version.

terminal

alternatives --config java

There are 2 programs which provide 'java'.

  Selection    Command
-----------------------------------------------
   1           /usr/lib/jvm/jre-1.5.0-gcj/bin/java
*+ 2           /usr/lib/jvm/jre-1.7.0-openjdk.x86_64/bin/java


java-1.8.0-openjdk is not installed.
I will install it.

terminal

sudo yum install -y java-1.8.0-openjdk

check using java version.

terminal

java -version
java version "1.7.0_91"

Java version is still not changed. I will switch java version.

terminal

sudo alternatives --config java

There are 3 programs which provide 'java'.

  Selection    Command
-----------------------------------------------
   1           /usr/lib/jvm/jre-1.5.0-gcj/bin/java
*+ 2           /usr/lib/jvm/jre-1.7.0-openjdk.x86_64/bin/java
   3           /usr/lib/jvm/jre-1.8.0-openjdk.x86_64/bin/java

Enter to keep the current selection[+], or type selection number: 3

I check using java version again.

terminal

java -version
openjdk version "1.8.0_65"
OpenJDK Runtime Environment (build 1.8.0_65-b17)
OpenJDK 64-Bit Server VM (build 25.65-b01, mixed mode)

Version was changed to java-1.8.0-openjdk.

Reinstallation of kurimoji plugijn


On java-1.8.0-openjdk, bin/plugin command executes again.

terminal

sudo /usr/share/elasticsearch/bin/plugin install --verbose analysis-kuromoji

Downloading .DONE
- Plugin information:
Name: analysis-kuromoji
Description: The Japanese (kuromoji) Analysis plugin integrates Lucene kuromoji analysis module into elasticsearch.
Site: false
Version: 2.1.1
JVM: true
 * Classname: org.elasticsearch.plugin.analysis.kuromoji.AnalysisKuromojiPlugin
 * Isolated: true
Installed analysis-kuromoji into /usr/share/elasticsearch/plugins/analysis-kuromoji

It worked out.
just in case, I will check installed plugin.

terminal

sudo /usr/share/elasticsearch/bin/plugin list
Installed plugins in /usr/share/elasticsearch/plugins:
    - analysis-kuromoji

I want to continie to using java7.

terminal

sudo alternatives --config java

There are 3 programs which provide 'java'.

  Selection    Command
-----------------------------------------------
   1           /usr/lib/jvm/jre-1.5.0-gcj/bin/java
*  2           /usr/lib/jvm/jre-1.7.0-openjdk.x86_64/bin/java
 + 3           /usr/lib/jvm/jre-1.8.0-openjdk.x86_64/bin/java

Enter to keep the current selection[+], or type selection number: 2

java -version
java version "1.7.0_91"
OpenJDK Runtime Environment (rhel-2.6.2.2.el6_7-x86_64 u91-b00)
OpenJDK 64-Bit Server VM (build 24.91-b01, mixed mode)

sudo /usr/share/elasticsearch/bin/plugin list
Installed plugins in /usr/share/elasticsearch/plugins:
    - analysis-kuromoji

It worked out.

Conclusion


On elasticsearch2.1.1, if you want to execute plugin command, you must update to java version 8.
Once installed, you can use by java version 7.

But I recommend that you makes your app environment latest. update work is very important.

See you

Reference Site


日本語


2016年1月6日水曜日

Rails5. Update work of rails v5.0.0 beta 1 from rails4. Page 2

  • Published Date:Jun. 6, 2016

Environment


  • rails 4.2.4, rails 4.2.5 → rails5.0.0 beta1
  • ruby 2.2.3
  • rbenv rbenv 0.4.0-183-gc18a3f9

Article Summary


Rails 5.0.0 Beta1 Released. I think Rails 5 will probably be released in spring of 2015.
But, if you change from rails 4 to rails 5 in Gemfile, your app would not operate correctly.

Currently, I'm doing much trial and error. At same time, I understood a lot of things. so, I write what I understood.
This article is a continuation from previous article.
read in Japanese

config.logger is unsupported


I took a lot of time this error. Rails 4.2.x implements log rotation from this setting. But this setting is fatal error on Rails 5.0.0 beta1.
So, you must change the following description.

Before

{project_folder}/config/environments/test.rb(development.rb and production.rb)

  config.logger = Logger.new('log/development.log', 'daily')

After

{project_folder}/config/environments/test.rb(development.rb and production.rb)

  # remove
  # config.logger = Logger.new('log/development.log', 'daily')

you must implement log rotation by another way.

cannot load such file -- sass


This error shows sass file was fail to read. So, remove sass file. Your app is launched normally.
This error shows that your app was fail to read sass file. You should remove sass file. if you do, your app will be launched successfully.

bin/setup


Compared with rails 4, this file was changed many settings.
For instance, rake commands were changed to rails commands.
you should use termial commnad.

terminal

rake rails:update

this command can overwrite bin/setup file. before execute, I recommend that git branch switch to new git branch.

Other


These files had better change to file of rails5.
you create sample rails 5 project, and your app should compared with sample rails 5 by diff.


// change
config/environments/development.rb

// new file
active_record_belongs_to_required_by_default.rb

Summary


Applied the contents of previous article and this article, I modified rails code. My app was be able to launch rails 5 successfully.
I plan to release my app on production mode in a few weeks.

See you.

Recommended Book for Rails 4 Developer


For Improving your ruby programming.


Administrating Site(createing rails)


Useful site


Japanese


Rails5 Update work of rails v5.0.0 beta 1 from rails4. Page 1

  • Published Date:Jun. 6, 2016

Environment


  • rails 4.2.4, rails 4.2.5 → rails5.0.0beta1
  • ruby 2.2.3
  • rbenv rbenv 0.4.0-183-gc18a3f9

Article Summary


Rails 5.0.0Beta1 Released. I think Rails 5 will probably be released in spring of 2015.
But, if you change from rails 4 to rails 5 in Gemfile, your app would not operate correctly.

Currently, I'm doing much trial and error. At same time, I understood a lot of things. so, I write what I understood.

Japanese

Spring is unsupported


On Rails 5.0.0Beta1, Spring gem is not available. So, if your app uses spring, you should remove spring gem.
if you use Bundler, you should do the follow.

terminal

vi Gemfile

// comment out
#gem 'spring'
#gem 'spring-commands-rspec'

rbenv exec bundle exec gem uninstall spring
rbenv exec bundle exec gem uninstall spring-commands-rspec

kaminari is unsupported


On Rails 5.0.0Beta1, kaminari gem is not available. it occurs ActionView::MissingTemplate.
if you want to use kaminari, you should change to latest kaminari gem.
if you use Bundler, you should change the Gemfile.

Before

{project_folder}/Gemfile

gem 'kaminari'

After

{project_folder}/Gemfile

gem 'kaminari', github: 'amatsuda/kaminari'

After you modified Gemfile, execute bundle update.

terminal

rbenv exec bundle install

Using kaminari 1.0.0.alpha (was 0.16.3) from git://github.com/amatsuda/kaminari.git (at master)

DEPRECATION WARNING: `serve_static_files` is deprecated and will be removed in Rails 5.1.


serve_static_files became deprecated. This is from Rails 4.2, and will remove it completely on Rails 5.1.
So, you must change the following description.

Before

{project_folder}/config/environments/test.rb(development.rb and production.rb)

  # Configure static asset server for tests with Cache-Control for performance.
  config.serve_static_files  = true

After

{project_folder}/config/environments/test.rb(development.rb and production.rb)

  # Configure static asset server for tests with Cache-Control for performance.
  config.public_file_server.enabled  = true

DEPRECATION WARNING: `static_cache_control` is deprecated and will be removed in Rails 5.1.


static_cache_control became deprecated. This will be also removed completely on Rails 5.1.
So, you must change the following description.

Before

{project_folder}/config/environments/test.rb(development.rb and production.rb)

  # config.serve_static_assets = ENV['RAILS_SERVE_STATIC_FILES'].present?
  config.static_cache_control = 'public, max-age=3600'

After

{project_folder}/config/environments/test.rb(development.rb and production.rb)

  # config.serve_static_assets = ENV['RAILS_SERVE_STATIC_FILES'].present?
  config.public_file_server.headers = { 'Cache-Control' => 'public, max-age=3600' }

DEPRECATION WARNING: before_filter is deprecated and will be removed in Rails 5.1.


before_filter became deprecated. This method is very useful, but removed completely on Rails 5.1.
So, you must change the following description.

Before

{projectfolder}/app/controllers/application_controller.rb

class ApplicationController < ActionController::Base
  # Prevent CSRF attacks by raising an exception.
  # For APIs, you may want to use :null_session instead.
  protect_from_forgery with: :exception

  before_filter :set_locale
  
  // something

end

After

{projectfolder}/app/controllers/application_controller.rb

class ApplicationController < ActionController::Base
  # Prevent CSRF attacks by raising an exception.
  # For APIs, you may want to use :null_session instead.
  protect_from_forgery with: :exception

  before_action :set_locale
  
  // something

DEPRECATION WARNING: use_transactional_fixtures= is deprecated and will be removed from Rails 5.0.


use_transactional_fixtures became deprecated. This is still unsupported on Rspec. So, you must not modify this.

Summary


if you think rails 5 update, it takes a lot of times.
so, you create new git branch soon, take measures.

I always think that rails major updating is difficult. But rails 5 updating is easier than rails 4 updating.
Rails has always evolved. This time is also same.

See you

Recommended Book for Rails 4 Developer


For Improving your ruby programming.


Administrating Site(createing rails)


Useful site


Japanese

2016年1月4日月曜日

Execute Rpsec Test. remote true ajax method on Rails Controller.

  • Published Date:Jun. 4, 2016

Article Summary


On Rails, developer can easy to implement ajax.
But, in case of doing rspec test, you must write code in a deffrent way from normal controller rspec test.

This article describes how toimplement "remote ajax rspec".

Environment


  • ruby 2.2.4
  • rails 4.2.5
  • spec-rails 3.0.2

Noraml Controller Implementation


Generally, when developers implement rails controller of rspec, implement like the following example.

/app/controller/test_controller.rb

post :confirm, @params

Detail Explanation

  • controller: test_controller.rb
  • method : confirm
  • method type : post
  • parameter : @params

This is general implementation method of rails controller.
Let's change rspec test from this to "remote true" ajax method.

"remote true" ajax method Controller Implementation


Using xhr, Rspec can call ajax method of controller.

/app/controller/test_controller.rb

xhr :post, :confirm, @params

Very easy.
Enjoy Rspec Life.

See you.

Recommended Book for Rails 4 Developer


For Improving your ruby programming.


Administrating Site(createing rails)


日本語

2016年1月3日日曜日

Update Ruby Version On Using Rails 4. Update from Ruby 2.2.4 to Ruby 2.3.0.

  • Published Date:Jun. 3, 2016

Article Summary


This article describes how to update from Ruby 2.2.4 to Ruby 2.3.0 on Rails 4.

Environment


  • Rails4.2.5
  • Ruby2.2.4 → Ruby2.3.0

Switch Ruby2.3.0


ruby 2.3.0 to proceed with the description in the premise on which it is installed.

terminal

// switch ruby version
rbenv global 2.3.0

ruby -v
ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-linux]

Install required Gem


Install required Gem for ruby 2.3.0p0.

terminal

// confirm gem version.
rbenv exec gem -v
2.5.1

rbenv exec gem list --local

*** LOCAL GEMS ***

bigdecimal (1.2.8)
did_you_mean (1.0.0)
io-console (0.4.5)
json (1.8.3)
minitest (5.8.3)
net-telnet (0.1.1)
power_assert (0.2.6)
psych (2.0.17)
rake (10.4.2)
rdoc (4.2.1)
test-unit (3.1.5)

// install bundler for ruby 2.3.0p0 
rbenv exec gem install bundler

rbenv exec gem list --local

*** LOCAL GEMS ***

bigdecimal (1.2.8)
bundler (1.11.2)
did_you_mean (1.0.0)
io-console (0.4.5)
json (1.8.3)
minitest (5.8.3)
net-telnet (0.1.1)
power_assert (0.2.6)
psych (2.0.17)
rake (10.4.2)
rdoc (4.2.1)
test-unit (3.1.5)

After Confirming ruby 2.3.0 and gem, Install required gem for rails project.

terminal

// move project folder
cd {prohect_folder}

// confirm gemfile.lock

// execute bundle install
rbenv exec bundle install --path /home/vagrant/vanish/dev/vendor/bundle

Bundle complete! 18 Gemfile dependencies, 70 gems now installed.

After completion, you execute test to confirm degradation.

terminal

// execute test
rbenv exec bundle exec rspec

Finished in 0.7514 seconds (files took 6.03 seconds to load)
42 examples, 0 failures, 4 pending

Worked out well.

Conclusion


In my case, It was easy to change from Ruby 2.2.4 to Ruby 2.3.0.
You should try it.
From now on, I will try to implement new function of Ruby 2.3.0.
Thank you for reading this article.

See you.

Recommended Book for Rails 4 Developer


For Improving your ruby programming.


Administrating Site(createing rails)


日本語