问:
Spring Boot Application cannot deploy on Wildfly 10.1
I am trying to deploy a Spring Boot Application that uses JAXRS to a Wildfly server.

When I do this I get the following error:

```<code>01:58:46,787 INFO  [javax.enterprise.resource.webcontainer.jsf.config] (ServerService Thread Pool -- 62) Initializing Mojarra 2.2.13.SP1 20160303-1204 for context '/test-spring-boot-jaxrs-demo'
01:58:49,155 INFO  [org.jboss.resteasy.resteasy_jaxrs.i18n] (ServerService Thread Pool -- 62) RESTEASY002225: Deploying javax.ws.rs.core.Application: class test.spring.boot.jaxrs.demo.JerseyConfig
01:58:49,221 ERROR [org.jboss.msc.service.fail] (ServerService Thread Pool -- 62) MSC000001: Failed to start service jboss.undertow.deployment.default-server.default-host./test-spring-boot-jaxrs-demo: org.jboss.msc.service.StartException in service jboss.undertow.deployment.default-server.default-host./test-spring-boot-jaxrs-demo: java.lang.NullPointerException
    at org.wildfly.extension.undertow.deployment.UndertowDeploymentService$1.run(UndertowDeploymentService.java:85)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
    at org.jboss.threads.JBossThread.run(JBossThread.java:320)
Caused by: java.lang.NullPointerException
    at org.jboss.resteasy.core.ConstructorInjectorImpl.<init>(ConstructorInjectorImpl.java:47)
    at org.jboss.resteasy.core.InjectorFactoryImpl.createConstructor(InjectorFactoryImpl.java:53)
    at org.jboss.resteasy.spi.ResteasyProviderFactory.injectedInstance(ResteasyProviderFactory.java:2271)
    at org.jboss.resteasy.core.interception.JaxrsInterceptorRegistry$AbstractInterceptorFactory.createInterceptor(JaxrsInterceptorRegistry.java:170)
    at org.jboss.resteasy.core.interception.JaxrsInterceptorRegistry$OnDemandInterceptorFactory.initialize(JaxrsInterceptorRegistry.java:188)
    at org.jboss.resteasy.core.interception.JaxrsInterceptorRegistry$OnDemandInterceptorFactory.checkInitialize(JaxrsInterceptorRegistry.java:203)
    at org.jboss.resteasy.core.interception.JaxrsInterceptorRegistry$OnDemandInterceptorFactory.getInterceptor(JaxrsInterceptorRegistry.java:214)
    at org.jboss.resteasy.core.interception.JaxrsInterceptorRegistry$AbstractInterceptorFactory.postMatch(JaxrsInterceptorRegistry.java:151)
    at org.jboss.resteasy.core.interception.JaxrsInterceptorRegistry.postMatch(JaxrsInterceptorRegistry.java:421)
    at org.jboss.resteasy.core.ResourceMethodInvoker.<init>(ResourceMethodInvoker.java:106)
    at org.jboss.resteasy.core.ResourceMethodRegistry.processMethod(ResourceMethodRegistry.java:281)
    at org.jboss.resteasy.core.ResourceMethodRegistry.register(ResourceMethodRegistry.java:252)
    at org.jboss.resteasy.core.ResourceMethodRegistry.addResourceFactory(ResourceMethodRegistry.java:222)
    at org.jboss.resteasy.core.ResourceMethodRegistry.addResourceFactory(ResourceMethodRegistry.java:194)
    at org.jboss.resteasy.core.ResourceMethodRegistry.addResourceFactory(ResourceMethodRegistry.java:180)
    at org.jboss.resteasy.core.ResourceMethodRegistry.addResourceFactory(ResourceMethodRegistry.java:157)
    at org.jboss.resteasy.core.ResourceMethodRegistry.addPerRequestResource(ResourceMethodRegistry.java:76)
    at org.jboss.resteasy.spi.ResteasyDeployment.registration(ResteasyDeployment.java:409)
    at org.jboss.resteasy.spi.ResteasyDeployment.start(ResteasyDeployment.java:250)
    at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.init(ServletContainerDispatcher.java:113)
    at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.init(HttpServletDispatcher.java:36)
    at io.undertow.servlet.core.LifecyleInterceptorInvocation.proceed(LifecyleInterceptorInvocation.java:117)
    at org.wildfly.extension.undertow.security.RunAsLifecycleInterceptor.init(RunAsLifecycleInterceptor.java:78)
    at io.undertow.servlet.core.LifecyleInterceptorInvocation.proceed(LifecyleInterceptorInvocation.java:103)
    at io.undertow.servlet.core.ManagedServlet$DefaultInstanceStrategy.start(ManagedServlet.java:250)
    at io.undertow.servlet.core.ManagedServlet.createServlet(ManagedServlet.java:133)
    at io.undertow.servlet.core.DeploymentManagerImpl$2.call(DeploymentManagerImpl.java:546)
    at io.undertow.servlet.core.DeploymentManagerImpl$2.call(DeploymentManagerImpl.java:517)
    at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:42)
    at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43)
    at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
    at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
    at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
    at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
    at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
    at io.undertow.servlet.core.DeploymentManagerImpl.start(DeploymentManagerImpl.java:559)
    at org.wildfly.extension.undertow.deployment.UndertowDeploymentService.startContext(UndertowDeploymentService.java:101)
    at org.wildfly.extension.undertow.deployment.UndertowDeploymentService$1.run(UndertowDeploymentService.java:82)
    ... 6 more

01:58:49,221 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) WFLYCTL0013: Operation ("deploy") failed - address: ([("deployment" => "test-spring-boot-jaxrs-demo.war")]) - failure description: {
    "WFLYCTL0080: Failed services" => {"jboss.undertow.deployment.default-server.default-host./test-spring-boot-jaxrs-demo" => "org.jboss.msc.service.StartException in service jboss.undertow.deployment.default-server.default-host./test-spring-boot-jaxrs-demo: java.lang.NullPointerException
    Caused by: java.lang.NullPointerException"},
    "WFLYCTL0412: Required services that are not installed:" => ["jboss.undertow.deployment.default-server.default-host./test-spring-boot-jaxrs-demo"],
    "WFLYCTL0180: Services with missing/unavailable dependencies" => undefined
}
</code>```

The last INFO message before the error talks about deploying class test.spring.boot.jaxrs.demo.JerseyConfig.  I can't seen anything wrong with this code at the moment and deploys ok in Spring Tools Suite using Tomcat 8.5.5.

Does anyone know what could be causing the problem?

JerseyConfig class:

```<code>package psd2.spring.boot.jaxrs.demo;

import javax.annotation.PostConstruct;
import javax.ws.rs.ApplicationPath;

import org.glassfish.jersey.server.ResourceConfig;
import org.springframework.stereotype.Component;

@Component
@ApplicationPath("/")
public class JerseyConfig extends ResourceConfig {

    @PostConstruct
    private void init() {
        packages("io.swagger.api");
    }
}
</code>```

POM

```<code><?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>io.swagger</groupId>
    <artifactId>test-spring-boot-jaxrs-demo</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>war</packaging>

    <name>test-demo</name>
    <description>Demo project for Test</description>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.5.2.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>

    <properties>
        <start-class>test.spring.boot.jaxrs.demo.testDemoApplication</start-class>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <java.version>1.8</java.version>
        <maven.compiler.source>${java.version}</maven.compiler.source>
        <maven.compiler.target>${java.version}</maven.compiler.target>
        <swagger-core-version>1.5.12</swagger-core-version>
        <jetty-version>9.2.9.v20150224</jetty-version>
        <jersey2-version>2.22.2</jersey2-version>
        <jackson-version>2.8.7</jackson-version>
        <junit-version>4.12</junit-version>
        <logback-version>1.1.7</logback-version>
        <servlet-api-version>2.5</servlet-api-version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-jersey</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-autoconfigure</artifactId>
        </dependency>
        <dependency>
          <groupId>org.springframework.boot</groupId>
          <artifactId>spring-boot-starter-web</artifactId>
          <exclusions>
            <exclusion>
              <groupId>org.springframework.boot</groupId>
              <artifactId>spring-boot-starter-tomcat</artifactId>
            </exclusion>
          </exclusions>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-websocket</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.tomcat.embed</groupId>
            <artifactId>tomcat-embed-websocket</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-tomcat</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
          <groupId>io.swagger</groupId>
          <artifactId>swagger-jersey2-jaxrs</artifactId>
          <scope>compile</scope>
          <version>${swagger-core-version}</version>
        </dependency>
        <dependency>
          <groupId>ch.qos.logback</groupId>
          <artifactId>logback-classic</artifactId>
          <scope>compile</scope>
        </dependency>
        <dependency>
          <groupId>ch.qos.logback</groupId>
          <artifactId>logback-core</artifactId>
          <scope>compile</scope>
        </dependency>
        <dependency>
          <groupId>junit</groupId>
          <artifactId>junit</artifactId>
          <scope>test</scope>
        </dependency>
        <dependency>
          <groupId>javax.servlet</groupId>
          <artifactId>javax.servlet-api</artifactId>
          <scope>provided</scope>
        </dependency>
        <dependency>
          <groupId>org.glassfish.jersey.containers</groupId>
          <artifactId>jersey-container-servlet-core</artifactId>
        </dependency>
        <dependency>
          <groupId>org.glassfish.jersey.media</groupId>
          <artifactId>jersey-media-multipart</artifactId>
          <version>${jersey2-version}</version>
        </dependency>
        <dependency>
          <groupId>com.fasterxml.jackson.datatype</groupId>
          <artifactId>jackson-datatype-joda</artifactId>
        </dependency>
        <dependency>
          <groupId>com.fasterxml.jackson.jaxrs</groupId>
          <artifactId>jackson-jaxrs-json-provider</artifactId>
        </dependency>
        <!-- Base64 encoding that works in both JVM and Android -->
        <dependency>
          <groupId>com.brsanthu</groupId>
          <artifactId>migbase64</artifactId>
          <version>2.2</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
        </dependency>

    </dependencies>

    <build>
       <finalName>test-spring-boot-jaxrs-demo</finalName>
        <plugins>
           <plugin>
              <artifactId>maven-assembly-plugin</artifactId>
              <configuration>
                <archive>
                  <manifest>
                    <mainClass>test.spring.boot.jaxrs.demo</mainClass>
                  </manifest>
                </archive>
                <descriptorRefs>
                  <descriptorRef>jar-with-dependencies</descriptorRef>
                </descriptorRefs>
              </configuration>
            </plugin>
        </plugins>
    </build>
    <repositories>
        <repository>
            <id>central</id>
            <name>Central</name>
            <url>http://central.maven.org/maven2/</url>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </repository>
        <repository>
            <id>spring-snapshots</id>
            <name>Spring Snapshots</name>
            <url>http://repo.spring.io/snapshot</url>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </repository>
        <repository>
            <id>spring-milestones</id>
            <name>Spring Milestones</name>
            <url>http://repo.spring.io/milestone</url>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </repository>
    </repositories>
    <pluginRepositories>
        <pluginRepository>
            <id>spring-snapshots</id>
            <name>Spring Snapshots</name>
            <url>http://repo.spring.io/snapshot</url>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </pluginRepository>
        <pluginRepository>
            <id>spring-milestones</id>
            <name>Spring Milestones</name>
            <url>http://repo.spring.io/milestone</url>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </pluginRepository>
    </pluginRepositories>
</project>
</code>```

