问:
Kotlin Compiler in Android Application: Connection refused to host: 127.0.0.1
I'm trying to compile a multimodule android application inside Docker (it's a CI build). Some of those modules contains Kotlin source code.

The build works fine on local environments (MacOS), but for some reason is failing on CI.

Local Environment

MacOS 10.125.

java version "1.8.0_121" (Java(TM) SE Runtime Environment (build 1.8.0_121-b13)

CI environment

Docker base image openjdk:8-jdk

App configuration

Gradle Wrapper 4.0.-rc1

Android Build tools 26

Kotlin version '1.1.2-2'

gradle.properties (although i have played around with all combinations and neither worked)

org.gradle.daemon=true
org.gradle.parallel=true
org.gradle.jvmargs=-Xmx2048M
org.gradle.configureondemand=true
kotlin.compiler.execution.strategy=in-process

It looks like it's related to some remote process, as is not being able to connect to it. I thought about Kotlin and Gradle deamon but after playing much with different gradle.properties and other configs I can not seem to get a configuration that works.

```warning: [options] bootstrap class path not set in conjunction with -source 1.7
Using kotlin incremental compilation
Using kotlin incremental compilation
1 warning
Compilation with Kotlin compile daemon was not successful
java.lang.IllegalStateException: Service is dying
    at org.jetbrains.kotlin.daemon.common.CompileService$CallResult$Dying.get(CompileService.kt:55)
    at org.jetbrains.kotlin.daemon.common.CompileService$CallResult$Dying.get(CompileService.kt:54)
    at org.jetbrains.kotlin.compilerRunner.GradleCompilerRunner.compileWithDaemon(GradleKotlinCompilerRunner.kt:150)
    at org.jetbrains.kotlin.compilerRunner.GradleCompilerRunner.compileWithDaemonOrFallback(GradleKotlinCompilerRunner.kt:112)
    at org.jetbrains.kotlin.compilerRunner.GradleCompilerRunner.compileWithDaemonOrFallback(GradleKotlinCompilerRunner.kt:49)
    at org.jetbrains.kotlin.compilerRunner.KotlinCompilerRunner.runCompiler(KotlinCompilerRunner.kt:134)
    at org.jetbrains.kotlin.compilerRunner.GradleCompilerRunner.runJvmCompiler(GradleKotlinCompilerRunner.kt:73)
    at org.jetbrains.kotlin.gradle.tasks.KotlinCompile.callCompiler$kotlin_gradle_plugin(Tasks.kt:259)
    at org.jetbrains.kotlin.gradle.tasks.KotlinCompile.callCompiler$kotlin_gradle_plugin(Tasks.kt:160)
    at org.jetbrains.kotlin.gradle.tasks.AbstractKotlinCompile.execute(Tasks.kt:141)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73)
    at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$IncrementalTaskAction.doExecute(DefaultTaskClassInfoStore.java:163)
    at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.execute(DefaultTaskClassInfoStore.java:134)
    at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.execute(DefaultTaskClassInfoStore.java:123)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$1.execute(ExecuteActionsTaskExecuter.java:115)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$1.execute(ExecuteActionsTaskExecuter.java:109)
    at org.gradle.internal.Transformers$4.transform(Transformers.java:169)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:106)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:56)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:109)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:90)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:68)
    at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:62)
    at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58)
    at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:88)
    at org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.java:46)
    at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:51)
    at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:54)
    at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
    at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:34)
    at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker$1.execute(DefaultTaskGraphExecuter.java:236)
    at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker$1.execute(DefaultTaskGraphExecuter.java:228)
    at org.gradle.internal.Transformers$4.transform(Transformers.java:169)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:106)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:61)
    at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:228)
    at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:215)
    at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.processTask(AbstractTaskPlanExecutor.java:77)
    at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.run(AbstractTaskPlanExecutor.java:58)
    at org.gradle.execution.taskgraph.ParallelTaskPlanExecutor.process(ParallelTaskPlanExecutor.java:50)
    at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter.execute(DefaultTaskGraphExecuter.java:113)
    at org.gradle.execution.SelectedTaskExecutionAction.execute(SelectedTaskExecutionAction.java:37)
    at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:37)
    at org.gradle.execution.DefaultBuildExecuter.access$000(DefaultBuildExecuter.java:23)
    at org.gradle.execution.DefaultBuildExecuter$1.proceed(DefaultBuildExecuter.java:43)
    at org.gradle.execution.DryRunBuildExecutionAction.execute(DryRunBuildExecutionAction.java:32)
    at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:37)
    at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:30)
    at org.gradle.initialization.DefaultGradleLauncher$RunTasksAction.execute(DefaultGradleLauncher.java:230)
    at org.gradle.initialization.DefaultGradleLauncher$RunTasksAction.execute(DefaultGradleLauncher.java:227)
    at org.gradle.internal.Transformers$4.transform(Transformers.java:169)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:106)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:56)
    at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:161)
    at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:112)
    at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:95)
    at org.gradle.launcher.exec.GradleBuildController.run(GradleBuildController.java:66)
    at org.gradle.tooling.internal.provider.ExecuteBuildActionRunner.run(ExecuteBuildActionRunner.java:28)
    at org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35)
    at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:41)
    at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:26)
    at org.gradle.tooling.internal.provider.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:75)
    at org.gradle.tooling.internal.provider.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:49)
    at org.gradle.tooling.internal.provider.ServicesSetupBuildActionExecuter.execute(ServicesSetupBuildActionExecuter.java:49)
    at org.gradle.tooling.internal.provider.ServicesSetupBuildActionExecuter.execute(ServicesSetupBuildActionExecuter.java:31)
    at org.gradle.launcher.daemon.server.exec.ExecuteBuild.doBuild(ExecuteBuild.java:67)
    at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
    at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
    at org.gradle.launcher.daemon.server.exec.WatchForDisconnection.execute(WatchForDisconnection.java:37)
    at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
    at org.gradle.launcher.daemon.server.exec.ResetDeprecationLogger.execute(ResetDeprecationLogger.java:26)
    at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
    at org.gradle.launcher.daemon.server.exec.RequestStopIfSingleUsedDaemon.execute(RequestStopIfSingleUsedDaemon.java:34)
    at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
    at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:74)
    at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:72)
    at org.gradle.util.Swapper.swap(Swapper.java:38)
    at org.gradle.launcher.daemon.server.exec.ForwardClientInput.execute(ForwardClientInput.java:72)
    at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
    at org.gradle.launcher.daemon.server.exec.LogAndCheckHealth.execute(LogAndCheckHealth.java:55)
    at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
    at org.gradle.launcher.daemon.server.exec.LogToClient.doBuild(LogToClient.java:60)
    at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
    at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
    at org.gradle.launcher.daemon.server.exec.EstablishBuildEnvironment.doBuild(EstablishBuildEnvironment.java:72)
    at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
    at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
    at org.gradle.launcher.daemon.server.exec.StartBuildOrRespondWithBusy$1.run(StartBuildOrRespondWithBusy.java:50)
    at org.gradle.launcher.daemon.server.DaemonStateCoordinator$1.run(DaemonStateCoordinator.java:297)
    at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
    at org.gradle.internal.concurrent.StoppableExecutorImpl$1.run(StoppableExecutorImpl.java:46)
    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:748)
Could not connect to kotlin daemon. Using fallback strategy.

 ...

:app:compileKotlin FAILED
Compilation with Kotlin compile daemon was not successful
java.rmi.UnmarshalException: Error unmarshaling return header; nested exception is:
    java.io.EOFException
    at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:229)
    at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:162)
    at java.rmi.server.RemoteObjectInvocationHandler.invokeRemoteMethod(RemoteObjectInvocationHandler.java:227)
    at java.rmi.server.RemoteObjectInvocationHandler.invoke(RemoteObjectInvocationHandler.java:179)
    at com.sun.proxy.$Proxy117.compile(Unknown Source)
    at org.jetbrains.kotlin.compilerRunner.GradleCompilerRunner.incrementalCompilationWithDaemon(GradleKotlinCompilerRunner.kt:211)
    at org.jetbrains.kotlin.compilerRunner.GradleCompilerRunner.compileWithDaemon(GradleKotlinCompilerRunner.kt:146)
    at org.jetbrains.kotlin.compilerRunner.GradleCompilerRunner.compileWithDaemonOrFallback(GradleKotlinCompilerRunner.kt:112)
    at org.jetbrains.kotlin.compilerRunner.GradleCompilerRunner.compileWithDaemonOrFallback(GradleKotlinCompilerRunner.kt:49)
    at org.jetbrains.kotlin.compilerRunner.KotlinCompilerRunner.runCompiler(KotlinCompilerRunner.kt:134)
    at org.jetbrains.kotlin.compilerRunner.GradleCompilerRunner.runJvmCompiler(GradleKotlinCompilerRunner.kt:73)
    at org.jetbrains.kotlin.gradle.tasks.KotlinCompile.callCompiler$kotlin_gradle_plugin(Tasks.kt:259)
    at org.jetbrains.kotlin.gradle.tasks.KotlinCompile.callCompiler$kotlin_gradle_plugin(Tasks.kt:160)
    at org.jetbrains.kotlin.gradle.tasks.AbstractKotlinCompile.execute(Tasks.kt:141)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73)
    at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$IncrementalTaskAction.doExecute(DefaultTaskClassInfoStore.java:163)
    at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.execute(DefaultTaskClassInfoStore.java:134)
    at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.execute(DefaultTaskClassInfoStore.java:123)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$1.execute(ExecuteActionsTaskExecuter.java:115)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$1.execute(ExecuteActionsTaskExecuter.java:109)
    at org.gradle.internal.Transformers$4.transform(Transformers.java:169)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:106)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:56)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:109)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:90)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:68)
    at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:62)
    at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58)
    at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:88)
    at org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.java:46)
    at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:51)
    at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:54)
    at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
    at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:34)
    at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker$1.execute(DefaultTaskGraphExecuter.java:236)
    at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker$1.execute(DefaultTaskGraphExecuter.java:228)
    at org.gradle.internal.Transformers$4.transform(Transformers.java:169)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:106)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:61)
    at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:228)
    at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:215)
    at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.processTask(AbstractTaskPlanExecutor.java:77)
    at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.run(AbstractTaskPlanExecutor.java:58)
    at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
    at org.gradle.internal.concurrent.StoppableExecutorImpl$1.run(StoppableExecutorImpl.java:46)
    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:748)
Caused by: java.io.EOFException
    at java.io.DataInputStream.readByte(DataInputStream.java:267)
    at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:215)
    ... 51 more
e: java.rmi.ConnectException: Connection refused to host: 127.0.0.1; nested exception is:
    java.net.ConnectException: Connection refused (Connection refused)
    at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:619)
    at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:216)
    at sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:202)
    at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:130)
    at java.rmi.server.RemoteObjectInvocationHandler.invokeRemoteMethod(RemoteObjectInvocationHandler.java:227)
    at java.rmi.server.RemoteObjectInvocationHandler.invoke(RemoteObjectInvocationHandler.java:179)
    at com.sun.proxy.$Proxy117.clearJarCache(Unknown Source)
    at org.jetbrains.kotlin.compilerRunner.GradleCompilerRunner.compileWithDaemon(GradleKotlinCompilerRunner.kt:158)
    at org.jetbrains.kotlin.compilerRunner.GradleCompilerRunner.compileWithDaemonOrFallback(GradleKotlinCompilerRunner.kt:112)
    at org.jetbrains.kotlin.compilerRunner.GradleCompilerRunner.compileWithDaemonOrFallback(GradleKotlinCompilerRunner.kt:49)
    at org.jetbrains.kotlin.compilerRunner.KotlinCompilerRunner.runCompiler(KotlinCompilerRunner.kt:134)
    at org.jetbrains.kotlin.compilerRunner.GradleCompilerRunner.runJvmCompiler(GradleKotlinCompilerRunner.kt:73)
    at org.jetbrains.kotlin.gradle.tasks.KotlinCompile.callCompiler$kotlin_gradle_plugin(Tasks.kt:259)
    at org.jetbrains.kotlin.gradle.tasks.KotlinCompile.callCompiler$kotlin_gradle_plugin(Tasks.kt:160)
    at org.jetbrains.kotlin.gradle.tasks.AbstractKotlinCompile.execute(Tasks.kt:141)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73)
    at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$IncrementalTaskAction.doExecute(DefaultTaskClassInfoStore.java:163)
    at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.execute(DefaultTaskClassInfoStore.java:134)
    at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.execute(DefaultTaskClassInfoStore.java:123)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$1.execute(ExecuteActionsTaskExecuter.java:115)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$1.execute(ExecuteActionsTaskExecuter.java:109)
    at org.gradle.internal.Transformers$4.transform(Transformers.java:169)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:106)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:56)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:109)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:90)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:68)
    at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:62)
    at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58)
    at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:88)
    at org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.java:46)
    at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:51)
    at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:54)
    at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
    at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:34)
    at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker$1.execute(DefaultTaskGraphExecuter.java:236)
    at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker$1.execute(DefaultTaskGraphExecuter.java:228)
    at org.gradle.internal.Transformers$4.transform(Transformers.java:169)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:106)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:61)
    at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:228)
    at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:215)
    at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.processTask(AbstractTaskPlanExecutor.java:77)
    at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.run(AbstractTaskPlanExecutor.java:58)
    at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
    at org.gradle.internal.concurrent.StoppableExecutorImpl$1.run(StoppableExecutorImpl.java:46)
    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:748)
Caused by: java.net.ConnectException: Connection refused (Connection refused)
    at java.net.PlainSocketImpl.socketConnect(Native Method)
    at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
    at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
    at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
    at java.net.Socket.connect(Socket.java:589)
    at java.net.Socket.connect(Socket.java:538)
    at java.net.Socket.<init>(Socket.java:434)
    at java.net.Socket.<init>(Socket.java:244)
    at org.jetbrains.kotlin.daemon.common.LoopbackNetworkInterface$ClientLoopbackSocketFactory.createSocket(NetworkUtils.kt:76)
    at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:613)
    ... 52 more

 e: Compiler terminated with internal error
 :app:compileKotlin FAILED
```

答:
This could be KT-15562 which describes the same problem and suggests that you disable "compiling independent modules in parallel".  You can also disable the Gradle daemon for the build.  Or even turning off incremental compilation (is probably best in CI to do full builds anyway).  Gradle properties for these settings:

```<code>org.gradle.daemon=false
org.gradle.parallel=false
kotlin.incremental=false
</code>```

This issue is showing in versions up through 1.1.2 so you can track the issue above, but also try the workarounds.

As another option, unexplained process death could be due to running out of memory in your container and not having enough or any swap space configured.

Body:
I'm trying to compile a multimodule android application inside Docker (it's a CI build). Some of those modules contains Kotlin source code.

