Sbt cannot assembly due to the deduplicate of the file - sbt

I am struggling to resolve the issue but hard to pinpoint the issue regarding the Sbt.
When I assembly using sbt then it throw the error as below.
The entire of the contents is large so I just attached the part of that.
[error] (assembly) deduplicate: different file contents found in the following:
[error] /Users/sclee01/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/io/netty/netty-all/4.1.68.Final/netty-all-4.1.68.Final.jar:META-INF/io.netty.versions.properties
[error] /Users/sclee01/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/io/netty/netty-buffer/4.1.50.Final/netty-buffer-4.1.50.Final.jar:META-INF/io.netty.versions.properties
[error] /Users/sclee01/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/io/netty/netty-codec/4.1.50.Final/netty-codec-4.1.50.Final.jar:META-INF/io.netty.versions.properties
[error] /Users/sclee01/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/io/netty/netty-common/4.1.50.Final/netty-common-4.1.50.Final.jar:META-INF/io.netty.versions.properties
[error] /Users/sclee01/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/io/netty/netty-handler/4.1.50.Final/netty-handler-4.1.50.Final.jar:META-INF/io.netty.versions.properties
[error] /Users/sclee01/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/io/netty/netty-resolver/4.1.50.Final/netty-resolver-4.1.50.Final.jar:META-INF/io.netty.versions.properties
[error] /Users/sclee01/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/io/netty/netty-transport-native-epoll/4.1.50.Final/netty-transport-native-epoll-4.1.50.Final.jar:META-INF/io.netty.versions.properties
[error] /Users/sclee01/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/io/netty/netty-transport-native-unix-common/4.1.50.Final/netty-transport-native-unix-common-4.1.50.Final.jar:META-INF/io.netty.versions.properties
[error] /Users/sclee01/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/io/netty/netty-transport/4.1.50.Final/netty-transport-4.1.50.Final.jar:META-INF/io.netty.versions.properties
I googled it and changed my assembly mergy strategy as below, but it didn't work.
As you can see, I added the case PathList("META-INF", _*) => MergeStrategy.discard to my code but the META-INF/* related errors were not disappear.
Any help will be appreciated.
Thanks.
assembly / assemblyMergeStrategy := {
case PathList("META-INF", _*) => MergeStrategy.discard
case "module-info.class" => MergeStrategy.discard
case "logback.xml" => MergeStrategy.discard
case PathList("mime.types") => MergeStrategy.last
case PathList("META-INF", xs # _*) => {
xs match {
case "services" :: _ :: Nil => MergeStrategy.concat
case _ => MergeStrategy.discard
}
}

Related

ZF3 zend-cache error Unable to resolve service "FilesystemCache" to a factory

I'm trying to use zend-cache with zend-rbac.
zend-rbac is ok, but when I try to add zend-cache I got this message:
Unable to resolve service "FilesystemCache" to a factory; are you certain you provided it during configuration?
My cache configuration at global.php is like this:
// Cache configuration.
'caches' => [
'FilesystemCache' => [
'adapter' => [
'name' => Filesystem::class,
'options' => [
// Store cached data in this directory.
'cache_dir' => './data/cache',
// Store cached data for 1 hour.
'ttl' => 60*60*1
],
],
'plugins' => [
[
'name' => 'serializer',
'options' => [
],
],
],
],
],
And in my RbacManagerFactory I'm calling it like this:
$cache = $container->get('FilesystemCache');
I already try to config FilesystemService in my module, like this:
'service_manager' => [
'factories' => [
\Zend\Cache\Storage\Adapter\FilesystemService::class => InvokableFactory::class,
],
],
But it didn't work
Do I need to config something more?
EDIT 2018-10-29
When I try to run the sample it gives this error:
[Mon Oct 29 12:06:13.097747 2018] [php7:warn] [pid 943] [client 127.0.0.1:48824] PHP Warning: file_put_contents(data/cache/module-config-cache.application.config.cache.php): failed to open stream: No such file or directory in /var/www/html/roledemo/vendor/zendframework/zend-modulemanager/src/Listener/AbstractListener.php on line 65
[Mon Oct 29 12:06:13.098593 2018] [php7:warn] [pid 943] [client 127.0.0.1:48824] PHP Warning: file_put_contents(data/cache/module-classmap-cache.application.module.cache.php): failed to open stream: No such file or directory in /var/www/html/roledemo/vendor/zendframework/zend-modulemanager/src/Listener/AbstractListener.php on line 65
[Mon Oct 29 12:06:13.112886 2018] [php7:error] [pid 943] [client 127.0.0.1:48824] PHP Fatal error: Method Zend\\View\\Helper\\HeadTitle::__toString() must not throw an exception, caught Zend\\I18n\\Exception\\ExtensionNotLoadedException: Zend\\I18n\\Translator component requires the intl PHP extension in /var/www/html/roledemo/module/Application/view/layout/layout.phtml on line 0
and I can't access any URL.
Could it be my php or apache version?
So I was missing some things, that's why it didn't work before:
Create data/cache folder and give it permission 775
Create public/img/captcha folder and give it permission 775
Add module Zend\Serializer and Zend\Cache to config/modules.config.php
Add the following to module/Login/config/module.config.php:
'rbac_manager' => [
'assertions' => [Service\RbacAssertionManager::class],
],
And, if you are following the text, not downloading the code:
Set $result as false in src/Service/RbacManager.php line 72

Gatling sbt assembly- jar file cannot created?

I am using gatling tool for performance testing.My gatling code is running perfectly. i am using intellij IDEA for my project. I am trying to create a jar file. It cannot created. i think this is sbt problem.please someone correct my sb My build.sbt file is here:
import io.gatling.sbt.GatlingPlugin
import sbtassembly.MergeStrategy
parallelExecution in Test := false
enablePlugins(GatlingPlugin, AssemblyPlugin)
lazy val root = (project in file("."))
.configs(IntegrationTest)
.settings(Defaults.itSettings: _*)
Project.inConfig(IntegrationTest)(baseAssemblySettings)
mainClass in assembly := Some("gatling.GatlingMain")
assemblyMergeStrategy in assembly := {
case x =>
val oldStrategy = (assemblyMergeStrategy in assembly).value
oldStrategy(x)
}
libraryDependencies ++= Seq(
"com.typesafe.play" % "play-json_2.11" % "2.6.2" % IntegrationTest,
"org.scalacheck" % "scalacheck_2.11" % "1.13.5" % IntegrationTest,
"com.typesafe" % "config" % "1.3.1" % IntegrationTest,
"io.gatling.highcharts" % "gatling-charts-highcharts" % "2.2.5" %
IntegrationTest,
"io.gatling" % "gatling-test-framework" % "2.2.5" % IntegrationTest,
"com.google.code.gson" % "gson" % "2.8.0" % IntegrationTest
)
resourceDirectory in Compile := baseDirectory.value /"resources"
assemblyJarName in (IntegrationTest, assembly):=s"${name.value}-${version.value}.jar"
when i am trying to create a jar file using sbt command sbt "it:assembly"
It shows the following error
[error] 1 error was encountered during merge
java.lang.RuntimeException: deduplicate: different file contents found in the following:
/Users/james/.ivy2/cache/io.netty/netty-buffer/jars/netty-buffer-4.0.44.Final.jar:META-INF/io.netty.versions.properties
/Users/james/.ivy2/cache/io.netty/netty-common/jars/netty-common-4.0.44.Final.jar:META-INF/io.netty.versions.properties
/Users/james/.ivy2/cache/io.netty/netty-codec-http/jars/netty-codec-http-4.0.44.Final.jar:META-INF/io.netty.versions.properties
/Users/james/.ivy2/cache/io.netty/netty-codec/jars/netty-codec-4.0.44.Final.jar:META-INF/io.netty.versions.properties
/Users/james/.ivy2/cache/io.netty/netty-transport/jars/netty-transport-4.0.44.Final.jar:META-INF/io.netty.versions.properties
/Users/james/.ivy2/cache/io.netty/netty-handler/jars/netty-handler-4.0.44.Final.jar:META-INF/io.netty.versions.properties
/Users/james/.ivy2/cache/io.netty/netty-transport-native-epoll/jars/netty-transport-native-epoll-4.0.44.Final-linux-x86_64.jar:META-INF/io.netty.versions.properties
at sbtassembly.Assembly$.applyStrategies(Assembly.scala:140)
at sbtassembly.Assembly$.x$1$lzycompute$1(Assembly.scala:25)
at sbtassembly.Assembly$.x$1$1(Assembly.scala:23)
at sbtassembly.Assembly$.stratMapping$lzycompute$1(Assembly.scala:23)
at sbtassembly.Assembly$.stratMapping$1(Assembly.scala:23)
at sbtassembly.Assembly$.inputs$lzycompute$1(Assembly.scala:67)
at sbtassembly.Assembly$.inputs$1(Assembly.scala:57)
at sbtassembly.Assembly$.apply(Assembly.scala:83)
at sbtassembly.Assembly$$anonfun$assemblyTask$1.apply(Assembly.scala:245)
at sbtassembly.Assembly$$anonfun$assemblyTask$1.apply(Assembly.scala:242)
at scala.Function1$$anonfun$compose$1.apply(Function1.scala:47)
at sbt.$tilde$greater$$anonfun$$u2219$1.apply(TypeFunctions.scala:40)
at sbt.std.Transform$$anon$4.work(System.scala:63)
at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:228)
at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:228)
at sbt.ErrorHandling$.wideConvert(ErrorHandling.scala:17)
at sbt.Execute.work(Execute.scala:237)
at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:228)
at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:228)
at sbt.ConcurrentRestrictions$$anon$4$$anonfun$1.apply(ConcurrentRestrictions.scala:159)
at sbt.CompletionService$$anon$2.call(CompletionService.scala:28)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
[error] (it:assembly) deduplicate: different file contents found in the following:
[error] /Users/james/.ivy2/cache/io.netty/netty-buffer/jars/netty-buffer-4.0.44.Final.jar:META-INF/io.netty.versions.properties
[error] /Users/james/.ivy2/cache/io.netty/netty-common/jars/netty-common-4.0.44.Final.jar:META-INF/io.netty.versions.properties
[error] /Users/james/.ivy2/cache/io.netty/netty-codec-http/jars/netty-codec-http-4.0.44.Final.jar:META-INF/io.netty.versions.properties
[error] /Users/james/.ivy2/cache/io.netty/netty-codec/jars/netty-codec-4.0.44.Final.jar:META-INF/io.netty.versions.properties
[error] /Users/james/.ivy2/cache/io.netty/netty-transport/jars/netty-transport-4.0.44.Final.jar:META-INF/io.netty.versions.properties
[error] /Users/james/.ivy2/cache/io.netty/netty-handler/jars/netty-handler-4.0.44.Final.jar:META-INF/io.netty.versions.properties
My sbt version is 0.13.16 and my scala version is 2.11.8. please someone help me to resolve this error. Thanks in advance
Most likely you don't need io.netty.versions.properties from all the io.netty libraries, one may be enough. I think something like this should work:
assemblyMergeStrategy in assembly := {
case p if p.endsWith("io.netty.versions.properties") =>
MergeStrategy.first
case x =>
val oldStrategy = (assemblyMergeStrategy in assembly).value
oldStrategy(x)
}

lua entry thread aborted: runtime error: attempt to concatenate field 'cookie_sessionid' (a nil value)

/etc/nginx/sites-enabled/default:
location /pine {
add_header Access-Control-Allow-Origin http://localhost:6285;
add_header Access-Control-Allow-Credentials true;
access_by_lua_file /home/akuznetsov/auth.lua;
proxy_pass http://localhost:9100;
}
auth.lua (version 1, works fine):
ngx.req.set_header('x-user-id', ngx.var.cookie_sessionid)
auth.lua (version 2, not working):
ngx.req.set_header('x-user-id', 'session:' .. ngx.var.cookie_sessionid)
in /var/log/nginx/error.log i get this error:
2016/04/06 16:13:10 [error] 14183#0: *1 lua entry thread aborted: runtime error: /home/akuznetsov/auth.lua:2: attempt to concatenate field 'cookie_sessionid' (a nil value)
stack traceback:
coroutine 0:
/home/akuznetsov/auth.lua:2: in function </home/akuznetsov/auth.lua:1>, client: 127.0.0.1, server: localhost, request: "OPTIONS /pine HTTP/1.1", host: "localhost", referrer: "http://localhost:6285/chart/kjckCBcG/?pine=http://localhost/pine"
What's wrong with concat?
ngx.var.cookie_sessionid is nil and just as message tell you, you can't concatenate (i.e. ..) that. Provide if check with logic to handle this case or use ngx.req.set_header('x-user-id', 'session:' .. ngx.var.cookie_sessionid or "") if you okay with using empty string as default.

What is the correct structure for using mocha to test your package?

Right now I have:
Package.describe({
name: 'parlay:synapsepay',
version: '0.0.1',
summary: 'synapse_pay_rest for Meteor',
git: 'https://github.com/parlaywithme/meteor-synapsepay',
documentation: 'README.md'
});
Package.onUse(function(api) {
api.versionsFrom('1.2.0.2');
api.use('coffeescript');
api.addFiles('synapsepay.coffee');
});
Package.onTest(function(api) {
api.use('coffeescript');
api.use('mike:mocha-package');
api.use('parlay:synapsepay');
api.addFiles('synapsepay-tests.coffee');
});
and
MochaWeb?.testOnly ->
describe 'sanity', ->
it 'is visible', ->
chai.assert.isDefined SynapsePay
https://github.com/parlaywithme/meteor-synapsepay
I'm getting a has no method 'testOnly' error, running
meteor test-packages ./
inside packages/meteor-synapsepay:
ERROR: packages.json parsing error [ ENOENT, no such file or directory '/Users/me/parlay/packages/meteor-synapsepay/packages.json' ]
[[[[[ Tests ]]]]]
=> Started proxy.
=> Started MongoDB.
W20151018-00:24:58.123(-4)? (STDERR)
W20151018-00:24:58.125(-4)? (STDERR) /Users/me/.meteor/packages/meteor-tool/.1.1.9.osr2yb++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/dev_bundle/server-lib/node_modules/fibers/future.js:245
W20151018-00:24:58.125(-4)? (STDERR) throw(ex);
W20151018-00:24:58.125(-4)? (STDERR) ^
W20151018-00:24:58.125(-4)? (STDERR) TypeError: Object [object Object] has no method 'testOnly'
W20151018-00:24:58.125(-4)? (STDERR) at Package (packages/local-test_parlay_synapsepay/synapsepay-tests.coffee:1:11)
W20151018-00:24:58.125(-4)? (STDERR) at packages/local-test_parlay_synapsepay/synapsepay-tests.coffee:1:1
W20151018-00:24:58.126(-4)? (STDERR) at packages/local-test_parlay_synapsepay/synapsepay-tests.coffee:1:1
W20151018-00:24:58.126(-4)? (STDERR) at /private/tmp/meteor-test-run1tbmejw/.meteor/local/build/programs/server/boot.js:242:10
W20151018-00:24:58.126(-4)? (STDERR) at Array.forEach (native)
W20151018-00:24:58.126(-4)? (STDERR) at Function._.each._.forEach (/Users/me/.meteor/packages/meteor-tool/.1.1.9.osr2yb++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/dev_bundle/server-lib/node_modules/underscore/underscore.js:79:11)
W20151018-00:24:58.126(-4)? (STDERR) at /private/tmp/meteor-test-run1tbmejw/.meteor/local/build/programs/server/boot.js:137:5
=> Exited with code: 8
While poorly documented at the moment, this issue can be solved easily:
Simply ditch testOnly and write your tests directly in your test file.
describe 'sanity', ->
it 'is visible', ->
chai.assert.isDefined SynapsePay
Mocha was first designed for application tests. Using it for package tests can prove challenging.
When you will have your tests running, you may also see big Meteor.methods Match errors in the console. It is a common issue that should not interfere with the tests themselves.

"node.js: throw e; // process.nextTick error," while trying browserid

I'm not going to use other module like request, how about writing this with http,
What should I consider while seeding post to browserid?
error:
$ coffee server.coffee
info - socket.io started
to send
to write
end?
node.js:201
throw e; // process.nextTick error, or 'error' event on first tick
^
Error: getaddrinfo ENOENT
at errnoException (dns.js:31:11)
at Object.onanswer [as oncomplete] (dns.js:140:16)
source:
ll = console.log
fs = require 'fs'
page = fs.readFileSync 'page.html', 'utf-8'
query = require 'querystring'
client = fs.readFileSync 'client.coffee', 'utf-8'
page = page.replace '###', client
handler = (req, res) ->
res.writeHead 200, 'Content-Type': 'text/html'
res.end page
http = require 'http'
app = http.createServer handler
app.listen 8000
io = (require 'socket.io').listen app
io.set 'log level', 1
io.sockets.on 'connection', (socket) ->
socket.emit 'ready', 'go'
socket.on 'assertion', (data) ->
msg = query.stringify
assertion: data
audience: 'localhost:8000'
options =
host: 'https://browserid.org'
path: '/verify'
method: 'POST'
headers:
'Content-Type': 'application/x-www-form-urlencoded'
'Content-Length': msg.length
ll 'to send'
request = http.request options, (response) ->
str = ''
ll 'prepare'
response.on 'data', (chunk) ->
str += chunk
ll str
response.on 'end', ->
ll str
request.write msg
ll 'to write'
request.end()
ll 'end?'
with long-stack-traces:
$ coffee server.coffee
info - socket.io started
to send
to write
end?
Uncaught Error: getaddrinfo ENOENT
at errnoException (dns.js:31:11)
at Object.onanswer [as oncomplete] (dns.js:140:16)
----------------------------------------
at EventEmitter.on
at Array.<anonymous> (http.js:1147:12)
at EventEmitter._tickCallback (node.js:192:40)
----------------------------------------
at EventEmitter.nextTick
at ClientRequest.onSocket (http.js:1115:11)
at Agent.addRequest (http.js:938:9)
at new ClientRequest (http.js:1068:16)
at Object.request (http.js:1331:10)
at Socket.<anonymous> (/home/chen/code/home/git/docview/learning/coffee/browserid/server.coffee:52:22)
at Socket.$emit (events.js:67:17)
at SocketNamespace.handlePacket (/usr/lib/nodejs/socket.io/lib/namespace.js:335:22)
----------------------------------------
at EventEmitter.on
at SocketNamespace.<anonymous> (/home/chen/code/home/git/docview/learning/coffee/browserid/server.coffee:37:19)
at SocketNamespace.$emit (events.js:88:20)
at connect (/usr/lib/nodejs/socket.io/lib/namespace.js:292:10)
at /usr/lib/nodejs/socket.io/lib/namespace.js:308:13
at SocketNamespace.authorize (/usr/lib/nodejs/socket.io/lib/namespace.js:252:5)
at SocketNamespace.handlePacket (/usr/lib/nodejs/socket.io/lib/namespace.js:302:14)
at Manager.handleClient (/usr/lib/nodejs/socket.io/lib/manager.js:669:30)
----------------------------------------
at EventEmitter.on
at Object.<anonymous> (/home/chen/code/home/git/docview/learning/coffee/browserid/server.coffee:35:14)
at Object.<anonymous> (/home/chen/code/home/git/docview/learning/coffee/browserid/server.coffee:71:4)
at Module._compile (module.js:441:26)
at Object.run (/usr/lib/nodejs/coffee-script/lib/coffee-script/coffee-script.js:68:25)
at /usr/lib/nodejs/coffee-script/lib/coffee-script/command.js:135:29
at /usr/lib/nodejs/coffee-script/lib/coffee-script/command.js:110:18
at [object Object].<anonymous> (fs.js:115:5)
at [object Object].emit (events.js:64:17)
Uncaught undefined
node.js:201
throw e; // process.nextTick error, or 'error' event on first tick
^
Looking at the http.request documentation, we find:
Options:
host: A domain name or IP address of the server to issue the request to. Defaults to 'localhost'.
hostname: To support url.parse() hostname is preferred over host
port: Port of remote server. Defaults to 80.
You might try these options instead:
options =
hostname: 'browserid.org'
port: 443
path: '/verify'
method: 'POST'
headers:
'Content-Type': 'application/x-www-form-urlencoded'
'Content-Length': msg.length
Edit: http.request doesn't work for SSL requests, for this, you need to use https.request. Changing to that fixes your other error as well, and the default port is 443 so you can omit that from the options if you wish.

Resources