UPDATED: I've reverted JerseyConfig.java code back the above and amended the code to remove Application Path and application appears to deploy but I am seeing a 403 forbidden error.  This application still works when run as a spring boot application using the same URL.

Logs

```<code>16:17:53,779 INFO  [org.jboss.modules] (main) JBoss Modules version 1.5.2.Final
16:17:54,044 INFO  [org.jboss.msc] (main) JBoss MSC version 1.2.6.Final
16:17:54,138 INFO  [org.jboss.as] (MSC service thread 1-7) WFLYSRV0049: WildFly Full 10.1.0.Final (WildFly Core 2.2.0.Final) starting
16:17:56,029 INFO  [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads - 1) WFLYDS0004: Found demo.war in deployment directory. To trigger deployment create a file called demo.war.dodeploy
16:17:56,055 INFO  [org.jboss.as.server] (Controller Boot Thread) WFLYSRV0039: Creating http management service using socket-binding (management-http)
16:17:56,102 INFO  [org.xnio] (MSC service thread 1-4) XNIO version 3.4.0.Final
16:17:56,102 INFO  [org.xnio.nio] (MSC service thread 1-4) XNIO NIO Implementation Version 3.4.0.Final
16:17:56,227 INFO  [org.jboss.as.connector.subsystems.datasources] (ServerService Thread Pool -- 33) WFLYJCA0004: Deploying JDBC-compliant driver class org.h2.Driver (version 1.3)
16:17:56,274 INFO  [org.wildfly.extension.io] (ServerService Thread Pool -- 37) WFLYIO001: Worker 'default' has auto-configured to 8 core threads with 64 task threads based on your 4 available processors
16:17:56,274 INFO  [org.jboss.as.security] (ServerService Thread Pool -- 53) WFLYSEC0002: Activating Security Subsystem
16:17:56,290 INFO  [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 38) WFLYCLINF0001: Activating Infinispan subsystem.
16:17:56,290 INFO  [org.jboss.as.security] (MSC service thread 1-8) WFLYSEC0001: Current PicketBox version=4.9.6.Final
16:17:56,305 INFO  [org.jboss.as.webservices] (ServerService Thread Pool -- 56) WFLYWS0002: Activating WebServices Extension
16:17:56,493 WARN  [org.jboss.as.txn] (ServerService Thread Pool -- 54) WFLYTX0013: Node identifier property is set to the default value. Please make sure it is unique.
16:17:56,509 INFO  [org.jboss.as.naming] (ServerService Thread Pool -- 46) WFLYNAM0001: Activating Naming Subsystem
16:17:56,540 INFO  [org.jboss.as.connector] (MSC service thread 1-8) WFLYJCA0009: Starting JCA Subsystem (WildFly/IronJacamar 1.3.4.Final)
16:17:56,556 INFO  [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-7) WFLYJCA0018: Started Driver service with driver-name = h2
16:17:56,556 INFO  [org.jboss.as.jsf] (ServerService Thread Pool -- 44) WFLYJSF0007: Activated the following JSF Implementations: [main]
16:17:56,634 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-6) WFLYUT0003: Undertow 1.4.0.Final starting
16:17:56,743 INFO  [org.jboss.as.naming] (MSC service thread 1-7) WFLYNAM0003: Starting Naming Service
16:17:56,743 INFO  [org.jboss.as.mail.extension] (MSC service thread 1-8) WFLYMAIL0001: Bound mail session [java:jboss/mail/Default]
16:17:56,774 INFO  [org.wildfly.extension.undertow] (ServerService Thread Pool -- 55) WFLYUT0014: Creating file handler for path 'C:\sandbox\apps\wildfly-jboss\wildfly-10.1.0.Final/welcome-content' with options [directory-listing: 'false', follow-symlink: 'false', case-sensitive: 'true', safe-symlink-paths: '[]']
16:17:56,806 INFO  [org.jboss.as.ejb3] (MSC service thread 1-7) WFLYEJB0481: Strict pool slsb-strict-max-pool is using a max instance size of 64 (per class), which is derived from thread worker pool sizing.
16:17:56,806 INFO  [org.jboss.as.ejb3] (MSC service thread 1-8) WFLYEJB0482: Strict pool mdb-strict-max-pool is using a max instance size of 16 (per class), which is derived from the number of CPUs on this host.
16:17:57,462 INFO  [org.jboss.remoting] (MSC service thread 1-3) JBoss Remoting version 4.0.21.Final
16:17:57,583 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-2) WFLYUT0012: Started server default-server.
16:17:57,583 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-2) WFLYUT0018: Host default-host starting
16:17:57,708 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-1) WFLYUT0006: Undertow HTTP listener default listening on 127.0.0.1:8080
16:17:57,724 WARN  [org.jboss.as.domain.management.security] (MSC service thread 1-3) WFLYDM0111: Keystore C:\sandbox\apps\wildfly-jboss\wildfly-10.1.0.Final\standalone\configuration\application.keystore not found, it will be auto generated on first use with a self signed certificate for host localhost
16:17:57,755 INFO  [org.jboss.as.server.deployment.scanner] (MSC service thread 1-4) WFLYDS0013: Started FileSystemDeploymentService for directory C:\sandbox\apps\wildfly-jboss\wildfly-10.1.0.Final\standalone\deployments
16:17:57,771 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-6) WFLYSRV0027: Starting deployment of "demo.war" (runtime-name: "demo.war")
16:17:58,333 INFO  [org.infinispan.factories.GlobalComponentRegistry] (MSC service thread 1-7) ISPN000128: Infinispan version: Infinispan 'Chakra' 8.2.4.Final
16:17:58,442 INFO  [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-5) WFLYJCA0001: Bound data source [java:jboss/datasources/ExampleDS]
16:17:58,505 INFO  [org.infinispan.configuration.cache.EvictionConfigurationBuilder] (ServerService Thread Pool -- 59) ISPN000152: Passivation configured without an eviction policy being selected. Only manually evicted entities will be passivated.
16:17:58,510 INFO  [org.infinispan.configuration.cache.EvictionConfigurationBuilder] (ServerService Thread Pool -- 59) ISPN000152: Passivation configured without an eviction policy being selected. Only manually evicted entities will be passivated.
16:17:58,512 INFO  [org.infinispan.configuration.cache.EvictionConfigurationBuilder] (ServerService Thread Pool -- 62) ISPN000152: Passivation configured without an eviction policy being selected. Only manually evicted entities will be passivated.
16:17:58,512 INFO  [org.infinispan.configuration.cache.EvictionConfigurationBuilder] (ServerService Thread Pool -- 62) ISPN000152: Passivation configured without an eviction policy being selected. Only manually evicted entities will be passivated.
16:17:58,527 INFO  [org.infinispan.configuration.cache.EvictionConfigurationBuilder] (ServerService Thread Pool -- 60) ISPN000152: Passivation configured without an eviction policy being selected. Only manually evicted entities will be passivated.
16:17:58,527 INFO  [org.infinispan.configuration.cache.EvictionConfigurationBuilder] (ServerService Thread Pool -- 60) ISPN000152: Passivation configured without an eviction policy being selected. Only manually evicted entities will be passivated.
16:18:00,024 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-5) WFLYUT0006: Undertow HTTPS listener https listening on 127.0.0.1:8443
16:18:00,137 INFO  [org.jboss.ws.common.management] (MSC service thread 1-5) JBWS022052: Starting JBossWS 5.1.5.Final (Apache CXF 3.1.6)
16:18:01,272 INFO  [org.wildfly.extension.undertow] (ServerService Thread Pool -- 58) WFLYUT0021: Registered web context: /demo
16:18:01,321 INFO  [org.jboss.as.server] (ServerService Thread Pool -- 34) WFLYSRV0010: Deployed "demo.war" (runtime-name : "demo.war")
16:18:01,524 INFO  [org.jboss.as] (Controller Boot Thread) WFLYSRV0060: Http management interface listening on http://127.0.0.1:9990/management
16:18:01,539 INFO  [org.jboss.as] (Controller Boot Thread) WFLYSRV0051: Admin console listening on http://127.0.0.1:9990
16:18:01,539 INFO  [org.jboss.as] (Controller Boot Thread) WFLYSRV0025: WildFly Full 10.1.0.Final (WildFly Core 2.2.0.Final) started in 8168ms - Started 401 of 651 services (404 services are lazy, passive or on-demand)
</code>```

答:
I think the only practicable option is to migrate to RESTEasy when moving to WildFly.

Refer here .This is a good example.

suppose this good place to start.

Body:
I am trying to deploy a Spring Boot Application that uses JAXRS to a Wildfly server.

When I do this I get the following error:

01:58:46,787 INFO  [javax.enterprise.resource.webcontainer.jsf.config] (ServerService Thread Pool -- 62) Initializing Mojarra 2.2.13.SP1 20160303-1204 for context '/test-spring-boot-jaxrs-demo'
01:58:49,155 INFO  [org.jboss.resteasy.resteasy_jaxrs.i18n] (ServerService Thread Pool -- 62) RESTEASY002225: Deploying javax.ws.rs.core.Application: class test.spring.boot.jaxrs.demo.JerseyConfig
01:58:49,221 ERROR [org.jboss.msc.service.fail] (ServerService Thread Pool -- 62) MSC000001: Failed to start service jboss.undertow.deployment.default-server.default-host./test-spring-boot-jaxrs-demo: org.jboss.msc.service.StartException in service jboss.undertow.deployment.default-server.default-host./test-spring-boot-jaxrs-demo: java.lang.NullPointerException
    at org.wildfly.extension.undertow.deployment.UndertowDeploymentService$1.run(UndertowDeploymentService.java:85)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
    at org.jboss.threads.JBossThread.run(JBossThread.java:320)
