问:
Is it possible to use thymeleaf variables to sum them in JS?
Here is the form I have ( many dishes where each has an input number ( quantity of dishes to order ).

The problem is that I would like to show the price of an order before the order is done, for this I need to sum somehow input of the ${dish.price}, but how can this be done?

```<code>    <form action="#" th:action="@{/menu}" th:object="${order}" method="post">

    <div th:each="dish : ${dishList}">
                    <div>
                        <h4 th:inline="text">[[${dish.name}]]<span class="price" th:text="${dish.price}">45</span></h4>
                        <p th:text="${dish.category}">DRINKS</p>
                        <p th:text="${dish.description}">
                            Aperiam tempore sit,perferendis numquam repudiandae porro
                            voluptate dicta saepe facilis.
                        </p>
                        <div>
                            <button class="decrement" type="button" onclick="stepperDecrement(this)">-</button>
                            <input
                                    th:value="0"
                                    th:name="${'dishIdQuantityMap[' + dish.id + ']'}"
                                    type="number"
                                    min="0"
                                    max="100"
                                    step="1"
                            />
                            <button class="increment" type="button" onclick="stepperIncrement(this)">+</button>
                        </div>
                    </div>
                </div>
            </div>
            <button type="submit" value="Submit">Confirm order</button>

</form>
</code>```

JS ( Just inputs +1 to input type"number" when the button is clicked )

```<code>    function stepperDecrement(btn){
    const inputEl = btn.nextElementSibling;
    const calcStep =inputEl.step * -1;
    const newValue = parseInt(inputEl.value) + calcStep;
    if(newValue >= inputEl.min && newValue <= inputEl.max){
        inputEl.value = newValue;
    }
}
function stepperIncrement(btn){
    const inputEl = btn.previousElementSibling;
    const calcStep = inputEl.step * 1;
    const newValue = parseInt(inputEl.value) + calcStep;
    if(newValue >= inputEl.min && newValue <= inputEl.max){
        inputEl.value = newValue;
    }
}
</code>```

Body:
Here is the form I have ( many dishes where each has an input number ( quantity of dishes to order ).

The problem is that I would like to show the price of an order before the order is done, for this I need to sum somehow input of the ${dish.price}, but how can this be done?

    <form action="#" th:action="@{/menu}" th:object="${order}" method="post">

[[${dish.name}]]45

DRINKS

                            Aperiam tempore sit,perferendis numquam repudiandae porro
                            voluptate dicta saepe facilis.

                            <button class="decrement" type="button" onclick="stepperDecrement(this)">-</button>
                            <input
                                    th:value="0"
                                    th:name="${'dishIdQuantityMap[' + dish.id + ']'}"
                                    type="number"
                                    min="0"
                                    max="100"
                                    step="1"
                            />
                            <button class="increment" type="button" onclick="stepperIncrement(this)">+</button>

            <button type="submit" value="Submit">Confirm order</button>

</form>

JS ( Just inputs +1 to input type"number" when the button is clicked )

    function stepperDecrement(btn){
    const inputEl = btn.nextElementSibling;
    const calcStep =inputEl.step * -1;
    const newValue = parseInt(inputEl.value) + calcStep;
    if(newValue >= inputEl.min && newValue <= inputEl.max){
        inputEl.value = newValue;
    }
}
function stepperIncrement(btn){
    const inputEl = btn.previousElementSibling;
    const calcStep = inputEl.step * 1;
    const newValue = parseInt(inputEl.value) + calcStep;
    if(newValue >= inputEl.min && newValue <= inputEl.max){
        inputEl.value = newValue;
    }
}

Body:
Of course yes, it is possible.

To get server data inside your thymeleaf templates, you can proceed various ways, and it depends on the context where you need that data.

Inside Javascript, (CSP "script-src 'unsafe-inline' ..." or <script th:inline="javascript" nonce="" ...> are required because writing JS inline is a bad way regarding all XSS caveats. Thanks OWASP), you can try to write : let productCategory = /*[[${productCategory}]]*/ '';

Inside Javascript with ES6+ modules (with webpack or any other solution), you can check an endpoint of your webapp (using Promise feature with polyfill) which will load data inside a form input element. And make your operations as usual. Have fun.


来源: stackexchange

问:
Split String at First Occurrence of an Integer using R
Note I have already read Split string at first occurrence of an integer in a string however my request is different because I would like to use R.

Suppose I have the following example data frame:

```<code>> df = data.frame(name_and_address =
      c("Mr. Smith12 Some street",
        "Mr. Jones345 Another street",
        "Mr. Anderson6 A different street"))
> df
                  name_and_address
1          Mr. Smith12 Some street
2      Mr. Jones345 Another street
3 Mr. Anderson6 A different street
</code>```

I would like to split the string at the first occurrence of an integer. Notice that the integers are of varying length.

The desired output can be like the following:

```<code>[[1]]
[1] "Mr. Smith"
[2] "12 Some street",

[[2]]
[1] "Mr. Jones"
[2] "345 Another street",

[[3]]
[1] "Mr. Anderson"
[2] "6 A different street"
</code>```

I have tried the following but I can not get the regular expression correct:

```<code># Attempt 1 (Does not work)
library(data.table)
tstrsplit(df,'(?=\\d+)', perl=TRUE, type.convert=TRUE)

# Attempt 2 (Does not work)
library(stringr)
str_split(df, "\\d+")
</code>```

答:
You can use tidyr::extract:

library(tidyr)
df <- df %>%
    extract("name_and_address", c("name", "address"), "(\\D*)(\\d.*)")
## => df
##           name              address
## 1    Mr. Smith       12 Some street
## 2    Mr. Jones   345 Another street
## 3 Mr. Anderson 6 A different street
```
<p>The <code>(\D*)(\d.*)</code> regex matches the following:</p>
<ul>
<li><code>(\D*)</code> - Group 1: any zero or more non-digit chars</li>
<li><code>(\d.*)</code>  - Group 2: a digit and then any zero or more chars as many as possible.</li>
</ul>
<p>Another solution with <code>stringr::str_split</code> is also possible:</p>
<pre class="lang-r prettyprint-override"><code>str_split(df$name_and_address, "(?=\\d)", n=2)
## => [[1]]
## [1] "Mr. Smith"      "12 Some street"

## [[2]]
## [1] "Mr. Jones"          "345 Another street"

## [[3]]
## [1] "Mr. Anderson"         "6 A different street"
</code>```

The (?=\d) positive lookahead finds a location before a digit, and n=2 tells stringr::str_split to only split into 2 chunks max.

Base R approach that does not return anything if there is no digit in the string:

df = data.frame(name_and_address = c("Mr. Smith12 Some street", "Mr. Jones345 Another street", "Mr. Anderson6 A different street", "1 digit is at the start", "No digits, sorry."))

df$name <- sub("^(?:(\\D*)\\d.*|.+)", "\\1", df$name_and_address)
df$address <- sub("^\\D*(\\d.*)?", "\\1", df$name_and_address)
df$name
# => [1] "Mr. Smith"    "Mr. Jones"    "Mr. Anderson" ""             ""
df$address
# => [1] "12 Some street"          "345 Another street"
#    [3] "6 A different street"    "1 digit is at the start"         ""
```

See an online R demo. This also supports cases when the first digit is the first char in the string.

ContentLicense: CC BY-SA 4.0

Body:
Note I have already read Split string at first occurrence of an integer in a string however my request is different because I would like to use R.

Suppose I have the following example data frame:

> df = data.frame(name_and_address =
      c("Mr. Smith12 Some street",
        "Mr. Jones345 Another street",
        "Mr. Anderson6 A different street"))
> df
                  name_and_address
1          Mr. Smith12 Some street
2      Mr. Jones345 Another street
3 Mr. Anderson6 A different street

I would like to split the string at the first occurrence of an integer. Notice that the integers are of varying length.

The desired output can be like the following:

[[1]]
[1] "Mr. Smith"
[2] "12 Some street",

[[2]]
[1] "Mr. Jones"
[2] "345 Another street",

[[3]]
[1] "Mr. Anderson"
[2] "6 A different street"

I have tried the following but I can not get the regular expression correct:

# Attempt 1 (Does not work)
library(data.table)
tstrsplit(df,'(?=\\d+)', perl=TRUE, type.convert=TRUE)

# Attempt 2 (Does not work)
library(stringr)
str_split(df, "\\d+")

Body:
You can use tidyr::extract:

library(tidyr)
df <- df %>%
    extract("name_and_address", c("name", "address"), "(\\D*)(\\d.*)")
## => df
##           name              address
## 1    Mr. Smith       12 Some street
## 2    Mr. Jones   345 Another street
## 3 Mr. Anderson 6 A different street

The (\D*)(\d.*) regex matches the following:

(\D*) - Group 1: any zero or more non-digit chars

(\d.*)  - Group 2: a digit and then any zero or more chars as many as possible.

Another solution with stringr::str_split is also possible:

str_split(df$name_and_address, "(?=\\d)", n=2)
## => [[1]]
## [1] "Mr. Smith"      "12 Some street"

## [[2]]
## [1] "Mr. Jones"          "345 Another street"

## [[3]]
## [1] "Mr. Anderson"         "6 A different street"

The (?=\d) positive lookahead finds a location before a digit, and n=2 tells stringr::str_split to only split into 2 chunks max.

Base R approach that does not return anything if there is no digit in the string:

df = data.frame(name_and_address = c("Mr. Smith12 Some street", "Mr. Jones345 Another street", "Mr. Anderson6 A different street", "1 digit is at the start", "No digits, sorry."))

df$name <- sub("^(?:(\\D*)\\d.*|.+)", "\\1", df$name_and_address)
df$address <- sub("^\\D*(\\d.*)?", "\\1", df$name_and_address)
df$name
# => [1] "Mr. Smith"    "Mr. Jones"    "Mr. Anderson" ""             ""
df$address
# => [1] "12 Some street"          "345 Another street"
#    [3] "6 A different street"    "1 digit is at the start"         ""

See an online R demo. This also supports cases when the first digit is the first char in the string.


问:
Can Dokan split out sales tax into a separate transaction?
We are currently running a marketplace using Dokan where all vendor/buyer transactions are handled by PayPal Express Checkout. Most of our user base is in California where tax rates vary between cities. WooCommerce tax settings are in place based on shipping address, but currently this gets tacked onto the money that the vendor receives, so they pocket the sales tax while we foot the bill out of our own pocket.

We have tried using the PayPal for WooCommerce Multi-Account Management plugin to send a flat percentage to our own PayPal account to deal with sales tax, but since this only allows a set percentage it is not suitable for California's infinite variety of tax rates, plus it incurs another transaction fee.

Is there any feasible way we can add sales tax to the total for the buyer, pay the vendor their share, and send the sales tax to our own PayPal account (with minimal or even no 2nd transaction fee)? If this is not possible with PayPal, is there any other payment provider that could do this & which could slot into Dokan with minimal hacking?

答: If you onboard every seller for multi-party payments including the third_party_details feature PARTNER_FEE (a necessary initial setup) -- then, for every transaction you can pass amount details including all item and tax information for display/transaction record purposes, and additionally include the tax amount you wish to collect as part of the partner_fee being deducted from what the seller receives and sent to you as the facilitator. This answer goes into more detail on that last part.</p>


问:
How do I use the length of another column in Pandas as a slice argument
I am trying to remove rows from a dataframe where the first sequence of letters in the Ref column are equal to the Product column.

For example, for the input:

```<code>+---------+---------------+
| Product | Provision Ref |
+---------+---------------+
| DVX     | DVX9251       |
+---------+---------------+
| CDV     | 22CDV95       |
+---------+---------------+
| TV      | TV12369       |
+---------+---------------+
| TV      | 992TV15       |
+---------+---------------+
</code>```

Desired output:

```<code>+---------+---------------+
| Product | Provision Ref |
+---------+---------------+
| CDV     | 22CDV95       |
+---------+---------------+
| TV      | 992TV15       |
+---------+---------------+
</code>```

I have tried both of the following pieces of code but they are not working

```<code>df = df.loc[df['Provision Ref'].str[0:df['Product'].map(len)] != df['Product']]
df = df.loc[df['Provision Ref'].str[0:int(df['Product'].map(len))] != df['Product']]
</code>```

答:
We can use a row-wise .apply(), because
df['Provision Ref'].str.startswith(df['Product']) isn't vectorized like that (as @anarchy wrote).

```<code>df[~df.apply(lambda row: row['Provision Ref'].startswith(row['Product']), axis=1)]

  Product Provision Ref
1     CDV       22CDV95
3      TV       992TV15
</code>```

Body:
I am trying to remove rows from a dataframe where the first sequence of letters in the Ref column are equal to the Product column.

For example, for the input:

+---------+---------------+
| Product | Provision Ref |
+---------+---------------+
| DVX     | DVX9251       |
+---------+---------------+
| CDV     | 22CDV95       |
+---------+---------------+
| TV      | TV12369       |
+---------+---------------+
| TV      | 992TV15       |
+---------+---------------+

Desired output:

+---------+---------------+
| Product | Provision Ref |
+---------+---------------+
| CDV     | 22CDV95       |
+---------+---------------+
| TV      | 992TV15       |
+---------+---------------+

I have tried both of the following pieces of code but they are not working

df = df.loc[df['Provision Ref'].str[0:df['Product'].map(len)] != df['Product']]
df = df.loc[df['Provision Ref'].str[0:int(df['Product'].map(len))] != df['Product']]

Body:
We can use a row-wise .apply(), because
df['Provision Ref'].str.startswith(df['Product']) isn't vectorized like that (as @anarchy wrote).

df[~df.apply(lambda row: row['Provision Ref'].startswith(row['Product']), axis=1)]

  Product Provision Ref
1     CDV       22CDV95
3      TV       992TV15


问:
SEVERE: Context [/example] startup failed due to previous errors
I'm new at Java EE + Spring + Hibernate + Maven combination. Trying to make a simple project with tomcat 6.0.

Our project just fine, no problem with debugging. But when i'm trying to run the server, it gives me "Error listenerStart" all the time.

I searched all around the web for 3 days but no solution about this error. Can anyone please help me about this situation?

Thanks for your help.

-My Console Output-

```<code>    13.Eki.2013 08:32:14 org.apache.catalina.core.AprLifecycleListener init
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files\Java\jdk1.6.0_45\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Microsoft\Web Platform Installer\;C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET Web Pages\v1.0\;C:\Program Files (x86)\Windows Kits\8.0\Windows Performance Toolkit\;C:\Program Files\Microsoft SQL Server\110\Tools\Binn\;c:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\;c:\Program Files\Microsoft SQL Server\100\Tools\Binn\;c:\Program Files\Microsoft SQL Server\100\DTS\Binn\;c:\Program Files (x86)\Microsoft SQL Server\90\Tools\binn\;C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\bin\;C:\MinGW\bin;C:\Program Files (x86)\Notepad++;C:\J2ETutorial\apache-maven-3.0.5\bin;C:\Program Files\Apache Software Foundation\Tomcat 6.0\bin;C:\Program Files (x86)\SDCC\bin;.
13.Eki.2013 08:32:15 org.apache.coyote.http11.Http11Protocol init
INFO: Initializing Coyote HTTP/1.1 on http-8081
13.Eki.2013 08:32:15 org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 2219 ms
13.Eki.2013 08:32:15 org.apache.catalina.core.StandardService start
INFO: Starting service Catalina
13.Eki.2013 08:32:15 org.apache.catalina.core.StandardEngine start
INFO: Starting Servlet Engine: Apache Tomcat/6.0.37
13.Eki.2013 08:32:21 org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring root WebApplicationContext
[INFO] [08:32:21.463] Root WebApplicationContext: initialization started
[INFO] [08:32:21.881] Refreshing Root WebApplicationContext: startup date [Sun Oct 13 08:32:21 VET 2013]; root of context hierarchy
[INFO] [08:32:22.365] Loading XML bean definitions from ServletContext resource [/WEB-INF/applicationContext.xml]
[INFO] [08:32:22.689] Loading XML bean definitions from ServletContext resource [/WEB-INF/datasource-config.xml]
[INFO] [08:32:23.001] Loading XML bean definitions from ServletContext resource [/WEB-INF/webflow-config.xml]
[INFO] [08:32:23.622] Loading properties file from class path resource [datasource.properties]
[INFO] [08:32:23.626] Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@17991de1: defining beans [org.springframework.context.support.PropertySourcesPlaceholderConfigurer#0,dataSource,entityManagerFactory,transactionManager,org.springframework.aop.config.internalAutoProxyCreator,org.springframework.transaction.annotation.AnnotationTransactionAttributeSource#0,org.springframework.transaction.interceptor.TransactionInterceptor#0,org.springframework.transaction.config.internalTransactionAdvisor,org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor#0,jpaFlowExecutionListener,facesContextListener,flowExecutor,flowRegistry,org.springframework.faces.model.converter.FacesConversionService#0,org.springframework.webflow.expression.spel.WebFlowSpringELExpressionParser#0,org.springframework.faces.webflow.JsfViewFactoryCreator#0,facesFlowBuilderServices,org.springframework.web.servlet.mvc.HttpRequestHandlerAdapter#0,jsfResourceRequestHandler,org.springframework.web.servlet.handler.SimpleUrlHandlerMapping#0,org.springframework.webflow.mvc.servlet.FlowHandlerMapping#0,org.springframework.faces.webflow.JsfFlowHandlerAdapter#0,faceletsViewResolver,org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter#0,securityFlowExecutionListener]; root of factory hierarchy
[ERROR] [08:32:23.628] Context initialization failed
org.springframework.beans.factory.BeanInitializationException: Could not load properties; nested exception is java.io.FileNotFoundException: class path resource [datasource.properties] cannot be opened because it does not exist
    at org.springframework.context.support.PropertySourcesPlaceholderConfigurer.postProcessBeanFactory(PropertySourcesPlaceholderConfigurer.java:147)
    at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:681)
    at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:656)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:446)
    at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:385)
    at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:284)
    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:111)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4206)
    at org.apache.catalina.core.StandardContext.start(StandardContext.java:4705)
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057)
    at org.apache.catalina.core.StandardHost.start(StandardHost.java:840)
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057)
    at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463)
    at org.apache.catalina.core.StandardService.start(StandardService.java:525)
    at org.apache.catalina.core.StandardServer.start(StandardServer.java:754)
    at org.apache.catalina.startup.Catalina.start(Catalina.java:595)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
