问:
Fresh grails installed - app fails to run
I'm trying out grails for the first time, but a simple app won't run right after it is created. I installed everything using sdkman. Here is what I have:

```<code>~$ sdk current
</code>```

Using:

gradle: 4.0
grails: 3.2.11
groovy: 2.4.12
java: 8u131-zulu

I execute:

```<code>grails create-app foo
cd ./foo
grails run-app
</code>```

This is what I get:

```<code>FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':findMainClass'.
Illegal null value provided in this collection: [null]
</code>```

I tried downgrading grails all the way to 3.2.3 but was still getting the error.

I'll put in the full stack trace below.

```<code>java.util.concurrent.ExecutionException: org.gradle.tooling.BuildException: Could not execute build using Gradle installation '/home/roman/.sdkman/candidates/gradle/current'.
    at java_util_concurrent_Future$get.call(Unknown Source)
    at run-app.run(run-app.groovy:89)
    at org.grails.cli.profile.commands.script.GroovyScriptCommand.handle(GroovyScriptCommand.groovy:152)
    at org.grails.cli.profile.AbstractProfile.handleCommand(AbstractProfile.groovy:481)
    at org.grails.cli.GrailsCli.handleCommand(GrailsCli.groovy:378)
    at org.grails.cli.GrailsCli.handleCommand(GrailsCli.groovy:351)
    at org.grails.cli.GrailsCli.execute(GrailsCli.groovy:272)
    at org.grails.cli.GrailsCli.main(GrailsCli.groovy:159)
Caused by: org.gradle.tooling.BuildException: Could not execute build using Gradle installation '/home/roman/.sdkman/candidates/gradle/current'.
    at org.gradle.tooling.internal.consumer.ExceptionTransformer.transform(ExceptionTransformer.java:51)
    at org.gradle.tooling.internal.consumer.ExceptionTransformer.transform(ExceptionTransformer.java:29)
    at org.gradle.tooling.internal.consumer.ResultHandlerAdapter.onFailure(ResultHandlerAdapter.java:41)
    at org.gradle.tooling.internal.consumer.async.DefaultAsyncConsumerActionExecutor$1$1.run(DefaultAsyncConsumerActionExecutor.java:57)
    at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:54)
    at org.gradle.internal.concurrent.StoppableExecutorImpl$1.run(StoppableExecutorImpl.java:40)
    at org.gradle.tooling.internal.consumer.BlockingResultHandler.getResult(BlockingResultHandler.java:46)
    at org.gradle.tooling.internal.consumer.DefaultBuildLauncher.run(DefaultBuildLauncher.java:77)
    at org.grails.cli.gradle.GradleUtil$_runBuildWithConsoleOutput_closure3.doCall(GradleUtil.groovy:88)
    at org.grails.cli.gradle.GradleUtil$_withProjectConnection_closure1.doCall(GradleUtil.groovy:69)
    at org.grails.cli.gradle.GradleUtil$_withProjectConnection_closure1.call(GradleUtil.groovy)
    at grails.io.support.SystemOutErrCapturer.withNullOutput(SystemOutErrCapturer.groovy:64)
    at org.grails.cli.gradle.GradleUtil.withProjectConnection(GradleUtil.groovy:68)
    at org.grails.cli.gradle.GradleUtil.runBuildWithConsoleOutput(GradleUtil.groovy:83)
    at org.grails.cli.gradle.GradleInvoker.invokeMethod(GradleInvoker.groovy:50)
    at org.grails.cli.gradle.GradleAsyncInvoker$_invokeMethod_closure2.doCall(GradleAsyncInvoker.groovy:57)
    at org.grails.cli.gradle.GradleAsyncInvoker$_invokeMethod_closure2.doCall(GradleAsyncInvoker.groovy)
Caused by: org.gradle.internal.exceptions.LocationAwareException: Execution failed for task ':findMainClass'.
    at org.gradle.initialization.DefaultExceptionAnalyser.transform(DefaultExceptionAnalyser.java:74)
    at org.gradle.initialization.MultipleBuildFailuresExceptionAnalyser.transform(MultipleBuildFailuresExceptionAnalyser.java:47)
    at org.gradle.initialization.StackTraceSanitizingExceptionAnalyser.transform(StackTraceSanitizingExceptionAnalyser.java:30)
    at org.gradle.initialization.DefaultGradleLauncher$1.run(DefaultGradleLauncher.java:124)
    at org.gradle.internal.work.DefaultWorkerLeaseService$2.execute(DefaultWorkerLeaseService.java:124)
    at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:116)
    at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:99)
    at org.gradle.launcher.exec.GradleBuildController.run(GradleBuildController.java:66)
    at org.gradle.tooling.internal.provider.runner.BuildModelActionRunner.run(BuildModelActionRunner.java:50)
    at org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35)
    at org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35)
    at org.gradle.tooling.internal.provider.ValidatingBuildActionRunner.run(ValidatingBuildActionRunner.java:32)
    at org.gradle.launcher.exec.RunAsBuildOperationBuildActionRunner$1.run(RunAsBuildOperationBuildActionRunner.java:43)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:317)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:309)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:185)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:95)
    at org.gradle.launcher.exec.RunAsBuildOperationBuildActionRunner.run(RunAsBuildOperationBuildActionRunner.java:40)
    at org.gradle.tooling.internal.provider.SubscribableBuildActionRunner.run(SubscribableBuildActionRunner.java:51)
    at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:44)
    at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:28)
    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:51)
    at org.gradle.tooling.internal.provider.ServicesSetupBuildActionExecuter.execute(ServicesSetupBuildActionExecuter.java:32)
    at org.gradle.tooling.internal.provider.GradleThreadBuildActionExecuter.execute(GradleThreadBuildActionExecuter.java:36)
    at org.gradle.tooling.internal.provider.GradleThreadBuildActionExecuter.execute(GradleThreadBuildActionExecuter.java:25)
    at org.gradle.tooling.internal.provider.StartParamsValidatingActionExecuter.execute(StartParamsValidatingActionExecuter.java:64)
    at org.gradle.tooling.internal.provider.StartParamsValidatingActionExecuter.execute(StartParamsValidatingActionExecuter.java:29)
    at org.gradle.tooling.internal.provider.SessionFailureReportingActionExecuter.execute(SessionFailureReportingActionExecuter.java:55)
    at org.gradle.tooling.internal.provider.SessionFailureReportingActionExecuter.execute(SessionFailureReportingActionExecuter.java:42)
    at org.gradle.tooling.internal.provider.SetupLoggingActionExecuter.execute(SetupLoggingActionExecuter.java:50)
    at org.gradle.tooling.internal.provider.SetupLoggingActionExecuter.execute(SetupLoggingActionExecuter.java:30)
    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:62)
    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 org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
Caused by: org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':findMainClass'.
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:100)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:70)
    at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:64)
    at org.gradle.api.internal.tasks.execution.ResolveTaskOutputCachingStateExecuter.execute(ResolveTaskOutputCachingStateExecuter.java:54)
    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:52)
    at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)
    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.run(DefaultTaskGraphExecuter.java:242)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:317)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:309)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:185)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:95)
    at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:235)
    at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:224)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.processTask(DefaultTaskPlanExecutor.java:121)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.access$200(DefaultTaskPlanExecutor.java:77)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:102)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:96)
    at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.execute(DefaultTaskExecutionPlan.java:612)
    at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.executeWithTask(DefaultTaskExecutionPlan.java:567)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.run(DefaultTaskPlanExecutor.java:96)
    ... 3 more
Caused by: java.lang.IllegalArgumentException: Illegal null value provided in this collection: [null]
    at org.gradle.util.GUtil.addToCollection(GUtil.java:144)
    at org.gradle.process.internal.JavaExecHandleBuilder.args(JavaExecHandleBuilder.java:193)
    at org.gradle.process.internal.JavaExecHandleBuilder.args(JavaExecHandleBuilder.java:188)
    at org.gradle.process.internal.JavaExecHandleBuilder.args(JavaExecHandleBuilder.java:32)
    at org.gradle.api.tasks.JavaExec.args(JavaExec.java:300)
    at org.grails.gradle.plugin.core.GrailsGradlePlugin$_configureConsoleTask_closure11$_closure28.doCall(GrailsGradlePlugin.groovy:369)
    at org.gradle.api.internal.ClosureBackedAction.execute(ClosureBackedAction.java:71)
    at org.gradle.util.ConfigureUtil.configureTarget(ConfigureUtil.java:160)
    at org.gradle.util.ConfigureUtil.configureSelf(ConfigureUtil.java:136)
    at org.gradle.api.internal.AbstractTask.configure(AbstractTask.java:595)
    at org.gradle.api.internal.AbstractTask.configure(AbstractTask.java:81)
    at org.gradle.util.ConfigureUtil.configure(ConfigureUtil.java:104)
    at org.gradle.util.ConfigureUtil$1.execute(ConfigureUtil.java:123)
    at org.gradle.internal.Actions$FilteredAction.execute(Actions.java:205)
    at org.gradle.api.internal.DefaultDomainObjectCollection.all(DefaultDomainObjectCollection.java:136)
    at org.gradle.api.internal.DefaultDomainObjectCollection.all(DefaultDomainObjectCollection.java:154)
    at org.gradle.api.internal.tasks.RealizableTaskCollection.all(RealizableTaskCollection.java:197)
    at org.gradle.api.internal.DefaultDomainObjectCollection.withType(DefaultDomainObjectCollection.java:165)
    at org.grails.gradle.plugin.core.GrailsGradlePlugin$_configureConsoleTask_closure11.doCall(GrailsGradlePlugin.groovy:368)
    at org.grails.gradle.plugin.core.GrailsGradlePlugin$_configureConsoleTask_closure11.call(GrailsGradlePlugin.groovy)
    at org.gradle.api.internal.AbstractTask$ClosureTaskAction.execute(AbstractTask.java:670)
    at org.gradle.api.internal.AbstractTask$ClosureTaskAction.execute(AbstractTask.java:651)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$1.run(ExecuteActionsTaskExecuter.java:122)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:317)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:309)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:185)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:95)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:111)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:92)
    ... 27 more
</code>```