Caused by: java.lang.NullPointerException
    at org.jboss.resteasy.core.ConstructorInjectorImpl.<init>(ConstructorInjectorImpl.java:47)
    at org.jboss.resteasy.core.InjectorFactoryImpl.createConstructor(InjectorFactoryImpl.java:53)
    at org.jboss.resteasy.spi.ResteasyProviderFactory.injectedInstance(ResteasyProviderFactory.java:2271)
    at org.jboss.resteasy.core.interception.JaxrsInterceptorRegistry$AbstractInterceptorFactory.createInterceptor(JaxrsInterceptorRegistry.java:170)
    at org.jboss.resteasy.core.interception.JaxrsInterceptorRegistry$OnDemandInterceptorFactory.initialize(JaxrsInterceptorRegistry.java:188)
    at org.jboss.resteasy.core.interception.JaxrsInterceptorRegistry$OnDemandInterceptorFactory.checkInitialize(JaxrsInterceptorRegistry.java:203)
    at org.jboss.resteasy.core.interception.JaxrsInterceptorRegistry$OnDemandInterceptorFactory.getInterceptor(JaxrsInterceptorRegistry.java:214)
    at org.jboss.resteasy.core.interception.JaxrsInterceptorRegistry$AbstractInterceptorFactory.postMatch(JaxrsInterceptorRegistry.java:151)
    at org.jboss.resteasy.core.interception.JaxrsInterceptorRegistry.postMatch(JaxrsInterceptorRegistry.java:421)
    at org.jboss.resteasy.core.ResourceMethodInvoker.<init>(ResourceMethodInvoker.java:106)
    at org.jboss.resteasy.core.ResourceMethodRegistry.processMethod(ResourceMethodRegistry.java:281)
    at org.jboss.resteasy.core.ResourceMethodRegistry.register(ResourceMethodRegistry.java:252)
    at org.jboss.resteasy.core.ResourceMethodRegistry.addResourceFactory(ResourceMethodRegistry.java:222)
    at org.jboss.resteasy.core.ResourceMethodRegistry.addResourceFactory(ResourceMethodRegistry.java:194)
    at org.jboss.resteasy.core.ResourceMethodRegistry.addResourceFactory(ResourceMethodRegistry.java:180)
    at org.jboss.resteasy.core.ResourceMethodRegistry.addResourceFactory(ResourceMethodRegistry.java:157)
    at org.jboss.resteasy.core.ResourceMethodRegistry.addPerRequestResource(ResourceMethodRegistry.java:76)
    at org.jboss.resteasy.spi.ResteasyDeployment.registration(ResteasyDeployment.java:409)
    at org.jboss.resteasy.spi.ResteasyDeployment.start(ResteasyDeployment.java:250)
    at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.init(ServletContainerDispatcher.java:113)
    at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.init(HttpServletDispatcher.java:36)
    at io.undertow.servlet.core.LifecyleInterceptorInvocation.proceed(LifecyleInterceptorInvocation.java:117)
    at org.wildfly.extension.undertow.security.RunAsLifecycleInterceptor.init(RunAsLifecycleInterceptor.java:78)
    at io.undertow.servlet.core.LifecyleInterceptorInvocation.proceed(LifecyleInterceptorInvocation.java:103)
    at io.undertow.servlet.core.ManagedServlet$DefaultInstanceStrategy.start(ManagedServlet.java:250)
    at io.undertow.servlet.core.ManagedServlet.createServlet(ManagedServlet.java:133)
    at io.undertow.servlet.core.DeploymentManagerImpl$2.call(DeploymentManagerImpl.java:546)
    at io.undertow.servlet.core.DeploymentManagerImpl$2.call(DeploymentManagerImpl.java:517)
    at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:42)
    at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43)
    at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
    at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
    at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
    at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
    at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
    at io.undertow.servlet.core.DeploymentManagerImpl.start(DeploymentManagerImpl.java:559)
    at org.wildfly.extension.undertow.deployment.UndertowDeploymentService.startContext(UndertowDeploymentService.java:101)
    at org.wildfly.extension.undertow.deployment.UndertowDeploymentService$1.run(UndertowDeploymentService.java:82)
    ... 6 more