The build works fine on local environments (MacOS), but for some reason is failing on CI.

Local Environment

MacOS 10.125.

java version "1.8.0_121" (Java(TM) SE Runtime Environment (build 1.8.0_121-b13)

CI environment

Docker base image openjdk:8-jdk

App configuration

Gradle Wrapper 4.0.-rc1

Android Build tools 26

Kotlin version '1.1.2-2'

gradle.properties (although i have played around with all combinations and neither worked)

org.gradle.daemon=true
org.gradle.parallel=true
org.gradle.jvmargs=-Xmx2048M
org.gradle.configureondemand=true
kotlin.compiler.execution.strategy=in-process

It looks like it's related to some remote process, as is not being able to connect to it. I thought about Kotlin and Gradle deamon but after playing much with different gradle.properties and other configs I can not seem to get a configuration that works.

warning: [options] bootstrap class path not set in conjunction with -source 1.7
Using kotlin incremental compilation
Using kotlin incremental compilation
1 warning
Compilation with Kotlin compile daemon was not successful
java.lang.IllegalStateException: Service is dying
    at org.jetbrains.kotlin.daemon.common.CompileService$CallResult$Dying.get(CompileService.kt:55)
    at org.jetbrains.kotlin.daemon.common.CompileService$CallResult$Dying.get(CompileService.kt:54)
    at org.jetbrains.kotlin.compilerRunner.GradleCompilerRunner.compileWithDaemon(GradleKotlinCompilerRunner.kt:150)
    at org.jetbrains.kotlin.compilerRunner.GradleCompilerRunner.compileWithDaemonOrFallback(GradleKotlinCompilerRunner.kt:112)
    at org.jetbrains.kotlin.compilerRunner.GradleCompilerRunner.compileWithDaemonOrFallback(GradleKotlinCompilerRunner.kt:49)
    at org.jetbrains.kotlin.compilerRunner.KotlinCompilerRunner.runCompiler(KotlinCompilerRunner.kt:134)
    at org.jetbrains.kotlin.compilerRunner.GradleCompilerRunner.runJvmCompiler(GradleKotlinCompilerRunner.kt:73)
    at org.jetbrains.kotlin.gradle.tasks.KotlinCompile.callCompiler$kotlin_gradle_plugin(Tasks.kt:259)
    at org.jetbrains.kotlin.gradle.tasks.KotlinCompile.callCompiler$kotlin_gradle_plugin(Tasks.kt:160)
    at org.jetbrains.kotlin.gradle.tasks.AbstractKotlinCompile.execute(Tasks.kt:141)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73)
    at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$IncrementalTaskAction.doExecute(DefaultTaskClassInfoStore.java:163)
    at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.execute(DefaultTaskClassInfoStore.java:134)
    at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.execute(DefaultTaskClassInfoStore.java:123)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$1.execute(ExecuteActionsTaskExecuter.java:115)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$1.execute(ExecuteActionsTaskExecuter.java:109)
    at org.gradle.internal.Transformers$4.transform(Transformers.java:169)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:106)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:56)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:109)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:90)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:68)
    at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:62)
    at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58)
    at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:88)
    at org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.java:46)
    at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:51)
    at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:54)
    at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
    at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:34)
    at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker$1.execute(DefaultTaskGraphExecuter.java:236)
    at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker$1.execute(DefaultTaskGraphExecuter.java:228)
    at org.gradle.internal.Transformers$4.transform(Transformers.java:169)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:106)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:61)
    at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:228)
    at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:215)
    at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.processTask(AbstractTaskPlanExecutor.java:77)
    at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.run(AbstractTaskPlanExecutor.java:58)
    at org.gradle.execution.taskgraph.ParallelTaskPlanExecutor.process(ParallelTaskPlanExecutor.java:50)
    at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter.execute(DefaultTaskGraphExecuter.java:113)
    at org.gradle.execution.SelectedTaskExecutionAction.execute(SelectedTaskExecutionAction.java:37)
    at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:37)
    at org.gradle.execution.DefaultBuildExecuter.access$000(DefaultBuildExecuter.java:23)
    at org.gradle.execution.DefaultBuildExecuter$1.proceed(DefaultBuildExecuter.java:43)
    at org.gradle.execution.DryRunBuildExecutionAction.execute(DryRunBuildExecutionAction.java:32)
    at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:37)
    at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:30)
    at org.gradle.initialization.DefaultGradleLauncher$RunTasksAction.execute(DefaultGradleLauncher.java:230)
    at org.gradle.initialization.DefaultGradleLauncher$RunTasksAction.execute(DefaultGradleLauncher.java:227)
    at org.gradle.internal.Transformers$4.transform(Transformers.java:169)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:106)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:56)
    at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:161)
    at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:112)
    at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:95)
    at org.gradle.launcher.exec.GradleBuildController.run(GradleBuildController.java:66)
    at org.gradle.tooling.internal.provider.ExecuteBuildActionRunner.run(ExecuteBuildActionRunner.java:28)
    at org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35)
    at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:41)
    at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:26)
    at org.gradle.tooling.internal.provider.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:75)
    at org.gradle.tooling.internal.provider.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:49)
    at org.gradle.tooling.internal.provider.ServicesSetupBuildActionExecuter.execute(ServicesSetupBuildActionExecuter.java:49)
    at org.gradle.tooling.internal.provider.ServicesSetupBuildActionExecuter.execute(ServicesSetupBuildActionExecuter.java:31)
    at org.gradle.launcher.daemon.server.exec.ExecuteBuild.doBuild(ExecuteBuild.java:67)
    at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
    at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
    at org.gradle.launcher.daemon.server.exec.WatchForDisconnection.execute(WatchForDisconnection.java:37)
    at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
    at org.gradle.launcher.daemon.server.exec.ResetDeprecationLogger.execute(ResetDeprecationLogger.java:26)
    at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
    at org.gradle.launcher.daemon.server.exec.RequestStopIfSingleUsedDaemon.execute(RequestStopIfSingleUsedDaemon.java:34)
    at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
    at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:74)
    at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:72)
    at org.gradle.util.Swapper.swap(Swapper.java:38)
    at org.gradle.launcher.daemon.server.exec.ForwardClientInput.execute(ForwardClientInput.java:72)
    at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
    at org.gradle.launcher.daemon.server.exec.LogAndCheckHealth.execute(LogAndCheckHealth.java:55)
    at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
    at org.gradle.launcher.daemon.server.exec.LogToClient.doBuild(LogToClient.java:60)
    at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
    at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
    at org.gradle.launcher.daemon.server.exec.EstablishBuildEnvironment.doBuild(EstablishBuildEnvironment.java:72)
    at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
    at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
    at org.gradle.launcher.daemon.server.exec.StartBuildOrRespondWithBusy$1.run(StartBuildOrRespondWithBusy.java:50)
    at org.gradle.launcher.daemon.server.DaemonStateCoordinator$1.run(DaemonStateCoordinator.java:297)
    at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
    at org.gradle.internal.concurrent.StoppableExecutorImpl$1.run(StoppableExecutorImpl.java:46)
    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:748)
