Why exception in NativeImageLoader.asMatrix. Works fine in eclipse but not as a servlet - deeplearning4j

I am getting a nullpointerexception when calling NativeImageLoader.asMatrix(). I am trying to figure out what the trace is telling me. I am working with DeepLearning 1.0.0-beta7.
Any hints?
Thanks!
2020-11-03 14:49:17,273 ERROR [stderr] (pool-19-thread-25) java.lang.NullPointerException
2020-11-03 14:49:17,273 ERROR [stderr] (pool-19-thread-25) at org.bytedeco.javacpp.indexer.LongRawIndexer.getRaw(LongRawIndexer.java:73)
2020-11-03 14:49:17,273 ERROR [stderr] (pool-19-thread-25) at org.bytedeco.javacpp.indexer.LongRawIndexer.get(LongRawIndexer.java:76)
2020-11-03 14:49:17,273 ERROR [stderr] (pool-19-thread-25) at org.nd4j.linalg.api.buffer.BaseDataBuffer.getLong(BaseDataBuffer.java:872)
2020-11-03 14:49:17,273 ERROR [stderr] (pool-19-thread-25) at org.nd4j.linalg.jcublas.buffer.BaseCudaDataBuffer.getLongUnsynced(BaseCudaDataBuffer.java:1304)
2020-11-03 14:49:17,273 ERROR [stderr] (pool-19-thread-25) at org.nd4j.linalg.api.buffer.BaseDataBuffer.asLong(BaseDataBuffer.java:813)
2020-11-03 14:49:17,273 ERROR [stderr] (pool-19-thread-25) at org.nd4j.linalg.jcublas.buffer.BaseCudaDataBuffer.asLong(BaseCudaDataBuffer.java:1539)
2020-11-03 14:49:17,274 ERROR [stderr] (pool-19-thread-25) at org.nd4j.linalg.api.ndarray.BaseShapeInfoProvider.createShapeInformation(BaseShapeInfoProvider.java:76)
2020-11-03 14:49:17,274 ERROR [stderr] (pool-19-thread-25) at org.nd4j.jita.constant.ProtectedCudaShapeInfoProvider.createShapeInformation(ProtectedCudaShapeInfoProvider.java:92)
2020-11-03 14:49:17,274 ERROR [stderr] (pool-19-thread-25) at org.nd4j.jita.constant.ProtectedCudaShapeInfoProvider.createShapeInformation(ProtectedCudaShapeInfoProvider.java:73)
2020-11-03 14:49:17,274 ERROR [stderr] (pool-19-thread-25) at org.nd4j.linalg.jcublas.CachedShapeInfoProvider.createShapeInformation(CachedShapeInfoProvider.java:42)
2020-11-03 14:49:17,274 ERROR [stderr] (pool-19-thread-25) at org.nd4j.linalg.api.ndarray.BaseNDArray.(BaseNDArray.java:181)
2020-11-03 14:49:17,274 ERROR [stderr] (pool-19-thread-25) at org.nd4j.linalg.api.ndarray.BaseNDArray.(BaseNDArray.java:310)
2020-11-03 14:49:17,274 ERROR [stderr] (pool-19-thread-25) at org.nd4j.linalg.api.ndarray.BaseNDArray.(BaseNDArray.java:363)
2020-11-03 14:49:17,274 ERROR [stderr] (pool-19-thread-25) at org.nd4j.linalg.api.ndarray.BaseNDArray.(BaseNDArray.java:786)
2020-11-03 14:49:17,274 ERROR [stderr] (pool-19-thread-25) at org.nd4j.linalg.jcublas.JCublasNDArray.(JCublasNDArray.java:287)
2020-11-03 14:49:17,274 ERROR [stderr] (pool-19-thread-25) at org.nd4j.linalg.jcublas.JCublasNDArrayFactory.create(JCublasNDArrayFactory.java:172)
2020-11-03 14:49:17,274 ERROR [stderr] (pool-19-thread-25) at org.nd4j.linalg.factory.Nd4j.create(Nd4j.java:4247)
2020-11-03 14:49:17,274 ERROR [stderr] (pool-19-thread-25) at org.nd4j.linalg.factory.Nd4j.create(Nd4j.java:3964)
2020-11-03 14:49:17,274 ERROR [stderr] (pool-19-thread-25) at org.datavec.image.loader.NativeImageLoader.transformImage(NativeImageLoader.java:671)
2020-11-03 14:49:17,274 ERROR [stderr] (pool-19-thread-25) at org.datavec.image.loader.NativeImageLoader.asMatrix(NativeImageLoader.java:594)
2020-11-03 14:49:17,274 ERROR [stderr] (pool-19-thread-25) at org.datavec.image.loader.Java2DNativeImageLoader.asMatrix(Java2DNativeImageLoader.java:92)
2020-11-03 14:49:17,274 ERROR [stderr] (pool-19-thread-25) at org.datavec.image.loader.Java2DNativeImageLoader.asMatrix(Java2DNativeImageLoader.java:70)
2020-11-03 14:49:17,274 ERROR [stderr] (pool-19-thread-25) at org.datavec.image.loader.Java2DNativeImageLoader.asMatrix(Java2DNativeImageLoader.java:102)
2020-11-03 14:49:17,274 ERROR [stderr] (pool-19-thread-25) at org.datavec.image.loader.NativeImageLoader.asMatrix(NativeImageLoader.java:407)