01:58:49,221 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) WFLYCTL0013: Operation ("deploy") failed - address: ([("deployment" => "test-spring-boot-jaxrs-demo.war")]) - failure description: {
    "WFLYCTL0080: Failed services" => {"jboss.undertow.deployment.default-server.default-host./test-spring-boot-jaxrs-demo" => "org.jboss.msc.service.StartException in service jboss.undertow.deployment.default-server.default-host./test-spring-boot-jaxrs-demo: java.lang.NullPointerException
    Caused by: java.lang.NullPointerException"},
    "WFLYCTL0412: Required services that are not installed:" => ["jboss.undertow.deployment.default-server.default-host./test-spring-boot-jaxrs-demo"],
    "WFLYCTL0180: Services with missing/unavailable dependencies" => undefined
}

The last INFO message before the error talks about deploying class test.spring.boot.jaxrs.demo.JerseyConfig.  I can't seen anything wrong with this code at the moment and deploys ok in Spring Tools Suite using Tomcat 8.5.5.

Does anyone know what could be causing the problem?

JerseyConfig class:

package psd2.spring.boot.jaxrs.demo;

import javax.annotation.PostConstruct;
import javax.ws.rs.ApplicationPath;

import org.glassfish.jersey.server.ResourceConfig;
import org.springframework.stereotype.Component;

@Component
@ApplicationPath("/")
public class JerseyConfig extends ResourceConfig {

    @PostConstruct
    private void init() {
        packages("io.swagger.api");
    }
}

POM

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>io.swagger</groupId>
    <artifactId>test-spring-boot-jaxrs-demo</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>war</packaging>

    <name>test-demo</name>
    <description>Demo project for Test</description>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.5.2.RELEASE</version>
        <relativePath/>
    </parent>

    <properties>
        <start-class>test.spring.boot.jaxrs.demo.testDemoApplication</start-class>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <java.version>1.8</java.version>
        <maven.compiler.source>${java.version}</maven.compiler.source>
        <maven.compiler.target>${java.version}</maven.compiler.target>
        <swagger-core-version>1.5.12</swagger-core-version>
        <jetty-version>9.2.9.v20150224</jetty-version>
        <jersey2-version>2.22.2</jersey2-version>
        <jackson-version>2.8.7</jackson-version>
        <junit-version>4.12</junit-version>
        <logback-version>1.1.7</logback-version>
        <servlet-api-version>2.5</servlet-api-version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-jersey</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-autoconfigure</artifactId>
        </dependency>
        <dependency>
          <groupId>org.springframework.boot</groupId>
          <artifactId>spring-boot-starter-web</artifactId>
          <exclusions>
            <exclusion>
              <groupId>org.springframework.boot</groupId>
              <artifactId>spring-boot-starter-tomcat</artifactId>
            </exclusion>
          </exclusions>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-websocket</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.tomcat.embed</groupId>
            <artifactId>tomcat-embed-websocket</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-tomcat</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
          <groupId>io.swagger</groupId>
          <artifactId>swagger-jersey2-jaxrs</artifactId>
          <scope>compile</scope>
          <version>${swagger-core-version}</version>
        </dependency>
        <dependency>
          <groupId>ch.qos.logback</groupId>
          <artifactId>logback-classic</artifactId>
          <scope>compile</scope>
        </dependency>
        <dependency>
          <groupId>ch.qos.logback</groupId>
          <artifactId>logback-core</artifactId>
          <scope>compile</scope>
        </dependency>
        <dependency>
          <groupId>junit</groupId>
          <artifactId>junit</artifactId>
          <scope>test</scope>
        </dependency>
        <dependency>
          <groupId>javax.servlet</groupId>
          <artifactId>javax.servlet-api</artifactId>
          <scope>provided</scope>
        </dependency>
        <dependency>
          <groupId>org.glassfish.jersey.containers</groupId>
          <artifactId>jersey-container-servlet-core</artifactId>
        </dependency>
        <dependency>
          <groupId>org.glassfish.jersey.media</groupId>
          <artifactId>jersey-media-multipart</artifactId>
          <version>${jersey2-version}</version>
        </dependency>
        <dependency>
          <groupId>com.fasterxml.jackson.datatype</groupId>
          <artifactId>jackson-datatype-joda</artifactId>
        </dependency>
        <dependency>
          <groupId>com.fasterxml.jackson.jaxrs</groupId>
          <artifactId>jackson-jaxrs-json-provider</artifactId>
        </dependency>

        <dependency>
          <groupId>com.brsanthu</groupId>
          <artifactId>migbase64</artifactId>
          <version>2.2</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
        </dependency>

    </dependencies>

    <build>
       <finalName>test-spring-boot-jaxrs-demo</finalName>
        <plugins>
           <plugin>
              <artifactId>maven-assembly-plugin</artifactId>
              <configuration>
                <archive>
                  <manifest>
                    <mainClass>test.spring.boot.jaxrs.demo</mainClass>
                  </manifest>
                </archive>
                <descriptorRefs>
                  <descriptorRef>jar-with-dependencies</descriptorRef>
                </descriptorRefs>
              </configuration>
            </plugin>
        </plugins>
    </build>
    <repositories>
        <repository>
            <id>central</id>
            <name>Central</name>
            <url>http://central.maven.org/maven2/</url>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </repository>
        <repository>
            <id>spring-snapshots</id>
            <name>Spring Snapshots</name>
            <url>http://repo.spring.io/snapshot</url>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </repository>
        <repository>
            <id>spring-milestones</id>
            <name>Spring Milestones</name>
            <url>http://repo.spring.io/milestone</url>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </repository>
    </repositories>
    <pluginRepositories>
        <pluginRepository>
            <id>spring-snapshots</id>
            <name>Spring Snapshots</name>
            <url>http://repo.spring.io/snapshot</url>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </pluginRepository>
        <pluginRepository>
            <id>spring-milestones</id>
            <name>Spring Milestones</name>
            <url>http://repo.spring.io/milestone</url>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </pluginRepository>
    </pluginRepositories>
</project>

UPDATED: I've reverted JerseyConfig.java code back the above and amended the code to remove Application Path and application appears to deploy but I am seeing a 403 forbidden error.  This application still works when run as a spring boot application using the same URL.

Logs

16:17:53,779 INFO  [org.jboss.modules] (main) JBoss Modules version 1.5.2.Final
16:17:54,044 INFO  [org.jboss.msc] (main) JBoss MSC version 1.2.6.Final
16:17:54,138 INFO  [org.jboss.as] (MSC service thread 1-7) WFLYSRV0049: WildFly Full 10.1.0.Final (WildFly Core 2.2.0.Final) starting
16:17:56,029 INFO  [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads - 1) WFLYDS0004: Found demo.war in deployment directory. To trigger deployment create a file called demo.war.dodeploy
16:17:56,055 INFO  [org.jboss.as.server] (Controller Boot Thread) WFLYSRV0039: Creating http management service using socket-binding (management-http)
16:17:56,102 INFO  [org.xnio] (MSC service thread 1-4) XNIO version 3.4.0.Final
16:17:56,102 INFO  [org.xnio.nio] (MSC service thread 1-4) XNIO NIO Implementation Version 3.4.0.Final
16:17:56,227 INFO  [org.jboss.as.connector.subsystems.datasources] (ServerService Thread Pool -- 33) WFLYJCA0004: Deploying JDBC-compliant driver class org.h2.Driver (version 1.3)
16:17:56,274 INFO  [org.wildfly.extension.io] (ServerService Thread Pool -- 37) WFLYIO001: Worker 'default' has auto-configured to 8 core threads with 64 task threads based on your 4 available processors
16:17:56,274 INFO  [org.jboss.as.security] (ServerService Thread Pool -- 53) WFLYSEC0002: Activating Security Subsystem
16:17:56,290 INFO  [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 38) WFLYCLINF0001: Activating Infinispan subsystem.
16:17:56,290 INFO  [org.jboss.as.security] (MSC service thread 1-8) WFLYSEC0001: Current PicketBox version=4.9.6.Final
16:17:56,305 INFO  [org.jboss.as.webservices] (ServerService Thread Pool -- 56) WFLYWS0002: Activating WebServices Extension
16:17:56,493 WARN  [org.jboss.as.txn] (ServerService Thread Pool -- 54) WFLYTX0013: Node identifier property is set to the default value. Please make sure it is unique.
16:17:56,509 INFO  [org.jboss.as.naming] (ServerService Thread Pool -- 46) WFLYNAM0001: Activating Naming Subsystem
16:17:56,540 INFO  [org.jboss.as.connector] (MSC service thread 1-8) WFLYJCA0009: Starting JCA Subsystem (WildFly/IronJacamar 1.3.4.Final)
16:17:56,556 INFO  [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-7) WFLYJCA0018: Started Driver service with driver-name = h2
16:17:56,556 INFO  [org.jboss.as.jsf] (ServerService Thread Pool -- 44) WFLYJSF0007: Activated the following JSF Implementations: [main]
16:17:56,634 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-6) WFLYUT0003: Undertow 1.4.0.Final starting
16:17:56,743 INFO  [org.jboss.as.naming] (MSC service thread 1-7) WFLYNAM0003: Starting Naming Service
16:17:56,743 INFO  [org.jboss.as.mail.extension] (MSC service thread 1-8) WFLYMAIL0001: Bound mail session [java:jboss/mail/Default]
16:17:56,774 INFO  [org.wildfly.extension.undertow] (ServerService Thread Pool -- 55) WFLYUT0014: Creating file handler for path 'C:\sandbox\apps\wildfly-jboss\wildfly-10.1.0.Final/welcome-content' with options [directory-listing: 'false', follow-symlink: 'false', case-sensitive: 'true', safe-symlink-paths: '[]']
16:17:56,806 INFO  [org.jboss.as.ejb3] (MSC service thread 1-7) WFLYEJB0481: Strict pool slsb-strict-max-pool is using a max instance size of 64 (per class), which is derived from thread worker pool sizing.
16:17:56,806 INFO  [org.jboss.as.ejb3] (MSC service thread 1-8) WFLYEJB0482: Strict pool mdb-strict-max-pool is using a max instance size of 16 (per class), which is derived from the number of CPUs on this host.
16:17:57,462 INFO  [org.jboss.remoting] (MSC service thread 1-3) JBoss Remoting version 4.0.21.Final
16:17:57,583 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-2) WFLYUT0012: Started server default-server.
16:17:57,583 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-2) WFLYUT0018: Host default-host starting
16:17:57,708 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-1) WFLYUT0006: Undertow HTTP listener default listening on 127.0.0.1:8080
16:17:57,724 WARN  [org.jboss.as.domain.management.security] (MSC service thread 1-3) WFLYDM0111: Keystore C:\sandbox\apps\wildfly-jboss\wildfly-10.1.0.Final\standalone\configuration\application.keystore not found, it will be auto generated on first use with a self signed certificate for host localhost
16:17:57,755 INFO  [org.jboss.as.server.deployment.scanner] (MSC service thread 1-4) WFLYDS0013: Started FileSystemDeploymentService for directory C:\sandbox\apps\wildfly-jboss\wildfly-10.1.0.Final\standalone\deployments
16:17:57,771 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-6) WFLYSRV0027: Starting deployment of "demo.war" (runtime-name: "demo.war")
16:17:58,333 INFO  [org.infinispan.factories.GlobalComponentRegistry] (MSC service thread 1-7) ISPN000128: Infinispan version: Infinispan 'Chakra' 8.2.4.Final
16:17:58,442 INFO  [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-5) WFLYJCA0001: Bound data source [java:jboss/datasources/ExampleDS]
16:17:58,505 INFO  [org.infinispan.configuration.cache.EvictionConfigurationBuilder] (ServerService Thread Pool -- 59) ISPN000152: Passivation configured without an eviction policy being selected. Only manually evicted entities will be passivated.
16:17:58,510 INFO  [org.infinispan.configuration.cache.EvictionConfigurationBuilder] (ServerService Thread Pool -- 59) ISPN000152: Passivation configured without an eviction policy being selected. Only manually evicted entities will be passivated.
16:17:58,512 INFO  [org.infinispan.configuration.cache.EvictionConfigurationBuilder] (ServerService Thread Pool -- 62) ISPN000152: Passivation configured without an eviction policy being selected. Only manually evicted entities will be passivated.
16:17:58,512 INFO  [org.infinispan.configuration.cache.EvictionConfigurationBuilder] (ServerService Thread Pool -- 62) ISPN000152: Passivation configured without an eviction policy being selected. Only manually evicted entities will be passivated.
16:17:58,527 INFO  [org.infinispan.configuration.cache.EvictionConfigurationBuilder] (ServerService Thread Pool -- 60) ISPN000152: Passivation configured without an eviction policy being selected. Only manually evicted entities will be passivated.
16:17:58,527 INFO  [org.infinispan.configuration.cache.EvictionConfigurationBuilder] (ServerService Thread Pool -- 60) ISPN000152: Passivation configured without an eviction policy being selected. Only manually evicted entities will be passivated.
16:18:00,024 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-5) WFLYUT0006: Undertow HTTPS listener https listening on 127.0.0.1:8443
16:18:00,137 INFO  [org.jboss.ws.common.management] (MSC service thread 1-5) JBWS022052: Starting JBossWS 5.1.5.Final (Apache CXF 3.1.6)
16:18:01,272 INFO  [org.wildfly.extension.undertow] (ServerService Thread Pool -- 58) WFLYUT0021: Registered web context: /demo
16:18:01,321 INFO  [org.jboss.as.server] (ServerService Thread Pool -- 34) WFLYSRV0010: Deployed "demo.war" (runtime-name : "demo.war")
16:18:01,524 INFO  [org.jboss.as] (Controller Boot Thread) WFLYSRV0060: Http management interface listening on http://127.0.0.1:9990/management
16:18:01,539 INFO  [org.jboss.as] (Controller Boot Thread) WFLYSRV0051: Admin console listening on http://127.0.0.1:9990
16:18:01,539 INFO  [org.jboss.as] (Controller Boot Thread) WFLYSRV0025: WildFly Full 10.1.0.Final (WildFly Core 2.2.0.Final) started in 8168ms - Started 401 of 651 services (404 services are lazy, passive or on-demand)


来源: stackexchange

问:
Insert read only strings into jTextArea
I am working in a translator that receive relational algebra expressions and translates them into SQL queries, I've already made the translator code, but I'm having some trouble validating the user's inputs.

The translator works with buttons that insert a default expression in the text area and gives the user a blank space to enter some parameters, here's an example:

```<code> Seleccionar(-the user enters parameters here-)( -the user enters parameters here- )
</code>```

Is there a way to make the word "Seleccionar" and the brackets read-only? So the user can't edit the default expressions?

答: Checkout this plugin Input Mask Plugin. It supports regex mask. You can use a regex like /Seleccionar\(.*?\)\(.*?\)/g to validate your input. Other way to go about is to simply use a separate input for each individual parameter.

ContentLicense: CC BY-SA 3.0

Title: Insert read only strings into jTextArea

Body:
I am working in a translator that receive relational algebra expressions and translates them into SQL queries, I've already made the translator code, but I'm having some trouble validating the user's inputs.

The translator works with buttons that insert a default expression in the text area and gives the user a blank space to enter some parameters, here's an example:

 Seleccionar(-the user enters parameters here-)( -the user enters parameters here- )

Is there a way to make the word "Seleccionar" and the brackets read-only? So the user can't edit the default expressions?


问:
How to update a table with joining two other tables
We have three tables here, Session table which is connected to Green_fact table with Session_id field. Time_session table is the third table which is made of SessionDate from Session table with a primary key for every single day.

How can I populate the Date_ID field in Green_fact table.
the code below is what I think use, but it doesn't work properly

```<code>update green_fact
   inner join "SESSION" on green_fact."SESSION_ID" = "SESSION"."SessionID"
   inner join "TIME_SESSION" on "TIME_SESSION"."SESSION_DATE" = "SESSION"."SessionDate"
   set green_fact."DATE_ID" = "TIME_SESSION"."ID" where green_fact."SESSION_ID" = "SESSION"."SessionID";
</code>```

答:
Oracle doesn't allow joins to be used in UPDATE statements, but sometimes one can rewrite such a statement as a MERGE (you don't specify the version of Oracle you're using, but since 10g one can omit the WHEN MATCHED or WHEN NOT MATCHED clauses of the MERGE):

```<code>MERGE INTO green_fact gf
USING (
    SELECT s."SessionID", ts.session_date, ts.id
      FROM session s INNER JOIN time_session ts
        ON s."SessionDate" = ts.session_date ) ts1
   ON ( gf.session_id = ts1."SessionID" )
 WHEN MATCHED THEN
   UPDATE
      SET gf.date_id = ts1.id;
</code>```

Hope this helps.

By the way, I cannot stress enough that mixed-case object names in Oracle are a bad idea. But maybe you're dealing with legacy data and don't have a choice.

Body:
We have three tables here, Session table which is connected to Green_fact table with Session_id field. Time_session table is the third table which is made of SessionDate from Session table with a primary key for every single day.

How can I populate the Date_ID field in Green_fact table.
the code below is what I think use, but it doesn't work properly

update green_fact
   inner join "SESSION" on green_fact."SESSION_ID" = "SESSION"."SessionID"
   inner join "TIME_SESSION" on "TIME_SESSION"."SESSION_DATE" = "SESSION"."SessionDate"
   set green_fact."DATE_ID" = "TIME_SESSION"."ID" where green_fact."SESSION_ID" = "SESSION"."SessionID";