Caused by: java.io.FileNotFoundException: class path resource [datasource.properties] cannot be opened because it does not exist
    at org.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.java:158)
    at org.springframework.core.io.support.PropertiesLoaderSupport.loadProperties(PropertiesLoaderSupport.java:181)
    at org.springframework.core.io.support.PropertiesLoaderSupport.mergeProperties(PropertiesLoaderSupport.java:161)
    at org.springframework.context.support.PropertySourcesPlaceholderConfigurer.postProcessBeanFactory(PropertySourcesPlaceholderConfigurer.java:138)
    ... 21 more
13.Eki.2013 08:32:23 org.apache.catalina.core.StandardContext listenerStart
SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanInitializationException: Could not load properties; nested exception is java.io.FileNotFoundException: class path resource [datasource.properties] cannot be opened because it does not exist
    at org.springframework.context.support.PropertySourcesPlaceholderConfigurer.postProcessBeanFactory(PropertySourcesPlaceholderConfigurer.java:147)
    at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:681)
    at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:656)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:446)
    at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:385)
    at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:284)
    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:111)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4206)
    at org.apache.catalina.core.StandardContext.start(StandardContext.java:4705)
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057)
    at org.apache.catalina.core.StandardHost.start(StandardHost.java:840)
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057)
    at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463)
    at org.apache.catalina.core.StandardService.start(StandardService.java:525)
    at org.apache.catalina.core.StandardServer.start(StandardServer.java:754)
    at org.apache.catalina.startup.Catalina.start(Catalina.java:595)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