Could not connect to kotlin daemon. Using fallback strategy.

 ...

:app:compileKotlin FAILED
Compilation with Kotlin compile daemon was not successful
java.rmi.UnmarshalException: Error unmarshaling return header; nested exception is:
    java.io.EOFException
    at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:229)
    at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:162)
    at java.rmi.server.RemoteObjectInvocationHandler.invokeRemoteMethod(RemoteObjectInvocationHandler.java:227)
    at java.rmi.server.RemoteObjectInvocationHandler.invoke(RemoteObjectInvocationHandler.java:179)
    at com.sun.proxy.$Proxy117.compile(Unknown Source)
    at org.jetbrains.kotlin.compilerRunner.GradleCompilerRunner.incrementalCompilationWithDaemon(GradleKotlinCompilerRunner.kt:211)
    at org.jetbrains.kotlin.compilerRunner.GradleCompilerRunner.compileWithDaemon(GradleKotlinCompilerRunner.kt:146)
    at org.jetbrains.kotlin.compilerRunner.GradleCompilerRunner.compileWithDaemonOrFallback(GradleKotlinCompilerRunner.kt:112)
    at org.jetbrains.kotlin.compilerRunner.GradleCompilerRunner.compileWithDaemonOrFallback(GradleKotlinCompilerRunner.kt:49)
    at org.jetbrains.kotlin.compilerRunner.KotlinCompilerRunner.runCompiler(KotlinCompilerRunner.kt:134)
    at org.jetbrains.kotlin.compilerRunner.GradleCompilerRunner.runJvmCompiler(GradleKotlinCompilerRunner.kt:73)
    at org.jetbrains.kotlin.gradle.tasks.KotlinCompile.callCompiler$kotlin_gradle_plugin(Tasks.kt:259)
    at org.jetbrains.kotlin.gradle.tasks.KotlinCompile.callCompiler$kotlin_gradle_plugin(Tasks.kt:160)
    at org.jetbrains.kotlin.gradle.tasks.AbstractKotlinCompile.execute(Tasks.kt:141)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73)
    at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$IncrementalTaskAction.doExecute(DefaultTaskClassInfoStore.java:163)
    at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.execute(DefaultTaskClassInfoStore.java:134)
    at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.execute(DefaultTaskClassInfoStore.java:123)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$1.execute(ExecuteActionsTaskExecuter.java:115)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$1.execute(ExecuteActionsTaskExecuter.java:109)
    at org.gradle.internal.Transformers$4.transform(Transformers.java:169)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:106)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:56)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:109)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:90)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:68)
    at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:62)
    at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58)
    at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:88)
    at org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.java:46)
    at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:51)
    at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:54)
    at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
    at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:34)
    at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker$1.execute(DefaultTaskGraphExecuter.java:236)
    at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker$1.execute(DefaultTaskGraphExecuter.java:228)
    at org.gradle.internal.Transformers$4.transform(Transformers.java:169)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:106)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:61)
    at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:228)
    at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:215)
    at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.processTask(AbstractTaskPlanExecutor.java:77)
    at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.run(AbstractTaskPlanExecutor.java:58)
    at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
    at org.gradle.internal.concurrent.StoppableExecutorImpl$1.run(StoppableExecutorImpl.java:46)
    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:748)
Caused by: java.io.EOFException
    at java.io.DataInputStream.readByte(DataInputStream.java:267)
    at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:215)
    ... 51 more
e: java.rmi.ConnectException: Connection refused to host: 127.0.0.1; nested exception is:
    java.net.ConnectException: Connection refused (Connection refused)
    at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:619)
    at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:216)
    at sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:202)
    at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:130)
    at java.rmi.server.RemoteObjectInvocationHandler.invokeRemoteMethod(RemoteObjectInvocationHandler.java:227)
    at java.rmi.server.RemoteObjectInvocationHandler.invoke(RemoteObjectInvocationHandler.java:179)
    at com.sun.proxy.$Proxy117.clearJarCache(Unknown Source)
    at org.jetbrains.kotlin.compilerRunner.GradleCompilerRunner.compileWithDaemon(GradleKotlinCompilerRunner.kt:158)
    at org.jetbrains.kotlin.compilerRunner.GradleCompilerRunner.compileWithDaemonOrFallback(GradleKotlinCompilerRunner.kt:112)
    at org.jetbrains.kotlin.compilerRunner.GradleCompilerRunner.compileWithDaemonOrFallback(GradleKotlinCompilerRunner.kt:49)
    at org.jetbrains.kotlin.compilerRunner.KotlinCompilerRunner.runCompiler(KotlinCompilerRunner.kt:134)
    at org.jetbrains.kotlin.compilerRunner.GradleCompilerRunner.runJvmCompiler(GradleKotlinCompilerRunner.kt:73)
    at org.jetbrains.kotlin.gradle.tasks.KotlinCompile.callCompiler$kotlin_gradle_plugin(Tasks.kt:259)
    at org.jetbrains.kotlin.gradle.tasks.KotlinCompile.callCompiler$kotlin_gradle_plugin(Tasks.kt:160)
    at org.jetbrains.kotlin.gradle.tasks.AbstractKotlinCompile.execute(Tasks.kt:141)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73)
    at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$IncrementalTaskAction.doExecute(DefaultTaskClassInfoStore.java:163)
    at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.execute(DefaultTaskClassInfoStore.java:134)
    at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.execute(DefaultTaskClassInfoStore.java:123)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$1.execute(ExecuteActionsTaskExecuter.java:115)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$1.execute(ExecuteActionsTaskExecuter.java:109)
    at org.gradle.internal.Transformers$4.transform(Transformers.java:169)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:106)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:56)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:109)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:90)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:68)
    at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:62)
    at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58)
    at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:88)
    at org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.java:46)
    at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:51)
    at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:54)
    at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
    at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:34)
    at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker$1.execute(DefaultTaskGraphExecuter.java:236)
    at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker$1.execute(DefaultTaskGraphExecuter.java:228)
    at org.gradle.internal.Transformers$4.transform(Transformers.java:169)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:106)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:61)
    at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:228)
    at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:215)
    at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.processTask(AbstractTaskPlanExecutor.java:77)
    at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.run(AbstractTaskPlanExecutor.java:58)
    at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
    at org.gradle.internal.concurrent.StoppableExecutorImpl$1.run(StoppableExecutorImpl.java:46)
    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:748)