答:
Same thing happend with me, when I was using gradle 4.0 with grails 3.2.11.
Just downgrade it to gradle 3.x. and it'll fix the issue.

Body:
I'm trying out grails for the first time, but a simple app won't run right after it is created. I installed everything using sdkman. Here is what I have:

~$ sdk current

Using:

gradle: 4.0
grails: 3.2.11
groovy: 2.4.12
java: 8u131-zulu

I execute:

grails create-app foo
cd ./foo
grails run-app

This is what I get:

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':findMainClass'.
Illegal null value provided in this collection: [null]

I tried downgrading grails all the way to 3.2.3 but was still getting the error.

I'll put in the full stack trace below.

java.util.concurrent.ExecutionException: org.gradle.tooling.BuildException: Could not execute build using Gradle installation '/home/roman/.sdkman/candidates/gradle/current'.
    at java_util_concurrent_Future$get.call(Unknown Source)
    at run-app.run(run-app.groovy:89)
    at org.grails.cli.profile.commands.script.GroovyScriptCommand.handle(GroovyScriptCommand.groovy:152)
    at org.grails.cli.profile.AbstractProfile.handleCommand(AbstractProfile.groovy:481)
    at org.grails.cli.GrailsCli.handleCommand(GrailsCli.groovy:378)
    at org.grails.cli.GrailsCli.handleCommand(GrailsCli.groovy:351)
    at org.grails.cli.GrailsCli.execute(GrailsCli.groovy:272)
    at org.grails.cli.GrailsCli.main(GrailsCli.groovy:159)
Caused by: org.gradle.tooling.BuildException: Could not execute build using Gradle installation '/home/roman/.sdkman/candidates/gradle/current'.
    at org.gradle.tooling.internal.consumer.ExceptionTransformer.transform(ExceptionTransformer.java:51)
    at org.gradle.tooling.internal.consumer.ExceptionTransformer.transform(ExceptionTransformer.java:29)
    at org.gradle.tooling.internal.consumer.ResultHandlerAdapter.onFailure(ResultHandlerAdapter.java:41)
    at org.gradle.tooling.internal.consumer.async.DefaultAsyncConsumerActionExecutor$1$1.run(DefaultAsyncConsumerActionExecutor.java:57)
    at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:54)
    at org.gradle.internal.concurrent.StoppableExecutorImpl$1.run(StoppableExecutorImpl.java:40)
    at org.gradle.tooling.internal.consumer.BlockingResultHandler.getResult(BlockingResultHandler.java:46)
    at org.gradle.tooling.internal.consumer.DefaultBuildLauncher.run(DefaultBuildLauncher.java:77)
    at org.grails.cli.gradle.GradleUtil$_runBuildWithConsoleOutput_closure3.doCall(GradleUtil.groovy:88)
    at org.grails.cli.gradle.GradleUtil$_withProjectConnection_closure1.doCall(GradleUtil.groovy:69)
    at org.grails.cli.gradle.GradleUtil$_withProjectConnection_closure1.call(GradleUtil.groovy)
    at grails.io.support.SystemOutErrCapturer.withNullOutput(SystemOutErrCapturer.groovy:64)
    at org.grails.cli.gradle.GradleUtil.withProjectConnection(GradleUtil.groovy:68)
    at org.grails.cli.gradle.GradleUtil.runBuildWithConsoleOutput(GradleUtil.groovy:83)
    at org.grails.cli.gradle.GradleInvoker.invokeMethod(GradleInvoker.groovy:50)
    at org.grails.cli.gradle.GradleAsyncInvoker$_invokeMethod_closure2.doCall(GradleAsyncInvoker.groovy:57)
    at org.grails.cli.gradle.GradleAsyncInvoker$_invokeMethod_closure2.doCall(GradleAsyncInvoker.groovy)
Caused by: org.gradle.internal.exceptions.LocationAwareException: Execution failed for task ':findMainClass'.
    at org.gradle.initialization.DefaultExceptionAnalyser.transform(DefaultExceptionAnalyser.java:74)
    at org.gradle.initialization.MultipleBuildFailuresExceptionAnalyser.transform(MultipleBuildFailuresExceptionAnalyser.java:47)
    at org.gradle.initialization.StackTraceSanitizingExceptionAnalyser.transform(StackTraceSanitizingExceptionAnalyser.java:30)
    at org.gradle.initialization.DefaultGradleLauncher$1.run(DefaultGradleLauncher.java:124)
    at org.gradle.internal.work.DefaultWorkerLeaseService$2.execute(DefaultWorkerLeaseService.java:124)
    at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:116)
    at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:99)
    at org.gradle.launcher.exec.GradleBuildController.run(GradleBuildController.java:66)
    at org.gradle.tooling.internal.provider.runner.BuildModelActionRunner.run(BuildModelActionRunner.java:50)
    at org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35)
    at org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35)
    at org.gradle.tooling.internal.provider.ValidatingBuildActionRunner.run(ValidatingBuildActionRunner.java:32)
    at org.gradle.launcher.exec.RunAsBuildOperationBuildActionRunner$1.run(RunAsBuildOperationBuildActionRunner.java:43)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:317)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:309)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:185)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:95)
    at org.gradle.launcher.exec.RunAsBuildOperationBuildActionRunner.run(RunAsBuildOperationBuildActionRunner.java:40)
    at org.gradle.tooling.internal.provider.SubscribableBuildActionRunner.run(SubscribableBuildActionRunner.java:51)
    at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:44)
    at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:28)
    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:51)
    at org.gradle.tooling.internal.provider.ServicesSetupBuildActionExecuter.execute(ServicesSetupBuildActionExecuter.java:32)
    at org.gradle.tooling.internal.provider.GradleThreadBuildActionExecuter.execute(GradleThreadBuildActionExecuter.java:36)
    at org.gradle.tooling.internal.provider.GradleThreadBuildActionExecuter.execute(GradleThreadBuildActionExecuter.java:25)
    at org.gradle.tooling.internal.provider.StartParamsValidatingActionExecuter.execute(StartParamsValidatingActionExecuter.java:64)
    at org.gradle.tooling.internal.provider.StartParamsValidatingActionExecuter.execute(StartParamsValidatingActionExecuter.java:29)
    at org.gradle.tooling.internal.provider.SessionFailureReportingActionExecuter.execute(SessionFailureReportingActionExecuter.java:55)
    at org.gradle.tooling.internal.provider.SessionFailureReportingActionExecuter.execute(SessionFailureReportingActionExecuter.java:42)
    at org.gradle.tooling.internal.provider.SetupLoggingActionExecuter.execute(SetupLoggingActionExecuter.java:50)
    at org.gradle.tooling.internal.provider.SetupLoggingActionExecuter.execute(SetupLoggingActionExecuter.java:30)
    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:62)
    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 org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
Caused by: org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':findMainClass'.
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:100)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:70)
    at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:64)
    at org.gradle.api.internal.tasks.execution.ResolveTaskOutputCachingStateExecuter.execute(ResolveTaskOutputCachingStateExecuter.java:54)
    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:52)
    at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)
    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.run(DefaultTaskGraphExecuter.java:242)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:317)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:309)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:185)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:95)
    at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:235)
    at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:224)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.processTask(DefaultTaskPlanExecutor.java:121)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.access$200(DefaultTaskPlanExecutor.java:77)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:102)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:96)
    at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.execute(DefaultTaskExecutionPlan.java:612)
    at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.executeWithTask(DefaultTaskExecutionPlan.java:567)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.run(DefaultTaskPlanExecutor.java:96)
    ... 3 more
Caused by: java.lang.IllegalArgumentException: Illegal null value provided in this collection: [null]
    at org.gradle.util.GUtil.addToCollection(GUtil.java:144)
    at org.gradle.process.internal.JavaExecHandleBuilder.args(JavaExecHandleBuilder.java:193)
    at org.gradle.process.internal.JavaExecHandleBuilder.args(JavaExecHandleBuilder.java:188)
    at org.gradle.process.internal.JavaExecHandleBuilder.args(JavaExecHandleBuilder.java:32)
    at org.gradle.api.tasks.JavaExec.args(JavaExec.java:300)
    at org.grails.gradle.plugin.core.GrailsGradlePlugin$_configureConsoleTask_closure11$_closure28.doCall(GrailsGradlePlugin.groovy:369)
    at org.gradle.api.internal.ClosureBackedAction.execute(ClosureBackedAction.java:71)
    at org.gradle.util.ConfigureUtil.configureTarget(ConfigureUtil.java:160)
    at org.gradle.util.ConfigureUtil.configureSelf(ConfigureUtil.java:136)
    at org.gradle.api.internal.AbstractTask.configure(AbstractTask.java:595)
    at org.gradle.api.internal.AbstractTask.configure(AbstractTask.java:81)
    at org.gradle.util.ConfigureUtil.configure(ConfigureUtil.java:104)
    at org.gradle.util.ConfigureUtil$1.execute(ConfigureUtil.java:123)
    at org.gradle.internal.Actions$FilteredAction.execute(Actions.java:205)
    at org.gradle.api.internal.DefaultDomainObjectCollection.all(DefaultDomainObjectCollection.java:136)
    at org.gradle.api.internal.DefaultDomainObjectCollection.all(DefaultDomainObjectCollection.java:154)
    at org.gradle.api.internal.tasks.RealizableTaskCollection.all(RealizableTaskCollection.java:197)
    at org.gradle.api.internal.DefaultDomainObjectCollection.withType(DefaultDomainObjectCollection.java:165)
    at org.grails.gradle.plugin.core.GrailsGradlePlugin$_configureConsoleTask_closure11.doCall(GrailsGradlePlugin.groovy:368)
    at org.grails.gradle.plugin.core.GrailsGradlePlugin$_configureConsoleTask_closure11.call(GrailsGradlePlugin.groovy)
    at org.gradle.api.internal.AbstractTask$ClosureTaskAction.execute(AbstractTask.java:670)
    at org.gradle.api.internal.AbstractTask$ClosureTaskAction.execute(AbstractTask.java:651)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$1.run(ExecuteActionsTaskExecuter.java:122)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:317)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:309)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:185)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:95)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:111)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:92)
    ... 27 more