Caused by: java.io.FileNotFoundException: class path resource [datasource.properties] cannot be opened because it does not exist
    at org.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.java:158)
    at org.springframework.core.io.support.PropertiesLoaderSupport.loadProperties(PropertiesLoaderSupport.java:181)
    at org.springframework.core.io.support.PropertiesLoaderSupport.mergeProperties(PropertiesLoaderSupport.java:161)
    at org.springframework.context.support.PropertySourcesPlaceholderConfigurer.postProcessBeanFactory(PropertySourcesPlaceholderConfigurer.java:138)
    ... 21 more
13.Eki.2013 08:32:23 org.apache.catalina.core.ApplicationContext log
INFO: Set web app root system property: 'app1' = [C:\J2ETutorial\j2eeapplication\target\j2eeapplication-0.0.1-SNAPSHOT\]
13.Eki.2013 08:32:23 org.apache.catalina.core.ApplicationContext log
INFO: Initializing log4j from [C:\J2ETutorial\j2eeapplication\target\j2eeapplication-0.0.1-SNAPSHOT\WEB-INF\classes\log4j.xml]
13.Eki.2013 08:32:24 com.sun.faces.config.ConfigureListener contextInitialized
INFO: Initializing Mojarra 2.1.10 (-SNAPSHOT 20120625-1354) for context '/nil'
[INFO] [08:32:27.792] Hibernate Validator 4.2.0.Final
13.Eki.2013 08:32:29 org.primefaces.webapp.PostConstructApplicationEventListener processEvent
INFO: Running on PrimeFaces 3.4
13.Eki.2013 08:32:29 org.apache.catalina.core.StandardContext start
SEVERE: Error listenerStart
13.Eki.2013 08:32:29 org.apache.catalina.core.StandardContext start
SEVERE: Context [/nil] startup failed due to previous errors
13.Eki.2013 08:32:29 org.apache.catalina.core.ApplicationContext log
INFO: Shutting down log4j
13.Eki.2013 08:32:29 org.apache.catalina.core.ApplicationContext log
INFO: Closing Spring root WebApplicationContext
13.Eki.2013 08:32:30 org.apache.coyote.http11.Http11Protocol start
INFO: Starting Coyote HTTP/1.1 on http-8081
13.Eki.2013 08:32:30 org.apache.jk.common.ChannelSocket init
INFO: JK: ajp13 listening on /0.0.0.0:8010
13.Eki.2013 08:32:30 org.apache.jk.server.JkMain start
INFO: Jk running ID=0 time=0/40  config=null
13.Eki.2013 08:32:30 org.apache.catalina.startup.Catalina start
INFO: Server startup in 15187 ms
</code>```

-My Server.xml File-

```<code><?xml version="1.0" encoding="UTF-8"?>
<!--
  Licensed to the Apache Software Foundation (ASF) under one or more
  contributor license agreements.  See the NOTICE file distributed with
  this work for additional information regarding copyright ownership.
  The ASF licenses this file to You under the Apache License, Version 2.0
  (the "License"); you may not use this file except in compliance with
  the License.  You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
--><!-- Note:  A "Server" is not itself a "Container", so you may not
     define subcomponents such as "Valves" at this level.
     Documentation at /docs/config/server.html
 --><Server port="8006" shutdown="SHUTDOWN">

  <!--APR library loader. Documentation at /docs/apr.html -->
  <Listener SSLEngine="on" className="org.apache.catalina.core.AprLifecycleListener"/>
  <!--Initialize Jasper prior to webapps are loaded. Documentation at /docs/jasper-howto.html -->
  <Listener className="org.apache.catalina.core.JasperListener"/>
  <!-- Prevent memory leaks due to use of particular java/javax APIs-->
  <Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener"/>
  <!-- JMX Support for the Tomcat server. Documentation at /docs/non-existent.html -->
  <Listener className="org.apache.catalina.mbeans.ServerLifecycleListener"/>
  <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener"/>

  <!-- Global JNDI resources
       Documentation at /docs/jndi-resources-howto.html
  -->
  <GlobalNamingResources>
    <!-- Editable user database that can also be used by
         UserDatabaseRealm to authenticate users
    -->
    <Resource auth="Container" description="User database that can be updated and saved" factory="org.apache.catalina.users.MemoryUserDatabaseFactory" name="UserDatabase" pathname="conf/tomcat-users.xml" type="org.apache.catalina.UserDatabase"/>
  </GlobalNamingResources>

  <!-- A "Service" is a collection of one or more "Connectors" that share
       a single "Container" Note:  A "Service" is not itself a "Container",
       so you may not define subcomponents such as "Valves" at this level.
       Documentation at /docs/config/service.html
   -->
  <Service name="Catalina">

    <!--The connectors can use a shared executor, you can define one or more named thread pools-->
    <!--
    <Executor name="tomcatThreadPool" namePrefix="catalina-exec-"
        maxThreads="150" minSpareThreads="4"/>
    -->

    <!-- A "Connector" represents an endpoint by which requests are received
         and responses are returned. Documentation at :
         Java HTTP Connector: /docs/config/http.html (blocking & non-blocking)
         Java AJP  Connector: /docs/config/ajp.html
         APR (HTTP/AJP) Connector: /docs/apr.html
         Define a non-SSL HTTP/1.1 Connector on port 8080
    -->
    <Connector connectionTimeout="20000" port="8081" protocol="HTTP/1.1" redirectPort="8443"/>
    <!-- A "Connector" using the shared thread pool-->
    <!--
    <Connector executor="tomcatThreadPool"
               port="8080" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443" />
    -->
    <!-- Define a SSL HTTP/1.1 Connector on port 8443
         This connector uses the JSSE configuration, when using APR, the
         connector should be using the OpenSSL style configuration
         described in the APR documentation -->
    <!--
    <Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true"
               maxThreads="150" scheme="https" secure="true"
               clientAuth="false" sslProtocol="TLS" />
    -->

    <!-- Define an AJP 1.3 Connector on port 8009 -->
    <Connector port="8010" protocol="AJP/1.3" redirectPort="8443"/>

    <!-- An Engine represents the entry point (within Catalina) that processes
         every request.  The Engine implementation for Tomcat stand alone
         analyzes the HTTP headers included with the request, and passes them
         on to the appropriate Host (virtual host).
         Documentation at /docs/config/engine.html -->

    <!-- You should set jvmRoute to support load-balancing via AJP ie :
    <Engine name="Catalina" defaultHost="localhost" jvmRoute="jvm1">
    -->
    <Engine defaultHost="localhost" name="Catalina">

      <!--For clustering, please take a look at documentation at:
          /docs/cluster-howto.html  (simple how to)
          /docs/config/cluster.html (reference documentation) -->
      <!--
      <Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"/>
      -->

      <!-- The request dumper valve dumps useful debugging information about
           the request and response data received and sent by Tomcat.
           Documentation at: /docs/config/valve.html -->
      <!--
      <Valve className="org.apache.catalina.valves.RequestDumperValve"/>
      -->

      <!-- This Realm uses the UserDatabase configured in the global JNDI
           resources under the key "UserDatabase".  Any edits
           that are performed against this UserDatabase are immediately
           available for use by the Realm.  -->
      <Realm className="org.apache.catalina.realm.UserDatabaseRealm" resourceName="UserDatabase"/>

      <!-- Define the default virtual host
           Note: XML Schema validation will not work with Xerces 2.2.
       -->
      <Host appBase="webapps" autoDeploy="true" name="localhost" unpackWARs="true" xmlNamespaceAware="false" xmlValidation="false">

        <!-- SingleSignOn valve, share authentication between web applications
             Documentation at: /docs/config/valve.html -->
        <!--
        <Valve className="org.apache.catalina.authenticator.SingleSignOn" />
        -->

        <!-- Access log processes all example.
             Documentation at: /docs/config/valve.html -->
        <!--
        <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
               prefix="localhost_access_log." suffix=".txt" pattern="common" resolveHosts="false"/>
        -->
       <Context docBase="C:\J2ETutorial\j2eeapplication\target\j2eeapplication-0.0.1-SNAPSHOT" path="/nil" reloadable="true"/>
      </Host>
    </Engine>
  </Service>