Caused by: java.net.ConnectException: Connection refused (Connection refused)
    at java.net.PlainSocketImpl.socketConnect(Native Method)
    at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
    at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
    at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
    at java.net.Socket.connect(Socket.java:589)
    at java.net.Socket.connect(Socket.java:538)
    at java.net.Socket.<init>(Socket.java:434)
    at java.net.Socket.<init>(Socket.java:244)
    at org.jetbrains.kotlin.daemon.common.LoopbackNetworkInterface$ClientLoopbackSocketFactory.createSocket(NetworkUtils.kt:76)
    at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:613)
    ... 52 more

 e: Compiler terminated with internal error
 :app:compileKotlin FAILED

Body:
This could be KT-15562 which describes the same problem and suggests that you disable "compiling independent modules in parallel".  You can also disable the Gradle daemon for the build.  Or even turning off incremental compilation (is probably best in CI to do full builds anyway).  Gradle properties for these settings:

org.gradle.daemon=false
org.gradle.parallel=false
kotlin.incremental=false

This issue is showing in versions up through 1.1.2 so you can track the issue above, but also try the workarounds.

As another option, unexplained process death could be due to running out of memory in your container and not having enough or any swap space configured.


来源: stackexchange

问:
C# - Lambda vs nested loops
Is is possible to convert following into a simpler more readable linq or lambda expression?

```<code>Dictionary<int, int> selectedProgramTierCombo = new Dictionary<int,int>();
foreach (int mainTierID in doc.TierID)
{
    foreach (PriceProgram priceProgram in doc.CommitmentProgram.PricingPrograms)
    {
        foreach (ProgramTier progTier in priceProgram.Tiers)
        {
            if (progTier.TierID == mainTierID )
            {
                selectedProgramTierCombo.Add(priceProgram.ProgramID, progTier.TierID);
            }
        }
    }
}
</code>```

Essentially doc.TierID is a an array (int[]) of TierIDs that client is currently on. Also the doc object contains a CommitmentProgram object which contains a list of PriceProgram. So, All I am trying to do is get the PriceProgram.ProgramID for each TierID.

The relationship between PriceProgram and TierID is that each PriceProgram has a list of tiers (ProgramTier object) and ProgramTier oject contains the corresponding TierID that we already have.

Let me know if my explaination doesn't make sense and I'll try to elaborate.

Edit

Jon,
I am getting The name 'priceProgram' does not exist in the current context error when I try to compile what you have suggested:

```<code>Dictionary<int, int> selectedProgramTierCombo =
    (from mainTierID in doc.TierID
     from priceProgram in doc.CommitmentProgram.PricingPrograms
     **join progTier in priceProgram.Tiers on mainTierID equals progTier.TierID**
     select new { priceProgram.ProgramID, progTier.TierID })
    .ToDictionary(x => x.ProgramID, x => x.TierID);
</code>```

答:
The Single kind of bugs me, but I have to go with what's being asked for.

```<code>Dictionary<int, int> selectedProgramTierCombo =
(
  from priceProgram in doc.CommitmentProgram.PricingPrograms
  let tierId =
  (
    from progTier in priceProgram.Tiers
    where doc.TierID.Any(mainTierID => mainTierID == progTier.TierID)
    select progTier.TierID
  ).Single()
  select new
  {
    ProgramID = priceProgram.ProgramID,
    TierID = tierID
  }
).ToDictionary(x => x.ProgramID, x => x.TierID);
</code>```

This is what I'd be more comfortable with:

```<code>ILookup<int, int> selectedProgramTierCombo =
(
  from priceProgram in doc.CommitmentProgram.PricingPrograms
  from progTier in priceProgram.Tiers
  where doc.TierID.Any(mainTierID => mainTierID == progTier.TierID)
  select new
  {
    ProgramID = priceProgram.ProgramID,
    TierID = progTier.TierID
  }
).ToLookup(x => x.ProgramID, x => x.TierID);
</code>```

ContentLicense: CC BY-SA 2.5

Title: C# - Lambda vs nested loops

Body:
Is is possible to convert following into a simpler more readable linq or lambda expression?

Dictionary<int, int> selectedProgramTierCombo = new Dictionary<int,int>();
foreach (int mainTierID in doc.TierID)
{
    foreach (PriceProgram priceProgram in doc.CommitmentProgram.PricingPrograms)
    {
        foreach (ProgramTier progTier in priceProgram.Tiers)
        {
            if (progTier.TierID == mainTierID )
            {
                selectedProgramTierCombo.Add(priceProgram.ProgramID, progTier.TierID);
            }
        }
    }
}

Essentially doc.TierID is a an array (int[]) of TierIDs that client is currently on. Also the doc object contains a CommitmentProgram object which contains a list of PriceProgram. So, All I am trying to do is get the PriceProgram.ProgramID for each TierID.

The relationship between PriceProgram and TierID is that each PriceProgram has a list of tiers (ProgramTier object) and ProgramTier oject contains the corresponding TierID that we already have.

Let me know if my explaination doesn't make sense and I'll try to elaborate.

Edit

Jon,
I am getting The name 'priceProgram' does not exist in the current context error when I try to compile what you have suggested:

Dictionary<int, int> selectedProgramTierCombo =
    (from mainTierID in doc.TierID
     from priceProgram in doc.CommitmentProgram.PricingPrograms
     **join progTier in priceProgram.Tiers on mainTierID equals progTier.TierID**
     select new { priceProgram.ProgramID, progTier.TierID })
    .ToDictionary(x => x.ProgramID, x => x.TierID);

Body:
The Single kind of bugs me, but I have to go with what's being asked for.

Dictionary<int, int> selectedProgramTierCombo =
(
  from priceProgram in doc.CommitmentProgram.PricingPrograms
  let tierId =
  (
    from progTier in priceProgram.Tiers
    where doc.TierID.Any(mainTierID => mainTierID == progTier.TierID)
    select progTier.TierID
  ).Single()
  select new
  {
    ProgramID = priceProgram.ProgramID,
    TierID = tierID
  }
).ToDictionary(x => x.ProgramID, x => x.TierID);

This is what I'd be more comfortable with:

ILookup<int, int> selectedProgramTierCombo =
(
  from priceProgram in doc.CommitmentProgram.PricingPrograms
  from progTier in priceProgram.Tiers
  where doc.TierID.Any(mainTierID => mainTierID == progTier.TierID)
  select new
  {
    ProgramID = priceProgram.ProgramID,
    TierID = progTier.TierID
  }
).ToLookup(x => x.ProgramID, x => x.TierID);


问:
Fetch Firebase data from app to website?
I have built an iphone app that writes data to firebase. That works fine. Now I want to display that data on a  website. I am totally new to programming, and had to learn swift from scratch.

So  my question is; is there a easy way to display the data on the webpage? It dont have to look  good as long as the data is displayed. I'm not sure if I'm able to learn another codelanguage just yet  ☺

答:
To build a web site you'd use a combination of HTML (for the layout of the web site), CSS (for the actual look of the web site) and JavaScript (for the logic of the web site). JavaScript is indeed a different language, but a second language should be easier than your first one.

I recommend studying the Firebase Database documentation for JavaScript and taking the Firebase codelab for web. They are the best ways to get started with Firebase.

ContentLicense: CC BY-SA 3.0


问:
random element from a list
Is there a way in python to select a random element form a list without considering a current element?

In other word, I want to do this

```<code>L=[1,2,3,4,5,6,7,8,9,10]
i=0
while(i<len(L):
  random.choice(L-L[i])
  i+=1
</code>```

For example, at iteration 0 I do not want to have the element 1
and at iteration 1 I do not want to have the element 2.

答:
All you have to pick a random element other than the current index , then you can try this

```<code>l=[i for i in range(1,11)]
from random import random
for i in l:
    while 1:
        tmp= int(random() * 10)
        if tmp!=i:
            print tmp
            break
</code>```

Title: random element from a list

Body:
Is there a way in python to select a random element form a list without considering a current element?

In other word, I want to do this