Body:
Oracle doesn't allow joins to be used in UPDATE statements, but sometimes one can rewrite such a statement as a MERGE (you don't specify the version of Oracle you're using, but since 10g one can omit the WHEN MATCHED or WHEN NOT MATCHED clauses of the MERGE):

MERGE INTO green_fact gf
USING (
    SELECT s."SessionID", ts.session_date, ts.id
      FROM session s INNER JOIN time_session ts
        ON s."SessionDate" = ts.session_date ) ts1
   ON ( gf.session_id = ts1."SessionID" )
 WHEN MATCHED THEN
   UPDATE
      SET gf.date_id = ts1.id;

Hope this helps.

By the way, I cannot stress enough that mixed-case object names in Oracle are a bad idea. But maybe you're dealing with legacy data and don't have a choice.


问:
ajax call to php not working 404 error mismatched localhost
I'm using xampp on my Windows 10 dev machine and when I launch my javascript app using chrome, the browser uses localhost:8080 as the root directory.

For my php ajax calls, I have to use the fully qualified path to get them to work. For example:

```<code>$.ajax({
        type: "GET",
        dataType: "json",
        url: "http://localhost/get_user.php",
        data: {email: $("#email").val()}
    });
</code>```

Note that I have to use localhost for the ajax calls whereas the javascript root is localhost:8080. My php files are stored locally in c:/xampp/htdocs.

I want to use a short form url that works on both my local dev machine and on the production website. Something like

```<code>$.ajax({
        type: "GET",
        dataType: "json",
        url: "/get_user.php",
        data: {email: $("#email").val()}
    });
</code>```

