Change Bundle level in felix? - osgi

I know how to set an initial bundle level, for just to be deployed bundle:
bundlelevel -i 5
But how do I change the level of an existing bundle? Help for bundlelevel says:
bundlelevel - set bundle start level or initial bundle start level
scope: felix
flags:
-i, --setinitial set the initial bundle start level
-s, --setlevel set the bundle's start level
parameters:
int target level
Bundle[] target identifiers
bundlelevel - query bundle start level
scope: felix
parameters:
Bundle bundle to query
I have no idea what "Bundle[]" argument is. I tried just bundle_id and [bundle_id], and even bundle name.
Let me show an example. Let's say I want to change bundle 5 (bookshelf api) level from 1 to 2.
g! lb
START LEVEL 5
ID|State |Level|Name
0|Active | 0|System Bundle (3.0.7)
1|Active | 1|Apache Felix Bundle Repository (1.6.2)
2|Active | 1|Apache Felix Gogo Command (0.6.1)
3|Active | 1|Apache Felix Gogo Runtime (0.6.1)
4|Active | 1|Apache Felix Gogo Shell (0.6.1)
5|Active | 1|Bookshelf Inventory API (1.5.0)
I tried the following:
g! bundlelevel -s 2 [5]
gogo: IllegalArgumentException: Cannot coerce
bundlelevel(String, String, ArrayList) to any of
[(boolean, boolean, int, Bundle[]), (Bundle)]
g! bundlelevel -s 2 5
Must specify target bundles.
Any help is appreciated.

Not the clearest of syntax messages I guess :) Bundle[] refers to bundle IDs. Do lb, get the ID for the bundle you want, then run
bundlelevel -s NEW_LEVEL BUNDLE_ID
e.g.: for level 4 and bundle 10, do
bundlelevel -s 4 10
Maybe you were getting complaints because you missed the -s?

Made some experience in FUSE ESB but never used felix.
Just downloaded felix 3.0.8 and tried:
g! lb
START LEVEL 1
ID|State |Level|Name
0|Active | 0|System Bundle (3.0.8)
1|Active | 1|Apache Felix Bundle Repository (1.6.2)
2|Active | 1|Apache Felix Gogo Command (0.8.0)
3|Active | 1|Apache Felix Gogo Runtime (0.8.0)
4|Active | 1|Apache Felix Gogo Shell (0.8.0)
g! bundlelevel -s 10 4
g! lb
START LEVEL 1
ID|State |Level|Name
0|Active | 0|System Bundle (3.0.8)
1|Active | 1|Apache Felix Bundle Repository (1.6.2)
2|Active | 1|Apache Felix Gogo Command (0.8.0)
3|Active | 1|Apache Felix Gogo Runtime (0.8.0)
4|Resolved | 10|Apache Felix Gogo Shell (0.8.0)
g!
I tried hard to reproduce your problem but could not. It seams to work as specified. Did you tried it in a fresh installation or with a newer felix version (do not know what you are using)?

Related

Can't load capistrano-recipes