L=[1,2,3,4,5,6,7,8,9,10]
i=0
while(i<len(L):
  random.choice(L-L[i])
  i+=1

For example, at iteration 0 I do not want to have the element 1
and at iteration 1 I do not want to have the element 2.

Body:
All you have to pick a random element other than the current index , then you can try this

l=[i for i in range(1,11)]
from random import random
for i in l:
    while 1:
        tmp= int(random() * 10)
        if tmp!=i:
            print tmp
            break


问:
Emacs: Wrong number of arguments when trying to run an interactive function
I am trying to create a command that will indent a selected region by 4 spaces.

The appropriate commands are: C-u 4 C-x <TAB>, when C-u is a shortcut for "universal-argument" command and C-x <TAB> is a shortcut for indent-rigidly, so I've written this function:

```<code>(defun my-tab ()
  (interactive)
  (universal-argument 4)
  (indent-rigidly))
</code>```

But when I'm trying to run the function (with M-x my-tab) I get this error:

Wrong number of arguments: (0 . 0), 1

What is the problem?

Thanks!

答:
If you look at the documentation for indent-rigidly (C-h f indent-rigidly), you'll notice that it takes 3-4 arguments:

```<code>(indent-rigidly START END ARG &optional INTERACTIVE)
</code>```

So, you should supply the start and end positions to it as well. You should also just give the ARG normally, instead of using universal-argument.

```<code>(defun my-tab (start end)
  (interactive (if (use-region-p)
                   (list (region-beginning) (region-end))
                 ;; Operate on the current line if region is not to be used.
                 (list (line-beginning-position) (line-end-position))))
  (indent-rigidly start end 4))
</code>```

Body:
I am trying to create a command that will indent a selected region by 4 spaces.

The appropriate commands are: C-u 4 C-x <TAB>, when C-u is a shortcut for "universal-argument" command and C-x <TAB> is a shortcut for indent-rigidly, so I've written this function:

(defun my-tab ()
  (interactive)
  (universal-argument 4)
  (indent-rigidly))

But when I'm trying to run the function (with M-x my-tab) I get this error:

Wrong number of arguments: (0 . 0), 1

What is the problem?

Thanks!

Body:
If you look at the documentation for indent-rigidly (C-h f indent-rigidly), you'll notice that it takes 3-4 arguments:

(indent-rigidly START END ARG &optional INTERACTIVE)

So, you should supply the start and end positions to it as well. You should also just give the ARG normally, instead of using universal-argument.

(defun my-tab (start end)
  (interactive (if (use-region-p)
                   (list (region-beginning) (region-end))
                 ;; Operate on the current line if region is not to be used.
                 (list (line-beginning-position) (line-end-position))))
  (indent-rigidly start end 4))


问:
Dynamic font resize
This script resize text based on the text length. All works fine but the text does not resize up when deleting characters. what's missing? Hoping there is a script guru around to help me!

  $('#location').keypress(function() {

    var textLength = $(this).val().length;

    if (textLength < 20) {
      // Do noting
    } else if (textLength < 40) {
      $(this).css('font-size', '16px');
    } else if (textLength > 40) {
      $(this).css('font-size', '24px');
    }
    //console.log(textLength);
  }); ```
<pre class="snippet-code-css lang-css prettyprint-override"><code>#location {
  font-size: 24px;
  outline: none;
  width: 200px;
  height: 30px;
  display: table-cell;
  vertical-align: middle;
  border: 1px solid #ccc;
}</code>```

<input type="text" id="location" placeholder="Placeholder Text" />```

答:
is this you wanted to do?

Kepress works for printable characters only. In order to detect backspace and delete use keyup or keydown

$(document).on('keyup keydown','#location',function() {

    var textLength = $(this).val().replace(/\s+/g,'').length; // first replace spaces then count
    console.log("Length without spaces "+textLength);
    if (textLength < 20) {
       $(this).css('font-size', '24px');
    } else if (textLength < 40) {
      $(this).css('font-size', '16px');
    } else if (textLength > 40) {
      $(this).css('font-size', '24px');
    }
    //console.log(textLength);
  });```
<pre class="snippet-code-css lang-css prettyprint-override"><code>#location {

  outline: none;
  width: 200px;
  height: 30px;
  display: table-cell;
  vertical-align: middle;
  border: 1px solid #ccc;
}</code>```

<input type="text" id="location" placeholder="Placeholder Text" />```

Title: Dynamic font resize

Body:
This script resize text based on the text length. All works fine but the text does not resize up when deleting characters. what's missing? Hoping there is a script guru around to help me!

  $('#location').keypress(function() {

    var textLength = $(this).val().length;

    if (textLength < 20) {
      // Do noting
    } else if (textLength < 40) {
      $(this).css('font-size', '16px');
    } else if (textLength > 40) {
      $(this).css('font-size', '24px');
    }
    //console.log(textLength);
  });

#location {
  font-size: 24px;
  outline: none;
  width: 200px;
  height: 30px;
  display: table-cell;
  vertical-align: middle;
  border: 1px solid #ccc;
}

<input type="text" id="location" placeholder="Placeholder Text" />

Body:
is this you wanted to do?

Kepress works for printable characters only. In order to detect backspace and delete use keyup or keydown

$(document).on('keyup keydown','#location',function() {

    var textLength = $(this).val().replace(/\s+/g,'').length; // first replace spaces then count
    console.log("Length without spaces "+textLength);
    if (textLength < 20) {
       $(this).css('font-size', '24px');
    } else if (textLength < 40) {
      $(this).css('font-size', '16px');
    } else if (textLength > 40) {
      $(this).css('font-size', '24px');
    }
    //console.log(textLength);
  });

#location {

  outline: none;
  width: 200px;
  height: 30px;
  display: table-cell;
  vertical-align: middle;
  border: 1px solid #ccc;
}

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input type="text" id="location" placeholder="Placeholder Text" />


问:
AngularJS - Cannot change directive template dynamically in link function

BEWARE

The accepted solution will break a directive with replace: true: HTML won't be replaced, specific CSS selectors in use will no longer work, etc.

I want my directive to dynamically change its template by watching a string received as attribute from the parent controller, so I used $compile from this answer together with $observe from this small part of an interesting tutorial, but alas it's not working, like shown in this plunkr.

About the error

If jQuery is included before AngularJS in the scripts, the replaceWith call throws me the following error:

```<code>TypeError: Cannot read property 'ownerDocument' of undefined
</code>```

But if I remove jQuery, forcing AngularJS to use its jqLite, the same part throws this error, making things clearer to a total jQuery agnostic like me:

```<code>TypeError: Failed to execute 'replaceChild' on 'Node': parameter 1 is not of type 'Node'.
</code>```

Even if it's clear to me that I'm not passing a valid 'Node' type object to the replaceWith, I don't know how to handle this situation, since I was expecting $compile to do the job.

The only things I know are that the console.log(tplContent) looks like this (a promise am I right?):

```<code>Object
{
  config: Object
  data: "<script type="text/ng-template" id="templateId.html">
  ↵  <p>TEMPLATE A</p>
  ↵</script>"
  headers: function (d)
  ng339: 10
  status: 200
  statusText: "OK"
}
</code>```

while the console.log($compile(tplContent)(scope)) returns an array with that  same object as first and only item:

```<code>[Object]
0: {
  config: Object
  data: "<script type="text/ng-template" id="templateId.html">
  ↵  <p>TEMPLATE A</p>
  ↵</script>"
  headers: function (d)
  ng339: 10
  status: 200
  statusText: "OK"
},
length: 1
</code>```

I do really want to avoid using any of the following two fallbacks, have you got any idea of what I'm doing wrong here?

The fallbacks a.k.a. don't tell me to do this

I know I could split the directive into two directives and ng-if them like this:

```<code>(function() {
  'use-strict';

  angular.module('app')
  .directive('dynamicTemplateA', dynamicTemplate);

  DynTplCtrl.$inject = ['$http', '$templateCache', '$compile', '$parse'];

  function dynamicTemplate($http, $templateCache, $compile, $parse) {
    var directive = {
      restrict: 'E',
      templateUrl: 'template-a.html',
      scope: {},
      bindToController: {
        tpl: '@',
        i: '='
      },
      controller: DynTplCtrl,
      controllerAs: 'dyntplctrl',
      link: linkFunc
    }

    return directive;

    function linkFunc(scope, el, attrs, ctrl) {}
  }

  DynTplCtrl.$inject = [];

  function DynTplCtrl() {}

})()

(function() {
  'use-strict';

  angular.module('app')
  .directive('dynamicTemplateB', dynamicTemplate);

  DynTplCtrl.$inject = ['$http', '$templateCache', '$compile', '$parse'];

  function dynamicTemplate($http, $templateCache, $compile, $parse) {
    var directive = {
      restrict: 'E',
      templateUrl: 'template-b.html',
      scope: {},
      bindToController: {
        tpl: '@',
        i: '='
      },
      controller: DynTplCtrl,
      controllerAs: 'dyntplctrl',
      link: linkFunc
    }

    return directive;

    function linkFunc(scope, el, attrs, ctrl) {}
  }

  DynTplCtrl.$inject = [];

  function DynTplCtrl() {}

})()
</code>```

and then in the controller.html:

```<code><div ng-repeat="i in [1,2,3]">
  <dynamic-template-a ng-if="mainctrl.tpl === 'a'" tpl="{{mainctrl.tpl}}" i="i"></dynamic-template-a>
  <dynamic-template-b ng-if="mainctrl.tpl === 'b'" tpl="{{mainctrl.tpl}}" i="i"></dynamic-template-b>
</div>
</code>```

I also know I could use ng-include like this:

```<code>(function() {
  'use-strict';

  angular.module('app')
  .directive('dynamicTemplateA', dynamicTemplate);

  DynTplCtrl.$inject = ['$http', '$templateCache', '$compile', '$parse'];

  function dynamicTemplate($http, $templateCache, $compile, $parse) {
    var directive = {
      restrict: 'E',
      template: '<div ng-include="dyntplctrl.getTemplateUrl()"></div>',
      scope: {},
      bindToController: {
        tpl: '@',
        i: '='
      },
      controller: DynTplCtrl,
      controllerAs: 'dyntplctrl',
      link: linkFunc
    }

    return directive;

    function linkFunc(scope, el, attrs, ctrl) {}
  }

  DynTplCtrl.$inject = [];

  function DynTplCtrl() {
    var vm = this;
    vm.getTemplateUrl = _getTemplateUrl;

    function _getTemplateUrl() {
      return 'template-' + vm.tpl + '.html';
    }
  }

})()
</code>```

答:
Credits to this question.

You need to change your code a bit while replacing the template:

```<code>el.html(tplContent.data);
$compile(el.contents())(scope);
</code>```

This will replace the element's contents (though you need to handle sanitization here), and then compiles the template in the directive's scope.

