问:
What is the difference between JavaScript and ECMAScript?
What's the difference between ECMAScript and JavaScript? From what I've deduced, ECMAScript is the standard and JavaScript is the implementation. Is this correct?</p>

答:
ECMAScript is a standard for JavaScript, look at these statements from MDN:

JavaScript

JavaScript (JS) is a lightweight interpreted or JIT-compiled
  programming language with first-class functions. While it is most
  well-known as the scripting language for Web pages, many non-browser
  environments also use it, such as node.js, Apache CouchDB and Adobe
  Acrobat. JavaScript is a prototype-based, multi-paradigm, dynamic
  language, supporting object-oriented, imperative, and declarative
  (e.g. functional programming) styles. Read more about JavaScript.

ECMAScript

The standard for JavaScript is ECMAScript. As of 2012, all modern
  browsers fully support ECMAScript 5.1. Older browsers support at least
  ECMAScript 3. On June 17, 2015, ECMA International published the sixth
  major version of ECMAScript, which is officially called ECMAScript
  2015, and was initially referred to as ECMAScript 6 or ES6. Since
  then, ECMAScript standards are on yearly release cycles. This
  documentation refers to the latest draft version, which is currently
  ECMAScript 2018.

For more info, visit here


来源: stackexchange

问:
jsonpath python module: module 'jsonpath' has no attribute 'jsonpath'
I use the same python code in a script and direct in cli. While in cli the code works with no errors, in the script it gives me an error.

```<code>AttributeError: module 'jsonpath' has no attribute 'jsonpath'
</code>```

Code:

```<code>import os
import click
import subprocess
import urllib.request
import json
import jsonpath

@cli.command()
@click.argument('search', required=False, nargs=-1)
def search(search):
    for srch in search:
        packs = urllib.request.urlopen("https://aur.archlinux.org//rpc/?v=5&type=search&arg="+srch).read()
        somejson = json.loads(packs)
        match = jsonpath.jsonpath(somejson, '$.results[*].Name,Version,Description')
        print(match)
</code>```

I use the same virtualenv for the cli and for the script.

Code cli:

```<code>(venv) [user@laptop pyapp]$ python
Python 3.6.1 (default, Mar 27 2017, 00:27:06)
[GCC 6.3.1 20170306] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import jsonpath
>>> import json
>>> import urllib.request
>>> jsontext = urllib.request.urlopen("https://aur.archlinux.org//rpc/?v=5&type=search&arg=teamviewer").read()
>>> somejson = json.loads(jsontext)
>>> match = jsonpath.jsonpath(somejson, '$.results[*].Name,Version,Description')
>>> print(match)
['teamviewer-quicksupport-beta', '11.0.52520-1', 'Teamviewer Quicksupport - All-In-One Software for Remote Support and Online Meetings - beta version', 'teamviewer10', '10.0.46203-1.1', 'All-In-One Software for Remote Support and Online Meetings', 'remmina-plugin-teamviewer', '1.2.3.0-1', 'A protocol plugin for Remmina to launch a TeamViewer connection.', 'teamviewer8', '8.0.20931-1', 'All-In-One Software for Remote Support and Online Meetings', 'teamviewer-quicksupport', '11.0.57095-2', 'Teamviewer Quicksupport - All-In-One Software for Remote Support and Online Meetings', 'teamviewer-openrc', '1.0-2', 'OpenRC scripts for teamviewer.', 'teamviewer-beta', '12.0.69753-1', 'All-In-One Software for Remote Support and Online Meetings - beta version', 'teamviewer11', '11.0.67687-1', 'All-in-one software for remote support and online meetings', 'teamviewer9', '9.0.32150-1', 'All-In-One Software for Remote Support and Online Meetings', 'teamviewer', '12.0.76279-6', 'All-In-One Software for Remote Support and Online Meetings']
</code>```

I don't understand what is wrong with the code.
The full code is here

答:
The module jsonpath was old. I resolved the problem by not using it.
I end up using the following code:</p>

```<code>@cli.command()
@click.argument('search', required=False, nargs=-1)
def search(search):
    """ Search AUR repositorie for package name. """
    for srch in search:
        packs = urllib.request.urlopen("https://aur.archlinux.org//rpc/?v=5&type=search&arg="+srch).read()
        print(type(packs))
        somejson = json.loads(packs)
        somej = somejson['results']
        print(type(somej))
        for pkg in somej:
            print("Name: "+pkg['Name'])
            print("Version: "+pkg['Version'])
            print("Desc: "+pkg['Description'])
            print("################")
</code>```

ContentLicense: CC BY-SA 3.0

Body:
I use the same python code in a script and direct in cli. While in cli the code works with no errors, in the script it gives me an error.

AttributeError: module 'jsonpath' has no attribute 'jsonpath'

Code:

import os
import click
import subprocess
import urllib.request
import json
import jsonpath

@cli.command()
@click.argument('search', required=False, nargs=-1)
def search(search):
    for srch in search:
        packs = urllib.request.urlopen("https://aur.archlinux.org//rpc/?v=5&type=search&arg="+srch).read()
        somejson = json.loads(packs)
        match = jsonpath.jsonpath(somejson, '$.results[*].Name,Version,Description')
        print(match)

I use the same virtualenv for the cli and for the script.

Code cli:

(venv) [user@laptop pyapp]$ python
Python 3.6.1 (default, Mar 27 2017, 00:27:06)
[GCC 6.3.1 20170306] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import jsonpath
>>> import json
>>> import urllib.request
>>> jsontext = urllib.request.urlopen("https://aur.archlinux.org//rpc/?v=5&type=search&arg=teamviewer").read()
>>> somejson = json.loads(jsontext)
>>> match = jsonpath.jsonpath(somejson, '$.results[*].Name,Version,Description')
>>> print(match)
['teamviewer-quicksupport-beta', '11.0.52520-1', 'Teamviewer Quicksupport - All-In-One Software for Remote Support and Online Meetings - beta version', 'teamviewer10', '10.0.46203-1.1', 'All-In-One Software for Remote Support and Online Meetings', 'remmina-plugin-teamviewer', '1.2.3.0-1', 'A protocol plugin for Remmina to launch a TeamViewer connection.', 'teamviewer8', '8.0.20931-1', 'All-In-One Software for Remote Support and Online Meetings', 'teamviewer-quicksupport', '11.0.57095-2', 'Teamviewer Quicksupport - All-In-One Software for Remote Support and Online Meetings', 'teamviewer-openrc', '1.0-2', 'OpenRC scripts for teamviewer.', 'teamviewer-beta', '12.0.69753-1', 'All-In-One Software for Remote Support and Online Meetings - beta version', 'teamviewer11', '11.0.67687-1', 'All-in-one software for remote support and online meetings', 'teamviewer9', '9.0.32150-1', 'All-In-One Software for Remote Support and Online Meetings', 'teamviewer', '12.0.76279-6', 'All-In-One Software for Remote Support and Online Meetings']

I don't understand what is wrong with the code.
The full code is here

Body:
The module jsonpath was old. I resolved the problem by not using it.
I end up using the following code:

@cli.command()
@click.argument('search', required=False, nargs=-1)
def search(search):
    """ Search AUR repositorie for package name. """
    for srch in search:
        packs = urllib.request.urlopen("https://aur.archlinux.org//rpc/?v=5&type=search&arg="+srch).read()
        print(type(packs))
        somejson = json.loads(packs)
        somej = somejson['results']
        print(type(somej))
        for pkg in somej:
            print("Name: "+pkg['Name'])
            print("Version: "+pkg['Version'])
            print("Desc: "+pkg['Description'])
            print("################")


问:
Using array.push to build JSON array
Can't figure this out.

```<code>var states = [];
for(var i = 0; i<transactions.length; i++){

  var state = {name: transactions[i].name, amount: transactions[i].amount}
  console.log(state)
  states.push[state];
 console.log(states)
}
</code>```

Just trying to put together a an array of abbreviated transactions data as "states".

My printed console looks like:

```<code>{ name: 'United Airlines', amount: -500 }
[]
{ name: 'McDonald\'s', amount: 12 }
[]
{ name: 'Starbucks', amount: 4.33 }
[]
{ name: 'SparkFun', amount: 89.4 }
[]
{ name: 'INTRST PYMNT', amount: -4.22 }
[]  <<<<<nothing in my states array?
</code>```

答:
push is a function. Call it with ().

By using [], you're trying to access a property of the push object.

Title: Using array.push to build JSON array

Body:
Can't figure this out.

var states = [];
for(var i = 0; i<transactions.length; i++){

  var state = {name: transactions[i].name, amount: transactions[i].amount}
  console.log(state)
  states.push[state];
 console.log(states)
}

Just trying to put together a an array of abbreviated transactions data as "states".

My printed console looks like:

{ name: 'United Airlines', amount: -500 }
[]
{ name: 'McDonald\'s', amount: 12 }
[]
{ name: 'Starbucks', amount: 4.33 }
[]
{ name: 'SparkFun', amount: 89.4 }
[]
{ name: 'INTRST PYMNT', amount: -4.22 }
[]  <<<<<nothing in my states array?


问:
Rails scope for sorting most recent children, and including those without children
I have the first part of this working. I can successfully call the most recent List with this :

```<code>scope :most_recent_chats, -> {
  where(list_type: 'my').joins(:chat_lines)
  .where('chat_lines.created_at = (SELECT MAX(chat_lines.created_at) FROM chat_lines where chat_lines.list_id = lists.id)')
  .group('lists.id')
}
</code>```

However, if a List has no chat_lines, it doesn't get returned.

My question is, how can I return all List's sorted by their most recent children ( chat_lines ), even if they don't have children.

答:
The RAILS joins method performs an Inner joins (records with matches in both tables). What you are looking for is a Left Outer joins call (records in the first table that may have records in the second).  In rails 5 left_outer_joins does this type of call, in rails 4 and below  you have to be explicit by doing join('LEFT OUTER JOIN "chat_lines" ON "chat_lines"."list_id" = "list"."id"')

For more information on the different type of joins call go to https://www.w3schools.com/sql/sql_join.asp

For more information on the Rails joins methods
http://guides.rubyonrails.org/active_record_querying.html#joining-tables

For Rails 4

```<code>where(list_type: 'my').join('LEFT OUTER JOIN "chat_lines" ON "chat_lines"."list_id" = "list"."id"')
  .order("GREATEST(chat_lines.created_at, list.created_at) DESC").limit(1).first
</code>```