来源: stackexchange

问:
X11 Wait for and Get Clipboard Text
I have to monitor the X11 Clipboard.

For the moment, I request the ClipBoard Selection each 5 seconds, then I hash the text returned from clipboard and I compare it with the hash calculate from the last check. If hash are not the same, I analysis the text content and do some stuff...

I don't like my method. I'm from Windows, and with the winapi, it is the kernel that notify your program when the clipboard has changed, and it's more efficient!

I just want to know if it is possible that X11 can notify your program as winapi when the clipboard has changed ? What is the more efficient way to check clipboard modifications with X11 ?

答:
Use XFixesSelectSelectionInput() from Xfixes extension and wait for XFixesSelectionNotify event.

Example:

```<code>// gcc -o xclipwatch xclipwatch.c -lX11 -lXfixes
...
#include <X11/extensions/Xfixes.h>
...
void WatchSelection(Display *display, Window window, const char *bufname)
{
  int event_base, error_base;
  XEvent event;
  Atom bufid = XInternAtom(display, bufname, False);

  assert( XFixesQueryExtension(display, &event_base, &error_base) );
  XFixesSelectSelectionInput(display, DefaultRootWindow(display), bufid, XFixesSetSelectionOwnerNotifyMask);

  while (True)
  {
    XNextEvent(display, &event);

    if (event.type == event_base + XFixesSelectionNotify &&
        ((XFixesSelectionNotifyEvent*)&event)->selection == bufid)
    {
      if (!PrintSelection(display, window, bufname, "UTF8_STRING"))
        PrintSelection(display, window, bufname, "STRING");

      fflush(stdout);
    }
  }
}
...
</code>```

This works both for bufname == "CLIPBOARD" and bufname == "PRIMARY" selection.

Also see PrintSelection() function in this answer.

ContentLicense: CC BY-SA 3.0

Title: X11 Wait for and Get Clipboard Text

Body:
Use XFixesSelectSelectionInput() from Xfixes extension and wait for XFixesSelectionNotify event.

Example:

// gcc -o xclipwatch xclipwatch.c -lX11 -lXfixes
...
#include <X11/extensions/Xfixes.h>
...
void WatchSelection(Display *display, Window window, const char *bufname)
{
  int event_base, error_base;
  XEvent event;
  Atom bufid = XInternAtom(display, bufname, False);

  assert( XFixesQueryExtension(display, &event_base, &error_base) );
  XFixesSelectSelectionInput(display, DefaultRootWindow(display), bufid, XFixesSetSelectionOwnerNotifyMask);

  while (True)
  {
    XNextEvent(display, &event);

    if (event.type == event_base + XFixesSelectionNotify &&
        ((XFixesSelectionNotifyEvent*)&event)->selection == bufid)
    {
      if (!PrintSelection(display, window, bufname, "UTF8_STRING"))
        PrintSelection(display, window, bufname, "STRING");

      fflush(stdout);
    }
  }
}
...

This works both for bufname == "CLIPBOARD" and bufname == "PRIMARY" selection.

Also see PrintSelection() function in this answer.


问:
Attempt to invoke virtual method 'void android.arch.lifecycle.LiveData.observe on a null object reference
I am getting the following error

I am using Android architecture components and tried to instantiate viewmodel and Observe data from LiveData. But im stuck here please help me solve this issue :

```<code>Attempt to invoke virtual method 'void android.arch.lifecycle.LiveData.observe(android.arch.lifecycle.LifecycleOwner, android.arch.lifecycle.Observer)' on a null object reference
</code>```

My Fragment is this :
While calling getCompany() method im getting and NullPoint Exception Error

```<code>    public class CompanyFragment extends LifecycleFragment {
    private CompanyViewModel companyViewModel;

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        companyViewModel = ViewModelProviders.of(this).get(CompanyViewModel.class);
        companyViewModel.initData();
        companyViewModel.getCompany().observe(this, new Observer<CompanyEntity>() {
            @Override
            public void onChanged(@Nullable CompanyEntity companyEntity) {

            }
        });
    }
    @Override
    public View onCreateView(LayoutInflater inflater,
                             @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        return inflater.inflate(R.layout.fragment_company, container, false);
    }
}
</code>```

My ViewModel class is this :

```<code>public class CompanyViewModel extends ViewModel {
    private LiveData<CompanyEntity> companyEntityLiveData;
    private CompanyRepository companyRepo;

    public CompanyViewModel() {}

    public CompanyViewModel(CompanyRepository companyRepo){
        this.companyRepo = companyRepo;
    }

    public void initData(){
        companyEntityLiveData = companyRepo.getCompany();
    }

    public LiveData<CompanyEntity> getCompany() {
        return companyEntityLiveData;
    }

}
</code>```

Error is at this line :

```<code>   companyViewModel.getCompany().observe(this, new Observer<CompanyEntity>() {
        @Override
        public void onChanged(@Nullable CompanyEntity companyEntity) {

        }
    });
</code>```

This is my CompanyRepository class:

```<code>public class CompanyRepository {
private WebService webService;

    public CompanyRepository(){

    }

    public LiveData<CompanyEntity> getCompany() {
        final MutableLiveData<CompanyEntity> data = new MutableLiveData<>();

        webService.getCompany().enqueue(new Callback<CompanyEntity>() {
            @Override
            public void onResponse(Call<CompanyEntity> call, Response<CompanyEntity> response) {
                data.setValue(response.body());
            }

            @Override
            public void onFailure(Call<CompanyEntity> call, Throwable t) {

            }
        });

        return data;
    }
}
</code>```

答:
In getCompany method you need to check whether companyEntityLiveData object is null, if so call service in it.</p>

```<code>public LiveData<CompanyEntity> getCompany() {
    if(companyEntityLiveData == null){
       companyEntityLiveData = companyRepo.getCompany();
    }
    return companyEntityLiveData;
}
</code>```

ContentLicense: CC BY-SA 4.0

Body:
I am getting the following error

I am using Android architecture components and tried to instantiate viewmodel and Observe data from LiveData. But im stuck here please help me solve this issue :

Attempt to invoke virtual method 'void android.arch.lifecycle.LiveData.observe(android.arch.lifecycle.LifecycleOwner, android.arch.lifecycle.Observer)' on a null object reference

My Fragment is this :
While calling getCompany() method im getting and NullPoint Exception Error

    public class CompanyFragment extends LifecycleFragment {
    private CompanyViewModel companyViewModel;

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        companyViewModel = ViewModelProviders.of(this).get(CompanyViewModel.class);
        companyViewModel.initData();
        companyViewModel.getCompany().observe(this, new Observer<CompanyEntity>() {
            @Override
            public void onChanged(@Nullable CompanyEntity companyEntity) {

            }
        });
    }
    @Override
    public View onCreateView(LayoutInflater inflater,
                             @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        return inflater.inflate(R.layout.fragment_company, container, false);
    }
}

My ViewModel class is this :

public class CompanyViewModel extends ViewModel {
    private LiveData<CompanyEntity> companyEntityLiveData;
    private CompanyRepository companyRepo;

    public CompanyViewModel() {}

    public CompanyViewModel(CompanyRepository companyRepo){
        this.companyRepo = companyRepo;
    }

    public void initData(){
        companyEntityLiveData = companyRepo.getCompany();
    }

    public LiveData<CompanyEntity> getCompany() {
        return companyEntityLiveData;
    }

}

Error is at this line :

   companyViewModel.getCompany().observe(this, new Observer<CompanyEntity>() {
        @Override
        public void onChanged(@Nullable CompanyEntity companyEntity) {

        }
    });

This is my CompanyRepository class:

public class CompanyRepository {
private WebService webService;

    public CompanyRepository(){

    }

    public LiveData<CompanyEntity> getCompany() {
        final MutableLiveData<CompanyEntity> data = new MutableLiveData<>();

        webService.getCompany().enqueue(new Callback<CompanyEntity>() {
            @Override
            public void onResponse(Call<CompanyEntity> call, Response<CompanyEntity> response) {
                data.setValue(response.body());
            }

            @Override
            public void onFailure(Call<CompanyEntity> call, Throwable t) {

            }
        });

        return data;
    }
}

Body:
In getCompany method you need to check whether companyEntityLiveData object is null, if so call service in it.

public LiveData<CompanyEntity> getCompany() {
    if(companyEntityLiveData == null){
       companyEntityLiveData = companyRepo.getCompany();
    }
    return companyEntityLiveData;
}


问:
GWT java URL Validator
Does someone knows a function that validate if a url is valid or not purely in GWT java without using any JSNI</p>

答: You should use regular expression in GWT. Here is similar topics Regex in GWT to match URLs and Regular Expressions and GWT</p>

ContentLicense: CC BY-SA 2.5

Title: GWT java URL Validator


问:
Scrapy setup ubuntu 16.04 or any other
My today installed fresh Ubuntu 16.04 was preinstalled with python:

```<code>p@Scrapy:~$ python --version
Python 2.7.11+
p@Scrapy:~$ python3 --version
Python 3.5.1+
</code>```

As mentioned on manual page http://doc.scrapy.org/en/latest/intro/install.html I open this link http://doc.scrapy.org/en/latest/topics/ubuntu.html#topics-ubuntu and tried to follow steps described to install Scrapy.

But I get an error after step 3

```<code>sudo apt-get update && sudo apt-get install scrapy
</code>```

...

```<code>The following packages have unmet dependencies:
 scrapy : Depends: python-support (>= 0.90.0) but it is not installable
          Recommends: python-setuptools but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
</code>```

I post a problem yesterday about error with Scrapy and looks like it was setup issue too but on Windows. Cannot setup Scrapy on windows So I tried today with Ubuntu and once more without luck.