</Server>
</code>```

-My web.xml File-

```<code><?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
        xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
        version="2.5">

        <display-name>J2EE Application Example</display-name>

        <context-param>
            <param-name>webAppRootKey</param-name>
            <param-value>app1</param-value>
        </context-param>

        <welcome-file-list>
                <welcome-file>index.jsp</welcome-file>
        </welcome-file-list>

        <context-param>
                <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
                <param-value>.xhtml</param-value>
        </context-param>

        <context-param>
        <param-name>log4jConfigLocation</param-name>
        <param-value>/WEB-INF/classes/log4j.xml</param-value>
                </context-param>

        <context-param>
                <param-name>facelets.DEVELOPMENT</param-name>
                <param-value>true</param-value>
        </context-param>

        <context-param>
                <param-name>javax.faces.FACELETS_REFRESH_PERIOD</param-name>
                <param-value>1</param-value>
        </context-param>

        <context-param>
                <param-name>contextConfigLocation</param-name>
                <param-value>/WEB-INF/applicationContext.xml</param-value>
        </context-param>

        <listener>
                <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
        </listener>

       <listener>
                <listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
        </listener>

        <servlet>
                <servlet-name>Resources Servlet</servlet-name>
                <servlet-class>org.springframework.js.resource.ResourceServlet</servlet-class>
                <load-on-startup>0</load-on-startup>
        </servlet>

        <servlet-mapping>
                <servlet-name>Resources Servlet</servlet-name>
                <url-pattern>/resources/*</url-pattern>
        </servlet-mapping>

        <servlet>
                <servlet-name>Spring MVC Dispatcher Servlet</servlet-name>
                <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
                <init-param>
                        <param-name>contextConfigLocation</param-name>
                        <param-value></param-value>
                </init-param>
                <load-on-startup>1</load-on-startup>
        </servlet>

        <servlet-mapping>
                <servlet-name>Spring MVC Dispatcher Servlet</servlet-name>
                <url-pattern>/app/*</url-pattern>
        </servlet-mapping>

        <servlet>
                <servlet-name>Faces Servlet</servlet-name>
                <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
                <load-on-startup>1</load-on-startup>
        </servlet>

        <servlet-mapping>
                <servlet-name>Faces Servlet</servlet-name>
                <url-pattern>*.jsf</url-pattern>
        </servlet-mapping>

        <filter>
                <filter-name>charEncodingFilter</filter-name>
                <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
                <init-param>
            <param-name>encoding</param-name>
            <param-value>UTF-8</param-value>
        </init-param>
        <init-param>
            <param-name>forceEncoding</param-name>
            <param-value>true</param-value>
        </init-param>
        </filter>

    <filter-mapping>
        <filter-name>charEncodingFilter</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>

    <!-- Spring security filters -->
    <filter>
                <filter-name>springSecurityFilterChain</filter-name>
                <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
        </filter>

        <filter-mapping>
                <filter-name>springSecurityFilterChain</filter-name>
                <url-pattern>/*</url-pattern>
        </filter-mapping>

</web-app>
</code>```

-My pom.xml File-

```<code><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>com.example.j2eeapp</groupId>
  <artifactId>j2eeapplication</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>war</packaging>
  <name>J2EE Application Example</name>

  <repositories>
        <repository>
                <id>prime-repo</id>
                <name>PrimeFaces Maven Repository</name>
                <url>http://repository.primefaces.org</url>
        </repository>
  </repositories>

  <dependencies>
        <dependency>
                <groupId>org.hibernate</groupId>
                <artifactId>hibernate-core</artifactId>
                <version>4.1.8.Final</version>
        </dependency>
        <dependency>
                <groupId>org.hibernate</groupId>
                <artifactId>hibernate-validator</artifactId>
                <version>4.2.0.Final</version>
        </dependency>
            <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.8.2</version>
            <scope>test</scope>
        </dependency>
        <dependency>
                <groupId>org.springframework.webflow</groupId>
                <artifactId>spring-webflow</artifactId>
                <version>2.3.1.RELEASE</version>
        </dependency>
        <dependency>
                <groupId>org.springframework.webflow</groupId>
                <artifactId>spring-faces</artifactId>
                <version>2.3.1.RELEASE</version>
        </dependency>
        <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-orm</artifactId>
                <version>3.1.1.RELEASE</version>
        </dependency>
        <dependency>
                <groupId>com.oracle</groupId>
                <artifactId>ojdbc14</artifactId>
                <version>10.2.0.1.0</version>
        </dependency>
        <dependency>
                <groupId>log4j</groupId>
                <artifactId>log4j</artifactId>
                <version>1.2.16</version>
        </dependency>
        <dependency>
                <groupId>com.sun.faces</groupId>
                <artifactId>jsf-impl</artifactId>
                <version>2.1.10</version>
        </dependency>
        <dependency>
                <groupId>com.sun.facelets</groupId>
                <artifactId>jsf-facelets</artifactId>
                <version>1.1.14</version>
        </dependency>
        <dependency>
                <groupId>com.sun.faces</groupId>
                <artifactId>jsf-api</artifactId>
                <version>2.1.10</version>
        </dependency>
        <dependency>
                <groupId>commons-dbcp</groupId>
                <artifactId>commons-dbcp</artifactId>
                <version>20030825.184428</version>
        </dependency>
        <dependency>
                <groupId>org.slf4j</groupId>
                <artifactId>slf4j-log4j12</artifactId>
                <version>1.6.4</version>
        </dependency>
        <dependency>
                <groupId>javax.servlet</groupId>
                <artifactId>javax.servlet-api</artifactId>
                <version>3.0.1</version>
                <scope>provided</scope>
        </dependency>
        <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-tx</artifactId>
                <version>3.0.5.RELEASE</version>
        </dependency>
        <dependency>
                <groupId>xml-apis</groupId>
                <artifactId>xml-apis</artifactId>
                <version>1.3.02</version>
        </dependency>
        <dependency>
                <groupId>org.springframework.security</groupId>
                <artifactId>spring-security-web</artifactId>
                <version>3.1.3.RELEASE</version>
        </dependency>
        <dependency>
                <groupId>org.springframework.security</groupId>
                <artifactId>spring-security-config</artifactId>
                <version>3.1.3.RELEASE</version>
        </dependency>
        <dependency>
                <groupId>org.primefaces</groupId>
                <artifactId>primefaces</artifactId>
                <version>3.4</version>
        </dependency>
        <dependency>
                <groupId>cglib</groupId>
                <artifactId>cglib</artifactId>
                <version>2.2.2</version>
                <scope>runtime</scope>
        </dependency>
        <dependency>
                <groupId>org.hibernate</groupId>
                <artifactId>hibernate-entitymanager</artifactId>
                <version>4.1.8.Final</version>
        </dependency>

  </dependencies>

</project>
</code>```

答:
In some occasions this error occurs because you have not configured the name of the datasource for the connection.
Example: <property name="jndiName" value="java:comp/env/jdbc/MYCONFIG"/>

ContentLicense: CC BY-SA 3.0

Body:
I'm new at Java EE + Spring + Hibernate + Maven combination. Trying to make a simple project with tomcat 6.0.

Our project just fine, no problem with debugging. But when i'm trying to run the server, it gives me "Error listenerStart" all the time.

I searched all around the web for 3 days but no solution about this error. Can anyone please help me about this situation?

Thanks for your help.

-My Console Output-

    13.Eki.2013 08:32:14 org.apache.catalina.core.AprLifecycleListener init
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files\Java\jdk1.6.0_45\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Microsoft\Web Platform Installer\;C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET Web Pages\v1.0\;C:\Program Files (x86)\Windows Kits\8.0\Windows Performance Toolkit\;C:\Program Files\Microsoft SQL Server\110\Tools\Binn\;c:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\;c:\Program Files\Microsoft SQL Server\100\Tools\Binn\;c:\Program Files\Microsoft SQL Server\100\DTS\Binn\;c:\Program Files (x86)\Microsoft SQL Server\90\Tools\binn\;C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\bin\;C:\MinGW\bin;C:\Program Files (x86)\Notepad++;C:\J2ETutorial\apache-maven-3.0.5\bin;C:\Program Files\Apache Software Foundation\Tomcat 6.0\bin;C:\Program Files (x86)\SDCC\bin;.
13.Eki.2013 08:32:15 org.apache.coyote.http11.Http11Protocol init
INFO: Initializing Coyote HTTP/1.1 on http-8081
13.Eki.2013 08:32:15 org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 2219 ms
13.Eki.2013 08:32:15 org.apache.catalina.core.StandardService start
INFO: Starting service Catalina
13.Eki.2013 08:32:15 org.apache.catalina.core.StandardEngine start
INFO: Starting Servlet Engine: Apache Tomcat/6.0.37
13.Eki.2013 08:32:21 org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring root WebApplicationContext
[INFO] [08:32:21.463] Root WebApplicationContext: initialization started
[INFO] [08:32:21.881] Refreshing Root WebApplicationContext: startup date [Sun Oct 13 08:32:21 VET 2013]; root of context hierarchy
[INFO] [08:32:22.365] Loading XML bean definitions from ServletContext resource [/WEB-INF/applicationContext.xml]
[INFO] [08:32:22.689] Loading XML bean definitions from ServletContext resource [/WEB-INF/datasource-config.xml]
[INFO] [08:32:23.001] Loading XML bean definitions from ServletContext resource [/WEB-INF/webflow-config.xml]
[INFO] [08:32:23.622] Loading properties file from class path resource [datasource.properties]
[INFO] [08:32:23.626] Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@17991de1: defining beans [org.springframework.context.support.PropertySourcesPlaceholderConfigurer#0,dataSource,entityManagerFactory,transactionManager,org.springframework.aop.config.internalAutoProxyCreator,org.springframework.transaction.annotation.AnnotationTransactionAttributeSource#0,org.springframework.transaction.interceptor.TransactionInterceptor#0,org.springframework.transaction.config.internalTransactionAdvisor,org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor#0,jpaFlowExecutionListener,facesContextListener,flowExecutor,flowRegistry,org.springframework.faces.model.converter.FacesConversionService#0,org.springframework.webflow.expression.spel.WebFlowSpringELExpressionParser#0,org.springframework.faces.webflow.JsfViewFactoryCreator#0,facesFlowBuilderServices,org.springframework.web.servlet.mvc.HttpRequestHandlerAdapter#0,jsfResourceRequestHandler,org.springframework.web.servlet.handler.SimpleUrlHandlerMapping#0,org.springframework.webflow.mvc.servlet.FlowHandlerMapping#0,org.springframework.faces.webflow.JsfFlowHandlerAdapter#0,faceletsViewResolver,org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter#0,securityFlowExecutionListener]; root of factory hierarchy
[ERROR] [08:32:23.628] Context initialization failed
org.springframework.beans.factory.BeanInitializationException: Could not load properties; nested exception is java.io.FileNotFoundException: class path resource [datasource.properties] cannot be opened because it does not exist
    at org.springframework.context.support.PropertySourcesPlaceholderConfigurer.postProcessBeanFactory(PropertySourcesPlaceholderConfigurer.java:147)
    at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:681)
    at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:656)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:446)
    at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:385)
    at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:284)
    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:111)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4206)
    at org.apache.catalina.core.StandardContext.start(StandardContext.java:4705)
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057)
    at org.apache.catalina.core.StandardHost.start(StandardHost.java:840)
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057)
    at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463)
    at org.apache.catalina.core.StandardService.start(StandardService.java:525)
    at org.apache.catalina.core.StandardServer.start(StandardServer.java:754)
    at org.apache.catalina.startup.Catalina.start(Catalina.java:595)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
Caused by: java.io.FileNotFoundException: class path resource [datasource.properties] cannot be opened because it does not exist
    at org.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.java:158)
    at org.springframework.core.io.support.PropertiesLoaderSupport.loadProperties(PropertiesLoaderSupport.java:181)
    at org.springframework.core.io.support.PropertiesLoaderSupport.mergeProperties(PropertiesLoaderSupport.java:161)
    at org.springframework.context.support.PropertySourcesPlaceholderConfigurer.postProcessBeanFactory(PropertySourcesPlaceholderConfigurer.java:138)
    ... 21 more
13.Eki.2013 08:32:23 org.apache.catalina.core.StandardContext listenerStart
SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanInitializationException: Could not load properties; nested exception is java.io.FileNotFoundException: class path resource [datasource.properties] cannot be opened because it does not exist
    at org.springframework.context.support.PropertySourcesPlaceholderConfigurer.postProcessBeanFactory(PropertySourcesPlaceholderConfigurer.java:147)
    at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:681)
    at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:656)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:446)
    at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:385)
    at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:284)
    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:111)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4206)
    at org.apache.catalina.core.StandardContext.start(StandardContext.java:4705)
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057)
    at org.apache.catalina.core.StandardHost.start(StandardHost.java:840)
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057)
    at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463)
    at org.apache.catalina.core.StandardService.start(StandardService.java:525)
    at org.apache.catalina.core.StandardServer.start(StandardServer.java:754)
    at org.apache.catalina.startup.Catalina.start(Catalina.java:595)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
Caused by: java.io.FileNotFoundException: class path resource [datasource.properties] cannot be opened because it does not exist
    at org.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.java:158)
    at org.springframework.core.io.support.PropertiesLoaderSupport.loadProperties(PropertiesLoaderSupport.java:181)
    at org.springframework.core.io.support.PropertiesLoaderSupport.mergeProperties(PropertiesLoaderSupport.java:161)
    at org.springframework.context.support.PropertySourcesPlaceholderConfigurer.postProcessBeanFactory(PropertySourcesPlaceholderConfigurer.java:138)
    ... 21 more
13.Eki.2013 08:32:23 org.apache.catalina.core.ApplicationContext log
INFO: Set web app root system property: 'app1' = [C:\J2ETutorial\j2eeapplication\target\j2eeapplication-0.0.1-SNAPSHOT\]
13.Eki.2013 08:32:23 org.apache.catalina.core.ApplicationContext log
INFO: Initializing log4j from [C:\J2ETutorial\j2eeapplication\target\j2eeapplication-0.0.1-SNAPSHOT\WEB-INF\classes\log4j.xml]
13.Eki.2013 08:32:24 com.sun.faces.config.ConfigureListener contextInitialized
INFO: Initializing Mojarra 2.1.10 (-SNAPSHOT 20120625-1354) for context '/nil'
[INFO] [08:32:27.792] Hibernate Validator 4.2.0.Final
13.Eki.2013 08:32:29 org.primefaces.webapp.PostConstructApplicationEventListener processEvent
INFO: Running on PrimeFaces 3.4
13.Eki.2013 08:32:29 org.apache.catalina.core.StandardContext start
SEVERE: Error listenerStart
13.Eki.2013 08:32:29 org.apache.catalina.core.StandardContext start
SEVERE: Context [/nil] startup failed due to previous errors
13.Eki.2013 08:32:29 org.apache.catalina.core.ApplicationContext log
INFO: Shutting down log4j
13.Eki.2013 08:32:29 org.apache.catalina.core.ApplicationContext log
INFO: Closing Spring root WebApplicationContext
13.Eki.2013 08:32:30 org.apache.coyote.http11.Http11Protocol start
INFO: Starting Coyote HTTP/1.1 on http-8081
13.Eki.2013 08:32:30 org.apache.jk.common.ChannelSocket init
INFO: JK: ajp13 listening on /0.0.0.0:8010
13.Eki.2013 08:32:30 org.apache.jk.server.JkMain start
INFO: Jk running ID=0 time=0/40  config=null
13.Eki.2013 08:32:30 org.apache.catalina.startup.Catalina start
INFO: Server startup in 15187 ms

-My Server.xml File-

<?xml version="1.0" encoding="UTF-8"?>
<Server port="8006" shutdown="SHUTDOWN">

  <Listener SSLEngine="on" className="org.apache.catalina.core.AprLifecycleListener"/>

  <Listener className="org.apache.catalina.core.JasperListener"/>

  <Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener"/>

  <Listener className="org.apache.catalina.mbeans.ServerLifecycleListener"/>
  <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener"/>

  <GlobalNamingResources>

    <Resource auth="Container" description="User database that can be updated and saved" factory="org.apache.catalina.users.MemoryUserDatabaseFactory" name="UserDatabase" pathname="conf/tomcat-users.xml" type="org.apache.catalina.UserDatabase"/>
  </GlobalNamingResources>

  <Service name="Catalina">

    <Connector connectionTimeout="20000" port="8081" protocol="HTTP/1.1" redirectPort="8443"/>

    <Connector port="8010" protocol="AJP/1.3" redirectPort="8443"/>

    <Engine defaultHost="localhost" name="Catalina">

      <Realm className="org.apache.catalina.realm.UserDatabaseRealm" resourceName="UserDatabase"/>

      <Host appBase="webapps" autoDeploy="true" name="localhost" unpackWARs="true" xmlNamespaceAware="false" xmlValidation="false">

       <Context docBase="C:\J2ETutorial\j2eeapplication\target\j2eeapplication-0.0.1-SNAPSHOT" path="/nil" reloadable="true"/>
      </Host>
    </Engine>
  </Service>
</Server>

-My web.xml File-

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
        xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
        version="2.5">

        <display-name>J2EE Application Example</display-name>

        <context-param>
            <param-name>webAppRootKey</param-name>
            <param-value>app1</param-value>
        </context-param>

        <welcome-file-list>
                <welcome-file>index.jsp</welcome-file>
        </welcome-file-list>

        <context-param>
                <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
                <param-value>.xhtml</param-value>
        </context-param>

        <context-param>
        <param-name>log4jConfigLocation</param-name>
        <param-value>/WEB-INF/classes/log4j.xml</param-value>
                </context-param>

        <context-param>
                <param-name>facelets.DEVELOPMENT</param-name>
                <param-value>true</param-value>
        </context-param>

        <context-param>
                <param-name>javax.faces.FACELETS_REFRESH_PERIOD</param-name>
                <param-value>1</param-value>
        </context-param>

        <context-param>
                <param-name>contextConfigLocation</param-name>
                <param-value>/WEB-INF/applicationContext.xml</param-value>
        </context-param>

        <listener>
                <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
        </listener>

       <listener>
                <listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
        </listener>

        <servlet>
                <servlet-name>Resources Servlet</servlet-name>
                <servlet-class>org.springframework.js.resource.ResourceServlet</servlet-class>
                <load-on-startup>0</load-on-startup>
        </servlet>

        <servlet-mapping>
                <servlet-name>Resources Servlet</servlet-name>
                <url-pattern>/resources/*</url-pattern>
        </servlet-mapping>

        <servlet>
                <servlet-name>Spring MVC Dispatcher Servlet</servlet-name>
                <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
                <init-param>
                        <param-name>contextConfigLocation</param-name>
                        <param-value></param-value>
                </init-param>
                <load-on-startup>1</load-on-startup>
        </servlet>

        <servlet-mapping>
                <servlet-name>Spring MVC Dispatcher Servlet</servlet-name>
                <url-pattern>/app/*</url-pattern>
        </servlet-mapping>

        <servlet>
                <servlet-name>Faces Servlet</servlet-name>
                <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
                <load-on-startup>1</load-on-startup>
        </servlet>

        <servlet-mapping>
                <servlet-name>Faces Servlet</servlet-name>
                <url-pattern>*.jsf</url-pattern>
        </servlet-mapping>

        <filter>
                <filter-name>charEncodingFilter</filter-name>
                <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
                <init-param>
            <param-name>encoding</param-name>
            <param-value>UTF-8</param-value>
        </init-param>
        <init-param>
            <param-name>forceEncoding</param-name>
            <param-value>true</param-value>
        </init-param>
        </filter>

    <filter-mapping>
        <filter-name>charEncodingFilter</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>

    <filter>
                <filter-name>springSecurityFilterChain</filter-name>
                <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
        </filter>

        <filter-mapping>
                <filter-name>springSecurityFilterChain</filter-name>
                <url-pattern>/*</url-pattern>
        </filter-mapping>

</web-app>

-My pom.xml File-

<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>com.example.j2eeapp</groupId>
  <artifactId>j2eeapplication</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>war</packaging>
  <name>J2EE Application Example</name>

  <repositories>
        <repository>
                <id>prime-repo</id>
                <name>PrimeFaces Maven Repository</name>
                <url>http://repository.primefaces.org</url>
        </repository>
  </repositories>

  <dependencies>
        <dependency>
                <groupId>org.hibernate</groupId>
                <artifactId>hibernate-core</artifactId>
                <version>4.1.8.Final</version>
        </dependency>
        <dependency>
                <groupId>org.hibernate</groupId>
                <artifactId>hibernate-validator</artifactId>
                <version>4.2.0.Final</version>
        </dependency>
            <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.8.2</version>
            <scope>test</scope>
        </dependency>
        <dependency>
                <groupId>org.springframework.webflow</groupId>
                <artifactId>spring-webflow</artifactId>
                <version>2.3.1.RELEASE</version>
        </dependency>
        <dependency>
                <groupId>org.springframework.webflow</groupId>
                <artifactId>spring-faces</artifactId>
                <version>2.3.1.RELEASE</version>
        </dependency>
        <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-orm</artifactId>
                <version>3.1.1.RELEASE</version>
        </dependency>
        <dependency>
                <groupId>com.oracle</groupId>
                <artifactId>ojdbc14</artifactId>
                <version>10.2.0.1.0</version>
        </dependency>
        <dependency>
                <groupId>log4j</groupId>
                <artifactId>log4j</artifactId>
                <version>1.2.16</version>
        </dependency>
        <dependency>
                <groupId>com.sun.faces</groupId>
                <artifactId>jsf-impl</artifactId>
                <version>2.1.10</version>
        </dependency>
        <dependency>
                <groupId>com.sun.facelets</groupId>
                <artifactId>jsf-facelets</artifactId>
                <version>1.1.14</version>
        </dependency>
        <dependency>
                <groupId>com.sun.faces</groupId>
                <artifactId>jsf-api</artifactId>
                <version>2.1.10</version>
        </dependency>
        <dependency>
                <groupId>commons-dbcp</groupId>
                <artifactId>commons-dbcp</artifactId>
                <version>20030825.184428</version>
        </dependency>
        <dependency>
                <groupId>org.slf4j</groupId>
                <artifactId>slf4j-log4j12</artifactId>
                <version>1.6.4</version>
        </dependency>
        <dependency>
                <groupId>javax.servlet</groupId>
                <artifactId>javax.servlet-api</artifactId>
                <version>3.0.1</version>
                <scope>provided</scope>
        </dependency>
        <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-tx</artifactId>
                <version>3.0.5.RELEASE</version>
        </dependency>
        <dependency>
                <groupId>xml-apis</groupId>
                <artifactId>xml-apis</artifactId>
                <version>1.3.02</version>
        </dependency>
        <dependency>
                <groupId>org.springframework.security</groupId>
                <artifactId>spring-security-web</artifactId>
                <version>3.1.3.RELEASE</version>
        </dependency>
        <dependency>
                <groupId>org.springframework.security</groupId>
                <artifactId>spring-security-config</artifactId>
                <version>3.1.3.RELEASE</version>
        </dependency>
        <dependency>
                <groupId>org.primefaces</groupId>
                <artifactId>primefaces</artifactId>
                <version>3.4</version>
        </dependency>
        <dependency>
                <groupId>cglib</groupId>
                <artifactId>cglib</artifactId>
                <version>2.2.2</version>
                <scope>runtime</scope>
        </dependency>
        <dependency>
                <groupId>org.hibernate</groupId>
                <artifactId>hibernate-entitymanager</artifactId>
                <version>4.1.8.Final</version>
        </dependency>

  </dependencies>

</project>


答:
I would use sub here:

```<code>df$name <- sub("(\\D+).*", "\\1", df$name_and_address)
df$address <- sub(".*?(\\d+.*)", "\\1", df$name_and_address)
</code>```

Title: Split String at First Occurrence of an Integer using R

Body:
I would use sub here:

df$name <- sub("(\\D+).*", "\\1", df$name_and_address)
df$address <- sub(".*?(\\d+.*)", "\\1", df$name_and_address)


问:
Unique key with NULLs
This question requires some hypothetical background. Let's consider an employee table that has columns name, date_of_birth, title, salary, using MySQL as the RDBMS. Since if any given person has the same name and birth date as another person, they are, by definition, the same person (barring amazing coincidences where we have two people named Abraham Lincoln born on February 12, 1809), we'll put a unique key on name and date_of_birth that means "don't store the same person twice." Now consider this data:

```<code>id name        date_of_birth title          salary
 1 John Smith  1960-10-02    President      500,000
 2 Jane Doe    1982-05-05    Accountant      80,000
 3 Jim Johnson NULL          Office Manager  40,000
 4 Tim Smith   1899-04-11    Janitor         95,000
</code>```

If I now try to run the following statement, it should and will fail:

```<code>INSERT INTO employee (name, date_of_birth, title, salary)
VALUES ('Tim Smith', '1899-04-11', 'Janitor', '95,000')
</code>```

If I try this one, it will succeed:

```<code>INSERT INTO employee (name, title, salary)
VALUES ('Jim Johnson', 'Office Manager', '40,000')
</code>```

And now my data will look like this:

```<code>id name        date_of_birth title          salary
 1 John Smith  1960-10-02    President      500,000
 2 Jane Doe    1982-05-05    Accountant      80,000
 3 Jim Johnson NULL          Office Manager  40,000
 4 Tim Smith   1899-04-11    Janitor         95,000
 5 Jim Johnson NULL          Office Manager  40,000
</code>```

This is not what I want but I can't say I entirely disagree with what happened. If we talk in terms of mathematical sets,

```<code>{'Tim Smith', '1899-04-11'} = {'Tim Smith', '1899-04-11'} <-- TRUE
{'Tim Smith', '1899-04-11'} = {'Jane Doe', '1982-05-05'} <-- FALSE
{'Tim Smith', '1899-04-11'} = {'Jim Johnson', NULL} <-- UNKNOWN
{'Jim Johnson', NULL} = {'Jim Johnson', NULL} <-- UNKNOWN
</code>```

My guess is that MySQL says, "Since I don't know that Jim Johnson with a NULL birth date isn't already in this table, I'll add him."

My question is: How can I prevent duplicates even though date_of_birth is not always known? The best I've come up with so far is to move date_of_birth to a different table. The problem with that, however, is that I might end up with, say, two cashiers with the same name, title and salary, different birth dates and no way to store them both without having duplicates.

答:
I think the fundamental question here is what you actually mean with

INSERT INTO employee (name, title, salary) VALUES ('Jim Johnson', 'Office Manager', '40,000')

Your own definition of a person is name AND birth date, so what does this statement mean in that context? I'd say that the solution to your problem is to prohibit inserting half identities, like the one above, by adding NOT NULL on both your name and date_of_birth columns. That way, the statement will fail and force you to enter complete identities and the unique key will do its job to prevent you from entering the same person twice.

ContentLicense: CC BY-SA 2.5

Title: Unique key with NULLs

Body:
This question requires some hypothetical background. Let's consider an employee table that has columns name, date_of_birth, title, salary, using MySQL as the RDBMS. Since if any given person has the same name and birth date as another person, they are, by definition, the same person (barring amazing coincidences where we have two people named Abraham Lincoln born on February 12, 1809), we'll put a unique key on name and date_of_birth that means "don't store the same person twice." Now consider this data:

id name        date_of_birth title          salary
 1 John Smith  1960-10-02    President      500,000
 2 Jane Doe    1982-05-05    Accountant      80,000
 3 Jim Johnson NULL          Office Manager  40,000
 4 Tim Smith   1899-04-11    Janitor         95,000

If I now try to run the following statement, it should and will fail:

INSERT INTO employee (name, date_of_birth, title, salary)
VALUES ('Tim Smith', '1899-04-11', 'Janitor', '95,000')

If I try this one, it will succeed:

INSERT INTO employee (name, title, salary)
VALUES ('Jim Johnson', 'Office Manager', '40,000')

And now my data will look like this:

id name        date_of_birth title          salary
 1 John Smith  1960-10-02    President      500,000
 2 Jane Doe    1982-05-05    Accountant      80,000
 3 Jim Johnson NULL          Office Manager  40,000
 4 Tim Smith   1899-04-11    Janitor         95,000
 5 Jim Johnson NULL          Office Manager  40,000

This is not what I want but I can't say I entirely disagree with what happened. If we talk in terms of mathematical sets,

{'Tim Smith', '1899-04-11'} = {'Tim Smith', '1899-04-11'} <-- TRUE
{'Tim Smith', '1899-04-11'} = {'Jane Doe', '1982-05-05'} <-- FALSE
{'Tim Smith', '1899-04-11'} = {'Jim Johnson', NULL} <-- UNKNOWN
{'Jim Johnson', NULL} = {'Jim Johnson', NULL} <-- UNKNOWN

My guess is that MySQL says, "Since I don't know that Jim Johnson with a NULL birth date isn't already in this table, I'll add him."

My question is: How can I prevent duplicates even though date_of_birth is not always known? The best I've come up with so far is to move date_of_birth to a different table. The problem with that, however, is that I might end up with, say, two cashiers with the same name, title and salary, different birth dates and no way to store them both without having duplicates.


问:
Problem with loading module ‘Distribution.Simple’
I was trying to build one new project in Haskell (GHC version 8.10.4, stack version 2.7.3, cabal version 3.6.2.0) using stack, but at the time of running the command stack setup I (surprisingly) got the following error:

```<code>Setup.hs:2:1: error:
    Could not load module ‘Distribution.Simple’
    It is a member of the hidden package ‘Cabal-3.2.1.0’.
    You can run ‘:set -package Cabal’ to expose it.
    (Note: this unloads all the modules in the current scope.)
    Use -v (or `:set -v` in ghci) to see a list of the files searched for.
  |
2 | import Distribution.Simple
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^
</code>```

Also, it is worth noting that I was trying to look for different solutions on the Internet, but didn't find the working one for me. The general idea was to explicitly add Cabal into the package.yaml file here:

```<code>library:
  source-dirs: src
  dependencies:
    - Cabal
</code>```

But that didn't save my situation. I was able to build the project without that step (well, just skipped that part), but I was interested to solve the issue.

Moreover, when I was trying to build Haskell package timeit (as an example, using the command line), there was the same error at the time of executing
runhaskell Setup.hs configure.

Interestingly, I didn't have this problem before (probably, it appeared after I updated GHC).

Does anybody know any ways of how to deal with such issue? Is there any way probably to reinstall the GHC, or cabal, or stack (if it helps)? Would be glad to see any comments and solutions.

答:
I had the same issue.
Deleting the files

~/.ghc/*/environments/default
```

(or the whole folder .ghc) solved the stack setup problem.

It seems that they were somehow interacting with stack's operations.

Body:
I was trying to build one new project in Haskell (GHC version 8.10.4, stack version 2.7.3, cabal version 3.6.2.0) using stack, but at the time of running the command stack setup I (surprisingly) got the following error:

Setup.hs:2:1: error:
    Could not load module ‘Distribution.Simple’
    It is a member of the hidden package ‘Cabal-3.2.1.0’.
    You can run ‘:set -package Cabal’ to expose it.
    (Note: this unloads all the modules in the current scope.)
    Use -v (or `:set -v` in ghci) to see a list of the files searched for.
  |
2 | import Distribution.Simple
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^

Also, it is worth noting that I was trying to look for different solutions on the Internet, but didn't find the working one for me. The general idea was to explicitly add Cabal into the package.yaml file here:

library:
  source-dirs: src
  dependencies:
    - Cabal

But that didn't save my situation. I was able to build the project without that step (well, just skipped that part), but I was interested to solve the issue.

Moreover, when I was trying to build Haskell package timeit (as an example, using the command line), there was the same error at the time of executing
runhaskell Setup.hs configure.

Interestingly, I didn't have this problem before (probably, it appeared after I updated GHC).

Does anybody know any ways of how to deal with such issue? Is there any way probably to reinstall the GHC, or cabal, or stack (if it helps)? Would be glad to see any comments and solutions.

Body:
I had the same issue.
Deleting the files

~/.ghc/*/environments/default

(or the whole folder .ghc) solved the stack setup problem.

It seems that they were somehow interacting with stack's operations.


问:
Windows font issue and how to debug for customer
Recently had a customer send in a ticket complaining that their font has changed (within the week or so).  The font on the site has not changed in probably a decade.  What I suspect is that perhaps a recent windows up that times in line with the change is effecting the font he sees, or, more likely, a setting changed on his end.

the font we use

```<code>font-family: "Helvetica Neue",Helvetica,Arial,sans-serif
</code>```

It is my understanding that Helvetica Neue will likely get replaced by something else on windows since, just from googling, I find that font is not included in windows.

My question is, is there any way I can help debug this on his end to figure out exactly what is going on?  It does make the site difficult to read for this user and I would like to fix it, and also know for sure what I am talking about. I usually try very hard not to just reply with, "looks good on my machine".  Inspecting it shows the same font family as what I posted above.

None of the font options in that css appear to be what is showing.

The one distinguishing trait I can see in the font is the letters de overlap or touch.

This is for web content, the browsers mentioned where most recent Chrome, which I also tested on (verified exact same version numbers) and did not have the issue, and Edge which I do not have.

答:
If you can't access their computer, it's going to be hard to pinpoint the exact cause. Windows font substitution is the normal culprit in this situation:

As stated here:

https://office-watch.com/2021/windows-substituting-arial-font-for-helvetica/

"Windows is setup to use Arial whenever it sees a reference to ‘Helvetica’. This happens at the Windows level and doesn’t just apply to Microsoft Office. Most web browsers get the same thing – web pages that ask for ‘Helvetica’ to display in web page will get the Arial font instead. It drives web designers crazy, especially since CSS has a way to choose from a family of preferred fonts.

Way down in the bowels of the Windows Registry is HCLM\SOFTWARE\Microsoft\Windows\NTCurrentVersion\FontSubstitutes which lists the substitutions."

Additionally, if you run a comparison of arial vs helvetica neue...using the word video you mentioned, you get this:

Notice the difference in kerning (separation between letters/characters) between characters 'd' and 'e'. Arial appears 'clumped' when compared to Helvetica Neue.

Body:
Recently had a customer send in a ticket complaining that their font has changed (within the week or so).  The font on the site has not changed in probably a decade.  What I suspect is that perhaps a recent windows up that times in line with the change is effecting the font he sees, or, more likely, a setting changed on his end.

the font we use

font-family: "Helvetica Neue",Helvetica,Arial,sans-serif

It is my understanding that Helvetica Neue will likely get replaced by something else on windows since, just from googling, I find that font is not included in windows.

My question is, is there any way I can help debug this on his end to figure out exactly what is going on?  It does make the site difficult to read for this user and I would like to fix it, and also know for sure what I am talking about. I usually try very hard not to just reply with, "looks good on my machine".  Inspecting it shows the same font family as what I posted above.

None of the font options in that css appear to be what is showing.

The one distinguishing trait I can see in the font is the letters de overlap or touch.

This is for web content, the browsers mentioned where most recent Chrome, which I also tested on (verified exact same version numbers) and did not have the issue, and Edge which I do not have.


问:
react error: Target container is not a DOM element, (not using redux)
For my react page, this is some code for our index page, and it works completely fine:

```<code>ReactDOM.render(
  <Form />,
  document.getElementById('reactEntry'),
);
</code>```

and in index.html:

```<code><div id="reactEntry" style="text-align: center;">
    Loading ...