For Rails 5

```<code>where(list_type: 'my').left_outer_joins(:chat_lines)
  .order("GREATEST(chat_lines.created_at, list.created_at) DESC").limit(1).first
</code>```

Body:
I have the first part of this working. I can successfully call the most recent List with this :

scope :most_recent_chats, -> {
  where(list_type: 'my').joins(:chat_lines)
  .where('chat_lines.created_at = (SELECT MAX(chat_lines.created_at) FROM chat_lines where chat_lines.list_id = lists.id)')
  .group('lists.id')
}

However, if a List has no chat_lines, it doesn't get returned.

My question is, how can I return all List's sorted by their most recent children ( chat_lines ), even if they don't have children.

Body:
The RAILS joins method performs an Inner joins (records with matches in both tables). What you are looking for is a Left Outer joins call (records in the first table that may have records in the second).  In rails 5 left_outer_joins does this type of call, in rails 4 and below  you have to be explicit by doing join('LEFT OUTER JOIN "chat_lines" ON "chat_lines"."list_id" = "list"."id"')

For more information on the different type of joins call go to https://www.w3schools.com/sql/sql_join.asp

For more information on the Rails joins methods
http://guides.rubyonrails.org/active_record_querying.html#joining-tables

For Rails 4

where(list_type: 'my').join('LEFT OUTER JOIN "chat_lines" ON "chat_lines"."list_id" = "list"."id"')
  .order("GREATEST(chat_lines.created_at, list.created_at) DESC").limit(1).first

For Rails 5

where(list_type: 'my').left_outer_joins(:chat_lines)
  .order("GREATEST(chat_lines.created_at, list.created_at) DESC").limit(1).first


问:
C# Class Auto increment ID
I am creating a class in C# called "Robot", and each robot requires a unique ID property which  gives themselves an identity.

Is there any way of creating an auto incremental ID for each new class object? So, If i created 5 new robots, their IDs respectively will be 1, 2, 3, 4, 5. If I then destroy robot 2 and create a new robot later, it will have the ID of 2. And if I add a 6th it will have the ID of 6 and so on..

Thanks.

答:
```<code>public static void beAddedTo<T>(this T item, Dictionary<int, T> dic) where T : m.lib.RandId
{
    Random ran = new Random();
    var ri = ran.Next();
    while (Program.DB.Rooms.ContainsKey(ri)) ri = ran.Next();
    item.Id = ri;
    dic.Add(item.Id, item);
}
</code>```

Not incremental but you can add and delete item how many time you want.
(Maximum item should be lower than int.Max/2)

Title: C# Class Auto increment ID

Body:
public static void beAddedTo<T>(this T item, Dictionary<int, T> dic) where T : m.lib.RandId
{
    Random ran = new Random();
    var ri = ran.Next();
    while (Program.DB.Rooms.ContainsKey(ri)) ri = ran.Next();
    item.Id = ri;
    dic.Add(item.Id, item);
}

Not incremental but you can add and delete item how many time you want.
(Maximum item should be lower than int.Max/2)


问:
MIPS N-way associative cache
This is a question about memory organization which I have had very difficulty to understand,

Assume we have an N-way set associative cache with the capacity 4096bytes. The
set field size of the address is 7 bits and the tag field 21 bits. If we assume that
the cache is used together with a 32-bit processor, what is then the block size (in
bytes), how many valid bits does the cache contain, and what is the associativity of
the cache?

答:
Here are some equation that is good to know in order to solve question of these type.

Parameter to know

```<code>C = cache capacity
b = block size
B = number of blocks
N = degree of associativity
S = number of set
tag_bits
set_bits (also called index)
byte_offset
v = valid bits
</code>```

Equations to know

```<code>B = C/b
S = B/N
b = 2^(byte_offset)
S = 2^(set_bits)
</code>```

Memory Address

```<code>|___tag________|____set___|___byte offset_|
</code>```

Now to the question

known:

```<code>C = 4096 bytes
set_bits = 7
tag_bits = 21
32 bits address field
</code>```

Asked:

```<code>b?
N?
v?
</code>```

Simply subtract the tag_bits and set_bits from the 32 bit field this gives you the byte_offset.

```<code>byte_offset = 32-21-7 = 4 bits

b = 2^4 = 16 bytes
S = 2^7 = 128 set
B = C/b = 4096/16 = 256
N = B/S = 256/128 = 2
v = B = 256 valid bits
</code>```

Title: MIPS N-way associative cache

Body:
Here are some equation that is good to know in order to solve question of these type.

Parameter to know

C = cache capacity
b = block size
B = number of blocks
N = degree of associativity
S = number of set
tag_bits
set_bits (also called index)
byte_offset
v = valid bits

Equations to know

B = C/b
S = B/N
b = 2^(byte_offset)
S = 2^(set_bits)

Memory Address

|___tag________|____set___|___byte offset_|

Now to the question

known:

C = 4096 bytes
set_bits = 7
tag_bits = 21
32 bits address field

Asked:

b?
N?
v?

Simply subtract the tag_bits and set_bits from the 32 bit field this gives you the byte_offset.

byte_offset = 32-21-7 = 4 bits

b = 2^4 = 16 bytes
S = 2^7 = 128 set
B = C/b = 4096/16 = 256
N = B/S = 256/128 = 2
v = B = 256 valid bits


问:
All source files for cocoa pods are compiled twice
I have an Xcode project (objective c, Xcode 8.2.1).

Whenever I do "Clean build" and build again, it takes a very long time. I started to look into the reason for this and I noticed that all my pod source files are being compiled twice (which I guess doubles the compile time).

At the top of Xcode, you can see the status of the build as it progresses

You can see in the screenshot above that Xcode is compiling 142 source files for the Realm pod, but it only has 71 source files. All my other pods have the same issue.

I tested creating a new xcode project and adding pods, and then I don't experience the same problem as in this project.

@Bdash suggested that I might be having the build setting "Build Active Architecture Only" set to "No", but I have checked this and it is set to "Yes".

Any ideas on what could be the problem here?

答:
This tends to happen when you have custom names for your build configurations. That is, if you have a name other than Debug or Release, CocoaPods will treat such configurations as release ones. Besides other things, this means enabling optimizations and setting the Build Active Architecture Only flag for those Pods to YES. Both options will hinder compilation times for Debug configurations.

To fix it you have to specify which configurations are Debug ones. Following the docs, you have to change your Podfile so it looks something like this:

```<code>project 'MyApp', 'MyAppRelease' => :release, 'MyAppDebug' => :debug
</code>```

Body:
This tends to happen when you have custom names for your build configurations. That is, if you have a name other than Debug or Release, CocoaPods will treat such configurations as release ones. Besides other things, this means enabling optimizations and setting the Build Active Architecture Only flag for those Pods to YES. Both options will hinder compilation times for Debug configurations.

To fix it you have to specify which configurations are Debug ones. Following the docs, you have to change your Podfile so it looks something like this:

project 'MyApp', 'MyAppRelease' => :release, 'MyAppDebug' => :debug


问:
Hibernate Timestamp with Timezone
I'm new to Hibernate and am working with an Oracle 10g database. We have columns in our tables that are of type TIMESTAMP WITH TIMEZONE. Hibernate does not seem to support this mapping directly. Is there a standard way to go about this?

答: An example of a UserType storing java.util.Calendar with time zone information is given in this blog post: http://www.joobik.com/2010/12/mapping-dates-and-time-zones-with.html</p>

OwnerDisplayName: Imran

Title: Hibernate Timestamp with Timezone


问:
Get only filename from full path of a file
I want to split the path and just save the file name test.xls in a new variable

```<code>$namearray = "C:\Users\z003m\Desktop\Service_Tickets\automationscript\vbs\Newfolder\test.xls"
</code>```

答:
Recommend using the built-in Split-Path:

```<code>$newVariable = Split-Path $namearray -Leaf
</code>```

Body:
I want to split the path and just save the file name test.xls in a new variable

$namearray = "C:\Users\z003m\Desktop\Service_Tickets\automationscript\vbs\Newfolder\test.xls"

Body:
Recommend using the built-in Split-Path:

$newVariable = Split-Path $namearray -Leaf


问:
Row wise operations in R
I have a dataframe with following layout:

```<code>id |diff
----
1 | 0
1 | 3
1 | 45
1 | 9
1 | 40
1 | 34
1 | 43
1 | 7
2 | 0
2 | 5
3 | 0
3 | 45
3 | 40
</code>```

I need to add a counter in a such a way that :

when the id changes the counter should reset to 1

when the id is same and the diff is less than 10 the counter shall give the preceding counter value.

when the id is same and the diff is greater than 10 the counter shall be incremented by +1.

The output I am looking for is :

```<code>id |diff | counter
-------------
1 | 0 | 1
1 | 3 | 1
1 | 45 | 2
1 | 9 |  2
1 | 40 | 3
1 | 34 | 4
1 | 43 | 5
1 | 7  | 5
2 | 0  | 1
2 | 5  | 1
3 | 0  | 1
3 | 45 | 2
3 | 40 | 3
</code>```

The for loop solution is :

```<code>for(i in 2:nrow(raw_data)){
  raw_data$counter[i]<- ifelse(raw_data$id[i]==raw_data$id[i-1],
        ifelse(raw_data$diff> 10,raw_data$counter[i-1] +1,raw_data$counter[i-1])
          ,1)}
</code>```

I am aware of the increase in time due to 'for' loop. Looking for a faster way.

答:
Hers's how to do that with dplyr:

```<code>df1 <- read.table(text="id diff
                  1  0
                  1  3
                  1  45
                  1  9
                  1  40
                  1  34
                  1  43
                  1  7
                  2  0
                  2  5
                  3  0
                  3  45
                  3  40",header=TRUE, stringsAsFactors=FALSE)
library(dplyr)
df1%>%
  group_by(id)%>%
  mutate(counter=cumsum(diff>10)+1)

      id  diff counter
   <int> <int>   <dbl>
1      1     0       1
2      1     3       1
3      1    45       2
4      1     9       2
5      1    40       3
6      1    34       4
7      1    43       5
8      1     7       5
9      2     0       1
10     2     5       1
11     3     0       1
12     3    45       2
13     3    40       3
</code>```

Title: Row wise operations in R

Body:
I have a dataframe with following layout:

id |diff
----
1 | 0
1 | 3
1 | 45
1 | 9
1 | 40
1 | 34
1 | 43
1 | 7
2 | 0
2 | 5
3 | 0
3 | 45
3 | 40