Ok so far looks like this call in the IntRawIndexer class is returning a null when in a Wildfly environment. /** The instance for the raw memory interface. */
protected static final Raw RAW = Raw.getInstance(); And looking closer at that it relies on sun.misc.Unsafe and if when checking for that will return a null if there is an exception when loading that class Class.forName("sun.misc.Unsafe") or when checking for methods of that class after the class is loaded. More effort and the root cause is Wildfly not finding the Unsafe class called from that jar. It can find it from servlet apparently from a test I did.

Related

I use cloudinary_gem 1.5.2 ,throw error "undefined method `http_code' for #<NoMethodError: undefined method `code' for nil:NilClass>"

I can upload image to cloudinary.but throw error
undefined method `http_code' for #<NoMethodError: undefined method `code' for nil:NilClass>".
Then I update gem cloudinary version to 1.13.1,It's not a problem or not solved. Throw the same exception.
Here is my code
result = params[:image].collect do |image|
Cloudinary::Uploader.upload(image, options)
end
Here is my error message
enter image description here
My ruby version is 2.3.2
My rails version is5.0.3

error while executing the command assets:precompile

Trying to do RAILS_ENV=production bundle exec rake assets:precompile
Get this error message:
ExecJS::ProgramError: Unexpected token: operator (>) (line: 48027, col: 50, pos: 1986183)
Error
at new JS_Parse_Error (<eval>:2357:10748)
at js_error (<eval>:2357:10967)
at croak (<eval>:2357:19192)
at token_error (<eval>:2357:19329)
at unexpected (<eval>:2357:19417)
at expr_atom (<eval>:2357:27609)
at maybe_unary (<eval>:2357:30102)
at expr_ops (<eval>:2357:30860)
at maybe_conditional (<eval>:2357:30952)
at maybe_assign (<eval>:2357:31395)
at maybe_assign (<eval>:2357:31569)
at expression (<eval>:2357:31708)
at expr_list (<eval>:2357:27913)
at subscripts (<eval>:2357:29811)
(in /home/parts-soft/www/parts-soft/releases/20171122232617/apps/www/app/assets/javascripts/application.js)
new JS_Parse_Error ((execjs):2357:10748)
js_error ((execjs):2357:10967)
croak ((execjs):2357:19192)
token_error ((execjs):2357:19329)
unexpected ((execjs):2357:19417)
expr_atom ((execjs):2357:27609)
maybe_unary ((execjs):2357:30102)
expr_ops ((execjs):2357:30860)
maybe_conditional ((execjs):2357:30952)
maybe_assign ((execjs):2357:31395)
maybe_assign ((execjs):2357:31569)
expression ((execjs):2357:31708)
expr_list ((execjs):2357:27913)
subscripts ((execjs):2357:29811)
/home/parts-soft/.rvm/gems/ruby-2.0.0-p247#parts-script-new-admin/gems/execjs-2.6.0/lib/execjs/ruby_racer_runtime.rb:36:in `rescue in block in eval'
/home/parts-soft/.rvm/gems/ruby-2.0.0-p247#parts-script-new-admin/gems/execjs-2.6.0/lib/execjs/ruby_racer_runtime.rb:33:in `block in eval'
/home/parts-soft/.rvm/gems/ruby-2.0.0-p247#parts-script-new-admin/gems/execjs-2.6.0/lib/execjs/ruby_racer_runtime.rb:75:in `block in lock'
When I do RAILS_ENV=production bundle exec rake assets:precompile:all
Sprockets::FileNotFound: couldn't find file 'handlebars.runtime'
(in /home/oil/www/oil/releases/20171122232617/apps/www/app/assets/javascripts/application.js:32)
Tell me what can I do?
In app.js I have not changed anything
Compile all assets locally.
Try following steps:
Add below code in Gemfile
group :assets do
gem 'sass-rails'
gem 'coffee-rails'
gem 'therubyracer'
end
Run bundle install
change line in config/environments/production.rb
config.assets.compile = true
Run commands:
RAILS_ENV=production rake assets:precompile

Rake 'assets:precompile' failing on deploying to AWS