</div>
</code>```

but we have a similar implementation for another page, called editor:

```<code>ReactDOM.render(
  <Editor />,
    document.getElementById("Editor")
  );

<div id="Editor" style="text-align: center;">
    Loading ...
</div>
</code>```

webpack.config.js

```<code>const path = require('path');

module.exports = {
  mode: 'development',
  entry: './newCharlaBots/js/main.jsx',
  output: {
    path: path.join(__dirname, '/newCharlaBots/static/js/'),
    filename: 'bundle.js',
  },
  module: {
    rules: [
      {
        // Test for js or jsx files
        test: /\.jsx?$/,
        // Exclude external modules from loader tests
        exclude: /node_modules/,
        loader: 'babel-loader',
        options: {
          presets: ['@babel/preset-env', '@babel/preset-react'],
        },
        //loaders: [{test: /\.js$/, exclude: /node_modules/, loaders: ['babel']},{test: /\.css$/, loaders: ['style', 'css']}]
      },
    ],
  },
  resolve: {
    extensions: ['.js', '.jsx'],
  },
};
</code>```

In this editor page, we get the error, "Target container is not a DOM element". I've tried looking at many StackOverflow posts but can't figure out what is the issue - does anyone have any insight on this?

答:
Check the location of the react js script tag.
I hope this answer is helpful.

    Loading ...

```