I need to add a counter in a such a way that :

when the id changes the counter should reset to 1

when the id is same and the diff is less than 10 the counter shall give the preceding counter value.

when the id is same and the diff is greater than 10 the counter shall be incremented by +1.

The output I am looking for is :

id |diff | counter
-------------
1 | 0 | 1
1 | 3 | 1
1 | 45 | 2
1 | 9 |  2
1 | 40 | 3
1 | 34 | 4
1 | 43 | 5
1 | 7  | 5
2 | 0  | 1
2 | 5  | 1
3 | 0  | 1
3 | 45 | 2
3 | 40 | 3

The for loop solution is :

for(i in 2:nrow(raw_data)){
  raw_data$counter[i]<- ifelse(raw_data$id[i]==raw_data$id[i-1],
        ifelse(raw_data$diff> 10,raw_data$counter[i-1] +1,raw_data$counter[i-1])
          ,1)}

I am aware of the increase in time due to 'for' loop. Looking for a faster way.

Body:
Hers's how to do that with dplyr:

df1 <- read.table(text="id diff
                  1  0
                  1  3
                  1  45
                  1  9
                  1  40
                  1  34
                  1  43
                  1  7
                  2  0
                  2  5
                  3  0
                  3  45
                  3  40",header=TRUE, stringsAsFactors=FALSE)
library(dplyr)
df1%>%
  group_by(id)%>%
  mutate(counter=cumsum(diff>10)+1)

      id  diff counter
   <int> <int>   <dbl>
1      1     0       1
2      1     3       1
3      1    45       2
4      1     9       2
5      1    40       3
6      1    34       4
7      1    43       5
8      1     7       5
9      2     0       1
10     2     5       1
11     3     0       1
12     3    45       2
13     3    40       3


问:
Python 3.5 (32-bit): ImportError: cannot import name NUMPY_MKL
I am new to Python and I am trying to install numpy+mkl and scipy (in the same order), but I get below error when I execute following steps:

```<code>import pandas as pd
import numpy as np
from sklearn.preprocessing import LabelEncoder
</code>```

I am using Python 3.5 (32-bit) on a Windows 7 64-bit OS.

There is a similar question already answered for the exact problem here: ImportError: cannot import name NUMPY_MKL

Going through the answer, I reinstalled my numpy+mkl pkg numpy‑1.11.2+mkl‑cp35‑cp35m‑win32.whl from the mentioned link (http://www.lfd.uci.edu/~gohlke/pythonlibs/#numpy) and then reinstalled scipy-0.18.1-cp35-cp35m-win32.whl as well, but that does not solve the problem and I still get the same error:

```<code>>>> exec(open("C:\\PythonFiles\\testpy1.py").read())
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<string>", line 3, in <module>
  File "C:\Users\msoudagar\AppData\Local\Programs\Python\Python3532\lib\site-packages\sklearn\__init__.py", line 57, in <module>
    from .base import clone
  File "C:\Users\msoudagar\AppData\Local\Programs\Python\Python35-32\lib\site-packages\sklearn\base.py", line 10, in <module>
    from scipy import sparse
  File "C:\Users\msoudagar\AppData\Local\Programs\Python\Python3532\lib\site-packages\scipy\__init__.py", line 61, in <module>
    from numpy._distributor_init import NUMPY_MKL  # requires numpy+mkl
ImportError: cannot import name 'NUMPY_MKL'
</code>```

Any inputs would be really helpful!

答:
I ran into the same issue on Windows with Python 3.5 64 bit. Manually installing numpy+mkl from wheel file solved the issue for me.
Select the appropriate wheel file from here (cp35,win32 for you):  and install it using pip install --user Path_to_local_file.whl replacing Path_to_local_file with wherever you saved the .whl file

This is a also a duplicate of ImportError: cannot import name NUMPY_MKL

Body:
I am new to Python and I am trying to install numpy+mkl and scipy (in the same order), but I get below error when I execute following steps:

import pandas as pd
import numpy as np
from sklearn.preprocessing import LabelEncoder

I am using Python 3.5 (32-bit) on a Windows 7 64-bit OS.

There is a similar question already answered for the exact problem here: ImportError: cannot import name NUMPY_MKL

Going through the answer, I reinstalled my numpy+mkl pkg numpy‑1.11.2+mkl‑cp35‑cp35m‑win32.whl from the mentioned link (http://www.lfd.uci.edu/~gohlke/pythonlibs/#numpy) and then reinstalled scipy-0.18.1-cp35-cp35m-win32.whl as well, but that does not solve the problem and I still get the same error:

>>> exec(open("C:\\PythonFiles\\testpy1.py").read())
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<string>", line 3, in <module>
  File "C:\Users\msoudagar\AppData\Local\Programs\Python\Python3532\lib\site-packages\sklearn\__init__.py", line 57, in <module>
    from .base import clone
  File "C:\Users\msoudagar\AppData\Local\Programs\Python\Python35-32\lib\site-packages\sklearn\base.py", line 10, in <module>
    from scipy import sparse
  File "C:\Users\msoudagar\AppData\Local\Programs\Python\Python3532\lib\site-packages\scipy\__init__.py", line 61, in <module>
    from numpy._distributor_init import NUMPY_MKL  # requires numpy+mkl
ImportError: cannot import name 'NUMPY_MKL'

Any inputs would be really helpful!


问:
Creating List in a loop
Is there any way to create a loop which will be creating new List

```<code>static Map<Integer, List> dataMap = new HashMap<>();
public static void dec_hex() {

        // Map<Integer, Integer> dataMap = new HashMap<>();
        // dataMap.put(0, 0);
        List<Integer> ls2 = new ArrayList<Integer>();
        List<Integer> ls3 = new ArrayList<Integer>();
        List<Integer> ls4 = new ArrayList<Integer>();
        List<Integer> ls5 = new ArrayList<Integer>();
        List<Integer> ls6 = new ArrayList<Integer>();
        List<Integer> ls7 = new ArrayList<Integer>();
        List<Integer> ls8 = new ArrayList<Integer>();
        List<Integer> ls9 = new ArrayList<Integer>();
        List<Integer> ls10 = new ArrayList<Integer>();

        System.out.println("Liczby");
        for (int i = 0; i < 201; i++) {
            String hex = Integer.toHexString(i);
            System.out.println("DEC: " + i + " HEX: " + hex);
            //for (int a = 2; a<11 ; a++){
            if (i % 2 == 0) {
                ls2.add(i);
                //myList.add(i);
                dataMap.put(2, ls2);
            }
            if (i % 3 == 0) {
                ls3.add(i);
                //myList.add(i);
                dataMap.put(3, ls3);
            }

            if (i % 4 == 0) {
                ls4.add(i);
                //myList.add(i);
                dataMap.put(4, ls4);
            }
            if (i % 5 == 0) {
                ls5.add(i);
                //myList.add(i);
                dataMap.put(5, ls5);
            }
            if (i % 6 == 0) {
                ls6.add(i);
                //myList.add(i);
                dataMap.put(6, ls6);
            }
            if (i % 7 == 0) {
                ls7.add(i);
                //myList.add(i);
                dataMap.put(7, ls7);
            }
            if (i % 8 == 0) {
                ls8.add(i);
            //  myList.add(i);
                dataMap.put(8, ls8);
            }
            if (i % 9 == 0) {
                ls9.add(i);
                //myList.add(i);
                dataMap.put(9, ls9);
            }
            if (i % 10 == 0) {
                ls10.add(i);
                //myList.add(i);
                dataMap.put(10, ls10);
            }
        }

        //String list = myList.toString();
        //System.out.println(list);
        dataMap.toString();
        System.out.println(dataMap);

    }
</code>```

Is there any way to create a loop to check if number is divisible?
If I'm going to use this

```<code>    for (int a = 2; a<11 ; a++){
 lsa.add(i); // lets say we've got one list
 dataMap.put(a, ls);
}
</code>```

The program won't work correctly cause the numbers will reapeat, cause I'm using the same lsa array.

答:
You can create a List of Lists.

```<code>int max = 10;
List<List<String>> listOfLists = new ArrayList<>();
for(int i=0; i<max; i++) {
             //create a new list and add it to listOfLists
    List<String> myList = new ArrayList<>();
    listOfLists.add(myList);
}
</code>```

Hope this helps. :)

Title: Creating List in a loop

Body:
Is there any way to create a loop which will be creating new List

static Map<Integer, List> dataMap = new HashMap<>();
public static void dec_hex() {

        // Map<Integer, Integer> dataMap = new HashMap<>();
        // dataMap.put(0, 0);
        List<Integer> ls2 = new ArrayList<Integer>();
        List<Integer> ls3 = new ArrayList<Integer>();
        List<Integer> ls4 = new ArrayList<Integer>();
        List<Integer> ls5 = new ArrayList<Integer>();
        List<Integer> ls6 = new ArrayList<Integer>();
        List<Integer> ls7 = new ArrayList<Integer>();
        List<Integer> ls8 = new ArrayList<Integer>();
        List<Integer> ls9 = new ArrayList<Integer>();
        List<Integer> ls10 = new ArrayList<Integer>();

        System.out.println("Liczby");
        for (int i = 0; i < 201; i++) {
            String hex = Integer.toHexString(i);
            System.out.println("DEC: " + i + " HEX: " + hex);
            //for (int a = 2; a<11 ; a++){
            if (i % 2 == 0) {
                ls2.add(i);
                //myList.add(i);
                dataMap.put(2, ls2);
            }
            if (i % 3 == 0) {
                ls3.add(i);
                //myList.add(i);
                dataMap.put(3, ls3);
            }

            if (i % 4 == 0) {
                ls4.add(i);
                //myList.add(i);
                dataMap.put(4, ls4);
            }
            if (i % 5 == 0) {
                ls5.add(i);
                //myList.add(i);
                dataMap.put(5, ls5);
            }
            if (i % 6 == 0) {
                ls6.add(i);
                //myList.add(i);
                dataMap.put(6, ls6);
            }
            if (i % 7 == 0) {
                ls7.add(i);
                //myList.add(i);
                dataMap.put(7, ls7);
            }
            if (i % 8 == 0) {
                ls8.add(i);
            //  myList.add(i);
                dataMap.put(8, ls8);
            }
            if (i % 9 == 0) {
                ls9.add(i);
                //myList.add(i);
                dataMap.put(9, ls9);
            }
            if (i % 10 == 0) {
                ls10.add(i);
                //myList.add(i);
                dataMap.put(10, ls10);
            }
        }

        //String list = myList.toString();
        //System.out.println(list);
        dataMap.toString();
        System.out.println(dataMap);

    }

Is there any way to create a loop to check if number is divisible?
If I'm going to use this

    for (int a = 2; a<11 ; a++){
 lsa.add(i); // lets say we've got one list
 dataMap.put(a, ls);
}

The program won't work correctly cause the numbers will reapeat, cause I'm using the same lsa array.

Body:
You can create a List of Lists.

int max = 10;
List<List<String>> listOfLists = new ArrayList<>();
for(int i=0; i<max; i++) {
             //create a new list and add it to listOfLists
    List<String> myList = new ArrayList<>();
    listOfLists.add(myList);
}

Hope this helps. :)


问:
Show user's name on Facebook Page Tab
I have a fan page on Facebook and I'd like to show a christmas message to the people who like the page.

The idea is:

If user likes page > say: "Merry Christmas first_name"
if user doesn't like the page > show generic message

I thought I'd be able to get the user's 1st name to display just that, since I don't want to store anything, but so far no success.

My code is:

```<code>require 'facebook.php';

$facebook = new Facebook(array(
  'appId'  => 'xx',
  'secret' => 'xx',
  'cookie' => true,
));

$session = $facebook->getSession();

$me = null;

if ($session)
{
  try
  {
    $uid = $facebook->getUser();
    $me = $facebook->api('/me');
  }
  catch (FacebookApiException $e)
  {
    error_log($e);
  }
}

$name = $me['first_name'];

echo 'Merry Christmas x ' . $name . ' x ' . $uid;
</code>```

But all it echoes is: "Merry Christmas x x 106998XX369535"

Where the number is the page's id, not the user's id.

Is there any way to do this without asking the user's permission?

答:
You cannot get any information about the user unless the user gives permission. Unfortunately.

But with "OAuth 2.0 for Canvas" you do receive a the signed_request POST. And this way is the only way to go about it; http://developers.facebook.com/docs/authentication/canvas

But user still needs to authorize your application.

ContentLicense: CC BY-SA 4.0

Title: Show user's name on Facebook Page Tab

Body:
I have a fan page on Facebook and I'd like to show a christmas message to the people who like the page.

The idea is:

If user likes page > say: "Merry Christmas first_name"
if user doesn't like the page > show generic message

I thought I'd be able to get the user's 1st name to display just that, since I don't want to store anything, but so far no success.

My code is:

require 'facebook.php';

$facebook = new Facebook(array(
  'appId'  => 'xx',
  'secret' => 'xx',
  'cookie' => true,
));

$session = $facebook->getSession();

$me = null;

if ($session)
{
  try
  {
    $uid = $facebook->getUser();
    $me = $facebook->api('/me');
  }
  catch (FacebookApiException $e)
  {
    error_log($e);
  }
}

$name = $me['first_name'];

echo 'Merry Christmas x ' . $name . ' x ' . $uid;

But all it echoes is: "Merry Christmas x x 106998XX369535"

Where the number is the page's id, not the user's id.

Is there any way to do this without asking the user's permission?

ContentLicense: CC BY-SA 2.5


问:
Is there any reason for GC to "slow" current execution even though GC logs show it doesn't?
Here is a description of my java program :

It is an optimization algorithm that runs for hours in a Thread, that
    is often interrupted by the service for querying stuff about the
    current optimization.

The optimization routine is a succession of simple operations (let us
  call it "moves") that are repeated over and over. Sometimes, the
  optimization procedure will slow down a lot : a move generally takes
  less than 100ms, and sometimes, it will take several seconds, even
  minutes.

Of course I thought about GC freezing the execution while performing full GC so I did some experiment and according to GC logs, minor collection are done very regularly and take 10ms, while full GC is very rare and takes no more than 2 seconds. I also ran some analysis via GC log analysis tools and the Throughput hits more than 95%. As an exemple, on a 7 minutes test run, there is only between 2 and 3 seconds lost due to GC according to GC log.

One should conclude GC is not the problem here. However, I observed that trying other GC algorithms would have quite a huge impact on how much time the "worst" moves will take (it can double/triple the execution time of "moves" when it starts to slow down). Therefore, GC seems to have an impact on it, even though GC logs tells me GC is not taking time.

Moreover, I also observe that "moves" tends to slow down in sequence : when one move slows down, the following one has a greater chance to slow down as well, even though they are not related in any way as these operations are fully independant. It just feels like the whole system is slowing down at some times, especially when the service is called a lot.

I read some things about memory fragmentation of heapspace that could lead to major slowing down in applications, and as my moves are creating and destroying a lot of objects, that could explain what I am experiencing here. However, I don't see why GC logs don't show this.

I am really reaching the limits of my knowledge and exeperience here and I would take any intuition or clue you may have to investigate further.

答:
Another explanation is that the cause of the slow-down is outside of the Java application.

It could be due to competition for CPU cycles with other processes.

It could be due to competition for memory (resulting in paging).

If you are running in a virtual machine, the resource competition could be between different VMs.

Or, it could be some unexpected behavior in your application:

Are you using WeakReference or SoftReference objects.

Do you use finalize() methods?

Have you tried profiling the application?

I suggest you try using OS-provided performance tools to see if there is other activity on the system that correlated to the pauses.  Also, looks for slowdowns / pauses in the system itself.


问:
Reading data from txt file using javascript, every 5 min
I'm trying to make the website that shows current temp at home and allows me to set the temp as I want. To read temp I use raspberry pi zero and python code to save the temp in every 5 min to the .txt file. The problem is that I need to read current temp on my website from that file in let's say very 5 min. I can use:

    <meta http-equiv="Refresh" content="s" />

But it doesn't look like a good choice so I though that I can use javascript and read data from the file. Unfortunately this function works only once no matter what I change in .txt file and refresh the web, output is still the same (looks like it save previous data to some kind of the global variable).

```<code>function readTextFile()
            {
                var rawFile = new XMLHttpRequest();
                rawFile.open("GET", 'text.txt', true);
                rawFile.onreadystatechange = function ()
            {
                if(rawFile.readyState === 4)
            {
                if(rawFile.status === 200 || rawFile.status == 0)
            {
                var allText = rawFile.responseText;
                alert(allText);
            }
        }
    }
    rawFile.send(null);
}
</code>```

On the left side at this picture there are data from the txt file (using php), and at the alert handler are data using javascript and submit button. These data should be the same.

So the question is: Can I read from a .txt file when its dynamicly change? And if so, how can I do it or what function use to do it? I don't know javascript very well.
I will be very grateful for help.

答:
Using XHR to fetch records in a defined interval is not a good solution. I would recommend you to use JavaScript EventSource API. You can use it to receive text/event-stream at a defined interval. You can learn more about it here -

https://developer.mozilla.org/en-US/docs/Web/API/EventSource

For your application, you can do this -

JavaScript -

var evtSource = new EventSource('PATH_TO_PHP_FILE');

evtSource.onmessage = function(e) {
    //e.data contains the fetched data
}
```
<h3>PHP Code -</h3>
<pre class="lang-php prettyprint-override"><code><?php
    header('Content-Type: text/event-stream');
    header('Cache-Control: no-cache');
    $myfile = fopen("FILE_NAME.txt", "r");
    echo "data:". fread($myfile,filesize("FILE_NAME.txt"))."\n\n";
    fclose($myfile);
    flush();
?>
</code>```

Body:
I'm trying to make the website that shows current temp at home and allows me to set the temp as I want. To read temp I use raspberry pi zero and python code to save the temp in every 5 min to the .txt file. The problem is that I need to read current temp on my website from that file in let's say very 5 min. I can use:

    <meta http-equiv="Refresh" content="s" />

But it doesn't look like a good choice so I though that I can use javascript and read data from the file. Unfortunately this function works only once no matter what I change in .txt file and refresh the web, output is still the same (looks like it save previous data to some kind of the global variable).

function readTextFile()
            {
                var rawFile = new XMLHttpRequest();
                rawFile.open("GET", 'text.txt', true);
                rawFile.onreadystatechange = function ()
            {
                if(rawFile.readyState === 4)
            {
                if(rawFile.status === 200 || rawFile.status == 0)
            {
                var allText = rawFile.responseText;
                alert(allText);
            }
        }
    }
    rawFile.send(null);
}

On the left side at this picture there are data from the txt file (using php), and at the alert handler are data using javascript and submit button. These data should be the same.

So the question is: Can I read from a .txt file when its dynamicly change? And if so, how can I do it or what function use to do it? I don't know javascript very well.
I will be very grateful for help.

Body:
Using XHR to fetch records in a defined interval is not a good solution. I would recommend you to use JavaScript EventSource API. You can use it to receive text/event-stream at a defined interval. You can learn more about it here -

https://developer.mozilla.org/en-US/docs/Web/API/EventSource

For your application, you can do this -

JavaScript -

var evtSource = new EventSource('PATH_TO_PHP_FILE');

evtSource.onmessage = function(e) {
    //e.data contains the fetched data
}

PHP Code -

<?php
    header('Content-Type: text/event-stream');
    header('Cache-Control: no-cache');
    $myfile = fopen("FILE_NAME.txt", "r");
    echo "data:". fread($myfile,filesize("FILE_NAME.txt"))."\n\n";
    fclose($myfile);
    flush();
?>


问:
Spark in memory when using SparkSession with enableHiveSupport
I want to know, when we use SparkSession with enableHiveSupport, does the spark maintain the whole data from the Hive table in memory or just the Dataset that we get as ResultSet after firing the hive query.</p>

答:
This is a issue about how Spark works.

First I will suggest you to read this

About to store the table in memory, this will not happens until you call cache() method as you can see here.

When you call enableHiveSupport() you are taking access to the metadata of your tables. All informations that is not the real data. When you call the transofrmations you will handle only the metadata to find the most efficient way to execute your data. When you call actions this will load your data from hive, load what is necessary to memory and will sotore the final data in memory just if you request.

I really suggest you to do a deep reading at the Quick Start Guide


问:
Angular directive testing select options
How do you select an option in an angular directive test?

```<code> var options = elem.find('#test-code-select option');
 expect(angular.element(options[0]).text()).to.equal('234');
 expect(angular.element(options[1]).text()).to.equal('236');
</code>```

These work fine, but how do I manually force the selection of an option?

```<code>angular.element(options[1]).click(); //nope
angular.element(options[1]).trigger('click'); //nope
angular.element(options[1]).attr('selected', true); //nope
</code>```

EDIT:

The directive template includes a select with an internal ng-model, I suspect this is the cause of the problem:

```<code><select id='test-code-select' ng-options='code as code for code in codeList' ng-model='code'>
</code>```

答:
I added this as another approach besides what has been answered by @ejain.

If you have jquery avaiable (i.e., not jqLite), I think the following should also work by triggering change on option:

```<code>var select = elem.find('#test-code-select');
var oneOption = select.find('option:contains("236")');
oneOption.prop('selected', 'selected').trigger('change');
expect(scope.code).toEqual('236');
</code>```

Body:
How do you select an option in an angular directive test?

 var options = elem.find('#test-code-select option');
 expect(angular.element(options[0]).text()).to.equal('234');
 expect(angular.element(options[1]).text()).to.equal('236');

These work fine, but how do I manually force the selection of an option?

angular.element(options[1]).click(); //nope
angular.element(options[1]).trigger('click'); //nope
angular.element(options[1]).attr('selected', true); //nope

EDIT:

The directive template includes a select with an internal ng-model, I suspect this is the cause of the problem:

<select id='test-code-select' ng-options='code as code for code in codeList' ng-model='code'>

Body:
I added this as another approach besides what has been answered by @ejain.

If you have jquery avaiable (i.e., not jqLite), I think the following should also work by triggering change on option:

var select = elem.find('#test-code-select');
var oneOption = select.find('option:contains("236")');
oneOption.prop('selected', 'selected').trigger('change');
expect(scope.code).toEqual('236');


问:
Code Options for Location & LocationPoint don't work on TextElement
```<code>The Revit API does not seem to have enabled certain aspects of either Location or LocationPoint with respect to TextElements.  When using the code below, the result is the error "Object reference not set to an instance of an object".  As noted with comments, it claims to get a Location, and also a LocationPoint, but there is nothing in the .Point.X (Y Z).  Note also that I am picking an actual TextElement in the first line.

    Reference One_Pick = uiDoc.Selection.PickObject(ObjectType.Element, "Select First Text");
    Id1 = One_Pick.ElementId;
    One_Pikt = uiDoc.Document.GetElement(One_Pick) as TextElement;
    Location One_Location = One_Pikt.Location;//does not fail;
    LocationPoint One_Pt = One_Location as LocationPoint;//does not fail;
    Double XX = One_Pt.Point.X; Double YY = One_Pt.Point.Y; Double ZZ = One_Pt.Point.Z;//fails setting XX
</code>```

What I am wanting to do is either sort multiple text elements by location, or else MOVE a text so it's justification point is at the midpoint or end of an object.

Revit version is 2016

答:
Yes indeed. The TextBox does not implement the Location property. The  Location property can provide either single point or a curve data. Unfortunately, the TextBox location is represented by something more complex, e.g., multiple points, which is not representable using LocationCurve or LocationPoint. Therefore, nothing at all is returned for text elements. You can query the text bounding box instead:

http://thebuildingcoder.typepad.com/blog/2014/10/new-text-note-and-text-width-calculation.html

Body:
The Revit API does not seem to have enabled certain aspects of either Location or LocationPoint with respect to TextElements.  When using the code below, the result is the error "Object reference not set to an instance of an object".  As noted with comments, it claims to get a Location, and also a LocationPoint, but there is nothing in the .Point.X (Y Z).  Note also that I am picking an actual TextElement in the first line.

    Reference One_Pick = uiDoc.Selection.PickObject(ObjectType.Element, "Select First Text");
    Id1 = One_Pick.ElementId;
    One_Pikt = uiDoc.Document.GetElement(One_Pick) as TextElement;
    Location One_Location = One_Pikt.Location;//does not fail;
    LocationPoint One_Pt = One_Location as LocationPoint;//does not fail;
    Double XX = One_Pt.Point.X; Double YY = One_Pt.Point.Y; Double ZZ = One_Pt.Point.Z;//fails setting XX

What I am wanting to do is either sort multiple text elements by location, or else MOVE a text so it's justification point is at the midpoint or end of an object.

Revit version is 2016


问:
Is this a bug of Scala, when defining a list such as :
I want to define a list[Char] in scala, but made a mistake. I missed a single quote character following 'b'. However I got a List[Any] instance. Is it a bug of Scala or normal result?

scala> val list = List('a',**'b**,'c','d')
list: List[Any] = List(a, 'b, c, d)

答:
It's not a bug. Single character leading means Symbol in Scala. I just knew that.
I'm sorry. I am just a beginner of Scala. </p>


问:
Webpack Normal Module Replacement for branding
I'm working on a brandable product and I have following folder structure:

```<code>-> default js folder
-> brands folder
----> a brand
--------> js
------------> brand specific js file
</code>```

I want to override a brand specific Javascript file with a default file (both of files have same name - for example I have a profile.js file for each folder) while bundling is in progress on Webpack. I found a way which is Normal Module Replacement but I couldn't realize it.

How can I do it? Can someone share an example Webpack config please?

答:
You can use resolve alias to override resolving of a file based on configuration (in this case, brand name or fallback to default). Here is a simple example:

```<code>const path = require('path');
const brand = process.env.BRAND;

// Then add this to your Webpack config
{
 ...
 resolve: {
   alias: {
     brand: brand
        ? path.resolve(__dirname, 'src', brand)
        : path.resolve(__dirname, 'src', 'defaultDirectory'), 'profile.js')
   }
 }
}
</code>```

Afterwards, when you need to bundle for a certain brand, just set BRAND=somebrand in the environment variable. Whenever you do import Profile from 'brand/profile' and import Contact from 'brand/contact', it will resolve to ./src/somebrand/profile.js and ./src/somebrand/contact.js, respectively.  It will fallback to default ./src/defaultDirectory/profile.js and ./src/defaultDirectory/contact.js if BRAND is not defined.

You can see more usage in documentation

Body:
I'm working on a brandable product and I have following folder structure:

-> default js folder
-> brands folder
----> a brand
--------> js
------------> brand specific js file

I want to override a brand specific Javascript file with a default file (both of files have same name - for example I have a profile.js file for each folder) while bundling is in progress on Webpack. I found a way which is Normal Module Replacement but I couldn't realize it.

How can I do it? Can someone share an example Webpack config please?

Body:
You can use resolve alias to override resolving of a file based on configuration (in this case, brand name or fallback to default). Here is a simple example:

const path = require('path');
const brand = process.env.BRAND;

// Then add this to your Webpack config
{
 ...
 resolve: {
   alias: {
     brand: brand
        ? path.resolve(__dirname, 'src', brand)
        : path.resolve(__dirname, 'src', 'defaultDirectory'), 'profile.js')
   }
 }
}

Afterwards, when you need to bundle for a certain brand, just set BRAND=somebrand in the environment variable. Whenever you do import Profile from 'brand/profile' and import Contact from 'brand/contact', it will resolve to ./src/somebrand/profile.js and ./src/somebrand/contact.js, respectively.  It will fallback to default ./src/defaultDirectory/profile.js and ./src/defaultDirectory/contact.js if BRAND is not defined.

You can see more usage in documentation


问:
Solr Tika, Text with style
I've seen  this link:
http://www.lucidimagination.com/Community/Hear-from-the-Experts/Articles/Content-Extraction-Tika
What I got is pure text without any style from Tika for Solr to search in .
Is it possible to have the text with its style from Solr?
In other words, we need to show text with its original style after searched by solr .</p>

答:
If you think about it, what is "original style" in a pdf? What components of the "style" do you want to keep?

It's not just font and weight, it's stroke, fill, angle, path, graphics, tracking, transparency, transformations and more. IF you got all that, how would you display it in your UI/Web?

You can't really replicate the original style any way other than displaying the original PDF. So that's the way people usually do it if they want the original formatting.

Otherwise, they just use the pure text.

Title: Solr Tika, Text with style


问:
Spring application doesn't work with compiled jar
I have a spring application which I'm trying to launch from compiled jar , and it's doesn't work for me.

The exception I'm getting is :

```<code>Failed to read schema document 'http://www.springframework.org/schema/beans/spring-beans-3.0.xsd', because 1) could not find the document; 2) the document could not be read; 3) the root element of the document is not <xsd:schema>.
</code>```

my bean's configuration file looks like :

```<code><beans
        xmlns="http://www.springframework.org/schema/beans"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns:context="http://www.springframework.org/schema/context"
       xsi:schemaLocation="
            http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
            http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd"
       default-init-method="init" default-destroy-method="destroy">
</code>```

The full stack trace :

```<code>#233 2015-08-05 18:04:32,686 |DEBUG| [main] [org.springframework.beans.factory.xml.PluggableSchemaResolver] org.springframework.beans.factory.xml.PluggableSchemaResolver.getSchemaMappings(PluggableSchemaResolver.java:146):
Loaded schema mappings: {http://www.springframework.org/schema/context/spring-context-3.1.xsd=org/springframework/context/config/spring-context-3.1.xsd, http://www.springframework.org/schema/lang/spring-lang-2.5.xsd=org/springframework/scripting/config/spring-lang-2.5.xsd, http://www.springframework.org/schema/lang/spring-lang.xsd=org/springframework/scripting/config/spring-lang-3.2.xsd, http://www.springframework.org/schema/context/spring-context-2.5.xsd=org/springframework/context/config/spring-context-2.5.xsd, http://www.springframework.org/schema/cache/spring-cache-3.1.xsd=org/springframework/cache/config/spring-cache-3.1.xsd, http://www.springframework.org/schema/lang/spring-lang-3.2.xsd=org/springframework/scripting/config/spring-lang-3.2.xsd, http://www.springframework.org/schema/context/spring-context.xsd=org/springframework/context/config/spring-context-3.2.xsd, http://www.springframework.org/schema/task/spring-task-3.0.xsd=org/springframework/scheduling/config/spring-task-3.0.xsd, http://www.springframework.org/schema/jee/spring-jee-3.1.xsd=org/springframework/ejb/config/spring-jee-3.1.xsd, http://www.springframework.org/schema/task/spring-task.xsd=org/springframework/scheduling/config/spring-task-3.2.xsd, http://www.springframework.org/schema/context/spring-context-3.0.xsd=org/springframework/context/config/spring-context-3.0.xsd, http://www.springframework.org/schema/lang/spring-lang-3.1.xsd=org/springframework/scripting/config/spring-lang-3.1.xsd, http://www.springframework.org/schema/task/spring-task-3.2.xsd=org/springframework/scheduling/config/spring-task-3.2.xsd, http://www.springframework.org/schema/jee/spring-jee.xsd=org/springframework/ejb/config/spring-jee-3.2.xsd, http://www.springframework.org/schema/cache/spring-cache.xsd=org/springframework/cache/config/spring-cache-3.2.xsd, http://www.springframework.org/schema/context/spring-context-3.2.xsd=org/springframework/context/config/spring-context-3.2.xsd, http://www.springframework.org/schema/cache/spring-cache-3.2.xsd=org/springframework/cache/config/spring-cache-3.2.xsd, http://www.springframework.org/schema/jee/spring-jee-3.0.xsd=org/springframework/ejb/config/spring-jee-3.0.xsd, http://www.springframework.org/schema/jee/spring-jee-2.0.xsd=org/springframework/ejb/config/spring-jee-2.0.xsd, http://www.springframework.org/schema/jee/spring-jee-2.5.xsd=org/springframework/ejb/config/spring-jee-2.5.xsd, http://www.springframework.org/schema/lang/spring-lang-3.0.xsd=org/springframework/scripting/config/spring-lang-3.0.xsd, http://www.springframework.org/schema/task/spring-task-3.1.xsd=org/springframework/scheduling/config/spring-task-3.1.xsd, http://www.springframework.org/schema/lang/spring-lang-2.0.xsd=org/springframework/scripting/config/spring-lang-2.0.xsd, http://www.springframework.org/schema/jee/spring-jee-3.2.xsd=org/springframework/ejb/config/spring-jee-3.2.xsd}
#801 2015-08-05 18:04:33,254 |WARN | [main] [org.springframework.beans.factory.xml.XmlBeanDefinitionReader] org.springframework.util.xml.SimpleSaxErrorHandler.warning(SimpleSaxErrorHandler.java:47):
Ignored XML validation warning
org.xml.sax.SAXParseException; lineNumber: 9; columnNumber: 65; schema_reference.4: Failed to read schema document 'http://www.springframework.org/schema/beans/spring-beans-3.0.xsd', because 1) could not find the document; 2) the document could not be read; 3) the root element of the document is not <xsd:schema>.
    at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
    at org.apache.xerces.util.ErrorHandlerWrapper.warning(Unknown Source)
    at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
    at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
    at org.apache.xerces.impl.xs.traversers.XSDHandler.reportSchemaWarning(Unknown Source)
    at org.apache.xerces.impl.xs.traversers.XSDHandler.getSchemaDocument1(Unknown Source)
    at org.apache.xerces.impl.xs.traversers.XSDHandler.getSchemaDocument(Unknown Source)
    at org.apache.xerces.impl.xs.traversers.XSDHandler.parseSchema(Unknown Source)
    at org.apache.xerces.impl.xs.XMLSchemaLoader.loadSchema(Unknown Source)
    at org.apache.xerces.impl.xs.XMLSchemaValidator.findSchemaGrammar(Unknown Source)
    at org.apache.xerces.impl.xs.XMLSchemaValidator.handleStartElement(Unknown Source)
    at org.apache.xerces.impl.xs.XMLSchemaValidator.startElement(Unknown Source)
    at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
    at org.apache.xerces.impl.XMLNSDocumentScannerImpl$NSContentDispatcher.scanRootElementHook(Unknown Source)
    at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
    at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
    at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
    at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
    at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
    at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)
    at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source)
    at org.springframework.beans.factory.xml.DefaultDocumentLoader.loadDocument(DefaultDocumentLoader.java:75)
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:388)
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:334)
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:302)
    at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:174)
    at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:209)
    at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:180)
    at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:243)
    at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:127)
    at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:93)
    at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:130)
    at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:537)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:451)
    at org.springframework.context.support.FileSystemXmlApplicationContext.<init>(FileSystemXmlApplicationContext.java:140)
    at org.springframework.context.support.FileSystemXmlApplicationContext.<init>(FileSystemXmlApplicationContext.java:84)
    at mock.DSStartup.main(DSStartup.java:44)
Caused by: java.net.UnknownHostException: www.springframework.org
    at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:178)
    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
    at java.net.Socket.connect(Socket.java:579)
    at java.net.Socket.connect(Socket.java:528)
    at sun.net.NetworkClient.doConnect(NetworkClient.java:180)
    at sun.net.www.http.HttpClient.openServer(HttpClient.java:432)
    at sun.net.www.http.HttpClient.openServer(HttpClient.java:527)
    at sun.net.www.http.HttpClient.<init>(HttpClient.java:211)
    at sun.net.www.http.HttpClient.New(HttpClient.java:308)
    at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:1004)
    at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:952)
    at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:851)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1301)
    at org.apache.xerces.impl.XMLEntityManager.setupCurrentEntity(Unknown Source)
    at org.apache.xerces.impl.XMLVersionDetector.determineDocVersion(Unknown Source)
    at org.apache.xerces.impl.xs.opti.SchemaParsingConfig.parse(Unknown Source)
    at org.apache.xerces.impl.xs.opti.SchemaParsingConfig.parse(Unknown Source)
    at org.apache.xerces.impl.xs.opti.SchemaDOMParser.parse(Unknown Source)
    ... 31 more
#807 2015-08-05 18:04:33,260 |FATAL| [main] [mock.DSStartup] mock.DSStartup.main(DSStartup.java:51):
Server failure, will shutdown and requires manual restart
org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 9 in XML document from URL [file:/Users/ie54553/Automation/AutomationProject/UAT-MOCK/src/main/resources/configuration/applicationBeans.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 9; columnNumber: 65; cvc-elt.1.a: Cannot find the declaration of element 'beans'.
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:396)
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:334)
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:302)
    at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:174)
    at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:209)
    at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:180)
    at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:243)
    at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:127)
    at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:93)
    at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:130)
    at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:537)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:451)
    at org.springframework.context.support.FileSystemXmlApplicationContext.<init>(FileSystemXmlApplicationContext.java:140)
    at org.springframework.context.support.FileSystemXmlApplicationContext.<init>(FileSystemXmlApplicationContext.java:84)
    at mock.DSStartup.main(DSStartup.java:44)
Caused by: org.xml.sax.SAXParseException; lineNumber: 9; columnNumber: 65; cvc-elt.1.a: Cannot find the declaration of element 'beans'.
    at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
    at org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown Source)
    at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
    at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
    at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
    at org.apache.xerces.impl.xs.XMLSchemaValidator.handleStartElement(Unknown Source)
    at org.apache.xerces.impl.xs.XMLSchemaValidator.startElement(Unknown Source)
    at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
    at org.apache.xerces.impl.XMLNSDocumentScannerImpl$NSContentDispatcher.scanRootElementHook(Unknown Source)
    at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
    at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
    at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
    at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
    at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
    at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)
    at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source)
    at org.springframework.beans.factory.xml.DefaultDocumentLoader.loadDocument(DefaultDocumentLoader.java:75)
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:388)
    ... 14 more
</code>```

Any suggestion how to fix the exception ?

thanks

答:
You can use the shade plugin:

This plugin provides the capability to package the artifact in an
  uber-jar, including its dependencies and to shade

Configuration

```<code><!-- Maven Shade Plugin -->
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-shade-plugin</artifactId>
          <version>2.3</version>
          <executions>
             <!-- Run shade goal on package phase -->
            <execution>
            <phase>package</phase>
            <goals>
                <goal>shade</goal>
            </goals>
            <configuration>
              <transformers>
                <!-- add Main-Class to manifest file -->
                                <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                    <mainClass>path.to.the.App</mainClass>
                </transformer>
              </transformers>
            </configuration>
              </execution>
          </executions>
        </plugin>
</code>```

Check this example for more details

Body:
I have a spring application which I'm trying to launch from compiled jar , and it's doesn't work for me.

The exception I'm getting is :

Failed to read schema document 'http://www.springframework.org/schema/beans/spring-beans-3.0.xsd', because 1) could not find the document; 2) the document could not be read; 3) the root element of the document is not <xsd:schema>.