So question how to setup Scrapy on Ubuntu 16.04 or may be other version? Looks like Scrapy manuals outdated. I would think Scrapy project died, but I know that people still use Scrapy. May be Scrapy only works with python 2.+? So I will stay with Windows. Cannot check all variants. It takes too much time. Can anyone mention stable config (operating system + python version) working with Scrapy?

Thanks.

Update

Here I tried with Docker. I create Dockerfile, other steps from terminal:

```<code>p@ScrapyPython3:~$ cat Dockerfile
$ cat Dockerfile
FROM ubuntu:xenial

ENV DEBIAN_FRONTEND noninteractive

RUN apt-get update

# Install Python3 and dev headers
RUN apt-get install -y \
    python3 \
    python-dev \
    python3-dev

# Install cryptography
RUN apt-get install -y \
    build-essential \
    libssl-dev \
    libffi-dev

# install lxml
RUN apt-get install -y \
    libxml2-dev \
    libxslt-dev

# install pip
RUN apt-get install -y python-pip

RUN useradd --create-home --shell /bin/bash scrapyuser

USER scrapyuser
WORKDIR /home/scrapyuser
p@ScrapyPython3:~$ sudo docker build -t redapple/scrapy-ubuntu-xenial .
Sending build context to Docker daemon 81.21 MB
Step 1 : $
Unknown instruction: $
p@ScrapyPython3:~$ sudo docker run -t -i redapple/scrapy-ubuntu-xenial
Unable to find image 'redapple/scrapy-ubuntu-xenial:latest' locally
Pulling repository docker.io/redapple/scrapy-ubuntu-xenial
docker: Error: image redapple/scrapy-ubuntu-xenial not found.
See 'docker run --help'.
p@ScrapyPython3:~$ pip install scrapy
Requirement already satisfied (use --upgrade to upgrade): scrapy in ./.local/lib/python2.7/site-packages
Requirement already satisfied (use --upgrade to upgrade): queuelib in ./.local/lib/python2.7/site-packages (from scrapy)
Requirement already satisfied (use --upgrade to upgrade): pyOpenSSL in ./.local/lib/python2.7/site-packages (from scrapy)
Requirement already satisfied (use --upgrade to upgrade): Twisted>=10.0.0 in ./.local/lib/python2.7/site-packages (from scrapy)
Requirement already satisfied (use --upgrade to upgrade): six>=1.5.2 in ./.local/lib/python2.7/site-packages (from scrapy)
Requirement already satisfied (use --upgrade to upgrade): w3lib>=1.14.2 in ./.local/lib/python2.7/site-packages (from scrapy)
Requirement already satisfied (use --upgrade to upgrade): service-identity in ./.local/lib/python2.7/site-packages (from scrapy)
Requirement already satisfied (use --upgrade to upgrade): cssselect>=0.9 in ./.local/lib/python2.7/site-packages (from scrapy)
Requirement already satisfied (use --upgrade to upgrade): lxml in ./.local/lib/python2.7/site-packages (from scrapy)
Requirement already satisfied (use --upgrade to upgrade): parsel>=0.9.3 in ./.local/lib/python2.7/site-packages (from scrapy)
Requirement already satisfied (use --upgrade to upgrade): PyDispatcher>=2.0.5 in ./.local/lib/python2.7/site-packages (from scrapy)
Requirement already satisfied (use --upgrade to upgrade): cryptography>=1.3 in ./.local/lib/python2.7/site-packages (from pyOpenSSL->scrapy)
Requirement already satisfied (use --upgrade to upgrade): zope.interface>=3.6.0 in ./.local/lib/python2.7/site-packages (from Twisted>=10.0.0->scrapy)
Requirement already satisfied (use --upgrade to upgrade): pyasn1-modules in ./.local/lib/python2.7/site-packages (from service-identity->scrapy)
Requirement already satisfied (use --upgrade to upgrade): pyasn1 in ./.local/lib/python2.7/site-packages (from service-identity->scrapy)
Requirement already satisfied (use --upgrade to upgrade): attrs in ./.local/lib/python2.7/site-packages (from service-identity->scrapy)
Requirement already satisfied (use --upgrade to upgrade): setuptools>=11.3 in ./.local/lib/python2.7/site-packages (from cryptography>=1.3->pyOpenSSL->scrapy)
Requirement already satisfied (use --upgrade to upgrade): ipaddress in ./.local/lib/python2.7/site-packages (from cryptography>=1.3->pyOpenSSL->scrapy)
Requirement already satisfied (use --upgrade to upgrade): enum34 in ./.local/lib/python2.7/site-packages (from cryptography>=1.3->pyOpenSSL->scrapy)
Requirement already satisfied (use --upgrade to upgrade): idna>=2.0 in ./.local/lib/python2.7/site-packages (from cryptography>=1.3->pyOpenSSL->scrapy)
Requirement already satisfied (use --upgrade to upgrade): cffi>=1.4.1 in ./.local/lib/python2.7/site-packages (from cryptography>=1.3->pyOpenSSL->scrapy)
Requirement already satisfied (use --upgrade to upgrade): pycparser in ./.local/lib/python2.7/site-packages (from cffi>=1.4.1->cryptography>=1.3->pyOpenSSL->scrapy)
p@ScrapyPython3:~$ scrapy version
The program 'scrapy' is currently not installed. You can install it by typing:
sudo apt install python-scrapy
</code>```

UPDATE 1
Looks like first row in Dockerfile should not be there. If i remove it ($ cat Dockerfile)

I can get docker image up and running, but once more no luck with pip install scrapy. More over I realize I have to do some overhead with docker to be able upload scrapy files there (I prefer GUI when coding). It there any tool installed in this Docker image? Here install log:

```<code>p@ScrapyPython3:~$ sudo docker run -t -i redapple/scrapy-ubuntu-xenial
    scrapyuser@41bef38de45d:~$ python --version
    Python 2.7.11+
    scrapyuser@41bef38de45d:~$ python3 --version
    Python 3.5.1+
    scrapyuser@41bef38de45d:~$ pip install scrapy
    Collecting scrapy
      Downloading Scrapy-1.1.0-py2.py3-none-any.whl (294kB)
        100% |################################| 296kB 245kB/s
    Collecting queuelib (from scrapy)
      Downloading queuelib-1.4.2-py2.py3-none-any.whl
    Collecting pyOpenSSL (from scrapy)
      Downloading pyOpenSSL-16.0.0-py2.py3-none-any.whl (45kB)
        100% |################################| 51kB 12.7MB/s
    Collecting Twisted>=10.0.0 (from scrapy)
      Downloading Twisted-16.2.0.tar.bz2 (2.9MB)
        100% |################################| 2.9MB 472kB/s
    Collecting six>=1.5.2 (from scrapy)
      Downloading six-1.10.0-py2.py3-none-any.whl
    Collecting w3lib>=1.14.2 (from scrapy)
      Downloading w3lib-1.14.2-py2.py3-none-any.whl
    Collecting service-identity (from scrapy)
      Downloading service_identity-16.0.0-py2.py3-none-any.whl
    Collecting cssselect>=0.9 (from scrapy)
      Downloading cssselect-0.9.2-py2.py3-none-any.whl
    Collecting lxml (from scrapy)
      Downloading lxml-3.6.0.tar.gz (3.7MB)
        100% |################################| 3.7MB 389kB/s
    Collecting parsel>=0.9.3 (from scrapy)
      Downloading parsel-1.0.2-py2.py3-none-any.whl
    Collecting PyDispatcher>=2.0.5 (from scrapy)
      Downloading PyDispatcher-2.0.5.tar.gz
    Collecting cryptography>=1.3 (from pyOpenSSL->scrapy)
      Downloading cryptography-1.4.tar.gz (399kB)
        100% |################################| 409kB 1.4MB/s
    Collecting zope.interface>=3.6.0 (from Twisted>=10.0.0->scrapy)
      Downloading zope.interface-4.2.0.tar.gz (146kB)
        100% |################################| 153kB 1.2MB/s
    Collecting pyasn1-modules (from service-identity->scrapy)
      Downloading pyasn1_modules-0.0.8-py2.py3-none-any.whl
    Collecting pyasn1 (from service-identity->scrapy)
      Downloading pyasn1-0.1.9-py2.py3-none-any.whl
    Collecting attrs (from service-identity->scrapy)
      Downloading attrs-16.0.0-py2.py3-none-any.whl
    Collecting idna>=2.0 (from cryptography>=1.3->pyOpenSSL->scrapy)
      Downloading idna-2.1-py2.py3-none-any.whl (54kB)
        100% |################################| 61kB 10.8MB/s
    Collecting setuptools>=11.3 (from cryptography>=1.3->pyOpenSSL->scrapy)
      Downloading setuptools-23.0.0-py2.py3-none-any.whl (435kB)
        100% |################################| 440kB 1.2MB/s
    Collecting enum34 (from cryptography>=1.3->pyOpenSSL->scrapy)
      Downloading enum34-1.1.6-py2-none-any.whl
    Collecting ipaddress (from cryptography>=1.3->pyOpenSSL->scrapy)
      Downloading ipaddress-1.0.16-py27-none-any.whl
    Collecting cffi>=1.4.1 (from cryptography>=1.3->pyOpenSSL->scrapy)
      Downloading cffi-1.6.0.tar.gz (397kB)
        100% |################################| 399kB 1.3MB/s
    Collecting pycparser (from cffi>=1.4.1->cryptography>=1.3->pyOpenSSL->scrapy)
      Downloading pycparser-2.14.tar.gz (223kB)
        100% |################################| 225kB 1.1MB/s
    Building wheels for collected packages: Twisted, lxml, PyDispatcher, cryptography, zope.interface, cffi, pycparser
      Running setup.py bdist_wheel for Twisted ... done
      Stored in directory: /home/scrapyuser/.cache/pip/wheels/fe/9d/3f/9f7b1c768889796c01929abb7cdfa2a9cdd32bae64eb7aa239
      Running setup.py bdist_wheel for lxml ... done
      Stored in directory: /home/scrapyuser/.cache/pip/wheels/6c/eb/a1/e4ff54c99630e3cc6ec659287c4fd88345cd78199923544412
      Running setup.py bdist_wheel for PyDispatcher ... done
      Stored in directory: /home/scrapyuser/.cache/pip/wheels/86/02/a1/5857c77600a28813aaf0f66d4e4568f50c9f133277a4122411
      Running setup.py bdist_wheel for cryptography ... done
      Stored in directory: /home/scrapyuser/.cache/pip/wheels/f6/6c/21/11ec069285a52d7fa8c735be5fc2edfb8b24012c0f78f93d20
      Running setup.py bdist_wheel for zope.interface ... done
      Stored in directory: /home/scrapyuser/.cache/pip/wheels/20/a2/bc/74fe87cee17134f5219ba01fe82dd8c10998377e0fb910bb22
      Running setup.py bdist_wheel for cffi ... done
      Stored in directory: /home/scrapyuser/.cache/pip/wheels/8f/00/29/553c1b1db38bbeec3fec428ae4e400cd8349ecd99fe86edea1
      Running setup.py bdist_wheel for pycparser ... done
      Stored in directory: /home/scrapyuser/.cache/pip/wheels/9b/f4/2e/d03e949a551719a1ffcb659f2c63d8444f4df12e994ce52112
    Successfully built Twisted lxml PyDispatcher cryptography zope.interface cffi pycparser
    Installing collected packages: queuelib, idna, pyasn1, six, setuptools, enum34, ipaddress, pycparser, cffi, cryptography, pyOpenSSL, zope.interface, Twisted, w3lib, pyasn1-modules, attrs, service-identity, cssselect, lxml, parsel, PyDispatcher, scrapy
    Successfully installed PyDispatcher Twisted attrs cffi cryptography cssselect enum34 idna ipaddress lxml parsel pyOpenSSL pyasn1 pyasn1-modules pycparser queuelib scrapy service-identity setuptools-20.7.0 six w3lib zope.interface
    You are using pip version 8.1.1, however version 8.1.2 is available.
    You should consider upgrading via the 'pip install --upgrade pip' command.
    scrapyuser@41bef38de45d:~$ scrapy version
    bash: scrapy: command not found
</code>```