I've added capistrano-recipes to my Gemfile
group :development do
...
gem 'capistrano-recipes',require: false
end
Added to my deploy script:
require 'capistrano-recipes'
The result of bundle list:
bundle list | grep capistrano
* capistrano (2.15.5)
* capistrano-ext (1.2.1)
* capistrano-platform-resources (0.1.3)
* capistrano-rbenv (1.0.5)
* capistrano-recipes (0.8.0)
But when I'm running command like cap -T I got error:
/usr/local/rvm/gems/ruby-2.0.0-p0-turbo/gems/capistrano-2.15.5/lib/capistrano/configuration/loading.rb:152:in `require': cannot load such file -- capistrano-recipes (LoadError)
from /usr/local/rvm/gems/ruby-2.0.0-p0-turbo/gems/capistrano-2.15.5/lib/capistrano/configuration/loading.rb:152:in `require'
from ./config/deploy.rb:12:in `load'
What might be a problem here? Thanks
From the README, this is what you should put in your deploy script:
require 'capistrano_recipes'
Note that it uses an underscore, and not a hyphen.
Either install the gem globally
gem install capistrano-recipes
cap -T
or just:
bundle exec cap -T

Why does jruby-openssl gem have strange folder structure?

From my understanding, a gem's folder structer is supposed to have a folder called lib and inside that folder have a <gem-name>.rb file. However, when I used jruby 1.6.8 and do bundle install to install jruby-openssl, I open up C:\jruby-1.6.8\lib\ruby\gems\1.8\gems\jruby-openssl-0.8.2 and instead of seeing an rb file, I see more sub folders that look like this:
jruby-openssl-0.8.2\
+---lib\
| +---1.8\
| | +---openssl\
| | +---openssl.rb
| +---1.9\
| | +---openssl\
| | +---openssl.rb
| +---ruby\
| | +---shared\
| +---shared\
| +---jopenssl\
| +---openssl\
| +---openssl.rb
+---test\
+---java\
Is there a reason that jruby-openssl isn't following the standard gem folder structure? Specifically, I seem to be having trouble with a gem 'jruby-openssl' command working. Should the gem command find and load the gem correctly if the jruby-openssl folder is in the LOAD_PATH?
ERROR DETAILS:
Here is the error that appears in C:\apachetomcat632\logs\MyWebapp.log
--- Backtrace
LoadError: OpenSSL::Cipher requires the jruby-openssl gem
(root) at file:/C:/apachetomcat632/shared/lib/jruby-complete.jar!/META-INF/jruby.home/lib/ruby/site_ruby/shared/jruby/openssl/autoloads/cipher.rb:8
MessageEncryptor at file:/C:/apachetomcat632/shared/lib/jruby-complete.jar!/META-INF/jruby.home/lib/ruby/site_ruby/shared/jruby/openssl/autoloads/cipher.rb:24
ActiveSupport at file:C:/apachetomcat632/shared/lib/cfe-gems.jar!/gems/activesupport-3.2.11/lib/active_support/message_encryptor.rb:12
(root) at file:C:/apachetomcat632/shared/lib/cfe-gems.jar!/gems/activesupport-3.2.11/lib/active_support/message_encryptor.rb:4
require at org/jruby/RubyKernel.java:1062
require at file:C:/apachetomcat632/shared/lib/cfe-gems.jar!/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:251
load_dependency at file:C:/apachetomcat632/shared/lib/cfe-gems.jar!/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:236
require at file:C:/apachetomcat632/shared/lib/cfe-gems.jar!/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:251
eager_autoload! at file:C:/apachetomcat632/shared/lib/cfe-gems.jar!/gems/activesupport-3.2.11/lib/active_support/message_encryptor.rb:43
each at org/jruby/RubyArray.java:1620
eager_autoload! at file:C:/apachetomcat632/shared/lib/cfe-gems.jar!/gems/activesupport-3.2.11/lib/active_support/dependencies/autoload.rb:43
Bootstrap at file:C:/apachetomcat632/shared/lib/cfe-gems.jar!/gems/railties-3.2.11/lib/rails/application/bootstrap.rb:20
instance_exec at org/jruby/RubyKernel.java:2091
run at file:C:/apachetomcat632/shared/lib/cfe-gems.jar!/gems/railties-3.2.11/lib/rails/initializable.rb:30
run_initializers at file:C:/apachetomcat632/shared/lib/cfe-gems.jar!/gems/railties-3.2.11/lib/rails/initializable.rb:55
each at org/jruby/RubyArray.java:1620
run_initializers at file:C:/apachetomcat632/shared/lib/cfe-gems.jar!/gems/railties-3.2.11/lib/rails/initializable.rb:54
initialize! at file:C:/apachetomcat632/shared/lib/cfe-gems.jar!/gems/railties-3.2.11/lib/rails/application.rb:136
send at org/jruby/RubyKernel.java:2105
method_missing at file:C:/apachetomcat632/shared/lib/cfe-gems.jar!/gems/railties-3.2.11/lib/rails/railtie/configurable.rb:30
(root) at C:/apachetomcat632/webapps/Bank62P/WEB-INF/rails/config/environment.rb:5
require at org/jruby/RubyKernel.java:1062
load_environment at C:/apachetomcat632/webapps/Bank62P/WEB-INF/rails/config/environment.rb:23
load_environment at file:/C:/apachetomcat632/shared/lib/jruby-rack.jar!/jruby/rack/rails_booter.rb:65
(root) at <script>:1
And here is entire cipher.rb file:
require 'rubygems'
# try to activate jruby-openssl gem for OpenSSL::SSL, raising error if gem not present
begin
gem 'jruby-openssl'
require 'openssl.rb'
rescue Gem::LoadError => e
raise LoadError.new("OpenSSL::Cipher requires the jruby-openssl gem")
end
To add to tadman's answer, if you look in the gemspec (gems/1.8/specifications/jruby-openssl-0.8.2.gemspec), you'll see this line:
s.require_paths = ["lib/shared"]
When you require 'openssl' in your code, it'll load the one in the shared dir. I believe that file will determine whether to load the 1.8 or 1.9 version.
With that said...
When I try to require 'openssl' with 0.8.2, I get an error:
LoadError: no such file to load -- openssl/dummy
When I use the latest (0.8.8) it works fine. Try upgrading.
Prior to version 1.7.0 of JRuby, 1.9 support was so incomplete that you'd be better off using 1.8 code. This is probably why there needs to be two separate implementations of that particular library.
Bundling them together like this is a little unusual, often 1.8 installations will just lock to an older version of the gem. JRuby presents a challenge here, and this looks like a fairly reasonable solution.

"foreman start" results in "Could not find bundler (>= 0) amongst..." error

I copied an example Procfile from heroku's docs, and am trying to use foreman to run a Sinatra app locally.
Whenever I try foreman start, I get this:
~/Repos/website ➜ foreman start
14:04:43 web.1 | started with pid 2916
14:04:44 web.1 | /usr/lib/ruby/site_ruby/1.9.1/rubygems/dependency.rb:247:in `to_specs': Could not find bundler (>= 0) amongst [bigdecimal-1.1.0, daemons-1.1.9, eventmachine-0.12.10, io-console-0.3, json-1.5.4, minitest-2.5.1, rack-1.4.1, rack-protection-1.2.0, rake-0.9.2.2, rdoc-3.9.4, rubygems-update-1.8.24, sinatra-1.3.3, thin-1.4.1, tilt-1.3.3, yard-0.8.2.1] (Gem::LoadError)
14:04:44 web.1 | from /usr/lib/ruby/site_ruby/1.9.1/rubygems/dependency.rb:256:in `to_spec'
14:04:44 web.1 | from /usr/lib/ruby/site_ruby/1.9.1/rubygems.rb:1231:in `gem'
14:04:44 web.1 | from /home/nicolas/.gem/ruby/1.9.1/bin/bundle:22:in `<main>'
14:04:44 web.1 | exited with code 1
14:04:44 system | sending SIGTERM to all processes
SIGTERM received
These are the contents of my Procfile:
web: bundle exec thin start -R config.ru -e $RACK_ENV -p $PORT
I tried this with and without rbenv. I currently have Ruby installed via Arch's package manager, pacman. I also have bundler installed. I have already tried answers listed here and here. Any help would be really appreciated.
After waiting a while, updating gems, and trying again, I now got this to work when the Procfile contains the following:
web: bundle exec rackup

Gem Problems with running Warbler under Maven

I am seeing something odd with our build management server (we are using Jenkins CI). Projects are built using Maven (version 3.0.3)
Other environment details:
Rails 3.1.3
Jruby 1.6.7
Ruby 1.9.2
Bundler 1.0.22 for rails gem management
warbler 1.3.5
We have a bash script which runs a bundle install, assets:precompile (rake task) and the rake war task:
jruby -S bundle install
jruby -S bundle exec rake assets:precompile
jruby -S bundle exec rake war RAILS_ENV=production
The pom.xml file for the project has a task called package which basically runs the above bash script, among some other post-build cleanup stuff.
My question:
If I run mvn package I get the following error:
[INFO] ..... Previous output of maven stuff .....
[INFO] + jruby -S bundle exec rake war RAILS_ENV=production
[INFO] Bundler::GemNotFound: Could not find rake-0.9.2.2 in any of the sources
[INFO] materialize at /mnt/data_drive/opt/jruby-1.6.7/lib/ruby/gems/1.8/gems/bundler-1.0.22/lib/bundler/spec_set.rb:88
[INFO] map! at org/jruby/RubyArray.java:2371
[INFO] materialize at /mnt/data_drive/opt/jruby-1.6.7/lib/ruby/gems/1.8/gems/bundler-1.0.22/lib/bundler/spec_set.rb:82
[INFO] specs at /mnt/data_drive/opt/jruby-1.6.7/lib/ruby/gems/1.8/gems/bundler-1.0.22/lib/bundler/definition.rb:107
[INFO] specs_for at /mnt/data_drive/opt/jruby-1.6.7/lib/ruby/gems/1.8/gems/bundler-1.0.22/lib/bundler/definition.rb:152
[INFO] requested_specs at /mnt/data_drive/opt/jruby-1.6.7/lib/ruby/gems/1.8/gems/bundler-1.0.22/lib/bundler/definition.rb:141
[INFO] requested_specs at /mnt/data_drive/opt/jruby-1.6.7/lib/ruby/gems/1.8/gems/bundler-1.0.22/lib/bundler/environment.rb:23
[INFO] setup at /mnt/data_drive/opt/jruby-1.6.7/lib/ruby/gems/1.8/gems/bundler-1.0.22/lib/bundler/runtime.rb:11
[INFO] setup at /mnt/data_drive/opt/jruby-1.6.7/lib/ruby/gems/1.8/gems/bundler-1.0.22/lib/bundler.rb:110
[INFO] (root) at /mnt/data_drive/opt/jruby-1.6.7/lib/ruby/gems/1.8/gems/bundler-1.0.22/lib/bundler/setup.rb:17
However if I simply run, in the command line in the project folder:
jruby -S bundle exec rake war RAILS_ENV=production
(which is essentially the command it seems to be barfing on) - everything succeeds, and it builds the WAR no problems, finds all the gem files, etc.
I am wondering if anyone would have any suggestions as to what the problem might be. I have done a jruby -S gem install rake -v '0.9.2.2' and also, just in case, a gem install rake -v '0.9.2.2' - however it has made no difference.
Any advice is appreciated :) Thanks!

Having no luck with Apache Felix deploy

I am trying to deploy a particular version of a bundle through Apache Felix's obr deploy command.
I want to install version 3.1.10 of File Install, but unfortunately deploy does not understand versions (when using # to specify them):
g! deploy "Apache Felix File Install"#3.1.10
Unknown bundle - Apache Felix File Install#3.1.10
Neither does it work if I try the semicolon:
g! deploy "Apache Felix File Install";3.1.10
Target resource(s):
-------------------
Apache Felix File Install (3.0.2)
Deploying...done.
gogo: CommandNotFoundException: Command not found: 3.1.10
Anybody has any idea what's going on?
P.S.:
BONUS points for anybody installing "File Install 3.0.2", and then placing a jar of "3.1.10" into the load directory (thereby installing another "File Install" bundle) - and then deleting the "3.0.2" version! Sadly this does not work, as "File Install" always suspends itself.
Works for me:
g! list -v file
Apache Felix File Install [org.apache.felix.fileinstall] (3.0.2, 3.0.0, 2.0.8, 2.0.4, 2.0.0, 1.2.0, 1.0.0, 0.9.2, 0.9.0)
g! deploy "Apache Felix File Install"#3.0.0
Target resource(s):
-------------------
Apache Felix File Install (3.0.0)
Optional resource(s):
---------------------
Apache Felix Configuration Admin Service (1.2.4)
Apache Felix Log Service (1.0.0)
Deploying...done.
g!
It looks like you are trying to deploy a version of File Install that isn't in the OBR repo...

Resources