my bean's configuration file looks like :

<beans
        xmlns="http://www.springframework.org/schema/beans"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns:context="http://www.springframework.org/schema/context"
       xsi:schemaLocation="
            http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
            http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd"
       default-init-method="init" default-destroy-method="destroy">

The full stack trace :

#233 2015-08-05 18:04:32,686 |DEBUG| [main] [org.springframework.beans.factory.xml.PluggableSchemaResolver] org.springframework.beans.factory.xml.PluggableSchemaResolver.getSchemaMappings(PluggableSchemaResolver.java:146):
Loaded schema mappings: {http://www.springframework.org/schema/context/spring-context-3.1.xsd=org/springframework/context/config/spring-context-3.1.xsd, http://www.springframework.org/schema/lang/spring-lang-2.5.xsd=org/springframework/scripting/config/spring-lang-2.5.xsd, http://www.springframework.org/schema/lang/spring-lang.xsd=org/springframework/scripting/config/spring-lang-3.2.xsd, http://www.springframework.org/schema/context/spring-context-2.5.xsd=org/springframework/context/config/spring-context-2.5.xsd, http://www.springframework.org/schema/cache/spring-cache-3.1.xsd=org/springframework/cache/config/spring-cache-3.1.xsd, http://www.springframework.org/schema/lang/spring-lang-3.2.xsd=org/springframework/scripting/config/spring-lang-3.2.xsd, http://www.springframework.org/schema/context/spring-context.xsd=org/springframework/context/config/spring-context-3.2.xsd, http://www.springframework.org/schema/task/spring-task-3.0.xsd=org/springframework/scheduling/config/spring-task-3.0.xsd, http://www.springframework.org/schema/jee/spring-jee-3.1.xsd=org/springframework/ejb/config/spring-jee-3.1.xsd, http://www.springframework.org/schema/task/spring-task.xsd=org/springframework/scheduling/config/spring-task-3.2.xsd, http://www.springframework.org/schema/context/spring-context-3.0.xsd=org/springframework/context/config/spring-context-3.0.xsd, http://www.springframework.org/schema/lang/spring-lang-3.1.xsd=org/springframework/scripting/config/spring-lang-3.1.xsd, http://www.springframework.org/schema/task/spring-task-3.2.xsd=org/springframework/scheduling/config/spring-task-3.2.xsd, http://www.springframework.org/schema/jee/spring-jee.xsd=org/springframework/ejb/config/spring-jee-3.2.xsd, http://www.springframework.org/schema/cache/spring-cache.xsd=org/springframework/cache/config/spring-cache-3.2.xsd, http://www.springframework.org/schema/context/spring-context-3.2.xsd=org/springframework/context/config/spring-context-3.2.xsd, http://www.springframework.org/schema/cache/spring-cache-3.2.xsd=org/springframework/cache/config/spring-cache-3.2.xsd, http://www.springframework.org/schema/jee/spring-jee-3.0.xsd=org/springframework/ejb/config/spring-jee-3.0.xsd, http://www.springframework.org/schema/jee/spring-jee-2.0.xsd=org/springframework/ejb/config/spring-jee-2.0.xsd, http://www.springframework.org/schema/jee/spring-jee-2.5.xsd=org/springframework/ejb/config/spring-jee-2.5.xsd, http://www.springframework.org/schema/lang/spring-lang-3.0.xsd=org/springframework/scripting/config/spring-lang-3.0.xsd, http://www.springframework.org/schema/task/spring-task-3.1.xsd=org/springframework/scheduling/config/spring-task-3.1.xsd, http://www.springframework.org/schema/lang/spring-lang-2.0.xsd=org/springframework/scripting/config/spring-lang-2.0.xsd, http://www.springframework.org/schema/jee/spring-jee-3.2.xsd=org/springframework/ejb/config/spring-jee-3.2.xsd}
#801 2015-08-05 18:04:33,254 |WARN | [main] [org.springframework.beans.factory.xml.XmlBeanDefinitionReader] org.springframework.util.xml.SimpleSaxErrorHandler.warning(SimpleSaxErrorHandler.java:47):
Ignored XML validation warning
org.xml.sax.SAXParseException; lineNumber: 9; columnNumber: 65; schema_reference.4: Failed to read schema document 'http://www.springframework.org/schema/beans/spring-beans-3.0.xsd', because 1) could not find the document; 2) the document could not be read; 3) the root element of the document is not <xsd:schema>.
    at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
    at org.apache.xerces.util.ErrorHandlerWrapper.warning(Unknown Source)
    at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
    at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
    at org.apache.xerces.impl.xs.traversers.XSDHandler.reportSchemaWarning(Unknown Source)
    at org.apache.xerces.impl.xs.traversers.XSDHandler.getSchemaDocument1(Unknown Source)
    at org.apache.xerces.impl.xs.traversers.XSDHandler.getSchemaDocument(Unknown Source)
    at org.apache.xerces.impl.xs.traversers.XSDHandler.parseSchema(Unknown Source)
    at org.apache.xerces.impl.xs.XMLSchemaLoader.loadSchema(Unknown Source)
    at org.apache.xerces.impl.xs.XMLSchemaValidator.findSchemaGrammar(Unknown Source)
    at org.apache.xerces.impl.xs.XMLSchemaValidator.handleStartElement(Unknown Source)
    at org.apache.xerces.impl.xs.XMLSchemaValidator.startElement(Unknown Source)
    at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
    at org.apache.xerces.impl.XMLNSDocumentScannerImpl$NSContentDispatcher.scanRootElementHook(Unknown Source)
    at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
    at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
    at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
    at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
    at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
    at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)
    at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source)
    at org.springframework.beans.factory.xml.DefaultDocumentLoader.loadDocument(DefaultDocumentLoader.java:75)
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:388)
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:334)
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:302)
    at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:174)
    at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:209)
    at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:180)
    at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:243)
    at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:127)
    at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:93)
    at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:130)
    at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:537)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:451)
    at org.springframework.context.support.FileSystemXmlApplicationContext.<init>(FileSystemXmlApplicationContext.java:140)
    at org.springframework.context.support.FileSystemXmlApplicationContext.<init>(FileSystemXmlApplicationContext.java:84)
    at mock.DSStartup.main(DSStartup.java:44)