Body:
For my react page, this is some code for our index page, and it works completely fine:

ReactDOM.render(
  <Form />,
  document.getElementById('reactEntry'),
);

and in index.html:

    Loading ...

but we have a similar implementation for another page, called editor:

ReactDOM.render(
  <Editor />,
    document.getElementById("Editor")
  );

    Loading ...

webpack.config.js

const path = require('path');

module.exports = {
  mode: 'development',
  entry: './newCharlaBots/js/main.jsx',
  output: {
    path: path.join(__dirname, '/newCharlaBots/static/js/'),
    filename: 'bundle.js',
  },
  module: {
    rules: [
      {
        // Test for js or jsx files
        test: /\.jsx?$/,
        // Exclude external modules from loader tests
        exclude: /node_modules/,
        loader: 'babel-loader',
        options: {
          presets: ['@babel/preset-env', '@babel/preset-react'],
        },
        //loaders: [{test: /\.js$/, exclude: /node_modules/, loaders: ['babel']},{test: /\.css$/, loaders: ['style', 'css']}]
      },
    ],
  },
  resolve: {
    extensions: ['.js', '.jsx'],
  },
};

In this editor page, we get the error, "Target container is not a DOM element". I've tried looking at many StackOverflow posts but can't figure out what is the issue - does anyone have any insight on this?