Also, for testing, I've removed the

Body:
BEWARE

The accepted solution will break a directive with replace: true: HTML won't be replaced, specific CSS selectors in use will no longer work, etc.

I want my directive to dynamically change its template by watching a string received as attribute from the parent controller, so I used $compile from this answer together with $observe from this small part of an interesting tutorial, but alas it's not working, like shown in this plunkr.

About the error

If jQuery is included before AngularJS in the scripts, the replaceWith call throws me the following error:

TypeError: Cannot read property 'ownerDocument' of undefined

But if I remove jQuery, forcing AngularJS to use its jqLite, the same part throws this error, making things clearer to a total jQuery agnostic like me:

TypeError: Failed to execute 'replaceChild' on 'Node': parameter 1 is not of type 'Node'.

Even if it's clear to me that I'm not passing a valid 'Node' type object to the replaceWith, I don't know how to handle this situation, since I was expecting $compile to do the job.

The only things I know are that the console.log(tplContent) looks like this (a promise am I right?):

Object
{
  config: Object
  data: ""
  headers: function (d)
  ng339: 10
  status: 200
  statusText: "OK"
}

while the console.log($compile(tplContent)(scope)) returns an array with that  same object as first and only item:

[Object]
0: {
  config: Object
  data: ""
  headers: function (d)
  ng339: 10
  status: 200
  statusText: "OK"
},
length: 1

I do really want to avoid using any of the following two fallbacks, have you got any idea of what I'm doing wrong here?

The fallbacks a.k.a. don't tell me to do this

I know I could split the directive into two directives and ng-if them like this:

(function() {
  'use-strict';

  angular.module('app')
  .directive('dynamicTemplateA', dynamicTemplate);

  DynTplCtrl.$inject = ['$http', '$templateCache', '$compile', '$parse'];

  function dynamicTemplate($http, $templateCache, $compile, $parse) {
    var directive = {
      restrict: 'E',
      templateUrl: 'template-a.html',
      scope: {},
      bindToController: {
        tpl: '@',
        i: '='
      },
      controller: DynTplCtrl,
      controllerAs: 'dyntplctrl',
      link: linkFunc
    }

    return directive;

    function linkFunc(scope, el, attrs, ctrl) {}
  }

  DynTplCtrl.$inject = [];

  function DynTplCtrl() {}

})()

(function() {
  'use-strict';

  angular.module('app')
  .directive('dynamicTemplateB', dynamicTemplate);

  DynTplCtrl.$inject = ['$http', '$templateCache', '$compile', '$parse'];

  function dynamicTemplate($http, $templateCache, $compile, $parse) {
    var directive = {
      restrict: 'E',
      templateUrl: 'template-b.html',
      scope: {},
      bindToController: {
        tpl: '@',
        i: '='
      },
      controller: DynTplCtrl,
      controllerAs: 'dyntplctrl',
      link: linkFunc
    }

    return directive;

    function linkFunc(scope, el, attrs, ctrl) {}
  }

  DynTplCtrl.$inject = [];

  function DynTplCtrl() {}

})()

and then in the controller.html:

  <dynamic-template-a ng-if="mainctrl.tpl === 'a'" tpl="{{mainctrl.tpl}}" i="i"></dynamic-template-a>
  <dynamic-template-b ng-if="mainctrl.tpl === 'b'" tpl="{{mainctrl.tpl}}" i="i"></dynamic-template-b>

I also know I could use ng-include like this:

(function() {
  'use-strict';

  angular.module('app')
  .directive('dynamicTemplateA', dynamicTemplate);

  DynTplCtrl.$inject = ['$http', '$templateCache', '$compile', '$parse'];

  function dynamicTemplate($http, $templateCache, $compile, $parse) {
    var directive = {
      restrict: 'E',
      template: '

',
      scope: {},
      bindToController: {
        tpl: '@',
        i: '='
      },
      controller: DynTplCtrl,
      controllerAs: 'dyntplctrl',
      link: linkFunc
    }

    return directive;

    function linkFunc(scope, el, attrs, ctrl) {}
  }

  DynTplCtrl.$inject = [];

  function DynTplCtrl() {
    var vm = this;
    vm.getTemplateUrl = _getTemplateUrl;

    function _getTemplateUrl() {
      return 'template-' + vm.tpl + '.html';
    }
  }

})()

Body:
Credits to this question.

You need to change your code a bit while replacing the template:

el.html(tplContent.data);
$compile(el.contents())(scope);

This will replace the element's contents (though you need to handle sanitization here), and then compiles the template in the directive's scope.

Also, for testing, I've removed the <script> tags from the template-a.html, and template-b.html.

Here is a forked plunker which has the changes mentioned above.


问:
Inter-container connection via localhost
I would like to set up my containers so that they connect to each other via localhost.

My setup is a main application container and two other containers that it needs to connect to (ActiveMQ and Wiremock).

I already run ActiveMQ and Wiremock in containers with the relevant ports exposed, and the main application runs through IntelliJ and connects to these. However, when I am not developing the main applications, I would like to run it in a container for simplicity but it cannot connect to the ports exposed by the others.

Setting --net=host doesn't seem to work, nor does creating a network docker network create <NAME> and assigning it in the docker run with --net=<NAME>.

The application already runs in a container in other environments on the host network.

答:
docker creates a default network in which all containers run, and sets a network name for each of your containers, using the container name.

if you have a contained named mq for your ActiveMQ, then you would use something like tcp://mq:61616 (or whatever protocol / port you have configured) from your other containers, to connect to it.

you shouldn't need to set the --net option unless you need to create a specific network for specific containers to use.


问:
Android Why EditText ellipsize doesn't work?
I have added an EditText to my layout, but the ellipsize doesn't work. Can anybody help me? Thanks.</p>

```<code><EditText
        android:layout_width="match_parent"
        android:layout_margin="10dp"
        android:singleLine="true"
        android:ellipsize="end"
        android:textSize="24dp"
        android:layout_height="wrap_content" />
</code>```

答:
Ellipsize="end" wont work for editable EditText so you need to make the EditText as non editable to make it work. Use the following code

```<code><EditText
       android:layout_width="match_parent"
       android:layout_margin="10dp"
       android:textSize="24dp"
       android:text="A long texttttttttttttttttttttttttttttttttttttttttttttt"
       android:lines="1"
       android:scrollHorizontally="true"
       android:ellipsize="end"
       android:singleLine="true"
       android:layout_height="wrap_content"
       tools:ignore="Deprecated" />
</code>```

ContentLicense: CC BY-SA 4.0

Body:
I have added an EditText to my layout, but the ellipsize doesn't work. Can anybody help me? Thanks.

<EditText
        android:layout_width="match_parent"
        android:layout_margin="10dp"
        android:singleLine="true"
        android:ellipsize="end"
        android:textSize="24dp"
        android:layout_height="wrap_content" />

Body:
Ellipsize="end" wont work for editable EditText so you need to make the EditText as non editable to make it work. Use the following code

<EditText
       android:layout_width="match_parent"
       android:layout_margin="10dp"
       android:textSize="24dp"
       android:text="A long texttttttttttttttttttttttttttttttttttttttttttttt"
       android:lines="1"
       android:scrollHorizontally="true"
       android:ellipsize="end"
       android:singleLine="true"
       android:layout_height="wrap_content"
       tools:ignore="Deprecated" />


问:
How to retrieve multiple blob images from database
Hi i am using Spring mvc and hibernate. I want to retrieve multiple blob images from database and want to display in jsp. I tried a lot but did not get fruitful answer. If anyone gives link or sample code then it would be great for me.</p>

答:
i'm using server side this code it's works for me

Spring Controller

```<code>@RequestMapping(value ="/getImages", method = RequestMethod.GET)
    @ResponseBody
    public List<Product> getStateList(HttpServletResponse response, HttpServletRequest request) {
        List<Product> image = imageService.getImageList();
        List<Product> imageList= new ArrayList<Product>();
        for (Product m : new ArrayList<Product>(image)) {
            String base64Encoded = javax.xml.bind.DatatypeConverter.printBase64Binary(m.getImage());
            Product imagepath = new Product();
            imagepath.setImagePath(base64Encoded);
            imagepath.setItemName(m.getItemName());
            imageList.add(imagepath);
        }
        return imageList;
    }
</code>```

DAO

```<code>public List<Product> getImageList() {
        String getImageQuery = "FROM Product";
        Query query = sessionFactory.getCurrentSession().createQuery(getImageQuery);
        @SuppressWarnings("unchecked")
        List<Product> imgList = query.list();
        return imgList;
    }
</code>```

Model Class

```<code>@Entity
@Table(name="imageUpload")
public class ImageUpload {

    @Id
    @Column(name="eloraId")
    private int eloraId;

    @Column(name="password")
    private String password;

    @Column(name="ownerName")
    private String ownerName;

    @Column(name="registeredId",columnDefinition="mediumblob")
    private byte[] registeredId;

    @Column(name="hospPanCard")
    private String hospPanCard;

    @Column(name="hospRegCert",columnDefinition="mediumblob")
    private byte[] hospRegCert;

    @Column(name="ownerPanCard",columnDefinition="mediumblob")
    private byte[] ownerPanCard;

    @Column(name="ownerselfDec",columnDefinition="mediumblob")
    private byte[] ownerselfDec;

    @Column(name="ownerAddProof",columnDefinition="mediumblob")
    private byte[] ownerAddProof;

    @Transient
    private String statusMessage;
}
</code>```