Caused by: java.net.UnknownHostException: www.springframework.org
    at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:178)
    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
    at java.net.Socket.connect(Socket.java:579)
    at java.net.Socket.connect(Socket.java:528)
    at sun.net.NetworkClient.doConnect(NetworkClient.java:180)
    at sun.net.www.http.HttpClient.openServer(HttpClient.java:432)
    at sun.net.www.http.HttpClient.openServer(HttpClient.java:527)
    at sun.net.www.http.HttpClient.<init>(HttpClient.java:211)
    at sun.net.www.http.HttpClient.New(HttpClient.java:308)
    at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:1004)
    at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:952)
    at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:851)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1301)
    at org.apache.xerces.impl.XMLEntityManager.setupCurrentEntity(Unknown Source)
    at org.apache.xerces.impl.XMLVersionDetector.determineDocVersion(Unknown Source)
    at org.apache.xerces.impl.xs.opti.SchemaParsingConfig.parse(Unknown Source)
    at org.apache.xerces.impl.xs.opti.SchemaParsingConfig.parse(Unknown Source)
    at org.apache.xerces.impl.xs.opti.SchemaDOMParser.parse(Unknown Source)
    ... 31 more
#807 2015-08-05 18:04:33,260 |FATAL| [main] [mock.DSStartup] mock.DSStartup.main(DSStartup.java:51):
Server failure, will shutdown and requires manual restart
org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 9 in XML document from URL [file:/Users/ie54553/Automation/AutomationProject/UAT-MOCK/src/main/resources/configuration/applicationBeans.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 9; columnNumber: 65; cvc-elt.1.a: Cannot find the declaration of element 'beans'.
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:396)
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:334)
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:302)
    at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:174)
    at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:209)
    at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:180)
    at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:243)
    at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:127)
    at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:93)
    at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:130)
    at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:537)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:451)
    at org.springframework.context.support.FileSystemXmlApplicationContext.<init>(FileSystemXmlApplicationContext.java:140)
    at org.springframework.context.support.FileSystemXmlApplicationContext.<init>(FileSystemXmlApplicationContext.java:84)
    at mock.DSStartup.main(DSStartup.java:44)