I tried to deploy my Rails app to AWS, using Capistrano.
After I ran cap production deploy I got a 'Rake Aborted' message with the following trace:
ExecJS::ProgramError: SyntaxError: Unexpected character '’' (line: 19420, col: 10, pos: 548371)
Error
at new JS_Parse_Error (<eval>:3623:11948)
at js_error (<eval>:3623:12167)
at parse_error (<eval>:3623:14184)
at Object.next_token [as input] (<eval>:3623:19902)
at next (<eval>:3623:21852)
at subscripts (<eval>:3624:1389)
at expr_atom (<eval>:3623:31205)
at maybe_unary (<eval>:3624:1752)
at expr_ops (<eval>:3624:2523)
at maybe_conditional (<eval>:3624:2615)
new JS_Parse_Error ((execjs):3623:11948)
js_error ((execjs):3623:12167)
parse_error ((execjs):3623:14184)
Object.next_token [as input] ((execjs):3623:19902)
next ((execjs):3623:21852)
subscripts ((execjs):3624:1389)
expr_atom ((execjs):3623:31205)
maybe_unary ((execjs):3624:1752)
expr_ops ((execjs):3624:2523)
maybe_conditional ((execjs):3624:2615)
/Users/apple/.rvm/gems/ruby-2.3.3/gems/execjs-2.7.0/lib/execjs/ruby_racer_runtime.rb:47:in `rescue in block in call'
/Users/apple/.rvm/gems/ruby-2.3.3/gems/execjs-2.7.0/lib/execjs/ruby_racer_runtime.rb:44:in `block in call'
/Users/apple/.rvm/gems/ruby-2.3.3/gems/execjs-2.7.0/lib/execjs/ruby_racer_runtime.rb:75:in `block in lock'
/Users/apple/.rvm/gems/ruby-2.3.3/gems/execjs-2.7.0/lib/execjs/ruby_racer_runtime.rb:73:in `Locker'
/Users/apple/.rvm/gems/ruby-2.3.3/gems/execjs-2.7.0/lib/execjs/ruby_racer_runtime.rb:73:in `lock'
/Users/apple/.rvm/gems/ruby-2.3.3/gems/execjs-2.7.0/lib/execjs/ruby_racer_runtime.rb:43:in `call'
/Users/apple/.rvm/gems/ruby-2.3.3/gems/uglifier-3.0.4/lib/uglifier.rb:184:in `run_uglifyjs'
/Users/apple/.rvm/gems/ruby-2.3.3/gems/uglifier-3.0.4/lib/uglifier.rb:146:in `compile'
This doesnt give me a particular location for the syntax error, how do I locate it?
Thanks in advance!
A more universal way to find the problem that use this code as bellow:
Run rails console
JS_PATH = "app/assets/javascripts/**/*.js";
Dir[JS_PATH].each do |file_name|
puts "\n#{file_name}"
puts Uglifier.compile(File.read(file_name))
end
It will show you the file and the line where the Uglifier is making the problem.

Error localhost:3000 - Errno::ECONNREFUSED at /courses

I'm trying to preview a page with courses and I get this error:
Errno::ECONNREFUSED at /courses
Connection refused -
{:data=>"fq=type%3ACourse&fq=hidden_b%3Afalse&sort=university_sponsor_b+desc%2C+university_partner_b+desc%2C+score+desc%2C+score+desc%2C+name_s+asc&start=0&rows=15&q=%2A%3A%2A", :method=>:post, :params=>{:wt=>:ruby}, :query=>"wt=ruby", :headers=>
{"Content-Type"=>"application/x-www-form-urlencoded; charset=UTF-8"}, :path=>"select", :uri=>#<URI::HTTP:0x0055dda6f37c60
URL:http://localhost:8982/solr/development/select?wt=ruby>, :open_timeout=>nil, :read_timeout=>nil, :retry_503=>nil, :retry_after_limit=>nil}
Does anybody know how to fix this error?
This happened to me before, maybe you didn't set the db properly.
Try something like this:
rake db:drop rake db:create rake db:migrate # rake db:seed

Unexpected token : operator (<) when pushing to heroku (rails)

for some reason I am getting a really weird error when pushing to heroku.
rake aborted!
remote: ExecJS::ProgramError: Unexpected token: operator (<) (line: 14451, col: 2, pos: 408763)
remote: Error
remote: at new JS_Parse_Error (/tmp/execjs...)
remote: at js_error (/tmp/execjs...)
remote: at croak (/tmp/execjs...)
remote: at token_error (/tmp/execjs...)
remote: at unexpected (/tmp/execjs...)
remote: at expr_atom (/tmp/execjs...)
remote: at maybe_unary (/tmp/execjs...)
remote: at expr_ops (/tmp/execjs...)
and does anyone know what the line: , col: , pos: represent?
are there any files that you need to see?
I had the same issue with webcomponents-lite.min.js. It looks as though heroku requires a new line at the end of the file.
As the entire file was on one line. I added a new empty line, i.e. went to the end of the file and pressed return.
Commit and pushed to heroku - problem solved.

Resources