Body:
i'm using server side this code it's works for me

Spring Controller

@RequestMapping(value ="/getImages", method = RequestMethod.GET)
    @ResponseBody
    public List<Product> getStateList(HttpServletResponse response, HttpServletRequest request) {
        List<Product> image = imageService.getImageList();
        List<Product> imageList= new ArrayList<Product>();
        for (Product m : new ArrayList<Product>(image)) {
            String base64Encoded = javax.xml.bind.DatatypeConverter.printBase64Binary(m.getImage());
            Product imagepath = new Product();
            imagepath.setImagePath(base64Encoded);
            imagepath.setItemName(m.getItemName());
            imageList.add(imagepath);
        }
        return imageList;
    }

DAO

public List<Product> getImageList() {
        String getImageQuery = "FROM Product";
        Query query = sessionFactory.getCurrentSession().createQuery(getImageQuery);
        @SuppressWarnings("unchecked")
        List<Product> imgList = query.list();
        return imgList;
    }

Model Class

@Entity
@Table(name="imageUpload")
public class ImageUpload {

    @Id
    @Column(name="eloraId")
    private int eloraId;

    @Column(name="password")
    private String password;

    @Column(name="ownerName")
    private String ownerName;

    @Column(name="registeredId",columnDefinition="mediumblob")
    private byte[] registeredId;

    @Column(name="hospPanCard")
    private String hospPanCard;

    @Column(name="hospRegCert",columnDefinition="mediumblob")
    private byte[] hospRegCert;

    @Column(name="ownerPanCard",columnDefinition="mediumblob")
    private byte[] ownerPanCard;

    @Column(name="ownerselfDec",columnDefinition="mediumblob")
    private byte[] ownerselfDec;

    @Column(name="ownerAddProof",columnDefinition="mediumblob")
    private byte[] ownerAddProof;

    @Transient
    private String statusMessage;
}


问:
How to create QList from std::vector
QList::fromStdList allows you to create QList from std::list. But how to create QList from std::vector?

Of course, aside from manual looping:

```<code>QList<T> myList;
myList.reserve(vector.size());
for(size_t i = 0, l = vector.size(); i < l; ++i)
    myList << vector[i];
</code>```

答:
QVector can be created from a std vector, so you could do this if you want to avoid a loop:

```<code>QList<T> myList = QList<T>::fromVector(QVector<T>::fromStdVector(vector));
</code>```

Of course, this would create an unnecessary copy in the process. Instead of having to write a loop, you could also use a std::copy and back_inserter

```<code>QList<T> myList;
myList.reserve(vector.size());
std::copy(vector.begin(), vector.end(), std::back_inserter(myList));
</code>```

Title: How to create QList from std::vector

Body:
QList::fromStdList allows you to create QList from std::list. But how to create QList from std::vector?

Of course, aside from manual looping:

QList<T> myList;
myList.reserve(vector.size());
for(size_t i = 0, l = vector.size(); i < l; ++i)
    myList << vector[i];

Body:
QVector can be created from a std vector, so you could do this if you want to avoid a loop:

QList<T> myList = QList<T>::fromVector(QVector<T>::fromStdVector(vector));

Of course, this would create an unnecessary copy in the process. Instead of having to write a loop, you could also use a std::copy and back_inserter

QList<T> myList;
myList.reserve(vector.size());
std::copy(vector.begin(), vector.end(), std::back_inserter(myList));


问:
Alternative to View for complex Data?
I have a table that contains partial data that is of no use to the user viewing my application. The viewer wants to see a similar table that has all the values calculated out, and wants to be able to quickly query THAT data. Normally, this would be the perfect place to use a View. Unfortunately the complex nature of the calculations limit my use of Views, so I need an alternate solution. I was thinking of doing something like the following...

Table A contains back-end data. Any time this table is updated, a trigger fired that updates Table B, which shows the result of these calculations. Table B can be queried quickly at this point.

My only concern is that the calculation procedure is somewhat lengthy, and Table A has the potential to be updated many times in bursts. Are there any solutions that are almost like a "Before Select" trigger? So basically Table A could be updated many times in a row, but the calculation would only occur when Table B was queried?

Here's an example timeline:

Table A is Updated

Table A is Updated Again [Don't run SP since nobody needs Table B data yet]

Data is requested from Table B [Run SP to update Table B before getting data]

Table A is Updated

Data is requested from Table B [Run SP to update Table B before getting data]

Data is requested from Table B [Don't run stored procedure because Table A wasn't updated between requests for Table B data]

So my questions are:

Is there anything existing like what I described above?

If not, is there a way to make triggers hold off until the completion of a batch of updates/inserts? Table A won't be modified very often, so I can live with a slow trigger when it is updated. The only problem is that when Table A does get updated, it is normally hundreds of rows at a time and I don't want a slow trigger to run every time.

Thanks for any solutions/insight!

Edit - A little more detail on why (I think at least) the trigger implementation would be slow:

The application that will be sending the Update/Insert/Delete statements is using LINQ-to-SQL, which isn't particularly good with batch operations. So if I wanted to delete a bunch of records, it would send a bunch of delete statements instead of a batch delete statement. Is there any way to group delete statements and have the trigger run after that? (Maybe I'm getting too far off topic here).

The "calculations" I'm speaking of involve some recursive functions and some decision-making processes. The data I'm actually dealing with is scheduling data. So Table A contains tasks which may or may not have a scheduled start. If there is no scheduled start defined, it has to derive it from its predecessors scheduled start + its predecessors duration. In some cases the predecessor might not have that information either, hence the recursive query that keeps digging until it finds the result. It's not painfully slow, but if it had to run on every insert/update/delete, it would get there. The "Table B" I refer to above is basically the same table, but it already has the calculated scheduled start data within (which needs to change on update of Table A).

答:
I would think a materialized view would be able to solve this, and run fairly fast.  However the OP doesn't say what the "calculations" are and only that they run slow.  As a result here is you best option:

Add a trigger to your main Table A, in that trigger insert the ID of the affected rows into a new "work needs to be done" table. This would have very low overhead, as the calculations are not done yet.

create a job that runs every x minutes to do the work calculations and clear the "work needs to be done" table.  This job would would populate and keep in sync your Table B, which has the final answers.

give access to the "query" only via a stored procedure call, in this procedure, run the processing used by the job (will make sure that the data in Table B is up to date) then it will run the query using Table B.

Title: Alternative to View for complex Data?


问:
Run cron4j at multiple different times
I need to write a Java class, which fetches different times from a database and then calls a function at those times. The times can change in the database and a value corresponding to the time in the Db is sent as arguments to the function.
I need to make sure this happens everyday at the time mentioned in the Db.

```<code> Scheduler s = new Scheduler();
    s.schedule("0 5 * * *", new Runnable() {
        public void run() {
            //call your function
            TestClass tc = new TestClass(value);
        }
    });
    // Starts the scheduler.
    s.start();
    try {
        Thread.sleep(1000L * 60L * 10L);
    } catch (InterruptedException e) {
        ;
    }
    // Stops the scheduler.
    s.stop();
</code>```

This code calls the class at 5:00:00 everyday, but I'm not sure what to pass in Thread.sleep()
I need to write for multiple different times too and make sure it runs for a long time, i.e. over a year.

答: If you want this to run for a year, then you shouldn't sleep(). You need to have your Scheduler stopped only of your application is shutting down. So as long as your application is running, supposedly for a year or more , your scheduler should be running too.

Title: Run cron4j at multiple different times

Body:
I need to write a Java class, which fetches different times from a database and then calls a function at those times. The times can change in the database and a value corresponding to the time in the Db is sent as arguments to the function.
I need to make sure this happens everyday at the time mentioned in the Db.

 Scheduler s = new Scheduler();
    s.schedule("0 5 * * *", new Runnable() {
        public void run() {
            //call your function
            TestClass tc = new TestClass(value);
        }
    });
    // Starts the scheduler.
    s.start();
    try {
        Thread.sleep(1000L * 60L * 10L);
    } catch (InterruptedException e) {
        ;
    }
    // Stops the scheduler.
    s.stop();

This code calls the class at 5:00:00 everyday, but I'm not sure what to pass in Thread.sleep()
I need to write for multiple different times too and make sure it runs for a long time, i.e. over a year.


问:
How to extract a string before and after slash
I am working on Parts of Speech tagging in R. I have a string with its Parts of Speech as below(Format: Word/POS_Tag). I want to extract words in one column and its corresponding Parts of Speech tag in other column and it frequency in 3rd column of a dataset.
Also, I need to remove any punctuation or special characters from the text before loading into dataset. I am not much familiar with RegEx. Can you please help me to resolve this.

(FYR. Sentence before applying POS_tag. --> "I like to play tennis tournament Next week, and I will participate on a play. I like playing guitar.")

Example: "I/PRP like/IN to/TO play/VB tennis/NN tournament/NN Next/JJ week/NN ,/, and/CC I/PRP will/MD participate/VB on/IN a/DT play/NN ./. I/PRP like/IN playing/VBG guitar/NN ./."

Note: In the above example, we have 3 occurrences of 'I' and 2 occurrences of 'like'. I need the count of words as well as below in a dataset.

```<code>Word           POS_Tag    Count
I              PRP        3
like           IN         2
to             TO         1
play           VB         1
tennis         NN         1
tournament     NN         1
Next           JJ         1
week           NN         1
and            CC         1
will           MD         1
partcipate     VB         1
on             IN         1
a              DT         1
play           NN         1
playing        VBG        1
guitar         NN         1
</code>```