答:
I'm using Ubuntu 16.04 too and the following did work for me:

Download and install Anaconda, a data-centric Python distribution provided at no cost by Continuum Analytics. Currently (2017-07-09) Python 3.6 and Python 2.7 are available.

Decide which version of scrapy is needed in your project and use conda, their paket manager to figure out which versions are available in a default installation of Anaconda:

conda search scrapy yields

1.3.3                   py36_0  defaults

If you can live with version 1.3.3, simply install it: conda install scrapy

According to the Scrapy website, the most recent stable version is 1.4.0 and you might want to go with that instead. You could probably run pip install scrapy to get it, but there is another way which I'd recommend:

Check the Anaconda cloud and realize that version 1.4.0 is available via conda-forge, a community-driven project in which numerous packages have been 'forged' to make them installable with conda.

You have now two options to install the most recent version from the conda-forge channel

explicitly state the channel: conda install -c conda-forge scrapy=1.4.0 or

add the conda-forge channel as the primary package source of your installation with conda config --add channels conda-forge and simply install scrapy with conda install scrapy then.

Title: Scrapy setup ubuntu 16.04 or any other

Body:
My today installed fresh Ubuntu 16.04 was preinstalled with python:

p@Scrapy:~$ python --version
Python 2.7.11+
p@Scrapy:~$ python3 --version
Python 3.5.1+

As mentioned on manual page http://doc.scrapy.org/en/latest/intro/install.html I open this link http://doc.scrapy.org/en/latest/topics/ubuntu.html#topics-ubuntu and tried to follow steps described to install Scrapy.

But I get an error after step 3

sudo apt-get update && sudo apt-get install scrapy

...

The following packages have unmet dependencies:
 scrapy : Depends: python-support (>= 0.90.0) but it is not installable
          Recommends: python-setuptools but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

I post a problem yesterday about error with Scrapy and looks like it was setup issue too but on Windows. Cannot setup Scrapy on windows So I tried today with Ubuntu and once more without luck.

So question how to setup Scrapy on Ubuntu 16.04 or may be other version? Looks like Scrapy manuals outdated. I would think Scrapy project died, but I know that people still use Scrapy. May be Scrapy only works with python 2.+? So I will stay with Windows. Cannot check all variants. It takes too much time. Can anyone mention stable config (operating system + python version) working with Scrapy?

Thanks.

Update

Here I tried with Docker. I create Dockerfile, other steps from terminal:

p@ScrapyPython3:~$ cat Dockerfile
$ cat Dockerfile
FROM ubuntu:xenial

ENV DEBIAN_FRONTEND noninteractive

RUN apt-get update

# Install Python3 and dev headers
RUN apt-get install -y \
    python3 \
    python-dev \
    python3-dev

# Install cryptography
RUN apt-get install -y \
    build-essential \
    libssl-dev \
    libffi-dev

# install lxml
RUN apt-get install -y \
    libxml2-dev \
    libxslt-dev

# install pip
RUN apt-get install -y python-pip

RUN useradd --create-home --shell /bin/bash scrapyuser

USER scrapyuser
WORKDIR /home/scrapyuser
p@ScrapyPython3:~$ sudo docker build -t redapple/scrapy-ubuntu-xenial .
Sending build context to Docker daemon 81.21 MB
Step 1 : $
Unknown instruction: $
p@ScrapyPython3:~$ sudo docker run -t -i redapple/scrapy-ubuntu-xenial
Unable to find image 'redapple/scrapy-ubuntu-xenial:latest' locally
Pulling repository docker.io/redapple/scrapy-ubuntu-xenial
docker: Error: image redapple/scrapy-ubuntu-xenial not found.
See 'docker run --help'.
p@ScrapyPython3:~$ pip install scrapy
Requirement already satisfied (use --upgrade to upgrade): scrapy in ./.local/lib/python2.7/site-packages
Requirement already satisfied (use --upgrade to upgrade): queuelib in ./.local/lib/python2.7/site-packages (from scrapy)
Requirement already satisfied (use --upgrade to upgrade): pyOpenSSL in ./.local/lib/python2.7/site-packages (from scrapy)
Requirement already satisfied (use --upgrade to upgrade): Twisted>=10.0.0 in ./.local/lib/python2.7/site-packages (from scrapy)
Requirement already satisfied (use --upgrade to upgrade): six>=1.5.2 in ./.local/lib/python2.7/site-packages (from scrapy)
Requirement already satisfied (use --upgrade to upgrade): w3lib>=1.14.2 in ./.local/lib/python2.7/site-packages (from scrapy)
Requirement already satisfied (use --upgrade to upgrade): service-identity in ./.local/lib/python2.7/site-packages (from scrapy)
Requirement already satisfied (use --upgrade to upgrade): cssselect>=0.9 in ./.local/lib/python2.7/site-packages (from scrapy)
Requirement already satisfied (use --upgrade to upgrade): lxml in ./.local/lib/python2.7/site-packages (from scrapy)
Requirement already satisfied (use --upgrade to upgrade): parsel>=0.9.3 in ./.local/lib/python2.7/site-packages (from scrapy)
Requirement already satisfied (use --upgrade to upgrade): PyDispatcher>=2.0.5 in ./.local/lib/python2.7/site-packages (from scrapy)
Requirement already satisfied (use --upgrade to upgrade): cryptography>=1.3 in ./.local/lib/python2.7/site-packages (from pyOpenSSL->scrapy)
Requirement already satisfied (use --upgrade to upgrade): zope.interface>=3.6.0 in ./.local/lib/python2.7/site-packages (from Twisted>=10.0.0->scrapy)
Requirement already satisfied (use --upgrade to upgrade): pyasn1-modules in ./.local/lib/python2.7/site-packages (from service-identity->scrapy)
Requirement already satisfied (use --upgrade to upgrade): pyasn1 in ./.local/lib/python2.7/site-packages (from service-identity->scrapy)
Requirement already satisfied (use --upgrade to upgrade): attrs in ./.local/lib/python2.7/site-packages (from service-identity->scrapy)
Requirement already satisfied (use --upgrade to upgrade): setuptools>=11.3 in ./.local/lib/python2.7/site-packages (from cryptography>=1.3->pyOpenSSL->scrapy)
Requirement already satisfied (use --upgrade to upgrade): ipaddress in ./.local/lib/python2.7/site-packages (from cryptography>=1.3->pyOpenSSL->scrapy)
Requirement already satisfied (use --upgrade to upgrade): enum34 in ./.local/lib/python2.7/site-packages (from cryptography>=1.3->pyOpenSSL->scrapy)
Requirement already satisfied (use --upgrade to upgrade): idna>=2.0 in ./.local/lib/python2.7/site-packages (from cryptography>=1.3->pyOpenSSL->scrapy)
Requirement already satisfied (use --upgrade to upgrade): cffi>=1.4.1 in ./.local/lib/python2.7/site-packages (from cryptography>=1.3->pyOpenSSL->scrapy)
Requirement already satisfied (use --upgrade to upgrade): pycparser in ./.local/lib/python2.7/site-packages (from cffi>=1.4.1->cryptography>=1.3->pyOpenSSL->scrapy)
p@ScrapyPython3:~$ scrapy version
The program 'scrapy' is currently not installed. You can install it by typing:
sudo apt install python-scrapy

UPDATE 1
Looks like first row in Dockerfile should not be there. If i remove it ($ cat Dockerfile)

I can get docker image up and running, but once more no luck with pip install scrapy. More over I realize I have to do some overhead with docker to be able upload scrapy files there (I prefer GUI when coding). It there any tool installed in this Docker image? Here install log:

p@ScrapyPython3:~$ sudo docker run -t -i redapple/scrapy-ubuntu-xenial
    scrapyuser@41bef38de45d:~$ python --version
    Python 2.7.11+
    scrapyuser@41bef38de45d:~$ python3 --version
    Python 3.5.1+
    scrapyuser@41bef38de45d:~$ pip install scrapy
    Collecting scrapy
      Downloading Scrapy-1.1.0-py2.py3-none-any.whl (294kB)
        100% |################################| 296kB 245kB/s
    Collecting queuelib (from scrapy)
      Downloading queuelib-1.4.2-py2.py3-none-any.whl
    Collecting pyOpenSSL (from scrapy)
      Downloading pyOpenSSL-16.0.0-py2.py3-none-any.whl (45kB)
        100% |################################| 51kB 12.7MB/s
    Collecting Twisted>=10.0.0 (from scrapy)
      Downloading Twisted-16.2.0.tar.bz2 (2.9MB)
        100% |################################| 2.9MB 472kB/s
    Collecting six>=1.5.2 (from scrapy)
      Downloading six-1.10.0-py2.py3-none-any.whl
    Collecting w3lib>=1.14.2 (from scrapy)
      Downloading w3lib-1.14.2-py2.py3-none-any.whl
    Collecting service-identity (from scrapy)
      Downloading service_identity-16.0.0-py2.py3-none-any.whl
    Collecting cssselect>=0.9 (from scrapy)
      Downloading cssselect-0.9.2-py2.py3-none-any.whl
    Collecting lxml (from scrapy)
      Downloading lxml-3.6.0.tar.gz (3.7MB)
        100% |################################| 3.7MB 389kB/s
    Collecting parsel>=0.9.3 (from scrapy)
      Downloading parsel-1.0.2-py2.py3-none-any.whl
    Collecting PyDispatcher>=2.0.5 (from scrapy)
      Downloading PyDispatcher-2.0.5.tar.gz
    Collecting cryptography>=1.3 (from pyOpenSSL->scrapy)
      Downloading cryptography-1.4.tar.gz (399kB)
        100% |################################| 409kB 1.4MB/s
    Collecting zope.interface>=3.6.0 (from Twisted>=10.0.0->scrapy)
      Downloading zope.interface-4.2.0.tar.gz (146kB)
        100% |################################| 153kB 1.2MB/s
    Collecting pyasn1-modules (from service-identity->scrapy)
      Downloading pyasn1_modules-0.0.8-py2.py3-none-any.whl
    Collecting pyasn1 (from service-identity->scrapy)
      Downloading pyasn1-0.1.9-py2.py3-none-any.whl
    Collecting attrs (from service-identity->scrapy)
      Downloading attrs-16.0.0-py2.py3-none-any.whl
    Collecting idna>=2.0 (from cryptography>=1.3->pyOpenSSL->scrapy)
      Downloading idna-2.1-py2.py3-none-any.whl (54kB)
        100% |################################| 61kB 10.8MB/s
    Collecting setuptools>=11.3 (from cryptography>=1.3->pyOpenSSL->scrapy)
      Downloading setuptools-23.0.0-py2.py3-none-any.whl (435kB)
        100% |################################| 440kB 1.2MB/s
    Collecting enum34 (from cryptography>=1.3->pyOpenSSL->scrapy)
      Downloading enum34-1.1.6-py2-none-any.whl
    Collecting ipaddress (from cryptography>=1.3->pyOpenSSL->scrapy)
      Downloading ipaddress-1.0.16-py27-none-any.whl
    Collecting cffi>=1.4.1 (from cryptography>=1.3->pyOpenSSL->scrapy)
      Downloading cffi-1.6.0.tar.gz (397kB)
        100% |################################| 399kB 1.3MB/s
    Collecting pycparser (from cffi>=1.4.1->cryptography>=1.3->pyOpenSSL->scrapy)
      Downloading pycparser-2.14.tar.gz (223kB)
        100% |################################| 225kB 1.1MB/s
    Building wheels for collected packages: Twisted, lxml, PyDispatcher, cryptography, zope.interface, cffi, pycparser
      Running setup.py bdist_wheel for Twisted ... done
      Stored in directory: /home/scrapyuser/.cache/pip/wheels/fe/9d/3f/9f7b1c768889796c01929abb7cdfa2a9cdd32bae64eb7aa239
      Running setup.py bdist_wheel for lxml ... done
      Stored in directory: /home/scrapyuser/.cache/pip/wheels/6c/eb/a1/e4ff54c99630e3cc6ec659287c4fd88345cd78199923544412
      Running setup.py bdist_wheel for PyDispatcher ... done
      Stored in directory: /home/scrapyuser/.cache/pip/wheels/86/02/a1/5857c77600a28813aaf0f66d4e4568f50c9f133277a4122411
      Running setup.py bdist_wheel for cryptography ... done
      Stored in directory: /home/scrapyuser/.cache/pip/wheels/f6/6c/21/11ec069285a52d7fa8c735be5fc2edfb8b24012c0f78f93d20
      Running setup.py bdist_wheel for zope.interface ... done
      Stored in directory: /home/scrapyuser/.cache/pip/wheels/20/a2/bc/74fe87cee17134f5219ba01fe82dd8c10998377e0fb910bb22
      Running setup.py bdist_wheel for cffi ... done
      Stored in directory: /home/scrapyuser/.cache/pip/wheels/8f/00/29/553c1b1db38bbeec3fec428ae4e400cd8349ecd99fe86edea1
      Running setup.py bdist_wheel for pycparser ... done
      Stored in directory: /home/scrapyuser/.cache/pip/wheels/9b/f4/2e/d03e949a551719a1ffcb659f2c63d8444f4df12e994ce52112
    Successfully built Twisted lxml PyDispatcher cryptography zope.interface cffi pycparser
    Installing collected packages: queuelib, idna, pyasn1, six, setuptools, enum34, ipaddress, pycparser, cffi, cryptography, pyOpenSSL, zope.interface, Twisted, w3lib, pyasn1-modules, attrs, service-identity, cssselect, lxml, parsel, PyDispatcher, scrapy
    Successfully installed PyDispatcher Twisted attrs cffi cryptography cssselect enum34 idna ipaddress lxml parsel pyOpenSSL pyasn1 pyasn1-modules pycparser queuelib scrapy service-identity setuptools-20.7.0 six w3lib zope.interface
    You are using pip version 8.1.1, however version 8.1.2 is available.
    You should consider upgrading via the 'pip install --upgrade pip' command.
    scrapyuser@41bef38de45d:~$ scrapy version
    bash: scrapy: command not found


问:
PHP Session and Cookie error in my Admin login page
I am working on Admin login page using PHP and MySQL. I am using XAMPP Control Panel v3.2.2 and Chrome browser.

I have used session and cookie in my admin login page but I have found following error

```<code>Notice: Undefined index: nam in C:\xampp\htdocs\online_voting\admin\index.php on line 3

Notice: Undefined index: pas in C:\xampp\htdocs\online_voting\admin\index.php on line 4
</code>```

in my index.php page.

I can not find out cause of this error. What might be the problem?

This is my MySQL database connection page.

connection.php

```<code><?php
error_reporting(1);
mysql_connect('localhost', 'root', '') or die(mysql_error());
mysql_select_db('poll') or die(mysql_error());

?>
</code>```

For Login :

Email : admin@gmail.com
Password : admin

Database name is poll and table name is tbadministrators .

```<code>-- Table structure for table `tbadministrators`
--

CREATE TABLE IF NOT EXISTS `tbadministrators` (
  `admin_id` int(5) NOT NULL AUTO_INCREMENT,
  `first_name` varchar(45) NOT NULL,
  `last_name` varchar(45) NOT NULL,
  `email` varchar(45) NOT NULL,
  `password` varchar(45) NOT NULL,
  PRIMARY KEY (`admin_id`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ;

--
-- Dumping data for table `tbadministrators`
--

INSERT INTO `tbadministrators` (`admin_id`, `first_name`, `last_name`, `email`, `password`) VALUES
(1, 'Md. Rezwanul', 'Haque', 'admin@gmail.com', '21232f297a57a5a743894a0e4a801fc3');

-- --------------------------------------------------------
</code>```

I have used following pages for admin login .

index.php

```<code><?php
      session_start();
      $myusername = $_SESSION['nam'] ;
      $mypassword = $_SESSION['pas'] ;
?>
<?php
      if(isset($_COOKIE['$email']) && $_COOKIE['$pass']){
          header("Location:admin.php");
          exit;
      }
?>

<!DOCTYPE html>
<html >
<head>
  <meta charset="UTF-8">
  <title>Admin Login Form</title>

  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/meyer-reset/2.0/reset.min.css">

  <link rel='stylesheet prefetch' href='https://fonts.googleapis.com/css?family=Roboto:400,100,300,500,700,900|RobotoDraft:400,100,300,500,700,900'>
<link rel='stylesheet prefetch' href='https://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css'>

      <link rel="stylesheet" href="css/style.css">

      <script language="JavaScript" src="js/admin.js">
  </script>

</head>

<body style="background-image:url('images/demo/backgrounds/bCY7Scu.png');">

<div class="pen-title">
  <h1>Admin Login Form</h1>
</div>

<div class="container" >
  <div class="card"></div>

  <div class="card">
    <h1 class="title">Login</h1>
    <form name="form1" action="checklogin.php" method="post" onsubmit="return loginValidate(this)">

      <div class="input-container">
        <input name="myusername" value="<?php echo $myusername  ?>" type="text" required="required"/>
        <label>Email</label>
        <div class="bar"></div>
      </div>
      <div class="input-container">
        <input name="mypassword" value="<?php echo $mypassword ?>" type="password"  required="required"/>
        <label>Password</label>
        <div class="bar"></div>
      </div>

      <center><tr><td colspan="2" align="center"><input type="checkbox" name="remember" value="1"> <font color="blue">Remember Me</font></td></tr></center><br>

      <div class="button-container">

        <button name="Submit"><span>Login</span></button>

      </div>
      <br><br>
    <center>Return to <a href="http://localhost/online_voting/index.php">Voter Panel</a></center>

    </form>
  </div>

</div>

</body>
</html>
</code>```

checklogin.php