Caused by: org.xml.sax.SAXParseException; lineNumber: 9; columnNumber: 65; cvc-elt.1.a: Cannot find the declaration of element 'beans'.
    at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
    at org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown Source)
    at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
    at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
    at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
    at org.apache.xerces.impl.xs.XMLSchemaValidator.handleStartElement(Unknown Source)
    at org.apache.xerces.impl.xs.XMLSchemaValidator.startElement(Unknown Source)
    at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
    at org.apache.xerces.impl.XMLNSDocumentScannerImpl$NSContentDispatcher.scanRootElementHook(Unknown Source)
    at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
    at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
    at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
    at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
    at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
    at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)
    at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source)
    at org.springframework.beans.factory.xml.DefaultDocumentLoader.loadDocument(DefaultDocumentLoader.java:75)
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:388)
    ... 14 more

Any suggestion how to fix the exception ?

thanks

Body:
You can use the shade plugin:

This plugin provides the capability to package the artifact in an
  uber-jar, including its dependencies and to shade

Configuration

<!-- Maven Shade Plugin -->
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-shade-plugin</artifactId>
          <version>2.3</version>
          <executions>
             <!-- Run shade goal on package phase -->
            <execution>
            <phase>package</phase>
            <goals>
                <goal>shade</goal>
            </goals>
            <configuration>
              <transformers>
                <!-- add Main-Class to manifest file -->
                                <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                    <mainClass>path.to.the.App</mainClass>
                </transformer>
              </transformers>
            </configuration>
              </execution>
          </executions>
        </plugin>