My understanding (and I'm new to this) is that if I use the short form url /get_user.php the system uses the same root as the client side app (i.e. http://localhost:8080/get_user.php). But only fully qualified http://localhost/get_user.php is working for my ajax calls.

I get the following error message when using the short form /get_user.php:

GET
  http://localhost:8080/check_login.php?password=xxxxxxxxxx&email=drew%40aol.com
  404 (Not Found)

So the client side uses localhost:8080 and the server side expects localhost. I'm sure this is probably an xampp config issue but haven't been able to solve on my own. Any insight would be appreciated.

答: Try changing your data type to jsonp rather than json. I think you are running into a cross-origin resource sharing problem. A permission problem, essentially. localhost and localhost:8080 are two different domains, as far as your browser is concerned. If your code is executed from localhost:8080 and you give it a relative url, like /something.php, it assumes you are requesting it from the same domain. localhost is equivalent to localhost:80. </p>

Body:
I'm using xampp on my Windows 10 dev machine and when I launch my javascript app using chrome, the browser uses localhost:8080 as the root directory.

For my php ajax calls, I have to use the fully qualified path to get them to work. For example:

$.ajax({
        type: "GET",
        dataType: "json",
        url: "http://localhost/get_user.php",
        data: {email: $("#email").val()}
    });

Note that I have to use localhost for the ajax calls whereas the javascript root is localhost:8080. My php files are stored locally in c:/xampp/htdocs.

I want to use a short form url that works on both my local dev machine and on the production website. Something like

$.ajax({
        type: "GET",
        dataType: "json",
        url: "/get_user.php",
        data: {email: $("#email").val()}
    });

My understanding (and I'm new to this) is that if I use the short form url /get_user.php the system uses the same root as the client side app (i.e. http://localhost:8080/get_user.php). But only fully qualified http://localhost/get_user.php is working for my ajax calls.

I get the following error message when using the short form /get_user.php:

GET
  http://localhost:8080/check_login.php?password=xxxxxxxxxx&email=drew%40aol.com
  404 (Not Found)

So the client side uses localhost:8080 and the server side expects localhost. I'm sure this is probably an xampp config issue but haven't been able to solve on my own. Any insight would be appreciated.


问:
Installing g++ 7.0.1 on Debian 8.7
I have been trying for quite some time to install g++ 7 on my Debian machine. I was able to install it quite easily on my mac (as homebrew had a formula for it). However I cannot seem to find a way to install it on Linux.

This individual had a thread on installing g++ 4.9, and changing the url he gave led me to this page, which seems to be in the right direction... But I imagine installing it this way might lead to a few potential problems down the road when I wish to update these packages.

Is there a source I'm missing? Or is there maybe a place where I can download and compile everything I need to get it running?

Thank you for your help.

Helpful Data:

My kernel is x86_64 Linux 3.16.0-4-amd64.

Edit: After following Dietrich's advice, I am now met with a new error:

```<code>Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 gcc-7 : Depends: cpp-7 (= 7-20170316-1) but it is not going to be installed
         Depends: libcc1-0 (>= 7-20170316-1) but it is not going to be installed
         Depends: binutils (>= 2.28) but 2.25-5+deb8u1 is to be installed
         Depends: libgcc-7-dev (= 7-20170316-1) but it is not going to be installed
         Depends: libisl15 (>= 0.15) but it is not installable
         Depends: libmpfr4 (>= 3.1.3) but 3.1.2-2 is to be installed
         Depends: libstdc++6 (>= 5) but 4.9.2-10 is to be installed
E: Unable to correct problems, you have held broken packages.
</code>```

This is how my sources.list is set up:

```<code>#------------------------------------------------------------------------------#
#                   OFFICIAL DEBIAN REPOS
#------------------------------------------------------------------------------#

###### Debian Main Repos
deb http://ftp.us.debian.org/debian/ jessie main contrib non-free
deb-src http://ftp.us.debian.org/debian/ jessie main contrib non-free

###### Debian Update Repos
deb http://security.debian.org/ jessie/updates main contrib non-free
deb http://ftp.us.debian.org/debian/ jessie-proposed-updates main contrib non-free
deb-src http://security.debian.org/ jessie/updates main contrib non-free
deb-src http://ftp.us.debian.org/debian/ jessie-proposed-updates main contrib non-free

###### For ffmpeg
deb http://www.deb-multimedia.org jessie main non-free

###### For gcc-7 (Experimental)
deb http://httpredir.debian.org/debian experimental main
</code>```

I'm guessing this is, as you said, a problem with me being on Debian stable? What would I need to do in order to fix this error, while remaining on stable?

Edit 2: Okay, so I figured out that last error. I just had to add go through for every individual dependency that gave my trouble and install it using apt-get install -t testing . Thank you to everyone who replied. You were all very helpful.

答:
The kernel is irrelevant.

GCC 7 has not been released yet, as you can see in the GCC 7 release notes:

Disclaimer: GCC 7 has not been released yet, so this document is a work-in-progress.

You may want to learn about what makes different Linux distros different.  In particular, what a rolling distribution is, and how Debian releases work.  In a rolling distribution, all of the packages continually get updated to newer versions.  Debian 8.7 (Jessie / stable) is not a rolling distribution.  The packages versions are frozen and only updated when necessary, for extra stability.  The latest version of GCC on Debian 8.7 is GCC 4.9.

Debian 9.0 (Stretch / testing) is a rolling release, at least until it gets frozen.  If you switch your computer to Stretch you will get GCC 6.3.

If you need something newer, you can either switch to Sid (unstable), or pin packages from Sid.

However, GCC 7 is only available in experimental because it hasn't been released yet.  You can install a single package from experimental if you like, see Debian Experimental for instructions.

Howto

Add to your /etc/apt/sources.list

```<code>https://wiki.debian.org/DebianExperimental
</code>```

Then

```<code>apt-get update
apt-get -t experimental install gcc-7
</code>```

Title: Installing g++ 7.0.1 on Debian 8.7

Body:
I have been trying for quite some time to install g++ 7 on my Debian machine. I was able to install it quite easily on my mac (as homebrew had a formula for it). However I cannot seem to find a way to install it on Linux.

This individual had a thread on installing g++ 4.9, and changing the url he gave led me to this page, which seems to be in the right direction... But I imagine installing it this way might lead to a few potential problems down the road when I wish to update these packages.

Is there a source I'm missing? Or is there maybe a place where I can download and compile everything I need to get it running?

Thank you for your help.

Helpful Data:

My kernel is x86_64 Linux 3.16.0-4-amd64.

Edit: After following Dietrich's advice, I am now met with a new error:

Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 gcc-7 : Depends: cpp-7 (= 7-20170316-1) but it is not going to be installed
         Depends: libcc1-0 (>= 7-20170316-1) but it is not going to be installed
         Depends: binutils (>= 2.28) but 2.25-5+deb8u1 is to be installed
         Depends: libgcc-7-dev (= 7-20170316-1) but it is not going to be installed
         Depends: libisl15 (>= 0.15) but it is not installable
         Depends: libmpfr4 (>= 3.1.3) but 3.1.2-2 is to be installed
         Depends: libstdc++6 (>= 5) but 4.9.2-10 is to be installed
E: Unable to correct problems, you have held broken packages.

This is how my sources.list is set up:

#------------------------------------------------------------------------------#
#                   OFFICIAL DEBIAN REPOS
#------------------------------------------------------------------------------#

###### Debian Main Repos
deb http://ftp.us.debian.org/debian/ jessie main contrib non-free
deb-src http://ftp.us.debian.org/debian/ jessie main contrib non-free

###### Debian Update Repos
deb http://security.debian.org/ jessie/updates main contrib non-free
deb http://ftp.us.debian.org/debian/ jessie-proposed-updates main contrib non-free
deb-src http://security.debian.org/ jessie/updates main contrib non-free
deb-src http://ftp.us.debian.org/debian/ jessie-proposed-updates main contrib non-free

###### For ffmpeg
deb http://www.deb-multimedia.org jessie main non-free

###### For gcc-7 (Experimental)
deb http://httpredir.debian.org/debian experimental main

I'm guessing this is, as you said, a problem with me being on Debian stable? What would I need to do in order to fix this error, while remaining on stable?

Edit 2: Okay, so I figured out that last error. I just had to add go through for every individual dependency that gave my trouble and install it using apt-get install -t testing . Thank you to everyone who replied. You were all very helpful.

Body:
The kernel is irrelevant.

GCC 7 has not been released yet, as you can see in the GCC 7 release notes:

Disclaimer: GCC 7 has not been released yet, so this document is a work-in-progress.

You may want to learn about what makes different Linux distros different.  In particular, what a rolling distribution is, and how Debian releases work.  In a rolling distribution, all of the packages continually get updated to newer versions.  Debian 8.7 (Jessie / stable) is not a rolling distribution.  The packages versions are frozen and only updated when necessary, for extra stability.  The latest version of GCC on Debian 8.7 is GCC 4.9.

Debian 9.0 (Stretch / testing) is a rolling release, at least until it gets frozen.  If you switch your computer to Stretch you will get GCC 6.3.

If you need something newer, you can either switch to Sid (unstable), or pin packages from Sid.

However, GCC 7 is only available in experimental because it hasn't been released yet.  You can install a single package from experimental if you like, see Debian Experimental for instructions.

Howto

Add to your /etc/apt/sources.list

https://wiki.debian.org/DebianExperimental

Then

apt-get update
apt-get -t experimental install gcc-7


问:
How can I access my webapp from my pc by Android emulator?
Well I'm trying to access my webapp from my android emulator device an exception is throwing: java.net.SocketException: socket failed: EACCES (Permission denied)

In browser all right:

Browser access from http://192.168.25.7:8080

But When I try to access it from my app:

App code and thrown exception

How should I make it work?

Note: I'm using Tomcat 9, vraptor to webapp and eclipse to android programming.

答:
Please make sure you have config permission to access network in AndroidManifest.xml.For example:

```<code><uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
</code>```

But you first change your IP like MoQ's suggestion.

Body:
Please make sure you have config permission to access network in AndroidManifest.xml.For example:

<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>

But you first change your IP like MoQ's suggestion.


问:
How to enable cors nodejs with express?
In summary I am using a viewer like api of dicom files called cornerstone, for this I connect to the WADO service of dc4chee to get the dicom, dcm4chee runs port 8080, and my application on node uses port 3000, so I am trying to show The browser's dicom.

https://www.npmjs.com/package/cornerstone-wado-image-loader

This is the error displayed by the browser

```<code>XMLHttpRequest can not load http: // localhost: 8080 / wado? RequestType = WADO & studyUID = 1.2.840.113704.1.111.5 ... 26513.429 & contentType = application% 2Fdicom & transferSyntax = 1.2.840.10008.1.2. In 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http: // localhost: 3000' is therefore not allowed access.
</code>```

In the documentation specified

Note that the web server must support Cross source resource sharing or the image will fail to load. If you are unable to get CORS enabled on the web server you are loading DICOM P10 instances from, you can use a reverse proxy. Here's a simple Node.js based on http-proxy that adds CORS headers that you might find useful.

And show this example code but I'm using express and this code does not work

```<code>Var http = require ('http'),
    HttpProxy = require ('http-proxy');

Var proxy = httpProxy.createProxyServer ({target: 'http: // localhost: 8042'}) .listen (8000);

Proxy.on ('proxyRes', function (proxyReq, req, res, options) {
  // add the CORS header to the response
  Res.setHeader ('Access-Control-Allow-Origin', '*');
});

Proxy.on ('error', function (e) {
  // suppress errors
});
</code>```

Also use npm cors here the code

```<code>Var express = require ('express')
Var cors = require ('cors')
Var app = express ()

App.get ('/ products /: id', cors (), function (req, res, next) {
  Res.json ({msg: 'This is CORS-enabled for a Single Route'))
})

App.listen (80, function () {
  Console.log ('CORS-enabled web server listening on port 80')
})
</code>```

But with this I enable the cors on port 3000 and not the 8080, I need the mode to activate or add 'Access-Control-Allow-Origin in headers response and not in header request,

How can I do to add CORS on port 8080 where dcm4chee runs from NODEjs?

update!

The server responds with the following;

RESPONDE HEADER

```<code>Content-Type:application/dicom
Date:Sat, 01 Apr 2017 01:15:38 GMT
Expires:0
Server:Apache-Coyote/1.1
Transfer-Encoding:chunked
X-Powered-By:Servlet 2.4; JBoss-4.2.3.GA (build: SVNTag=JBoss_4_2_3_GA
date=200807181439)/JBossWeb-2.0
</code>```

REQUEST HEADER

```<code>Accept:*/*
Accept-Encoding:gzip, deflate, sdch, br
Accept-Language:es-ES,es;q=0.8,en-US;q=0.6,en;q=0.4
Connection:keep-alive
Host:localhost:8080
Origin:http: //localhost:3000
Referer:http: //localhost:3000/
User-Agent:Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like
Gecko) Chrome/55.0.2883.87 Safari/537.36
</code>```

HOW TO ENABLE THE CORS IN RESPONSE HEADER??

答:
The error displayed by the browser means, server localhost:8080 refused a request from localhost:3000, It seems cors didn't set well on server localhost:8080.

The response header should have something like this:

```<code>Access-Control-Allow-Headers:Content-Type,Content-Length, Authorization, Accept,X-Requested-With
Access-Control-Allow-Methods:PUT,POST,GET,DELETE,OPTIONS
Access-Control-Allow-Origin:*
</code>```

Try add cors header in your 8080 server.

```<code>app.all('*', function (req, res) {
 res.header("Access-Control-Allow-Origin", "*");
 res.header("Access-Control-Allow-Headers", "Content-Type,Content-Length, Authorization, Accept,X-Requested-With");
 res.header("Access-Control-Allow-Methods", "PUT,POST,GET,DELETE,OPTIONS");
 //...
});
</code>```

ContentLicense: CC BY-SA 4.0

Title: How to enable cors nodejs with express?

Body:
In summary I am using a viewer like api of dicom files called cornerstone, for this I connect to the WADO service of dc4chee to get the dicom, dcm4chee runs port 8080, and my application on node uses port 3000, so I am trying to show The browser's dicom.

https://www.npmjs.com/package/cornerstone-wado-image-loader

This is the error displayed by the browser

XMLHttpRequest can not load http: // localhost: 8080 / wado? RequestType = WADO & studyUID = 1.2.840.113704.1.111.5 ... 26513.429 & contentType = application% 2Fdicom & transferSyntax = 1.2.840.10008.1.2. In 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http: // localhost: 3000' is therefore not allowed access.

In the documentation specified

Note that the web server must support Cross source resource sharing or the image will fail to load. If you are unable to get CORS enabled on the web server you are loading DICOM P10 instances from, you can use a reverse proxy. Here's a simple Node.js based on http-proxy that adds CORS headers that you might find useful.

And show this example code but I'm using express and this code does not work

Var http = require ('http'),
    HttpProxy = require ('http-proxy');

Var proxy = httpProxy.createProxyServer ({target: 'http: // localhost: 8042'}) .listen (8000);

Proxy.on ('proxyRes', function (proxyReq, req, res, options) {
  // add the CORS header to the response
  Res.setHeader ('Access-Control-Allow-Origin', '*');
});

Proxy.on ('error', function (e) {
  // suppress errors
});

Also use npm cors here the code

Var express = require ('express')
Var cors = require ('cors')
Var app = express ()

App.get ('/ products /: id', cors (), function (req, res, next) {
  Res.json ({msg: 'This is CORS-enabled for a Single Route'))
})

App.listen (80, function () {
  Console.log ('CORS-enabled web server listening on port 80')
})

But with this I enable the cors on port 3000 and not the 8080, I need the mode to activate or add 'Access-Control-Allow-Origin in headers response and not in header request,

How can I do to add CORS on port 8080 where dcm4chee runs from NODEjs?

update!

The server responds with the following;

RESPONDE HEADER

Content-Type:application/dicom
Date:Sat, 01 Apr 2017 01:15:38 GMT
Expires:0
Server:Apache-Coyote/1.1
Transfer-Encoding:chunked
X-Powered-By:Servlet 2.4; JBoss-4.2.3.GA (build: SVNTag=JBoss_4_2_3_GA
date=200807181439)/JBossWeb-2.0

REQUEST HEADER

Accept:*/*
Accept-Encoding:gzip, deflate, sdch, br
Accept-Language:es-ES,es;q=0.8,en-US;q=0.6,en;q=0.4
Connection:keep-alive
Host:localhost:8080
Origin:http: //localhost:3000
Referer:http: //localhost:3000/
User-Agent:Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like
Gecko) Chrome/55.0.2883.87 Safari/537.36

HOW TO ENABLE THE CORS IN RESPONSE HEADER??

Body:
The error displayed by the browser means, server localhost:8080 refused a request from localhost:3000, It seems cors didn't set well on server localhost:8080.

The response header should have something like this:

Access-Control-Allow-Headers:Content-Type,Content-Length, Authorization, Accept,X-Requested-With
Access-Control-Allow-Methods:PUT,POST,GET,DELETE,OPTIONS
Access-Control-Allow-Origin:*

Try add cors header in your 8080 server.

app.all('*', function (req, res) {
 res.header("Access-Control-Allow-Origin", "*");
 res.header("Access-Control-Allow-Headers", "Content-Type,Content-Length, Authorization, Accept,X-Requested-With");
 res.header("Access-Control-Allow-Methods", "PUT,POST,GET,DELETE,OPTIONS");
 //...
});


问:
Reading from excel/text file without skipping whitespaces unless made by a tab
I have a project on Power Plant Monitoring and it requires me to read in data from either of two files (an excel file or a text file). The data consists of 97 columns and 515 rows with a mixture of integers and strings. Hence, my idea was to declare 97 arrays to store the values in each column into their separate respective array. However, some columns contain strings with multiple words. Therefore one row may have one word in a column, while another row may have three etc. This is a problem because when I read in the rows, each string is assigned to a different string array when I want the programme to read the entire phrase as one string and store that string in the array initialised for that column. This causes the data to shift and some data is not assigned to the correct array etc.

I have a basic knowledge of C++, nothing spectacular but if I am not mistaken istreams stops reading when it meets a space and does not differentiate between tab spaces or normal spacebar spaces. Can anyone help me fix this problem so I could store the data properly and develop my KPIs?

I have included a portion of my data and also an attempt of trying to read in 4 columns of the code. Note that each column is separated by a tab in the text file version of the data.

```<code>ID Com NID  Plant                    Operator
3   N       Rock                     Alabama Elec Co
3   N       Rock                     Alabama Elec Co
4   N       Walt Boulder Co          Alabama Elec Co
10  N   3   Greene County            Alabama Elec Co
46  N   1   Browns Ferry             Tennessee Valley Authority
</code>```

ID Com NID  Plant                    Operator
3   N       Rock                     Alabama Elec Co
3   N       Rock                     Alabama Elec Co
4   N       Walt Boulder Co          Alabama Elec Co
10  N   3   Greene County            Alabama Elec Co

46  N   1   Browns Ferry             Tennessee Valley Authority

Illustrating the problem I am experiencing, if I have 4 string arrays for the four columns, in the first row, 3 would assign to array1, N to array2, Rock to array3 and Elec to array4. However, in row 3, 4 would assign to array1, N would assign to array2, Walt to array 3 but Boulder would assign to array 4 instead of the entire plant name being stored.
A similar fate occurs in row 5 which messes up the organisation of the data and does not allow me to manipulate it properly and accurately.

```<code>//numLines is taken from previous code to determine the
//number of lines in the file
std::string *ID = new std::string[numLines];
std::string *YN = new std::string[numLines];
std::string *nuclearID = new std::string[numLines];
std::string *plantName = new std::string[numLines];

std::ifstream infile;
infile.open("nocommagenerationdata.dat");
if (infile.is_open()) {
    int i = 0;
    while (i<numLines) {
        infile >> ID[i] >> YN[i] >> nuclearID[i] >> plantName[i];
        std::cout << ID[i] << YN[i] << nuclearID[i] << plantName[i] << std::endl;

        i++;
    }

}
infile.close();
</code>```

I also initially tried initialising a string with a counter to see if the data in one row lines up with the other but it clearly showed that the data shifted because of the selfsame reading in a string with a space problem.

```<code>std::ifstream infile;
infile.open("nocommagenerationdata.dat");
if (infile.is_open()) {
    int i = 0; std::string temp;
    while (i<numLines) {
        infile >> temp;
        std::cout << i << "." << temp << std::endl;

        i++;
    }

}
infile.close();
</code>```

I would appreciate any assistance

答:
Just some hints.

Define a struct or class that represents the records you are reading from the file. You will only need one array to hold the records as they are constructed from each line in the file.

Investigate how to use std::getline to read each line in your file and std::strtok to parse each line for record data.

This will work for your tab-delimited text file. If your excel file is not tab-delimited, then you need to save a copy as tab-delimited.

Body:
I have a project on Power Plant Monitoring and it requires me to read in data from either of two files (an excel file or a text file). The data consists of 97 columns and 515 rows with a mixture of integers and strings. Hence, my idea was to declare 97 arrays to store the values in each column into their separate respective array. However, some columns contain strings with multiple words. Therefore one row may have one word in a column, while another row may have three etc. This is a problem because when I read in the rows, each string is assigned to a different string array when I want the programme to read the entire phrase as one string and store that string in the array initialised for that column. This causes the data to shift and some data is not assigned to the correct array etc.

I have a basic knowledge of C++, nothing spectacular but if I am not mistaken istreams stops reading when it meets a space and does not differentiate between tab spaces or normal spacebar spaces. Can anyone help me fix this problem so I could store the data properly and develop my KPIs?

I have included a portion of my data and also an attempt of trying to read in 4 columns of the code. Note that each column is separated by a tab in the text file version of the data.

ID Com NID  Plant                    Operator
3   N       Rock                     Alabama Elec Co
3   N       Rock                     Alabama Elec Co
4   N       Walt Boulder Co          Alabama Elec Co
10  N   3   Greene County            Alabama Elec Co
46  N   1   Browns Ferry             Tennessee Valley Authority

ID Com NID  Plant                    Operator
3   N       Rock                     Alabama Elec Co
3   N       Rock                     Alabama Elec Co
4   N       Walt Boulder Co          Alabama Elec Co
10  N   3   Greene County            Alabama Elec Co

46  N   1   Browns Ferry             Tennessee Valley Authority

Illustrating the problem I am experiencing, if I have 4 string arrays for the four columns, in the first row, 3 would assign to array1, N to array2, Rock to array3 and Elec to array4. However, in row 3, 4 would assign to array1, N would assign to array2, Walt to array 3 but Boulder would assign to array 4 instead of the entire plant name being stored.
A similar fate occurs in row 5 which messes up the organisation of the data and does not allow me to manipulate it properly and accurately.

//numLines is taken from previous code to determine the
//number of lines in the file
std::string *ID = new std::string[numLines];
std::string *YN = new std::string[numLines];
std::string *nuclearID = new std::string[numLines];
std::string *plantName = new std::string[numLines];

std::ifstream infile;
infile.open("nocommagenerationdata.dat");
if (infile.is_open()) {
    int i = 0;
    while (i<numLines) {
        infile >> ID[i] >> YN[i] >> nuclearID[i] >> plantName[i];
        std::cout << ID[i] << YN[i] << nuclearID[i] << plantName[i] << std::endl;

        i++;
    }

}
infile.close();

I also initially tried initialising a string with a counter to see if the data in one row lines up with the other but it clearly showed that the data shifted because of the selfsame reading in a string with a space problem.

std::ifstream infile;
infile.open("nocommagenerationdata.dat");
if (infile.is_open()) {
    int i = 0; std::string temp;
    while (i<numLines) {
        infile >> temp;
        std::cout << i << "." << temp << std::endl;

        i++;
    }

}
infile.close();

I would appreciate any assistance


问:
Get position of string from "right to left"
it's me again.

This time I need help for find the position of a string, but from right to left.

Ex:

The new car is: > SUV Ford (user file: 1191.jpg), OK ;)

Failure was in battery: >> Pickup Chevrolet (user file: 23.jpg), BAD :'(

The new car is: > SUV Kia (user file: 8.jpg), OK ;)

The new car is: > SUV Toyota (user file: 27411058.jpg), OK ;)

Failure was in battery: >>> SUV Dodge (user file: 9409.jpg), BAD, Priority

So, I'd like get the position of 'NUMBER.jpg', but from right to left:

Index #: 8 --> right to left

Index #: 10 --> right to left

Index #: 8 --> right to left

Index #: 8 --> right to left

Index #: 16 --> right to left

How can I do it in python 2.7?

@dot.Py Where are you? I need your support.

答:
Result is in capture group 1.

Starts from the end (far right) and backtracks until it finds it.

This is the fastest way it can be done (engines optimize this for speed).

.*((?<!\d)\d+\.jpg)

Expanded

```<code> .*
 (                             # (1 start)
      (?<! \d )
      \d+
      \. jpg
 )                             # (1 end)
</code>```

Body:
Result is in capture group 1.

Starts from the end (far right) and backtracks until it finds it.

This is the fastest way it can be done (engines optimize this for speed).

.*((?<!\d)\d+\.jpg)

Expanded

 .*
 (                             # (1 start)
      (?<! \d )
      \d+
      \. jpg
 )                             # (1 end)


问:
Synchronize Ajax Requests
I have ajax requests (multiple) coming to my servlet.
Each Request is created on the onBlur of the text box.
I have a total of 3 such text boxes.
I have a requirement that when the response of the firt result comes, then only should the next request be fired.
Please let me know if any one has worked on anything like this.
I am using Dojo/Digit on client side and simple java Servlet at the server side.
Thanks.</p>

答:
You can put an attribute on a node before sending the ajax request. In the call back function you can change the attribute on the node. Before sending any ajax requests you can check this attribute and if already one ajax request is being processed you can avoid sending new request.

It is better to give the user an indication that already one request is being processed.

There is also one attribute called 'sync' http://api.dojotoolkit.org/jsdoc/dojo.xhrGet.
But making that to true is not advisable.

ContentLicense: CC BY-SA 2.5

Title: Synchronize Ajax Requests


问:
How can i add checkbox on my JTable?
This is a Drag and Drop Java Swing

Here's my code

```<code>prod.removeColumn(prod.getColumnModel().getColumn(0));

    String sql = "select prod_id,prod_description,prod_wh_name,prod_fr_name from product order by prod_description asc";
    PreparedStatement pst = con.prepareStatement(sql);
    ResultSet rs = pst.executeQuery();
    while(rs.next())
    {
        int columns = rs.getMetaData().getColumnCount();
        Object[] row = new Object[columns];
        for(int i = 1 ; i <=columns;i++)
        {
            row[i - 1] = rs.getObject(i);
        }
        ((DefaultTableModel) prod.getModel()).insertRow(rs.getRow() -1,row);
    }
</code>```

I want to add a checkbox on the left side of every data in jtable(Prod Description), Any solution for that? and can select more than one? and how can i get the data of the selected item? Thanks in advance!

答:
One way is to create a "wrapper" TableModel.

In this example a column containing check marks will be added to the left of the columns in any existing TableModel:

```<code>import java.awt.*;
import java.awt.event.*;
import java.util.*;
import javax.swing.*;
import javax.swing.table.*;

public class CheckBoxWrapperTableModel extends AbstractTableModel
{
    private ArrayList<Boolean> checkBoxes = new ArrayList<>();

    private DefaultTableModel model;
    private String columnName;

    public CheckBoxWrapperTableModel(DefaultTableModel model, String columnName)
    {
        this.model = model;
        this.columnName = columnName;

        for (int i = 0; i < model.getRowCount(); i++)
            checkBoxes.add( Boolean.FALSE );
    }

    @Override
    public String getColumnName(int column)
    {
        return (column > 0) ? model.getColumnName(column - 1) : columnName;
    }

    @Override
    public int getRowCount()
    {
        return model.getRowCount();
    }

    @Override
    public int getColumnCount()
    {
        return model.getColumnCount() + 1;
    }

    @Override
    public Object getValueAt(int row, int column)
    {
        if (column > 0)
            return model.getValueAt(row, column - 1);
        else
        {
            Object value = checkBoxes.get(row);
            return (value == null) ? Boolean.FALSE : value;
        }
    }

    @Override
    public boolean isCellEditable(int row, int column)
    {
        if (column > 0)
            return model.isCellEditable(row, column - 1);
        else
            return true;
    }

    @Override
    public void setValueAt(Object value, int row, int column)
    {
        if (column > 0)
            model.setValueAt(value, row, column - 1);
        else
        {
            checkBoxes.set(row, (Boolean)value);
        }

        fireTableCellUpdated(row, column);
    }

    @Override
    public Class getColumnClass(int column)
    {
        return (column > 0) ? model.getColumnClass(column - 1) : Boolean.class;
    }

    public void removeRow(int row)
    {
        checkBoxes.remove(row);
        fireTableRowsDeleted(row, row);
        model.removeRow(row);
    }

    private static void createAndShowGUI()
    {
        //  Create the table with check marks in the first column

        DefaultTableModel model = new DefaultTableModel(5, 1);

        for (int i = 0; i < model.getRowCount(); i++)
        {
            model.setValueAt("" + i, i, 0);
        }

        CheckBoxWrapperTableModel wrapperModel = new CheckBoxWrapperTableModel(model, "Select");
        JTable table = new JTable(wrapperModel);

        //  Add button to delete selected rows

        JButton button = new JButton( "Delete Selected Rows" );
        button.addActionListener( new ActionListener()
        {
            @Override
            public void actionPerformed(ActionEvent e)
            {
                for (int i = table.getRowCount() - 1; i >= 0; i--)
                {
                    Boolean selected = (Boolean)table.getValueAt(i, 0);
                    System.out.println(selected + " : " + i);

                    if (selected)
                    {
                        wrapperModel.removeRow(i);
                    }

                }
            }
        });

        JFrame frame = new JFrame("SSCCE");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.add( new JScrollPane( table ) );
        frame.add( button, BorderLayout.PAGE_END );
        frame.pack();
        frame.setLocationByPlatform( true );
        frame.setVisible( true );
    }

    public static void main(String[] args)
    {
        EventQueue.invokeLater( () -> createAndShowGUI() );
/*
        EventQueue.invokeLater(new Runnable()
        {
            public void run()
            {
                createAndShowGUI();
            }
        });
*/
    }
}
</code>```

This allows you to add the check box even if you don't have access to the original TableModel when it is created to add your own column of check boxes.

Title: How can i add checkbox on my JTable?

Body:
This is a Drag and Drop Java Swing

Here's my code

prod.removeColumn(prod.getColumnModel().getColumn(0));

    String sql = "select prod_id,prod_description,prod_wh_name,prod_fr_name from product order by prod_description asc";
    PreparedStatement pst = con.prepareStatement(sql);
    ResultSet rs = pst.executeQuery();
    while(rs.next())
    {
        int columns = rs.getMetaData().getColumnCount();
        Object[] row = new Object[columns];
        for(int i = 1 ; i <=columns;i++)
        {
            row[i - 1] = rs.getObject(i);
        }
        ((DefaultTableModel) prod.getModel()).insertRow(rs.getRow() -1,row);
    }

I want to add a checkbox on the left side of every data in jtable(Prod Description), Any solution for that? and can select more than one? and how can i get the data of the selected item? Thanks in advance!

Body:
One way is to create a "wrapper" TableModel.

In this example a column containing check marks will be added to the left of the columns in any existing TableModel:

import java.awt.*;
import java.awt.event.*;
import java.util.*;
import javax.swing.*;
import javax.swing.table.*;

public class CheckBoxWrapperTableModel extends AbstractTableModel
{
    private ArrayList<Boolean> checkBoxes = new ArrayList<>();

    private DefaultTableModel model;
    private String columnName;

    public CheckBoxWrapperTableModel(DefaultTableModel model, String columnName)
    {
        this.model = model;
        this.columnName = columnName;

        for (int i = 0; i < model.getRowCount(); i++)
            checkBoxes.add( Boolean.FALSE );
    }

    @Override
    public String getColumnName(int column)
    {
        return (column > 0) ? model.getColumnName(column - 1) : columnName;
    }

    @Override
    public int getRowCount()
    {
        return model.getRowCount();
    }

    @Override
    public int getColumnCount()
    {
        return model.getColumnCount() + 1;
    }

    @Override
    public Object getValueAt(int row, int column)
    {
        if (column > 0)
            return model.getValueAt(row, column - 1);
        else
        {
            Object value = checkBoxes.get(row);
            return (value == null) ? Boolean.FALSE : value;
        }
    }

    @Override
    public boolean isCellEditable(int row, int column)
    {
        if (column > 0)
            return model.isCellEditable(row, column - 1);
        else
            return true;
    }

    @Override
    public void setValueAt(Object value, int row, int column)
    {
        if (column > 0)
            model.setValueAt(value, row, column - 1);
        else
        {
            checkBoxes.set(row, (Boolean)value);
        }

        fireTableCellUpdated(row, column);
    }

    @Override
    public Class getColumnClass(int column)
    {
        return (column > 0) ? model.getColumnClass(column - 1) : Boolean.class;
    }

    public void removeRow(int row)
    {
        checkBoxes.remove(row);
        fireTableRowsDeleted(row, row);
        model.removeRow(row);
    }

    private static void createAndShowGUI()
    {
        //  Create the table with check marks in the first column

        DefaultTableModel model = new DefaultTableModel(5, 1);

        for (int i = 0; i < model.getRowCount(); i++)
        {
            model.setValueAt("" + i, i, 0);
        }

        CheckBoxWrapperTableModel wrapperModel = new CheckBoxWrapperTableModel(model, "Select");
        JTable table = new JTable(wrapperModel);

        //  Add button to delete selected rows

        JButton button = new JButton( "Delete Selected Rows" );
        button.addActionListener( new ActionListener()
        {
            @Override
            public void actionPerformed(ActionEvent e)
            {
                for (int i = table.getRowCount() - 1; i >= 0; i--)
                {
                    Boolean selected = (Boolean)table.getValueAt(i, 0);
                    System.out.println(selected + " : " + i);

                    if (selected)
                    {
                        wrapperModel.removeRow(i);
                    }

                }
            }
        });

        JFrame frame = new JFrame("SSCCE");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.add( new JScrollPane( table ) );
        frame.add( button, BorderLayout.PAGE_END );
        frame.pack();
        frame.setLocationByPlatform( true );
        frame.setVisible( true );
    }

    public static void main(String[] args)
    {
        EventQueue.invokeLater( () -> createAndShowGUI() );
/*
        EventQueue.invokeLater(new Runnable()
        {
            public void run()
            {
                createAndShowGUI();
            }
        });
*/
    }
}

This allows you to add the check box even if you don't have access to the original TableModel when it is created to add your own column of check boxes.


问:
how to solve Array to string conversion when try to save data to database
i create a code like this

```<code>$peringkat=0;
$ranking = array("$ATTT[0]" => "$HA[0]", "$ATTT[1]" => "$HA[1]");
arsort($ranking);
foreach ($ranking as $alternatif => $nilaialternatif) {
$peringkat++;
echo "
<th class='akhir'><input class='rankingakhir' type='text' name='alternatif[]' value='$alternatif' size='12' readonly></th>
<td class='akhir'><input class='nilaiakhir' type='text' name='nilaialternatif[]' value=".number_format($nilaialternatif, 3, '.', ',')." size='12' readonly></td>
<td class='akhir'><input class='rankakhir' type='text' name='rankingalternatif[]' value='$peringkat' size='12' readonly></td></tr>";

}
echo '<div class="akhir"><input class="akhir" type="submit" value="Simpan Ranking ke Database"></div></table></div></div>
</code>```

my database code like this

```<code><?php  //Sript PHP
$Host = "localhost";
$User = "root";             //Memilih user/pengguna
$Password = "";             //Password, Biasanya Kosong
$db       = "spkjazuly";         //Memilih Database
$konek=mysql_connect($Host,$User,$Password)or die (mysql_error());
mysql_select_db ($db,$konek) or die (mysql_error("TIdak Terhubung Ke Server Mysql")); //Menghubungkan ke Mysql dan memilih Database
mysql_query("insert INTO ranking (idr,alternatif,nilai,ranking) VALUE(DEFAULT,'$_GET[alternatif]','$_GET[nilaialternatif]','$_GET[rankingalternatif]')") //Perintah Mysql untuk mengisi tabel Tamu
or die(mysql_error("Tidak Berhasil Menyimpan !"));  //Or Die (mysql_error()) Pesan Error
echo "<h1>Berhasil Menyimpan Data</h1>";
?>
</code>```

i try run var_dump and the result is like this

```<code>array(3) { ["alternatif"]=> array(2) { [0]=> string(12) "Alternatif 1" [1]=> string(12) "Alternatif 2" } ["nilaialternatif"]=> array(2) { [0]=> string(5) "0.628" [1]=> string(5) "0.372" } ["rankingalternatif"]=> array(2) { [0]=> string(1) "1" [1]=> string(1) "2" } }
</code>```

error displaying

table live desain

database table

答:
First of all Do not use mysql_* as ther are deprecated. Use mysqli or PDO instead. The error is here:

```<code>VALUE(DEFAULT,'$_GET[alternatif]','$_GET[nilaialternatif]','$_GET[rankingalternatif]')")
</code>```

as

```<code>["alternatif"]=> array(2)
</code>```

and you can't directly insert an array in a table column.

Body:
i create a code like this

$peringkat=0;
$ranking = array("$ATTT[0]" => "$HA[0]", "$ATTT[1]" => "$HA[1]");
arsort($ranking);
foreach ($ranking as $alternatif => $nilaialternatif) {
$peringkat++;
echo "
<input class='rankingakhir' type='text' name='alternatif[]' value='$alternatif' size='12' readonly>
<input class='nilaiakhir' type='text' name='nilaialternatif[]' value=".number_format($nilaialternatif, 3, '.', ',')." size='12' readonly>
<input class='rankakhir' type='text' name='rankingalternatif[]' value='$peringkat' size='12' readonly>
";

}
echo '
<input class="akhir" type="submit" value="Simpan Ranking ke Database">

my database code like this

<?php  //Sript PHP
$Host = "localhost";
$User = "root";             //Memilih user/pengguna
$Password = "";             //Password, Biasanya Kosong
$db       = "spkjazuly";         //Memilih Database
$konek=mysql_connect($Host,$User,$Password)or die (mysql_error());
mysql_select_db ($db,$konek) or die (mysql_error("TIdak Terhubung Ke Server Mysql")); //Menghubungkan ke Mysql dan memilih Database
mysql_query("insert INTO ranking (idr,alternatif,nilai,ranking) VALUE(DEFAULT,'$_GET[alternatif]','$_GET[nilaialternatif]','$_GET[rankingalternatif]')") //Perintah Mysql untuk mengisi tabel Tamu
or die(mysql_error("Tidak Berhasil Menyimpan !"));  //Or Die (mysql_error()) Pesan Error
echo "
Berhasil Menyimpan Data
";
?>

i try run var_dump and the result is like this

array(3) { ["alternatif"]=> array(2) { [0]=> string(12) "Alternatif 1" [1]=> string(12) "Alternatif 2" } ["nilaialternatif"]=> array(2) { [0]=> string(5) "0.628" [1]=> string(5) "0.372" } ["rankingalternatif"]=> array(2) { [0]=> string(1) "1" [1]=> string(1) "2" } }

error displaying

table live desain

database table

Body:
First of all Do not use mysql_* as ther are deprecated. Use mysqli or PDO instead. The error is here:

VALUE(DEFAULT,'$_GET[alternatif]','$_GET[nilaialternatif]','$_GET[rankingalternatif]')")

as

["alternatif"]=> array(2)

and you can't directly insert an array in a table column.


问:
Root.plist app settings missing when debugging
I have created a settings bundle and Root.plist.  When I run my app using the Release|iPhoneSimulator build I can see and edit my settings in the "Settings app" just fine, as expected.

However when I run my app in Debug|iPhoneSimulation mode my settings are gone and replaced by the Debugger Settings.  Is there a way to keep my original Root.plist settings intack while debugging??

I must be doing something stupid because I can't find any references to anyone else having this problem.

Thanks.

答:
Looks like the examples I've been using to figure out how to do this are bogus.

To resolve the issue I deleted the Root.plist and then re-added it by doing a Add..New File...Property List.  Once I added my custom settings to this plist everything started working.

So if you see examples (such as this one, http://conceptdev.blogspot.com/2009/08/monotouch-settingsbundle.html) where they are telling you to manually create an xml file and then rename it to Root.plist, don't do this.  It doesn't work.