```<code><!DOCTYPE html>
<html>
<body style="background-color:powderblue;">

<?php
//session_start();
ini_set ("display_errors", "1");
error_reporting(E_ALL);

ob_start();
session_start();
require('../connection.php');

$tbl_name="tbAdministrators"; // Table name

/*
$myusername=$_POST['myusername'];
$mypassword=$_POST['mypassword'];
$encrypted_mypassword=md5($mypassword);

$myusername = stripslashes($myusername);
$mypassword = stripslashes($mypassword);
$myusername = mysql_real_escape_string($myusername);
$mypassword = mysql_real_escape_string($mypassword);
*/

$myusername=$_POST['myusername'];
$mypassword=$_POST['mypassword'];
$encrypted_mypassword=md5($mypassword);

$myusername = stripslashes($myusername);
$mypassword = stripslashes($mypassword);
$myusername = mysql_real_escape_string($myusername);
$mypassword = mysql_real_escape_string($mypassword);

$sql="SELECT * FROM $tbl_name WHERE email='$myusername' and password='$encrypted_mypassword'" or die(mysql_error());
$result=mysql_query($sql) or die(mysql_error());

$count=mysql_num_rows($result);

if($count==1){
    // If everything checks out, you will now be forwarded to admin.php
     // $user = mysql_fetch_assoc($result);
     // $_SESSION['admin_id'] = $user['admin_id'];
    // header("location:admin.php");

                if(isset($_POST['remember']))
                {
                    setcookie('$email',$_POST['myusername'], time()+30*24*60*60);
                    setcookie('$pass', $_POST['mypassword'],time()+30*24*60*60);
                    $_SESSION['curname']=$myusername;
                    $_SESSION['curpass']=$mypassword;

                    $user = mysql_fetch_assoc($result);
                    $_SESSION['admin_id'] = $user['admin_id'];

                    header("Location:admin.php");
                    exit;
                }
                else
                {
                    $log1=11;
                    $_SESSION['log1'] = $log1;
                    $_SESSION['curname']=$myusername;
                    $_SESSION['curpass']=$mypassword;

                    $user = mysql_fetch_assoc($result);
                    $_SESSION['admin_id'] = $user['admin_id'];

                    header("Location:admin.php");
                    exit;
                }

}
//If the username or password is wrong, you will receive this message below.
else {
    echo "<br> <br> <br> ";
    echo "<center> <h3>Wrong Username or Password<br><br>Return to <a href=\"index.php\">login</a> </h3></center>";
}

ob_end_flush();

?>

</body>
</html>
</code>```

admin.php

```<code><?php
    session_start();
    require('../connection.php');
    $log1 = $_SESSION['log1'];
?>
<?php
      if(isset($_COOKIE['$email']) && $_COOKIE['$pass']){
            $curnam = $_SESSION['curname'];
            $curpas = $_SESSION['curpass'];
        }
        else if($log1 == 11)
        {
            $curnam = $_SESSION['curname'];
            $curpas = $_SESSION['curpass'];
        }
        else
        {
           echo '<img src="e1.jpg" width="100%" height="100%"  />';  /* here goes the page when destroy the cookies */
           exit;
        }
?>
<!DOCTYPE html>
<html>
<head>
<title>online voting</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">

<link href="layout/styles/layout.css" rel="stylesheet" type="text/css" media="all">
<script language="JavaScript" src="js/user.js">
</script>

</head>
<body id="top">
<div class="wrapper bgded overlay" style="background-image:url('images/demo/backgrounds/background1.jpg');">
  <section id="testimonials" class="hoc container clear">

    <h2 class="font-x3 uppercase btmspace-80 underlined"> Online <a href="#">Voting</a></h2>
    <ul class="nospace group">

       <li class="one_third">

          <blockquote>In this page, Admin can set candidates for voting and view results.</blockquote>

      </li>

    </ul>

  </section>
</div>
<!-- JAVASCRIPTS -->
<script src="layout/scripts/jquery.min.js"></script>
<script src="layout/scripts/jquery.backtotop.js"></script>
<script src="layout/scripts/jquery.mobilemenu.js"></script>
<!-- IE9 Placeholder Support -->
<script src="layout/scripts/jquery.placeholder.min.js"></script>
<!-- / IE9 Placeholder Support -->
</body>
</html>
</code>```

logout.php

```<code><?php
  session_start();
  //session_destroy();
  /*header("location: index.php");
  exit;*/
  if( isset($_COOKIE['$email']) and isset($_COOKIE['$pass'])){
      setcookie('$email',' ',time()-30*24*60*60);
      setcookie('$pass',' ',time()-30*24*60*60);
      $nam=$_COOKIE['$email'];
      $pas=$_COOKIE['$pass'];
      $_SESSION['nam'] = $nam;
      $_SESSION['pas'] = $pas;
      header("location: index.php");
      exit;
  }
  else
  {
    header("location: index.php");
    exit;
  }
?>
</code>```

PHP: "Notice: Undefined variable", "Notice: Undefined index", and "Notice: Undefined offset"

From their solutions could not help me properly.

答:
When you first time visit the page at that time your value not set in session. So you have to check first if value is set or not then assign the value. Change the following in index.php:

```<code><?php
      session_start();
      $myusername = isset($_SESSION['nam'])?$_SESSION['nam']:"" ;
      $mypassword = isset($_SESSION['pas'])?$_SESSION['pas']:"" ;
?>
</code>```

Body:
I am working on Admin login page using PHP and MySQL. I am using XAMPP Control Panel v3.2.2 and Chrome browser.

I have used session and cookie in my admin login page but I have found following error

Notice: Undefined index: nam in C:\xampp\htdocs\online_voting\admin\index.php on line 3

Notice: Undefined index: pas in C:\xampp\htdocs\online_voting\admin\index.php on line 4

in my index.php page.

I can not find out cause of this error. What might be the problem?

This is my MySQL database connection page.

connection.php

<?php
error_reporting(1);
mysql_connect('localhost', 'root', '') or die(mysql_error());
mysql_select_db('poll') or die(mysql_error());

?>

For Login :

Email : admin@gmail.com
Password : admin

Database name is poll and table name is tbadministrators .

-- Table structure for table `tbadministrators`
--