Thanks.

答:
We extract the words (\\w+) from the string with str_extract_all (from stringr), then create a data.table with two columns from the alternate words of the vector ('v1'), grouped by 'Word', and 'POS_Tag', get the number of elements (.N)

```<code>library(stringr)
library(data.table)
v1 <- str_extract_all(str1, "\\w+")[[1]]
data.table(Word = v1[c(TRUE, FALSE)], POS_Tag = v1[c(FALSE, TRUE)])[
    , .(Count = .N), .(Word, POS_Tag)]
#           Word POS_Tag Count
# 1:           I     PRP     3
# 2:        like      IN     2
# 3:          to      TO     1
# 4:        play      VB     1
# 5:      tennis      NN     1
# 6:  tournament      NN     1
# 7:        Next      JJ     1
# 8:        week      NN     1
# 9:         and      CC     1
#10:        will      MD     1
#11: participate      VB     1
#12:          on      IN     1
#13:           a      DT     1
#14:        play      NN     1
#15:     playing     VBG     1
#16:      guitar      NN     1
</code>```

We can also do this with tidyverse

```<code>library(tidyverse)
data_frame(string = str1) %>%
       separate_rows(string) %>%
       group_by(grp = rep(c("Word", "POS_Tag"), length.out = n())) %>%
       mutate(i1 = row_number()) %>%
       spread(grp, string) %>% select(-i1) %>%
       count(Word, POS_Tag) %>%
       filter(Word != ".")
# A tibble: 16 x 3
#          Word POS_Tag     n
#         <chr>   <chr> <int>
# 1           a      DT     1
# 2         and      CC     1
# 3      guitar      NN     1
# 4           I     PRP     3
# 5        like      IN     2
# 6        Next      JJ     1
# 7          on      IN     1
# 8 participate      VB     1
# 9        play      NN     1
#10        play      VB     1
#11     playing     VBG     1
#12      tennis      NN     1
#13          to      TO     1
#14  tournament      NN     1
#15        week      NN     1
#16        will      MD     1
</code>```

data

```<code>str1 <- "I/PRP like/IN to/TO play/VB tennis/NN tournament/NN Next/JJ week/NN ,/, and/CC I/PRP will/MD participate/VB on/IN a/DT play/NN ./. I/PRP like/IN playing/VBG guitar/NN ./."
</code>```

Body:
I am working on Parts of Speech tagging in R. I have a string with its Parts of Speech as below(Format: Word/POS_Tag). I want to extract words in one column and its corresponding Parts of Speech tag in other column and it frequency in 3rd column of a dataset.
Also, I need to remove any punctuation or special characters from the text before loading into dataset. I am not much familiar with RegEx. Can you please help me to resolve this.

(FYR. Sentence before applying POS_tag. --> "I like to play tennis tournament Next week, and I will participate on a play. I like playing guitar.")

Example: "I/PRP like/IN to/TO play/VB tennis/NN tournament/NN Next/JJ week/NN ,/, and/CC I/PRP will/MD participate/VB on/IN a/DT play/NN ./. I/PRP like/IN playing/VBG guitar/NN ./."

Note: In the above example, we have 3 occurrences of 'I' and 2 occurrences of 'like'. I need the count of words as well as below in a dataset.

Word           POS_Tag    Count
I              PRP        3
like           IN         2
to             TO         1
play           VB         1
tennis         NN         1
tournament     NN         1
Next           JJ         1
week           NN         1
and            CC         1
will           MD         1
partcipate     VB         1
on             IN         1
a              DT         1
play           NN         1
playing        VBG        1
guitar         NN         1

Thanks.

Body:
We extract the words (\\w+) from the string with str_extract_all (from stringr), then create a data.table with two columns from the alternate words of the vector ('v1'), grouped by 'Word', and 'POS_Tag', get the number of elements (.N)

library(stringr)
library(data.table)
v1 <- str_extract_all(str1, "\\w+")[[1]]
data.table(Word = v1[c(TRUE, FALSE)], POS_Tag = v1[c(FALSE, TRUE)])[
    , .(Count = .N), .(Word, POS_Tag)]
#           Word POS_Tag Count
# 1:           I     PRP     3
# 2:        like      IN     2
# 3:          to      TO     1
# 4:        play      VB     1
# 5:      tennis      NN     1
# 6:  tournament      NN     1
# 7:        Next      JJ     1
# 8:        week      NN     1
# 9:         and      CC     1
#10:        will      MD     1
#11: participate      VB     1
#12:          on      IN     1
#13:           a      DT     1
#14:        play      NN     1
#15:     playing     VBG     1
#16:      guitar      NN     1

We can also do this with tidyverse

library(tidyverse)
data_frame(string = str1) %>%
       separate_rows(string) %>%
       group_by(grp = rep(c("Word", "POS_Tag"), length.out = n())) %>%
       mutate(i1 = row_number()) %>%
       spread(grp, string) %>% select(-i1) %>%
       count(Word, POS_Tag) %>%
       filter(Word != ".")
# A tibble: 16 x 3
#          Word POS_Tag     n
#         <chr>   <chr> <int>
# 1           a      DT     1
# 2         and      CC     1
# 3      guitar      NN     1
# 4           I     PRP     3
# 5        like      IN     2
# 6        Next      JJ     1
# 7          on      IN     1
# 8 participate      VB     1
# 9        play      NN     1
#10        play      VB     1
#11     playing     VBG     1
#12      tennis      NN     1
#13          to      TO     1
#14  tournament      NN     1
#15        week      NN     1
#16        will      MD     1

data

str1 <- "I/PRP like/IN to/TO play/VB tennis/NN tournament/NN Next/JJ week/NN ,/, and/CC I/PRP will/MD participate/VB on/IN a/DT play/NN ./. I/PRP like/IN playing/VBG guitar/NN ./."


问:
Jboss Java Date daylight saving time
Have an issue where, when clocks are moved due to a Daylight savings time (twice a year), dates are not correct in Java (I am based in Central Europe: GMT+2 in summer, GMT+1 in winter)

If time is moved 1 hour ahead, new Date() still returns old time (1 hour behind of current time).

In Java 7, can this be solved, without restarting the Jboss application servers?

If I change the time manually in Windows, reproduce the problem: Date is not updated to the system date unless jboss is restarted.

```<code>Calendar c = Calendar.getInstance();
c.setTime(new Date());
</code>```

答:
Use ZonedDateTime class from JDK 8 java.time. It accommodates the Daylight Saving Time changes.
Refer the details at : https://docs.oracle.com/javase/8/docs/api/java/time/ZonedDateTime.html

Title: Jboss Java Date daylight saving time

Body:
Have an issue where, when clocks are moved due to a Daylight savings time (twice a year), dates are not correct in Java (I am based in Central Europe: GMT+2 in summer, GMT+1 in winter)

If time is moved 1 hour ahead, new Date() still returns old time (1 hour behind of current time).

In Java 7, can this be solved, without restarting the Jboss application servers?

If I change the time manually in Windows, reproduce the problem: Date is not updated to the system date unless jboss is restarted.

Calendar c = Calendar.getInstance();
c.setTime(new Date());


问:
How to get hover efect only on part of the element?
I have the below code:

.container {
 padding-top:20px;
}

.container:hover {
 background-color: red;
}

.text {
  padding-top: 20px;
}

.container:before {
content: 'before';
top: 5px;
position: absolute;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div class='container'>
  <span class='text'>
    My text
  </span>
</div></code>```

I needed the 'before' as a title so inserted it as a pseudo, moved up and created palce for it by adding padding to the div. Now when I hover over the div the pseudo gets highlighted as well, which I don't want.

AS it's a skin for external app I have very limited possibilities to add elements to dom, which is what I guess should be done. How can I highlight only bottom part of the div without the pseudo? Maybe there's a better way to style the pseudo itself so that it doesn't get hovered over? Pure CSS appreciated.

答:
An simple solution is to use a margin-top on the container class instead of padding-top.

.container {
  margin-top: 30px;
  background-clip: content-box;
}

.container:hover {
  background-color: red;
}

.text {
  padding-top: 20px;
}

.container:before {
  content: 'before';
  top: 5px;
  position: absolute;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div class='container'>
  <span class='text'>
    My text
  </span>
</div></code>```

Body:
I have the below code:

.container {
 padding-top:20px;
}

.container:hover {
 background-color: red;
}

.text {
  padding-top: 20px;
}

.container:before {
content: 'before';
top: 5px;
position: absolute;
}

    My text

I needed the 'before' as a title so inserted it as a pseudo, moved up and created palce for it by adding padding to the div. Now when I hover over the div the pseudo gets highlighted as well, which I don't want.

AS it's a skin for external app I have very limited possibilities to add elements to dom, which is what I guess should be done. How can I highlight only bottom part of the div without the pseudo? Maybe there's a better way to style the pseudo itself so that it doesn't get hovered over? Pure CSS appreciated.

Body:
An simple solution is to use a margin-top on the container class instead of padding-top.

.container {
  margin-top: 30px;
  background-clip: content-box;
}

.container:hover {
  background-color: red;
}

.text {
  padding-top: 20px;
}

.container:before {
  content: 'before';
  top: 5px;
  position: absolute;
}

<div class='container'>
  <span class='text'>
    My text
  </span>
</div>