Body:
Check the location of the react js script tag.
I hope this answer is helpful.

<script>
  console.log("script #1:", document.getElementById("Editor")); // null
</script>
<div id="Editor" style="text-align: center;">
    Loading ...
</div>
<script>
  console.log("script #2:", document.getElementById("Editor")); // <div id="Editor" ...
</script>


问:
SQL nested query with join operations
I have a table P with person1id and person2id columns, and a table J with each person's personId and their name columns. I want to have a query that generates a table of person1id, person2id, name1, name2 columns. In the result, name1 is the name of person1id, name2 is the name of person2id.  Is it possible to do this via nested query?

The tables look like below

table P

person1id
person2id

p1_1
p2_1

p1_2
p2_2

table J

personId
name

p1_1
name1

p1_2
name2

p2_1
name3

p2_2
name4

The expected result looks like

person1id
person2id
name1
name2

p1_1
p2_1
name1
name3

p1_2
p2_2
name2
name4

答:
Figured out a query without join.

SELECT person1id,
       person2id,
       (SELECT name FROM J WHERE personId = person1id) AS name1,
       (SELECT name FROM J WHERE personId = person2id) AS name2
FROM P
```
<p>Another one with left join.</p>
<pre class="lang-sql prettyprint-override"><code>SELECT person1id,
       person2id,
       j1.name as name1,
       j2.name as name2
FROM P
LEFT JOIN J j1 ON person1id = j1.personId
LEFT JOIN J j2 ON person2id = j2.personId
</code>```