Check this example for more details


问:
Mac Services in Firefox Deprecated?
For just a few months, I've used a Mac Automator Workflow that wraps the HTML "em" tags around my selected text. It's to tag text in my Google Calendar that then runs through an API to turn it into a schedule of events in a web page.

I would just highlight the word "big" in: "this is a big thing"

And run this brief script:

```<code>on run {input, parameters}
    return "<em>" & input & "</em>"
end run
</code>```

And it's now

```<code>"this is a <em>big</em> thing"
</code>```

But this week, after the latest update to Firefox (53.0), trying to run the service return the error message:

There was a problem with the input to the Service  [Show Workflow] [OK]

Is support for Services another feature that Firefox is removing, just like JavaScript?

Is there possibly a Preference I can set to make it run again?

Or am I going to have to learn to create my own WebExtensions to avoid having to type tags by hand?

Thanks in advance!

答: This is a bug in Firefox 53. See Bug 1361116: Services menu in os x does not send pasteboard data to the service, where it is reported to be fixed in Firefox 54.</p>

Title: Mac Services in Firefox Deprecated?

Body:
For just a few months, I've used a Mac Automator Workflow that wraps the HTML "em" tags around my selected text. It's to tag text in my Google Calendar that then runs through an API to turn it into a schedule of events in a web page.

I would just highlight the word "big" in: "this is a big thing"

And run this brief script:

on run {input, parameters}
    return "" & input & ""
end run

And it's now

"this is a big thing"

But this week, after the latest update to Firefox (53.0), trying to run the service return the error message:

There was a problem with the input to the Service  [Show Workflow] [OK]

Is support for Services another feature that Firefox is removing, just like JavaScript?

Is there possibly a Preference I can set to make it run again?

Or am I going to have to learn to create my own WebExtensions to avoid having to type tags by hand?

Thanks in advance!


问:
Inconsistent execution of executeScript in Cordova inAppBrowser on iOS
I'm having some trouble with some inAppBrowser behavior in my cordova app. Here's the code:

```<code>var codePass = fooCode;
var executeScriptFunc = function(event) {
  ref.executeScript({
    code: codePass
  }, function (value) {});
  ref.removeEventListener('loadstop', executeScriptFunc);
};

var ref = cordova.InAppBrowser.open(fooObject.link, "_blank", "location=yes,enableViewportScale=yes");
ref.addEventListener('loadstop', executeScriptFunc)
</code>```

The strange thing here is that the code works perfectly every time when emulated. It opens the browser and executes the script no problem. But when I try it on my actual iPhone device, it doesn't always work. The script executes maybe every other time. But it's never even that consistent.

Both the emulator and iPhone are using iOS 9.3.4. Any ideas?

答:
Make sure also that you don't have other event handlers firing at the same time during your polling.

I had multiple pollers all firing every second and that's when I ran into the issue.

After changing the polling time so they all fired at different times, the issue went away.

Body:
I'm having some trouble with some inAppBrowser behavior in my cordova app. Here's the code:

var codePass = fooCode;
var executeScriptFunc = function(event) {
  ref.executeScript({
    code: codePass
  }, function (value) {});
  ref.removeEventListener('loadstop', executeScriptFunc);
};

var ref = cordova.InAppBrowser.open(fooObject.link, "_blank", "location=yes,enableViewportScale=yes");
ref.addEventListener('loadstop', executeScriptFunc)

The strange thing here is that the code works perfectly every time when emulated. It opens the browser and executes the script no problem. But when I try it on my actual iPhone device, it doesn't always work. The script executes maybe every other time. But it's never even that consistent.

Both the emulator and iPhone are using iOS 9.3.4. Any ideas?


问:
How to know that a thread in a Thread Pool hangs/freezes
I have queue of tasks for the ThreadPool, and each task has a tendency to froze locking up all the resources it is using. And these cant be released unless the service is restarted.

Is there a way in the ThreadPool to know that its thread is already frozen? I have an idea of using a time out, (though i still dont know how to write it), but i think its not safe because the length of time for processing is not uniform.

答:
One way is to use a watchdog timer (a solution usually done in hardware but applicable to software as well).

Have each thread set a thread-specific value to 1 at least once every five seconds (for example).

Then your watchdog timer wakes every ten seconds (again, this is an example figure only) and checks to ensure that all the values are 1. If they're not 1, then a thread has locked up.

The watchdog timer then sets them all to 0 and goes back to sleep for the next cycle.

Providing your worker threads are written in such a way so that they will be able to set the values in a timely manner under non-frozen conditions, this scheme will work okay.

The first thread that locks up will not set its value to 1, and this will be detected by the watchdog timer on the next cycle.

However, a better solution is to find out why the threads are freezing in the first place and fix that.


问:
Microsoft Bot Framework. Hide text message from users
Faced with a problem when using the Microsoft Bot Framework. I develop a bot that will run on Skype. I need create a hero card with two buttons (Yes/No), and send it to the user.
I have to say, that use Microsoft Bot Framework API and Python (but language doesn't matter, I think).
Use type - 'imBack' and value - string.
When press the button, the message will appear in chat, with the  value.
This is bad for me. I want to hide a message from the user in this case is that it only received my skype bot.
According to the documentation can be done. But I is not working for me.

Sending context with actions

It can be useful to send context back to your bot (e.g. a request ID)
  without showing this information to the user in a message. To do this
  you can append hidden XML to the visible string shown to the user,
  which is only seen by your bot.

Visible message <context hiddenId='10'/>

It is written in the documentation.
I would be very grateful for the help.

答:
Just a tip that would have saved me some time. As of today, postBack is supported on skype. There is a difference in the behavior compared to the emulator though.

In the emulator, the object put in the Value property of the card action buttons will come in the message.Value property. In the Skype case, the object will come as a string in the message.Text property.

Although this doesn't help differentiate between whether the user clicks a button or writes some text (as opposed to what happens in the emulator) this is still better than writing hidden xml directly, imo.


问:
Could not load file or assembly error in SSIS Web Service Task
I'm trying to call a web service using the Web Service Task in SSIS. In the HTTP connection Manager I gave the Server URL, I haven't defined any proxy server. I downloaded the WSDL file. And I selected the Service and Method in the Input tab. The method expects a string parameter which I am passing through. I'm getting the following error. I even tried changing the Protection Level to DontSaveSensitive but still getting this error. Please help</p>

```<code> Error: 0xC002F304 at Web Service Task, Web Service Task: An error
 occurred with the following error message:
 "Microsoft.SqlServer.Dts.Tasks.WebServiceTask.WebserviceTaskException:
 Could not execute the Web method. The error is: Could not load file or
 assembly 'Microsoft.SqlServer.WebServiceTask, Version=14.100.0.0,
 Culture=neutral, PublicKeyToken=89845dcd8080cc91' or one of its
 dependencies. The system cannot find the file specified.at  Microsoft.SqlServer.Dts.Tasks.WebServiceTask.WebServiceTaskUtil.Invoke(DTSWebMethodInfo methodInfo, String serviceName, Object connection, VariableDispenser taskVariableDispenser)
 at Microsoft.SqlServer.Dts.Tasks.WebServiceTask.WebServiceTask.executeThread()".
</code>```

答:
In windows 8 the assemblies are located at: C:\Windows\Microsoft.NET\assembly\GAC_MSIL

The error states that it cannot find a file or assembly in Microsoft.SqlServer.WebServiceTask. And it also says that it is looking for Version=14.100.0.0 with PublicKeyToken=89845dcd8080cc91.

I went into the following path: C:\Windows\Microsoft.NET\assembly\GAC_MSIL\Microsoft.SqlServer.WebServiceTask

And there were 3 folders but none of them had a Version 14 in its name. So I created a new folder with the name "v4.0_14.100.0.0__89845dcd8080cc91"

And I the copied Microsoft.SqlServer.WebServiceTask DLL from the v4.0_13.0.0.0__89845dcd8080cc91 folder to the new folder (v4.0_14.100.0.0__89845dcd8080cc91). This worked for me.

Body:
I'm trying to call a web service using the Web Service Task in SSIS. In the HTTP connection Manager I gave the Server URL, I haven't defined any proxy server. I downloaded the WSDL file. And I selected the Service and Method in the Input tab. The method expects a string parameter which I am passing through. I'm getting the following error. I even tried changing the Protection Level to DontSaveSensitive but still getting this error. Please help

 Error: 0xC002F304 at Web Service Task, Web Service Task: An error
 occurred with the following error message:
 "Microsoft.SqlServer.Dts.Tasks.WebServiceTask.WebserviceTaskException:
 Could not execute the Web method. The error is: Could not load file or
 assembly 'Microsoft.SqlServer.WebServiceTask, Version=14.100.0.0,
 Culture=neutral, PublicKeyToken=89845dcd8080cc91' or one of its
 dependencies. The system cannot find the file specified.at  Microsoft.SqlServer.Dts.Tasks.WebServiceTask.WebServiceTaskUtil.Invoke(DTSWebMethodInfo methodInfo, String serviceName, Object connection, VariableDispenser taskVariableDispenser)
 at Microsoft.SqlServer.Dts.Tasks.WebServiceTask.WebServiceTask.executeThread()".


问:
Echo selected in drop down menu
I am getting confused now.
Why am I not able to echo an selected item?

```<code>                  echo'
                  <form class="form-horizontal form-calculator" id="interval" action="includes/toolbox_interval.php" method="post">
                  <div class="modal-body">
                      <div class="form-group">
                          <label for="interval">Kies interval</label>
                          <select class="form-control" name="interval" id="interval">
                            <option></option>
                            <option'; if($row['days'] == 7){ echo 'selected="selected"'; } echo 'value="7">Wekelijks</option>
                            <option value="14">2 wekelijks</option>
                            <option value="30">Maandelijks</option>
                            <option value="91">Elk kwartaal</option>
                            <option value="365">Jaarlijks</option>
                          </select>
                        </div>
                  </div>
                  </form>';
</code>```

答:
Muiter,

For one, you need spaces, try the following--

```<code><option '; if($row['days'] == 7){ echo 'selected="selected"'; } echo ' value="7">Wekelijks</option>
</code>```

Notice the space after option tag and before the value attribute

If you do not have the spaces, here are the scenarios you are facing...

The if condition has met. As a result, your resulting option tag will be:

```<code><optionselected="selected"value="7">Wekelijks</option>
</code>```

The if condition has not met. In which case, your resulting option tag will be:

```<code><optionvalue="7">Wekelijks</option>
</code>```

Hope this helps!

-Rush

Title: Echo selected in drop down menu

Body:
I am getting confused now.
Why am I not able to echo an selected item?

                  echo'
                  <form class="form-horizontal form-calculator" id="interval" action="includes/toolbox_interval.php" method="post">

                          Kies interval
                          <select class="form-control" name="interval" id="interval">
                            <option></option>
                            <option'; if($row['days'] == 7){ echo 'selected="selected"'; } echo 'value="7">Wekelijks</option>
                            <option value="14">2 wekelijks</option>
                            <option value="30">Maandelijks</option>
                            <option value="91">Elk kwartaal</option>
                            <option value="365">Jaarlijks</option>
                          </select>

                  </form>';

Body:
Muiter,

For one, you need spaces, try the following--

<option '; if($row['days'] == 7){ echo 'selected="selected"'; } echo ' value="7">Wekelijks</option>

Notice the space after option tag and before the value attribute

If you do not have the spaces, here are the scenarios you are facing...

The if condition has met. As a result, your resulting option tag will be:

<optionselected="selected"value="7">Wekelijks</option>

The if condition has not met. In which case, your resulting option tag will be:

<optionvalue="7">Wekelijks</option>

Hope this helps!

-Rush


问:
URL rewrite - Sitecore on IIS
I have a Sitecore application running on top of IIS 8.5. I want to redirect/rewrite from #1 to #2 URL.

http://mywebsite.com/a/a1/webpage.aspx

http://mywebsite.com/a/a2/webpage.aspx

I tried to do on IIS-URL rewrite level, it just doesn't work and nothing happen.

<rule name="redirect_a1_to_a2" enabled="false" stopProcessing="true">
    <match url="a/a1/" />
    <conditions>
        <add input="{PATH_INFO}" pattern="a/a1(/?)" />
    </conditions>
    <action type="Redirect" url="http://mywebsite.com/a/a2" />
</rule>
```

Please help.

答:
Your rule is correct. Then only thing you need to do is to enable the rule.

Just change:

```<code>enabled="false"
</code>```

to

```<code>enabled="true"
</code>```

Title: URL rewrite - Sitecore on IIS

Body:
I have a Sitecore application running on top of IIS 8.5. I want to redirect/rewrite from #1 to #2 URL.

http://mywebsite.com/a/a1/webpage.aspx

http://mywebsite.com/a/a2/webpage.aspx

I tried to do on IIS-URL rewrite level, it just doesn't work and nothing happen.

<rule name="redirect_a1_to_a2" enabled="false" stopProcessing="true">
    <match url="a/a1/" />
    <conditions>
        <add input="{PATH_INFO}" pattern="a/a1(/?)" />
    </conditions>
    <action type="Redirect" url="http://mywebsite.com/a/a2" />
</rule>

Please help.

Body:
Your rule is correct. Then only thing you need to do is to enable the rule.

Just change:

enabled="false"

to

enabled="true"