CREATE TABLE IF NOT EXISTS `tbadministrators` (
  `admin_id` int(5) NOT NULL AUTO_INCREMENT,
  `first_name` varchar(45) NOT NULL,
  `last_name` varchar(45) NOT NULL,
  `email` varchar(45) NOT NULL,
  `password` varchar(45) NOT NULL,
  PRIMARY KEY (`admin_id`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ;

--
-- Dumping data for table `tbadministrators`
--

INSERT INTO `tbadministrators` (`admin_id`, `first_name`, `last_name`, `email`, `password`) VALUES
(1, 'Md. Rezwanul', 'Haque', 'admin@gmail.com', '21232f297a57a5a743894a0e4a801fc3');

-- --------------------------------------------------------

I have used following pages for admin login .

index.php

<?php
      session_start();
      $myusername = $_SESSION['nam'] ;
      $mypassword = $_SESSION['pas'] ;
?>
<?php
      if(isset($_COOKIE['$email']) && $_COOKIE['$pass']){
          header("Location:admin.php");
          exit;
      }
?>

<!DOCTYPE html>

  <meta charset="UTF-8">
  <title>Admin Login Form</title>

  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/meyer-reset/2.0/reset.min.css">

  <link rel='stylesheet prefetch' href='https://fonts.googleapis.com/css?family=Roboto:400,100,300,500,700,900|RobotoDraft:400,100,300,500,700,900'>
<link rel='stylesheet prefetch' href='https://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css'>

      <link rel="stylesheet" href="css/style.css">

Admin Login Form

Login

    <form name="form1" action="checklogin.php" method="post" onsubmit="return loginValidate(this)">

        <input name="myusername" value="<?php echo $myusername  ?>" type="text" required="required"/>
        Email

        <input name="mypassword" value="<?php echo $mypassword ?>" type="password"  required="required"/>
        Password

<input type="checkbox" name="remember" value="1"> Remember Me

        <button name="Submit">Login</button>

    Return to Voter Panel

    </form>

checklogin.php

<!DOCTYPE html>

<?php
//session_start();
ini_set ("display_errors", "1");
error_reporting(E_ALL);

ob_start();
session_start();
require('../connection.php');

$tbl_name="tbAdministrators"; // Table name

/*
$myusername=$_POST['myusername'];
$mypassword=$_POST['mypassword'];
$encrypted_mypassword=md5($mypassword);

$myusername = stripslashes($myusername);
$mypassword = stripslashes($mypassword);
$myusername = mysql_real_escape_string($myusername);
$mypassword = mysql_real_escape_string($mypassword);
*/

$myusername=$_POST['myusername'];
$mypassword=$_POST['mypassword'];
$encrypted_mypassword=md5($mypassword);

$myusername = stripslashes($myusername);
$mypassword = stripslashes($mypassword);
$myusername = mysql_real_escape_string($myusername);
$mypassword = mysql_real_escape_string($mypassword);

$sql="SELECT * FROM $tbl_name WHERE email='$myusername' and password='$encrypted_mypassword'" or die(mysql_error());
$result=mysql_query($sql) or die(mysql_error());

$count=mysql_num_rows($result);

if($count==1){
    // If everything checks out, you will now be forwarded to admin.php
     // $user = mysql_fetch_assoc($result);
     // $_SESSION['admin_id'] = $user['admin_id'];
    // header("location:admin.php");

                if(isset($_POST['remember']))
                {
                    setcookie('$email',$_POST['myusername'], time()+30*24*60*60);
                    setcookie('$pass', $_POST['mypassword'],time()+30*24*60*60);
                    $_SESSION['curname']=$myusername;
                    $_SESSION['curpass']=$mypassword;

                    $user = mysql_fetch_assoc($result);
                    $_SESSION['admin_id'] = $user['admin_id'];

                    header("Location:admin.php");
                    exit;
                }
                else
                {
                    $log1=11;
                    $_SESSION['log1'] = $log1;
                    $_SESSION['curname']=$myusername;
                    $_SESSION['curpass']=$mypassword;

                    $user = mysql_fetch_assoc($result);
                    $_SESSION['admin_id'] = $user['admin_id'];

                    header("Location:admin.php");
                    exit;
                }

}
//If the username or password is wrong, you will receive this message below.
else {
    echo "

 ";
    echo "
Wrong Username or Password

Return to login
";
}

ob_end_flush();

?>

admin.php

<?php
    session_start();
    require('../connection.php');
    $log1 = $_SESSION['log1'];
?>
<?php
      if(isset($_COOKIE['$email']) && $_COOKIE['$pass']){
            $curnam = $_SESSION['curname'];
            $curpas = $_SESSION['curpass'];
        }
        else if($log1 == 11)
        {
            $curnam = $_SESSION['curname'];
            $curpas = $_SESSION['curpass'];
        }
        else
        {
           echo '';  /* here goes the page when destroy the cookies */
           exit;
        }
?>
<!DOCTYPE html>

<title>online voting</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">

<link href="layout/styles/layout.css" rel="stylesheet" type="text/css" media="all">

 Online Voting

In this page, Admin can set candidates for voting and view results.

logout.php

<?php
  session_start();
  //session_destroy();
  /*header("location: index.php");
  exit;*/
  if( isset($_COOKIE['$email']) and isset($_COOKIE['$pass'])){
      setcookie('$email',' ',time()-30*24*60*60);
      setcookie('$pass',' ',time()-30*24*60*60);
      $nam=$_COOKIE['$email'];
      $pas=$_COOKIE['$pass'];
      $_SESSION['nam'] = $nam;
      $_SESSION['pas'] = $pas;
      header("location: index.php");
      exit;
  }
  else
  {
    header("location: index.php");
    exit;
  }
?>

PHP: "Notice: Undefined variable", "Notice: Undefined index", and "Notice: Undefined offset"

From their solutions could not help me properly.

Body:
When you first time visit the page at that time your value not set in session. So you have to check first if value is set or not then assign the value. Change the following in index.php:

<?php
      session_start();
      $myusername = isset($_SESSION['nam'])?$_SESSION['nam']:"" ;
      $mypassword = isset($_SESSION['pas'])?$_SESSION['pas']:"" ;
?>


问:
Navisworks Treeview to Datatable
I want to covert a treeview from a model in navisworks and create a datatable.
I tried to use foreach but no luck.

any help would be Appreciated

答:
I resolved my problem by getting the Descendants and passed this into an IEnumerable

```<code>var Descendants = PL.oDoc.Models.First.RootItem.Descendants.Select(x => x);
</code>```

and then with this method I convert that into an datatable:

```<code>    public static DataTable DataTable<T>(this IEnumerable<T> items)
    {
        var tb = new DataTable(typeof(T).Name);

        PropertyInfo[] props = typeof(T).GetProperties(BindingFlags.Public | BindingFlags.Instance);

        foreach (var prop in props)
        {
            tb.Columns.Add(prop.Name, prop.PropertyType);
        }

        foreach (var item in items)
        {
            var values = new object[props.Length];
            for (var i = 0; i < props.Length; i++)
            {
                values[i] = props[i].GetValue(item, null);
            }

            tb.Rows.Add(values);
        }

        return tb;
    }
</code>```

Title: Navisworks Treeview to Datatable

Body:
I resolved my problem by getting the Descendants and passed this into an IEnumerable

var Descendants = PL.oDoc.Models.First.RootItem.Descendants.Select(x => x);

and then with this method I convert that into an datatable:

    public static DataTable DataTable<T>(this IEnumerable<T> items)
    {
        var tb = new DataTable(typeof(T).Name);

        PropertyInfo[] props = typeof(T).GetProperties(BindingFlags.Public | BindingFlags.Instance);

        foreach (var prop in props)
        {
            tb.Columns.Add(prop.Name, prop.PropertyType);
        }

        foreach (var item in items)
        {
            var values = new object[props.Length];
            for (var i = 0; i < props.Length; i++)
            {
                values[i] = props[i].GetValue(item, null);
            }

            tb.Rows.Add(values);
        }

        return tb;
    }


问:
C string based programming code
Can anyone please provide me the code in c programming language of problem in which we enter "ABCD"  as an input in run time  and we get "ZYXW"  as output and I tried to solve this using ASCII Code </p>

答:
Hope this will help you . Read about ascii code of character . Also you have to gain knowledge of pointer and string . </p>

```<code>#include<stdio.h>

int main(){
    char ch[20];
    scanf("%s",ch);
    for(const char *s = ch; *s; ++s)
        putchar('Z'-(*s-'A'));
    return 0;
}
</code>```

Title: C string based programming code

Body:
Hope this will help you . Read about ascii code of character . Also you have to gain knowledge of pointer and string .

#include<stdio.h>

int main(){
    char ch[20];
    scanf("%s",ch);
    for(const char *s = ch; *s; ++s)
        putchar('Z'-(*s-'A'));
    return 0;
}


问:
Tkinter with or without OOP
Studying Tkinter and I've only found tutorials on Tkinter without OOP, but looking at the Python.org documentation it looks like it's all in OOP. What's the benefit of using classes? It seems like more work and the syntax looks night and day from what I've learned so far. </p>

答:
This is going to be a really generic answer and most of the answers to this will be opinionated anyways. Speaking of which,the answer will likely be downvoted and closed because of this.

Anyways... Let's say you have a big GUI with a bunch of complicated logic sure you could write one huge file with hundreds, if not thousands of lines, and proxy a bunch of stuff through different functions and make it work. But, the logic is messy.

What if you could compartmentalize different sections of the GUI and all the logic surrounding them. Then, takes those components and aggregate them into the sum which makes the GUI?

This is exactly what you can use classes for in Tkinter. More generally, this is essentially what you use classes for - abstracting things into (reusable - instances) objects which provide a useful utility.

Example:

An app I built ages ago with Tkinter when I first learned it was a file moving program. The file moving program let you select the source / destination directory, had logging capabilities, search functions, monitoring processes for when downloads complete, and regex renaming options, unzipping archives, etcetera. Basically, everything I could think of for moving files.

So, what I did was I split the app up like this (at a high level)

1) Have a main which is the aggregate of the components forming the main GUI

Aggregates were essentially a sidebar, buttons / labels for selection various options split into their own sections as needed, and a scrolled text area for operation logging + search.

So, the main components were split like this:

2) A sidebar which had the following components

Section which contained the options for monitoring processes

Section which contained options for custom regular expressions or premade ones for renaming files

Section for various flag such as unpacking

3) A logging / text area section with search functionality build in + the options to dump (save) log files or view them.

That's a high level description of the "big" components which were comprised from the smaller components which were their own classes. So, by using classes I was able to wrap the complicated logic up into small pieces that were self contained.

Granted, you can do the same thing with functions, but you have "pieces" of a GUI which you can consider objects (classes) which fit together. So, it just makes for cleaner code / logic.

Title: Tkinter with or without OOP


问:
Egit installed but not showing
Good day everyone. I'm using Eclipse Luna and trying to use EGit tools but, it isn't working anymore.

I only see apply patch in the "team" option:

Import -> git projects isn't showing as well :

I checked preferences, and I didn't see git as well

I tried to switch workspace, running eclipse with -clean parameter, but it didn't help. I also checked if egit and jgit are installed, and they're installed:

I checked the error Log and I found something:

I hope someone can help me "restore" the Git thingy. Thanks!

答:
Try going to Windows -> Preferences -> General - Capabilities

Then click the ADVANCED button and you should see the GIT not marked

Title: Egit installed but not showing


问:
SQL queries from database with Laravel
I'm using Laravel and trying to do an SQL query from my Controller in a public function, but I'm really confused where I would put my table in the argument and if quotes go around the argument. Here is my code

```<code> public function selectMethod(){
    $results = DB::select('select firstname from people where id = 1');
    print_r($results);
    return view('pages.selectMethod');
}
</code>```

table is called people

My .env is configured to my database correctly and I get this error

FatalErrorException in AboutController.php line 90:
Class 'App\Http\Controllers\DB' not found

Thanks !

答:
you should add use Illuminate\Support\Facades\DB;
at the top of your page
for example :

```<code>    <?php

namespace App\Http\Controllers;

use Illuminate\Support\Facades\DB;
use App\Http\Controllers\Controller;

class UserController extends Controller
{
    /**
     * Show a list of all of the application's users.
     *
     * @return Response
     */
    public function index()
    {
        $users = DB::table('users')->get();

        return view('user.index', ['users' => $users]);
    }
}
</code>```

Title: SQL queries from database with Laravel

Body:
I'm using Laravel and trying to do an SQL query from my Controller in a public function, but I'm really confused where I would put my table in the argument and if quotes go around the argument. Here is my code

 public function selectMethod(){
    $results = DB::select('select firstname from people where id = 1');
    print_r($results);
    return view('pages.selectMethod');
}

table is called people

My .env is configured to my database correctly and I get this error

FatalErrorException in AboutController.php line 90:
Class 'App\Http\Controllers\DB' not found

Thanks !

Body:
you should add use Illuminate\Support\Facades\DB;
at the top of your page
for example :

    <?php

namespace App\Http\Controllers;

use Illuminate\Support\Facades\DB;
use App\Http\Controllers\Controller;

class UserController extends Controller
{
    /**
     * Show a list of all of the application's users.
     *
     * @return Response
     */
    public function index()
    {
        $users = DB::table('users')->get();

        return view('user.index', ['users' => $users]);
    }
}


问:
String to Double in Java
I have in my Java app double numbers. I need to convert String to Double, but string representation of number is

, - separates decimal part of number (
  example    1,5  eq 6/4 )

. - separates groups of three digits (
  example  1.000.000  eq 1000000 )

.
How to achieve this conversion String to Double ?

答:
You need to get rid of the , and replace , with .:

```<code>String s = "1000.000,15";
double d = Double.valueOf(s.replaceAll("\\.", "").replaceAll("\\,", "."));
System.out.print(d);
</code>```

Title: String to Double in Java

Body:
You need to get rid of the , and replace , with .:

String s = "1000.000,15";
double d = Double.valueOf(s.replaceAll("\\.", "").replaceAll("\\,", "."));
System.out.print(d);