Title: SQL nested query with join operations

Body:
Figured out a query without join.

SELECT person1id,
       person2id,
       (SELECT name FROM J WHERE personId = person1id) AS name1,
       (SELECT name FROM J WHERE personId = person2id) AS name2
FROM P

Another one with left join.

SELECT person1id,
       person2id,
       j1.name as name1,
       j2.name as name2
FROM P
LEFT JOIN J j1 ON person1id = j1.personId
LEFT JOIN J j2 ON person2id = j2.personId


问:
MacOS/VisualStudioCode/Omnisharp missing .NET Framework 4.6.1
I'm on macOS Catalina running:

vscode 1.48.1

ms-dotnettools.csharp 1.23.1 (which is omnisharp underneath)

Visual Studio For Mac 8.7.3

Mono MDK 6.12.0.91

I have a project that targets .NET 4.6.1. I use vscode for this project. I also have another project that uses Visual Studio For Mac for Xamarin reasons. Unfortunately, it seems that the later versions of Visual Studio For Mac require at least Mono MDK 6.10.x. That version doesn't appear to support .NET 4.6.1. This means Omnisharp can't load the projects for vscode project. I've tried downgrading the Mono MDK without success for the vscode project. All my googling gets  me to the download pages for the developer packs for Windows that have .NET framework 4.6.1, which are useless, or ways to force Omnisharp to see a 4.6.1 framework at some other path by setting an environment variable, FrameworkPathOverride, to the appropriate place, which doesn't exist on my system. At this point the only path I can see is to retarget my 4.6.1 application to a later framework but that will take forever. All I really need is a 4.6.1 framework for macOS. Halp?

EDIT: Yes, I know .NET is for Windows and Mono is for everything else. Mono provides compatibility with .NET versions and Omnisharp has handled this properly in the past. The problem only appeared after updating Visual Studio For Mac and the Mono MDK.

EDIT: Solved, see accepted answer for details

答:
I had the same issue. it was fixed by the @jsimon's steps. Thank you!

OS : macOS Monterey version 12.2
MacBook Pro M1 arm64

VsCode 1.64.0 (universal)
dotnet --version
6.0.101

steps: 1. open the VSCode 2. Code -> Preferences -> Extensions
3. click on the (wheal) settings on C# for Visual Studio Code (powered by OmniSharp). and Extension Settings
4. find Edit in settings.json
add "omnisharp.useGlobalMono": "always" to the end. you may need to add "," if you have other settings
5. save and close, and open VsCode project.
6. go back to the ominsharp settings
7. Omnisharp: Use Modern Net , select this to use .NET 6 (in my case)
enjoy!