问:
Outlook Addin Settings and Auto-Implemented Properties
I have an outlook addin that sets some values in the addin options page.  There are then properties that are initialized to the values of the settings like so:

public string Prop1 { get; } = Properties.Settings.Default.Setting1;

My question is if the value of Properties.Settings.Default.Setting1 is changed during runtime through the addin options page, will the property reflect the change?

From what I understand it generates a hidden backing field to hold the value of the property which I am initializing it to.

So the property is not equivalent to

```<code>public string Prop1
{
    get {
        return Properties.Settings.Default.Setting1;
    }
}
</code>```

but is

```<code>public string Prop1
{
    get {
        return hidden_backing_field;
    }
}
</code>```

Which would mean that Prop1 wouldn't reflect the changed value of Properties.Settings.Default.Setting1.

How would I handle such a case?  Would I need to make sure to re-set the property each time the options are changed?

Thanks in advance for helping clear up my confusion with auto-implemented properties.

答:
Yes, the property would be initialized only once when the object is created. Why not simply always return the desired value?</p>

```<code>public string Prop1
{
    get {
        return Properties.Settings.Default.Setting1;
    }
}
</code>```

Body:
I have an outlook addin that sets some values in the addin options page.  There are then properties that are initialized to the values of the settings like so:

public string Prop1 { get; } = Properties.Settings.Default.Setting1;

My question is if the value of Properties.Settings.Default.Setting1 is changed during runtime through the addin options page, will the property reflect the change?

From what I understand it generates a hidden backing field to hold the value of the property which I am initializing it to.

So the property is not equivalent to

public string Prop1
{
    get {
        return Properties.Settings.Default.Setting1;
    }
}

but is

public string Prop1
{
    get {
        return hidden_backing_field;
    }
}

Which would mean that Prop1 wouldn't reflect the changed value of Properties.Settings.Default.Setting1.

How would I handle such a case?  Would I need to make sure to re-set the property each time the options are changed?

Thanks in advance for helping clear up my confusion with auto-implemented properties.

Body:
Yes, the property would be initialized only once when the object is created. Why not simply always return the desired value?

public string Prop1
{
    get {
        return Properties.Settings.Default.Setting1;
    }
}


来源: stackexchange

问:
How to preserve JS object data after the object you set it to changes?
I have a scheduler with custom events. In the edit event popup, there is a cancel button. The scheduler is from a javascript library, so not of my creation, I only created its custom functionality.

So in the edit popup (which triggers edit event), I set a variable to hold the current state of the event data. Then if I make any changes and press cancel instead of save, the cancel event is triggered. In the cancel event, the 'currentState' event data is now changed to the new state of all the changed data, which I don't want. I need the old data so I can revert it all back, then refresh scheduler.

This is my cancel event:

```<code>cancel: function(e){
                            console.log('Cancelling', e);

                            var kendoEvent = new kendo.data.SchedulerEvent();
                            var schema = e.sender.dataSource.options.schema.model.fields;
                            console.log(e.sender.dataSource.hasChanges());
                            console.log(currentEventState);
                            $.each(schema, function(index, value){
                                //console.log(value);
                                console.log(index);
                                kendoEvent[index] = e.sender.oldEventData[index];
                                if(index == 'ownerId'){
                                    kendoEvent.ownerId = currentEventState.ownerId[0].value;
                                }
                            });

                            console.log(kendoEvent);
                            console.log(getIndexById(kendoEvent.taskId));
                            eventData[getIndexById(kendoEvent.taskId)] = kendoEvent;
                            e.sender.dataSource.read();
                            if(e.event.id != '0'){
                                dontUpdate = 1;
                                //e.sender.dataSource.sync();
                            }
                        },
</code>```

Where e.sender is the scheduler, and e.event is the event data (with any changes that were made). In the edit event the first thing I do is add oldEventData field to e.sender and set it to e.event. But... if changes are made to e.event AFTER e.sender.oldEventData is set, e.sender.oldEventData STILL gets changed to reflect all the changes made...

How might I preserve this old data so I can revert it back? I tried just doing a global variable instead of creating a new field in e.sender, but after setting the global variable to e.event, it still reflected any changes made >:(.

答:
Discovered that cloning the data into the field e.sender.oldEventData prevented it from being tied to e.event. So e.event could change without messing with the old data.

This was achieved with a simple JSON.parse(JSON.stringify(e.event)).

I attempted Object.freeze(e.sender.oldEventData), which kept the old data, but made it completely unable to modify at all, so wasn't the best solution for me.

ContentLicense: CC BY-SA 3.0

Body:
I have a scheduler with custom events. In the edit event popup, there is a cancel button. The scheduler is from a javascript library, so not of my creation, I only created its custom functionality.

So in the edit popup (which triggers edit event), I set a variable to hold the current state of the event data. Then if I make any changes and press cancel instead of save, the cancel event is triggered. In the cancel event, the 'currentState' event data is now changed to the new state of all the changed data, which I don't want. I need the old data so I can revert it all back, then refresh scheduler.

This is my cancel event:

cancel: function(e){
                            console.log('Cancelling', e);

                            var kendoEvent = new kendo.data.SchedulerEvent();
                            var schema = e.sender.dataSource.options.schema.model.fields;
                            console.log(e.sender.dataSource.hasChanges());
                            console.log(currentEventState);
                            $.each(schema, function(index, value){
                                //console.log(value);
                                console.log(index);
                                kendoEvent[index] = e.sender.oldEventData[index];
                                if(index == 'ownerId'){
                                    kendoEvent.ownerId = currentEventState.ownerId[0].value;
                                }
                            });

                            console.log(kendoEvent);
                            console.log(getIndexById(kendoEvent.taskId));
                            eventData[getIndexById(kendoEvent.taskId)] = kendoEvent;
                            e.sender.dataSource.read();
                            if(e.event.id != '0'){
                                dontUpdate = 1;
                                //e.sender.dataSource.sync();
                            }
                        },

Where e.sender is the scheduler, and e.event is the event data (with any changes that were made). In the edit event the first thing I do is add oldEventData field to e.sender and set it to e.event. But... if changes are made to e.event AFTER e.sender.oldEventData is set, e.sender.oldEventData STILL gets changed to reflect all the changes made...

How might I preserve this old data so I can revert it back? I tried just doing a global variable instead of creating a new field in e.sender, but after setting the global variable to e.event, it still reflected any changes made >:(.


问:
How to convert a 2D array to a value object in ruby
I have a 2D array:

```<code>a = [["john doe", "01/03/2017", "01/04/2017", "event"], ["jane doe", "01/05/2017", "01/06/2017", "event"]...]
</code>```

I would like to convert it to a value object in ruby. I found how to do it with a hash Ruby / Replace value in array of hash in the second answer of this question but not a 2D array. I would like to assign the value at a[0][0] to an attribute named "name", a[0][1] to "date1", a[0][2] to "date2" and a[0][3] to "event".

This is something like what I'd like to accomplish although it is not complete and I dont know how to assign multiple indexes to the different attributes in one loop:

```<code>class Schedule_info
   arrt_accessor :name, :date1, :date2, :event

   def initialize arr
       #I would like this loop to contain all 4 attr assignments
       arr.each {|i| instance_variable_set(:name, i[0])}
</code>```

答:
This should be short and clean enough, without unneeded metaprogramming :</p>

```<code>data = [["john doe", "01/03/2017", "01/04/2017", "event"],
        ["jane doe", "01/05/2017", "01/06/2017", "event"]]

class ScheduleInfo
  attr_reader :name, :date1, :date2, :type

  def initialize(*params)
    @name, @date1, @date2, @type = params
  end

  def to_s
    format('%s for %s between %s and %s', type, name, date1, date2)
  end
end

p info = ScheduleInfo.new('jane', '31/03/2017', '01/04/2017', 'party')
# #<ScheduleInfo:0x00000000d854a0 @name="jane", @date1="31/03/2017", @date2="01/04/2017", @type="party">
puts info.name
# "jane"

schedule_infos = data.map{ |params| ScheduleInfo.new(*params) }
puts schedule_infos
# event for john doe between 01/03/2017 and 01/04/2017
# event for jane doe between 01/05/2017 and 01/06/2017
</code>```

Body:
I have a 2D array:

a = [["john doe", "01/03/2017", "01/04/2017", "event"], ["jane doe", "01/05/2017", "01/06/2017", "event"]...]

I would like to convert it to a value object in ruby. I found how to do it with a hash Ruby / Replace value in array of hash in the second answer of this question but not a 2D array. I would like to assign the value at a[0][0] to an attribute named "name", a[0][1] to "date1", a[0][2] to "date2" and a[0][3] to "event".

This is something like what I'd like to accomplish although it is not complete and I dont know how to assign multiple indexes to the different attributes in one loop:

class Schedule_info
   arrt_accessor :name, :date1, :date2, :event

   def initialize arr
       #I would like this loop to contain all 4 attr assignments
       arr.each {|i| instance_variable_set(:name, i[0])}

Body:
This should be short and clean enough, without unneeded metaprogramming :

data = [["john doe", "01/03/2017", "01/04/2017", "event"],
        ["jane doe", "01/05/2017", "01/06/2017", "event"]]

class ScheduleInfo
  attr_reader :name, :date1, :date2, :type

  def initialize(*params)
    @name, @date1, @date2, @type = params
  end

  def to_s
    format('%s for %s between %s and %s', type, name, date1, date2)
  end
end

p info = ScheduleInfo.new('jane', '31/03/2017', '01/04/2017', 'party')
# #<ScheduleInfo:0x00000000d854a0 @name="jane", @date1="31/03/2017", @date2="01/04/2017", @type="party">
puts info.name
# "jane"

schedule_infos = data.map{ |params| ScheduleInfo.new(*params) }
puts schedule_infos
# event for john doe between 01/03/2017 and 01/04/2017
# event for jane doe between 01/05/2017 and 01/06/2017


问:
Representing a minimum spanning tree using an adjacency list
I have been attempting to solve a problem for class. The problem is:

Given an undirected graph G, find the minimum spanning tree within G.

In order to pass this question my function must take in, and return, an adjacency list. However, I'm not sure how to go about representing the input and output as an adjacency list.

```<code>from collections import defaultdict

class Graph:

    def __init__(self,vertices):
        self.V= vertices
        self.graph = []

    def Edge(self,u,v,w):
        self.graph.append([u,v,w])

    # A utility function to find set of an element i
    def find(self, parent, i):
        if parent[i] == i:
            return i
        return self.find(parent, parent[i])

    # A function that does union of two sets of x and y
    def union(self, parent, rank, x, y):
        xroot = self.find(parent, x)
        yroot = self.find(parent, y)

        # Attach smaller rank tree under root of high rank tree
        if rank[xroot] < rank[yroot]:
            parent[xroot] = yroot
        elif rank[xroot] > rank[yroot]:
            parent[yroot] = xroot
        # If ranks are same, then make one as root and increment rank by one
        else :
            parent[yroot] = xroot
            rank[xroot] += 1

    # The main function to build the MST
    def Question3(G):

        MST =[] # This will store the MST
        e = 0 # An index variable used for MST[]
        i = 0 # An index variable for sorted edges
        G.graph =  sorted(G.graph,key=lambda item: item[2])

        parent = [] ; rank = []

        # Create V subsets with single elements
        for node in range(G.V):
            parent.append(node)
            rank.append(0)

        # Edges to be taken is equal to V-1
        while e < G.V -1 :

            # Take smallest edge and increment the index
            u,v,w =  G.graph[i]
            i = i + 1
            x = G.find(parent, u)
            y = G.find(parent ,v)

            # If including this edge does't cause cycle, include it
            # in result and increment the index of result for next edge
            if x != y:
                e = e + 1
                MST.append([u,v,w])
                G.union(parent, rank, x, y)
            # Else discard the edge
        print "Minimum Spanning Tree"
        for u,v,weight  in MST:
            print ("%d -- %d == %d" % (u,v,weight))

g = Graph(4)
g.Edge(0, 1, 9)
g.Edge(0, 2, 6)
g.Edge(0, 3, 5)
g.Edge(1, 3, 12)
g.Edge(2, 3, 4)
g.Question3()
print """---End Question 3---
"""
</code>```

答:
Let's say that you compute the minimum spanning tree as the list of edges called MST. Now, MST contains triples (u, v, weight). What you can do is to iterate over edges in MST and for each such edge (u, v, weight) append a tuple (v, weight) to the adjacency list of u, and also append a tuple (u, weight) to the adjacency list of v.  In pseudo-code it may look like that:

```<code>adj = {} # your resulting adjacency lists, one for each vertex in the graph
for u, v, weight in MST:
   if u not in adj:
      adj[u] = []
   adj[u].append((v, weight))
   if v not in adj:
      adj[v] = []
   adj[v].append((u, weight))
</code>```

Body:
I have been attempting to solve a problem for class. The problem is:

Given an undirected graph G, find the minimum spanning tree within G.

In order to pass this question my function must take in, and return, an adjacency list. However, I'm not sure how to go about representing the input and output as an adjacency list.

from collections import defaultdict

class Graph:

    def __init__(self,vertices):
        self.V= vertices
        self.graph = []

    def Edge(self,u,v,w):
        self.graph.append([u,v,w])

    # A utility function to find set of an element i
    def find(self, parent, i):
        if parent[i] == i:
            return i
        return self.find(parent, parent[i])

    # A function that does union of two sets of x and y
    def union(self, parent, rank, x, y):
        xroot = self.find(parent, x)
        yroot = self.find(parent, y)

        # Attach smaller rank tree under root of high rank tree
        if rank[xroot] < rank[yroot]:
            parent[xroot] = yroot
        elif rank[xroot] > rank[yroot]:
            parent[yroot] = xroot
        # If ranks are same, then make one as root and increment rank by one
        else :
            parent[yroot] = xroot
            rank[xroot] += 1

    # The main function to build the MST
    def Question3(G):

        MST =[] # This will store the MST
        e = 0 # An index variable used for MST[]
        i = 0 # An index variable for sorted edges
        G.graph =  sorted(G.graph,key=lambda item: item[2])

        parent = [] ; rank = []

        # Create V subsets with single elements
        for node in range(G.V):
            parent.append(node)
            rank.append(0)

        # Edges to be taken is equal to V-1
        while e < G.V -1 :

            # Take smallest edge and increment the index
            u,v,w =  G.graph[i]
            i = i + 1
            x = G.find(parent, u)
            y = G.find(parent ,v)

            # If including this edge does't cause cycle, include it
            # in result and increment the index of result for next edge
            if x != y:
                e = e + 1
                MST.append([u,v,w])
                G.union(parent, rank, x, y)
            # Else discard the edge
        print "Minimum Spanning Tree"
        for u,v,weight  in MST:
            print ("%d -- %d == %d" % (u,v,weight))

g = Graph(4)
g.Edge(0, 1, 9)
g.Edge(0, 2, 6)
g.Edge(0, 3, 5)
g.Edge(1, 3, 12)
g.Edge(2, 3, 4)
g.Question3()
print """---End Question 3---
"""

Body:
Let's say that you compute the minimum spanning tree as the list of edges called MST. Now, MST contains triples (u, v, weight). What you can do is to iterate over edges in MST and for each such edge (u, v, weight) append a tuple (v, weight) to the adjacency list of u, and also append a tuple (u, weight) to the adjacency list of v.  In pseudo-code it may look like that:

adj = {} # your resulting adjacency lists, one for each vertex in the graph
for u, v, weight in MST:
   if u not in adj:
      adj[u] = []
   adj[u].append((v, weight))
   if v not in adj:
      adj[v] = []
   adj[v].append((u, weight))


问:
Nuget list is not refreshing after manual deletion of files
We deleted some versions of packages from nexus. When we run nuget list -AllVersions, still getting the ones that are already deleted. Basically looks like the packages list is not refreshing and just appending with new versions. How to sync/refresh packages versions list?</p>

答: We deleted in database and reindexed, but nuget did not refresh the versions. So we restored the packages and deleted from the ui console. </p>


问:
Using 'Lock' in web applications
A few months ago I was interviewing for a job inside the company I am currently in, I dont have a strong web development background, but one of the questions he posed to me was how could you improve this block of code.

I dont remember the code block perfectly but to sum it up it was a web hit counter, and he used lock on the hitcounter.

```<code>lock(HitCounter)
{
   // Bla...
}
</code>```

However after some discussion he said, lock is good but never use it in web applications!

What is the basis behind his statement? Why shouldnt I use lock in web applications?

答:
First of all, you never want to lock an object that you actually use in any application. You want to create a lock object and lock that:

```<code>private readonly object _hitCounterLock = new object();
lock(_hitCounterLock)
{
    //blah
}
</code>```

As for the web portion of the question, when you lock you block every thread that attempts to access the object (which for the web could be hundreds or thousands of users). They will all be waiting until each thread ahead of them unlocks.

ContentLicense: CC BY-SA 2.5

Title: Using 'Lock' in web applications

Body:
A few months ago I was interviewing for a job inside the company I am currently in, I dont have a strong web development background, but one of the questions he posed to me was how could you improve this block of code.

I dont remember the code block perfectly but to sum it up it was a web hit counter, and he used lock on the hitcounter.

lock(HitCounter)
{
   // Bla...
}

However after some discussion he said, lock is good but never use it in web applications!

What is the basis behind his statement? Why shouldnt I use lock in web applications?

Body:
First of all, you never want to lock an object that you actually use in any application. You want to create a lock object and lock that:

private readonly object _hitCounterLock = new object();
lock(_hitCounterLock)
{
    //blah
}

As for the web portion of the question, when you lock you block every thread that attempts to access the object (which for the web could be hundreds or thousands of users). They will all be waiting until each thread ahead of them unlocks.


问:
update to buildToolsVersion 25 results ClassNotFoundException
I had such setup and all was fine.

compileSdkVersion 25

buildToolsVersion "23.0.3"

classpath 'com.android.tools.build:gradle:2.2.3'

After increase to:

b uildToolsVersion '25.0.0'

classpath 'com.android.tools.build:gradle:2.3.0'

I got ClassNotFoundException for one of my providers.

I have tried with 24.0.3 - same issue.

P.S. i can't make compileSdkVersion lower, because app is in market

答:
The only thing that helped me to use latest libraries:</p>

```<code>public class AppClass extends Application {
//this will initialize multidex in your own Application class
  @Override
  protected void attachBaseContext(Context base) {
      super.attachBaseContext(base);
      MultiDex.install(this);
  }
}
</code>```

Body:
The only thing that helped me to use latest libraries:

public class AppClass extends Application {
//this will initialize multidex in your own Application class
  @Override
  protected void attachBaseContext(Context base) {
      super.attachBaseContext(base);
      MultiDex.install(this);
  }
}


问:
PDF content extractor library for Android
Does anyone know a good Java library (for Android) to extract the text content in a PDF? I have used PDFClown with Java but I cannot use it with Android because Android does not have Java AWT support. Instead it uses android.graphics package.

I'm looking for Android library similar to PDFClown but I couldn't find it anywhere in the internet. Please help me. Thanks

答: There's an Android port of Apache's PDFBox at https://github.com/TomRoush/PdfBox-Android</p>


问:
Is PHP used for quick and easy website where other languages are used in more complex websites?
I just put this question in serverfault.com and I know that this question may be rejected in Stackoverflow.

But I thought programmers know better.

This stat shows that PHP is used by 75.2% of all the websites whose server-side programming language.

http://w3techs.com/technologies/overview/programming_language/all

And this page shows that PHP is the least used server-side language in ranked by usage on top websites

http://w3techs.com/technologies/topsite/programming_language

Q1. Does this mean PHP is used for quick and easy website where other languages are used in more complex websites?

Q2. Why PHP is ranked at the bottom? Or why big company tend to use other language than PHP?

Update: I know that facebook and other biggies uses PHP. But it does not tell why there are more other languages are used in top websites.

答: PHP is the easiest to deploy because it's almost always already setup on a web server.  Other languages never seem to be setup to actually deploy websites on shared hosting or anywhere else... you have to do it yourself or pay someone to specifically allow the language to serve web content.  As far as I have experienced this is the sole reason other languages aren't being adopted at a quick rate.  Python has a great syntax and it's much more intuitive in a lot of ways compared to PHP but you don't see it ready to deploy a site on hosting plans very often.</p>


问:
upgrading to spring 4.2.5 has caused a startup error around quartz scheduler
upgrading to spring 4.2.5 has caused a startup problem around quartz scheduler  -

```<code>NoSuchMethodError : org.quartz.Scheduler.getListenerManager()

Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'intAppService' defined in file [SaPvApp-context.xml]: Cannot resolve reference to bean 'quartzScheduler' while setting bean property 'quartzScheduler'; nested exception is org.springframework.beans.factory.Bean

CreationException: Error creating bean with name 'quartzScheduler' defined in file [C:\Integration Apps\SAPV\config\SaPvApp-context.xml]:
Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: org.quartz.Scheduler.getListenerManager()Lorg/quartz/ListenerManager;
</code>```

from pom:

```<code><dependency>
  <groupId>org.opensymphony.quartz</groupId>
  <artifactId>quartz</artifactId>
  <version>1.6.5</version>
</dependency>
</code>```

from context file:

```<code><bean name="quartzScheduler" class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
    <property name="autoStartup" value="false" />
    <property name="schedulerName" value="PvScheduler" />
    <property name="triggers">
        <list>
            <!-- <ref bean="cronTrigger" /> -->
        </list>
    </property>
</bean>

<bean id="jobDetail" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
    <property name="targetObject" ref="serviceTask" />
    <property name="targetMethod" value="run" />
    <property name="concurrent" value="false" />
    <property name="group" value="PV" />
    <property name="name" value="${app.service.name}${app.service.instance}-Job" />
    <property name="jobListenerNames">
        <list>
            <!-- <value>PvJobListener</value> -->
        </list>
    </property>
</bean>

<bean id="cronTrigger" class="org.springframework.scheduling.quartz.CronTriggerBean">
    <property name="jobDetail" ref="jobDetail" />
    <!--<property name="cronExpression" value="10 0/01 * * * ?"  />-->
    <!-- run twice a day at 3am and 3pm -->
     <property name="cronExpression" value="0 0 3,15 ? * *"  />
    <!-- run every 30 minutes, at 10 seconds after the minute (i.e. 10:00:10 am, 10:30:10 am, etc.)
    <property name="cronExpression" value="10 0/30 * * * ?"  />  -->
</bean>
</code>```

edit: attempting to upgrade quartz to 2.2.2:

```<code>    /**
 * Listen for Job and Scheduler events.
 */
public void listen() {
    if (this.quartzScheduler != null) {
        try {
            this.quartzScheduler.addJobListener(this);
            this.quartzScheduler.addSchedulerListener(this);
        }
        catch (SchedulerException e) {
            throw new IntegrationServiceException("listen", e);
        }
    }
}
</code>```

Errors:

The method addJobListener(QuartzTaskScheduler) is undefined for the type Scheduler

The method addSchedulerListener(QuartzTaskScheduler) is undefined for the type Scheduler

Edit 4/3/17:
I was able to resolve the abstract error by adding abstract=”true” to my bean definition however, i'm getting a new error posted below:

```<code>Error creating bean with name 'jobDetail' defined in file [C:\Integration Apps\SAPV\config\SaPvApp-context.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'jobListenerNames' of bean class

[org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean]: Bean property 'jobListenerNames' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1518)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1226)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:543)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
        at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:753)
        at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:839)
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:538)
        at org.springframework.context.support.FileSystemXmlApplicationContext.<init>(FileSystemXmlApplicationContext.java:140)
        at org.springframework.context.support.FileSystemXmlApplicationContext.<init>(FileSystemXmlApplicationContext.java:84)
        at AbstractCommandLineApplication.runApplication(AbstractCommandLineApplication.java:93)
        at AbstractCommandLineApplication.runApplication(AbstractCommandLineApplication.java:54)
        at cmd.SaPvApp.main(SaPvApp.java:18)
Caused by: org.springframework.beans.NotWritablePropertyException: Invalid property 'jobListenerNames' of bean class [org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean]: Bean property 'jobListenerNames' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
        at org.springframework.beans.BeanWrapperImpl.createNotWritablePropertyException(BeanWrapperImpl.java:231)
        at org.springframework.beans.AbstractNestablePropertyAccessor.setPropertyValue(AbstractNestablePropertyAccessor.java:423)
        at org.springframework.beans.AbstractNestablePropertyAccessor.setPropertyValue(AbstractNestablePropertyAccessor.java:280)
        at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:95)
        at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:75)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1514)
        ... 15 more
</code>```

edit 4/3/17 pt2:
I commented out jobListernersNames and got a new error:

```<code>org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [org.springframework.scheduling.quartz.CronTriggerBean] for bean with name 'cronTrigger' defined in file [C:\Integration Apps\SAPV\config\SaPvApp-context.xml]; nested exception is java.lang.ClassNotFoundException:

org.springframework.scheduling.quartz.CronTriggerBean
        at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1352)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.determineTargetType(AbstractAutowireCapableBeanFactory.java:628)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.predictBeanType(AbstractAutowireCapableBeanFactory.java:597)
        at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:1445)
        at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:975)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:752)
        at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:839)
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:538)
        at org.springframework.context.support.FileSystemXmlApplicationContext.<init>(FileSystemXmlApplicationContext.java:140)
        at org.springframework.context.support.FileSystemXmlApplicationContext.<init>(FileSystemXmlApplicationContext.java:84)
        at AbstractCommandLineApplication.runApplication(AbstractCommandLineApplication.java:93)
        at AbstractCommandLineApplication.runApplication(AbstractCommandLineApplication.java:54)
        at cmd.SaPvApp.main(SaPvApp.java:18)
Caused by: java.lang.ClassNotFoundException: org.springframework.scheduling.quartz.CronTriggerBean
        at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
        at org.springframework.util.ClassUtils.forName(ClassUtils.java:250)
        at org.springframework.beans.factory.support.AbstractBeanDefinition.resolveBeanClass(AbstractBeanDefinition.java:394)
        at org.springframework.beans.factory.support.AbstractBeanFactory.doResolveBeanClass(AbstractBeanFactory.java:1397)
        at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1344)
        ... 12 more
</code>```

Here is the state of the context.xml file (note if I add back the ref to cronTrigger it gets my original error:

```<code><bean name="intAppService" class="QuartzTaskScheduler" init-method="listen" abstract="true">
    <property name="name" value="PvJobListener" />
    <property name="quartzScheduler" ref="quartzScheduler"/>
</bean>

<bean name="quartzScheduler" class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
    <property name="autoStartup" value="false" />
    <property name="schedulerName" value="PvScheduler" />
    <property name="triggers">
        <list>
            <!--<ref bean="cronTrigger" />-->
        </list>
    </property>
</bean>

<bean id="jobDetail" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
    <property name="targetObject" ref="serviceTask" />
    <property name="targetMethod" value="run" />
    <property name="concurrent" value="false" />
    <property name="group" value="PV" />
    <property name="name" value="${app.service.name}${app.service.instance}-Job" />
    <!--<property name="jobListenerNames">
        <list>
            <value>PvJobListener</value>
        </list>
    </property>-->
</bean>

<bean name="serviceTask" class="SaPvService">
    <property name="serviceTaskName" value="${app.service.name}${app.service.instance}"/>
    <property name="hoursRepository" ref="hoursRepository"/>
    <property name="primaveraSessionService" ref="primaveraSessionService"/>
    <property name="resourceRateProcessor" ref="resourceRateProcessor"/>
    <property name="workChunkRepository" ref="workChunkRepository"/>
</bean>

<bean id="cronTrigger" class="org.springframework.scheduling.quartz.CronTriggerBean">
    <property name="jobDetail" ref="jobDetail" />
    <!--<property name="cronExpression" value="10 0/01 * * * ?"  />-->
    <!-- run twice a day at 3am and 3pm -->
     <property name="cronExpression" value="0 0 3,15 ? * *"  />
    <!-- run every 30 minutes, at 10 seconds after the minute (i.e. 10:00:10 am, 10:30:10 am, etc.)
    <property name="cronExpression" value="10 0/30 * * * ?"  />  -->
</bean>
</code>```

edit 4/3/17 pt2 a:
I put the cronTrigger ref back in this is the error for that situation:

context:

```<code><bean id="cronTrigger" class="org.springframework.scheduling.quartz.CronTriggerBean">
    <property name="jobDetail" ref="jobDetail" />
    <!--<property name="cronExpression" value="10 0/01 * * * ?"  />-->
    <!-- run twice a day at 3am and 3pm -->
     <property name="cronExpression" value="0 0 3,15 ? * *"  />
    <!-- run every 30 minutes, at 10 seconds after the minute (i.e. 10:00:10 am, 10:30:10 am, etc.)
    <property name="cronExpression" value="10 0/30 * * * ?"  />  -->
</bean>

<bean name="quartzScheduler" class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
    <property name="autoStartup" value="false" />
    <property name="schedulerName" value="PvScheduler" />
    <property name="triggers">
        <list>
            <ref bean="cronTrigger" />
        </list>
    </property>
</bean>
</code>```

error:

```<code>2017-04-03 14:34:22,792 WARN {main} [org.springframework.context.support.FileSystemXmlApplicationContext] - Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [org.springframework.scheduling.quartz.CronTriggerBean] for bean with name 'cronTrigger' defined in file [C:\Integration Apps\SAPV\config\SaPvApp-context.xml]; nested exception is java.lang.ClassNotFoundException: org.springframework.scheduling.quartz.CronTriggerBean
*** SaPvApp: Unexpected service error at Mon Apr 03 14:34:23 CDT 2017
org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [org.springframework.scheduling.quartz.CronTriggerBean] for bean with name 'cronTrigger' defined in file [C:\Integration Apps\SAPV\config\SaPvApp-context.xml]; nested exception is java.lang.ClassNotFoundException: org.springframework.scheduling.quartz.CronTriggerBean
        at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1352)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.determineTargetType(AbstractAutowireCapableBeanFactory.java:628)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.predictBeanType(AbstractAutowireCapableBeanFactory.java:597)
        at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:1445)
        at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:975)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:752)
        at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:839)
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:538)
        at org.springframework.context.support.FileSystemXmlApplicationContext.<init>(FileSystemXmlApplicationContext.java:140)
        at org.springframework.context.support.FileSystemXmlApplicationContext.<init>(FileSystemXmlApplicationContext.java:84)
        at AbstractCommandLineApplication.runApplication(AbstractCommandLineApplication.java:93)
        at AbstractCommandLineApplication.runApplication(AbstractCommandLineApplication.java:54)
        at cmd.SaPvApp.main(SaPvApp.java:18)
Caused by: java.lang.ClassNotFoundException: org.springframework.scheduling.quartz.CronTriggerBean
        at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
        at org.springframework.util.ClassUtils.forName(ClassUtils.java:250)
        at org.springframework.beans.factory.support.AbstractBeanDefinition.resolveBeanClass(AbstractBeanDefinition.java:394)
        at org.springframework.beans.factory.support.AbstractBeanFactory.doResolveBeanClass(AbstractBeanFactory.java:1397)
        at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1344)
        ... 12 more
</code>```

update 4/3/17 14:55 CT:
I changed the context file CronTriggerBean is now CronTriggerFactoryBean
now i'm getting this error:

```<code>2017-04-03 14:52:47,570 INFO {main} [org.quartz.core.QuartzScheduler] -

Scheduler meta-data: Quartz Scheduler (v2.2.2) 'PvScheduler' with instanceId 'NON_CLUSTERED'
  Scheduler class: 'org.quartz.core.QuartzScheduler' - running locally.
  NOT STARTED.
  Currently in standby mode.
  Number of jobs executed: 0
  Using thread pool 'org.quartz.simpl.SimpleThreadPool' - with 10 threads.
  Using job-store 'org.quartz.simpl.RAMJobStore' - which does not support persistence. and is not clustered.

2017-04-03 14:52:47,572 INFO {main} [org.quartz.impl.StdSchedulerFactory] - Quartz scheduler 'PvScheduler' initialized from an externally provided properties instance.
2017-04-03 14:52:47,574 INFO {main} [org.quartz.impl.StdSchedulerFactory] - Quartz scheduler version: 2.2.2
2017-04-03 14:52:47,576 INFO {main} [org.quartz.core.QuartzScheduler] - JobFactory set to: org.springframework.scheduling.quartz.AdaptableJobFactory@749ad37c
*** SaPvApp: Registering JVM shutdown hook
*** SaPvApp: version 17.1.0
*** SaPvApp: Adding service-stop event listeners
*** SaPvApp: Starting service at Mon Apr 03 14:52:47 CDT 2017
*** SaPvApp: Unexpected service error at Mon Apr 03 14:52:47 CDT 2017
org.springframework.beans.factory.BeanIsAbstractException: Error creating bean with name 'intAppService': Bean definition is abstract
        at org.springframework.beans.factory.support.AbstractBeanFactory.checkMergedBeanDefinition(AbstractBeanFactory.java:1288)
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:285)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
        at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1054)
        at AbstractCommandLineApplication.runApplication(AbstractCommandLineApplication.java:112)
        at AbstractCommandLineApplication.runApplication(AbstractCommandLineApplication.java:54)
        at cmd.SaPvApp.main(SaPvApp.java:18)
*** SaPvApp: Calling service stop event listeners
*** SaPvApp: Exiting service at Mon Apr 03 14:52:47 CDT 2017
*** SaPvApp ShutdownHook: Service shutdown initiated at Mon Apr 03 14:52:47 CDT 2017
*** SaPvApp ShutdownHook: Closing application context
2017-04-03 14:52:47,609 INFO {ApplicationShutdownHook} [org.springframework.context.support.FileSystemXmlApplicationContext] - Closing org.springframework.context.support.FileSystemXmlApplicationContext@63e31ee: startup date [Mon Apr 03 14:52:41 CDT 2017]; root of context hierarchy
2017-04-03 14:52:47,615 INFO {ApplicationShutdownHook} [org.springframework.context.support.DefaultLifecycleProcessor] - Stopping beans in phase 2147483647
2017-04-03 14:52:47,618 INFO {ApplicationShutdownHook} [org.springframework.scheduling.quartz.SchedulerFactoryBean] - Shutting down Quartz Scheduler
2017-04-03 14:52:47,619 INFO {ApplicationShutdownHook} [org.quartz.core.QuartzScheduler] - Scheduler PvScheduler_$_NON_CLUSTERED shutting down.
2017-04-03 14:52:47,620 INFO {ApplicationShutdownHook} [org.quartz.core.QuartzScheduler] - Scheduler PvScheduler_$_NON_CLUSTERED paused.
2017-04-03 14:52:47,621 INFO {ApplicationShutdownHook} [org.quartz.core.QuartzScheduler] - Scheduler PvScheduler_$_NON_CLUSTERED shutdown complete.
*** SaPvApp ShutdownHook: Service shutdown complete
</code>```

edit 4/4/17 07:59:
I tried creating a parent abstract class

```<code><dependency>
  <groupId>org.opensymphony.quartz</groupId>
  <artifactId>quartz</artifactId>
  <version>1.6.5</version>
</dependency>
</code>```0

but I'm getting this error:

```<code><dependency>
  <groupId>org.opensymphony.quartz</groupId>
  <artifactId>quartz</artifactId>
  <version>1.6.5</version>
</dependency>
</code>```1

If I don't make the java code class abstract I get a compile error about this:

```<code><dependency>
  <groupId>org.opensymphony.quartz</groupId>
  <artifactId>quartz</artifactId>
  <version>1.6.5</version>
</dependency>
</code>```2

I'm not sure how to fix this?

答: Your overriden quartz version is not compatible with the version of Springs. Remove quartz version declaration from your pom Or try to upgrade the quartz version to 2.2.2 which is supported by Spring context 4.2.5.</p>

ContentLicense: CC BY-SA 4.0

Body:
upgrading to spring 4.2.5 has caused a startup problem around quartz scheduler  -

NoSuchMethodError : org.quartz.Scheduler.getListenerManager()

Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'intAppService' defined in file [SaPvApp-context.xml]: Cannot resolve reference to bean 'quartzScheduler' while setting bean property 'quartzScheduler'; nested exception is org.springframework.beans.factory.Bean

CreationException: Error creating bean with name 'quartzScheduler' defined in file [C:\Integration Apps\SAPV\config\SaPvApp-context.xml]:
Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: org.quartz.Scheduler.getListenerManager()Lorg/quartz/ListenerManager;

from pom:

<dependency>
  <groupId>org.opensymphony.quartz</groupId>
  <artifactId>quartz</artifactId>
  <version>1.6.5</version>
</dependency>

from context file:

<bean name="quartzScheduler" class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
    <property name="autoStartup" value="false" />
    <property name="schedulerName" value="PvScheduler" />
    <property name="triggers">
        <list>

        </list>
    </property>
</bean>

<bean id="jobDetail" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
    <property name="targetObject" ref="serviceTask" />
    <property name="targetMethod" value="run" />
    <property name="concurrent" value="false" />
    <property name="group" value="PV" />
    <property name="name" value="${app.service.name}${app.service.instance}-Job" />
    <property name="jobListenerNames">
        <list>

        </list>
    </property>
</bean>

<bean id="cronTrigger" class="org.springframework.scheduling.quartz.CronTriggerBean">
    <property name="jobDetail" ref="jobDetail" />

     <property name="cronExpression" value="0 0 3,15 ? * *"  />

</bean>

edit: attempting to upgrade quartz to 2.2.2:

    /**
 * Listen for Job and Scheduler events.
 */
public void listen() {
    if (this.quartzScheduler != null) {
        try {
            this.quartzScheduler.addJobListener(this);
            this.quartzScheduler.addSchedulerListener(this);
        }
        catch (SchedulerException e) {
            throw new IntegrationServiceException("listen", e);
        }
    }
}

Errors:

The method addJobListener(QuartzTaskScheduler) is undefined for the type Scheduler

The method addSchedulerListener(QuartzTaskScheduler) is undefined for the type Scheduler

Edit 4/3/17:
I was able to resolve the abstract error by adding abstract=”true” to my bean definition however, i'm getting a new error posted below:

Error creating bean with name 'jobDetail' defined in file [C:\Integration Apps\SAPV\config\SaPvApp-context.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'jobListenerNames' of bean class

[org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean]: Bean property 'jobListenerNames' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1518)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1226)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:543)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
        at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:753)
        at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:839)
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:538)
        at org.springframework.context.support.FileSystemXmlApplicationContext.<init>(FileSystemXmlApplicationContext.java:140)
        at org.springframework.context.support.FileSystemXmlApplicationContext.<init>(FileSystemXmlApplicationContext.java:84)
        at AbstractCommandLineApplication.runApplication(AbstractCommandLineApplication.java:93)
        at AbstractCommandLineApplication.runApplication(AbstractCommandLineApplication.java:54)
        at cmd.SaPvApp.main(SaPvApp.java:18)
Caused by: org.springframework.beans.NotWritablePropertyException: Invalid property 'jobListenerNames' of bean class [org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean]: Bean property 'jobListenerNames' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
        at org.springframework.beans.BeanWrapperImpl.createNotWritablePropertyException(BeanWrapperImpl.java:231)
        at org.springframework.beans.AbstractNestablePropertyAccessor.setPropertyValue(AbstractNestablePropertyAccessor.java:423)
        at org.springframework.beans.AbstractNestablePropertyAccessor.setPropertyValue(AbstractNestablePropertyAccessor.java:280)
        at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:95)
        at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:75)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1514)
        ... 15 more

edit 4/3/17 pt2:
I commented out jobListernersNames and got a new error:

org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [org.springframework.scheduling.quartz.CronTriggerBean] for bean with name 'cronTrigger' defined in file [C:\Integration Apps\SAPV\config\SaPvApp-context.xml]; nested exception is java.lang.ClassNotFoundException:

org.springframework.scheduling.quartz.CronTriggerBean
        at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1352)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.determineTargetType(AbstractAutowireCapableBeanFactory.java:628)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.predictBeanType(AbstractAutowireCapableBeanFactory.java:597)
        at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:1445)
        at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:975)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:752)
        at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:839)
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:538)
        at org.springframework.context.support.FileSystemXmlApplicationContext.<init>(FileSystemXmlApplicationContext.java:140)
        at org.springframework.context.support.FileSystemXmlApplicationContext.<init>(FileSystemXmlApplicationContext.java:84)
        at AbstractCommandLineApplication.runApplication(AbstractCommandLineApplication.java:93)
        at AbstractCommandLineApplication.runApplication(AbstractCommandLineApplication.java:54)
        at cmd.SaPvApp.main(SaPvApp.java:18)
Caused by: java.lang.ClassNotFoundException: org.springframework.scheduling.quartz.CronTriggerBean
        at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
        at org.springframework.util.ClassUtils.forName(ClassUtils.java:250)
        at org.springframework.beans.factory.support.AbstractBeanDefinition.resolveBeanClass(AbstractBeanDefinition.java:394)
        at org.springframework.beans.factory.support.AbstractBeanFactory.doResolveBeanClass(AbstractBeanFactory.java:1397)
        at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1344)
        ... 12 more

Here is the state of the context.xml file (note if I add back the ref to cronTrigger it gets my original error:

<bean name="intAppService" class="QuartzTaskScheduler" init-method="listen" abstract="true">
    <property name="name" value="PvJobListener" />
    <property name="quartzScheduler" ref="quartzScheduler"/>
</bean>

<bean name="quartzScheduler" class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
    <property name="autoStartup" value="false" />
    <property name="schedulerName" value="PvScheduler" />
    <property name="triggers">
        <list>

        </list>
    </property>
</bean>

<bean id="jobDetail" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
    <property name="targetObject" ref="serviceTask" />
    <property name="targetMethod" value="run" />
    <property name="concurrent" value="false" />
    <property name="group" value="PV" />
    <property name="name" value="${app.service.name}${app.service.instance}-Job" />

</bean>

<bean name="serviceTask" class="SaPvService">
    <property name="serviceTaskName" value="${app.service.name}${app.service.instance}"/>
    <property name="hoursRepository" ref="hoursRepository"/>
    <property name="primaveraSessionService" ref="primaveraSessionService"/>
    <property name="resourceRateProcessor" ref="resourceRateProcessor"/>
    <property name="workChunkRepository" ref="workChunkRepository"/>
</bean>

<bean id="cronTrigger" class="org.springframework.scheduling.quartz.CronTriggerBean">
    <property name="jobDetail" ref="jobDetail" />

     <property name="cronExpression" value="0 0 3,15 ? * *"  />

</bean>

edit 4/3/17 pt2 a:
I put the cronTrigger ref back in this is the error for that situation:

context:

<bean id="cronTrigger" class="org.springframework.scheduling.quartz.CronTriggerBean">
    <property name="jobDetail" ref="jobDetail" />

     <property name="cronExpression" value="0 0 3,15 ? * *"  />

</bean>

<bean name="quartzScheduler" class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
    <property name="autoStartup" value="false" />
    <property name="schedulerName" value="PvScheduler" />
    <property name="triggers">
        <list>
            <ref bean="cronTrigger" />
        </list>
    </property>
</bean>

error:

2017-04-03 14:34:22,792 WARN {main} [org.springframework.context.support.FileSystemXmlApplicationContext] - Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [org.springframework.scheduling.quartz.CronTriggerBean] for bean with name 'cronTrigger' defined in file [C:\Integration Apps\SAPV\config\SaPvApp-context.xml]; nested exception is java.lang.ClassNotFoundException: org.springframework.scheduling.quartz.CronTriggerBean
*** SaPvApp: Unexpected service error at Mon Apr 03 14:34:23 CDT 2017
org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [org.springframework.scheduling.quartz.CronTriggerBean] for bean with name 'cronTrigger' defined in file [C:\Integration Apps\SAPV\config\SaPvApp-context.xml]; nested exception is java.lang.ClassNotFoundException: org.springframework.scheduling.quartz.CronTriggerBean
        at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1352)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.determineTargetType(AbstractAutowireCapableBeanFactory.java:628)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.predictBeanType(AbstractAutowireCapableBeanFactory.java:597)
        at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:1445)
        at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:975)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:752)
        at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:839)
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:538)
        at org.springframework.context.support.FileSystemXmlApplicationContext.<init>(FileSystemXmlApplicationContext.java:140)
        at org.springframework.context.support.FileSystemXmlApplicationContext.<init>(FileSystemXmlApplicationContext.java:84)
        at AbstractCommandLineApplication.runApplication(AbstractCommandLineApplication.java:93)
        at AbstractCommandLineApplication.runApplication(AbstractCommandLineApplication.java:54)
        at cmd.SaPvApp.main(SaPvApp.java:18)
Caused by: java.lang.ClassNotFoundException: org.springframework.scheduling.quartz.CronTriggerBean
        at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
        at org.springframework.util.ClassUtils.forName(ClassUtils.java:250)
        at org.springframework.beans.factory.support.AbstractBeanDefinition.resolveBeanClass(AbstractBeanDefinition.java:394)
        at org.springframework.beans.factory.support.AbstractBeanFactory.doResolveBeanClass(AbstractBeanFactory.java:1397)
        at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1344)
        ... 12 more

update 4/3/17 14:55 CT:
I changed the context file CronTriggerBean is now CronTriggerFactoryBean
now i'm getting this error:

2017-04-03 14:52:47,570 INFO {main} [org.quartz.core.QuartzScheduler] -

Scheduler meta-data: Quartz Scheduler (v2.2.2) 'PvScheduler' with instanceId 'NON_CLUSTERED'
  Scheduler class: 'org.quartz.core.QuartzScheduler' - running locally.
  NOT STARTED.
  Currently in standby mode.
  Number of jobs executed: 0
  Using thread pool 'org.quartz.simpl.SimpleThreadPool' - with 10 threads.
  Using job-store 'org.quartz.simpl.RAMJobStore' - which does not support persistence. and is not clustered.

2017-04-03 14:52:47,572 INFO {main} [org.quartz.impl.StdSchedulerFactory] - Quartz scheduler 'PvScheduler' initialized from an externally provided properties instance.
2017-04-03 14:52:47,574 INFO {main} [org.quartz.impl.StdSchedulerFactory] - Quartz scheduler version: 2.2.2
2017-04-03 14:52:47,576 INFO {main} [org.quartz.core.QuartzScheduler] - JobFactory set to: org.springframework.scheduling.quartz.AdaptableJobFactory@749ad37c
*** SaPvApp: Registering JVM shutdown hook
*** SaPvApp: version 17.1.0
*** SaPvApp: Adding service-stop event listeners
*** SaPvApp: Starting service at Mon Apr 03 14:52:47 CDT 2017
*** SaPvApp: Unexpected service error at Mon Apr 03 14:52:47 CDT 2017
org.springframework.beans.factory.BeanIsAbstractException: Error creating bean with name 'intAppService': Bean definition is abstract
        at org.springframework.beans.factory.support.AbstractBeanFactory.checkMergedBeanDefinition(AbstractBeanFactory.java:1288)
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:285)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
        at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1054)
        at AbstractCommandLineApplication.runApplication(AbstractCommandLineApplication.java:112)
        at AbstractCommandLineApplication.runApplication(AbstractCommandLineApplication.java:54)
        at cmd.SaPvApp.main(SaPvApp.java:18)
*** SaPvApp: Calling service stop event listeners
*** SaPvApp: Exiting service at Mon Apr 03 14:52:47 CDT 2017
*** SaPvApp ShutdownHook: Service shutdown initiated at Mon Apr 03 14:52:47 CDT 2017
*** SaPvApp ShutdownHook: Closing application context
2017-04-03 14:52:47,609 INFO {ApplicationShutdownHook} [org.springframework.context.support.FileSystemXmlApplicationContext] - Closing org.springframework.context.support.FileSystemXmlApplicationContext@63e31ee: startup date [Mon Apr 03 14:52:41 CDT 2017]; root of context hierarchy
2017-04-03 14:52:47,615 INFO {ApplicationShutdownHook} [org.springframework.context.support.DefaultLifecycleProcessor] - Stopping beans in phase 2147483647
2017-04-03 14:52:47,618 INFO {ApplicationShutdownHook} [org.springframework.scheduling.quartz.SchedulerFactoryBean] - Shutting down Quartz Scheduler
2017-04-03 14:52:47,619 INFO {ApplicationShutdownHook} [org.quartz.core.QuartzScheduler] - Scheduler PvScheduler_$_NON_CLUSTERED shutting down.
2017-04-03 14:52:47,620 INFO {ApplicationShutdownHook} [org.quartz.core.QuartzScheduler] - Scheduler PvScheduler_$_NON_CLUSTERED paused.
2017-04-03 14:52:47,621 INFO {ApplicationShutdownHook} [org.quartz.core.QuartzScheduler] - Scheduler PvScheduler_$_NON_CLUSTERED shutdown complete.
*** SaPvApp ShutdownHook: Service shutdown complete

edit 4/4/17 07:59:
I tried creating a parent abstract class

    <bean name="intAppServiceParent" abstract = "true">
    <property name="nameParent" value="PvJobListenerParent" />
    <property name="quartzSchedulerParent" ref="quartzSchedulerParent"/>
</bean>

<bean name="intAppService" class="QuartzTaskScheduler" init-method="listen" parent = "intAppServiceParent">
    <property name="name" value="PvJobListener" />
    <property name="quartzScheduler" ref="quartzScheduler"/>
</bean>

but I'm getting this error:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'intAppService' defined in file [C:\Integration Apps\SAPV\config\SaPvApp-context.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [QuartzTaskScheduler]: Is it an abstract class?; nested exception is java.lang.InstantiationException

If I don't make the java code class abstract I get a compile error about this:

The type QuartzTaskScheduler must implement the inherited abstract method SchedulerListener.triggersPaused(String)

I'm not sure how to fix this?


问:
ini file not being ready properly
I keep getting this error:

Warning: mysql_connect(): Unknown MySQL server host 'elephant' (1) 4

My ini file is this:

```<code>[Database]
DBHostName = "localhost"
DatabaseName = "elephant"
DBUserName = "elephant"
DBPassword = "practice"

[Config]
ConfigTableName = "stage2_config"
Skin="purple"
</code>```

My file that reads the ini file and gives the error is this on the line with the double bold stars. I have no idea what is going on here and why it says the host isn't localhost.

```<code><?php
 $gv_SystemTest = "<h2>system.php has been included</h2>";

 $gv_SystemFileInfo = pathinfo(__FILE__);
 $gv_SystemDirectory = $gv_SystemFileInfo['dirname'] . '/';
 $gv_SystemINIpath = $gv_SystemDirectory . '';

 $gv_SiteGlobals = parse_ini_file($gv_SystemINIpath . $_SERVER['WIA_SYSTEM_INI'], true);

 function echoContent($p_ContentID) {
 global $gv_SiteGlobals;

 $fv_dbLink = mysql_connect($gv_SiteGlobals['Database']['DBHostName'],
 $gv_SiteGlobals['Database']['DBUserName'],
 $gv_SiteGlobals['Database']['DBPassword']);
 **mysql_connect($gv_SiteGlobals['Database']['DatabaseName']);**

 $fv_TheQuery = "select *from wia_content where content_id = $p_ContentID";
</code>```

答:
Dont use mysql use only mysqli or pdo

I think you want to select db

to select db you should be mysql_select_db()

```<code>mysql_select_db('foo', $link);
</code>```

your error in this line

```<code>mysql_connect($gv_SiteGlobals['Database']['DatabaseName']);
</code>```

it should be of the form

```<code>mysql_connect('localhost', 'mysql_user', 'mysql_password');
</code>```

Title: ini file not being ready properly

Body:
I keep getting this error:

Warning: mysql_connect(): Unknown MySQL server host 'elephant' (1) 4

My ini file is this:

[Database]
DBHostName = "localhost"
DatabaseName = "elephant"
DBUserName = "elephant"
DBPassword = "practice"

[Config]
ConfigTableName = "stage2_config"
Skin="purple"

My file that reads the ini file and gives the error is this on the line with the double bold stars. I have no idea what is going on here and why it says the host isn't localhost.

<?php
 $gv_SystemTest = "
system.php has been included
";

 $gv_SystemFileInfo = pathinfo(__FILE__);
 $gv_SystemDirectory = $gv_SystemFileInfo['dirname'] . '/';
 $gv_SystemINIpath = $gv_SystemDirectory . '';

 $gv_SiteGlobals = parse_ini_file($gv_SystemINIpath . $_SERVER['WIA_SYSTEM_INI'], true);

 function echoContent($p_ContentID) {
 global $gv_SiteGlobals;

 $fv_dbLink = mysql_connect($gv_SiteGlobals['Database']['DBHostName'],
 $gv_SiteGlobals['Database']['DBUserName'],
 $gv_SiteGlobals['Database']['DBPassword']);
 **mysql_connect($gv_SiteGlobals['Database']['DatabaseName']);**

 $fv_TheQuery = "select *from wia_content where content_id = $p_ContentID";

Body:
Dont use mysql use only mysqli or pdo

I think you want to select db

to select db you should be mysql_select_db()

mysql_select_db('foo', $link);

your error in this line

mysql_connect($gv_SiteGlobals['Database']['DatabaseName']);

it should be of the form

mysql_connect('localhost', 'mysql_user', 'mysql_password');


问:
Overwriting when appending to list of lists in Python
I am trying to group the index of continuous events from a list of events based on their value.

However, there is an error in my code in appending to the events_list list that I can't spot.
When my code appends it overwrites the values of the previously appended items.

The last print statement returns [[24],[24],[24],[24],[24]] instead of the expected [[0,1,2,3,4],[7],[8,9],[10,11,12],[16, 17, 18, 19, 20, 21],[24]]

```<code>single_events = [1,1,1,1,1,0,0,-1,1,1,-1,-1,-1,0,0,0,-1,-1,-1,-1,-1,-1,0,0,1]

events_list = []
current_event = []

for i, event in enumerate(single_events):
    print('\nRecord: ', i, ',\tEvent Type: ', event)
    if (current_event == []) and (event != 0):
        current_event.append(i)
        print('Current Event: ', current_event)

    elif (current_event == []) and (acc == 0):
        pass

    elif (current_event != []) and (event == single_events[current_event[-1]]):
        current_event.append(i)
        print('Current Event: ', current_event)

    elif (current_event != []) and (event != single_events[current_event[-1]]):
        print('Event to be appended: ', current_event)
        events_list.append(current_event)
        print('\nNEW EVENT LIST!!!: ', events_list)
        current_event[:] = []
        if event == 0:
            pass
        else:
            current_event.append(i)
        print('Current Event: ', current_event)

print('\n', events_list)
</code>```

答:
You're reusing the same reference for current_event for every iteration.

That:

```<code>current_event[:] = []
</code>```

empties the list, but keeps the same reference. You need to create a new reference to avoid modifying the previously stored lists, like this:

```<code>current_event = []
</code>```

by changing just that I get: [[0, 1, 2, 3, 4], [7], [8, 9], [10, 11, 12], [16, 17, 18, 19, 20, 21]] as a result

Aside: conditions like elif (current_event == []) and (acc == 0): can be better rewritten like:

```<code>elif not current_event and acc==0:
</code>```

empty list is considered as "Falsy", no need to compare to empty (same thing for acc but comparing to 0 is clearer).

Body:
I am trying to group the index of continuous events from a list of events based on their value.

However, there is an error in my code in appending to the events_list list that I can't spot.
When my code appends it overwrites the values of the previously appended items.

The last print statement returns [[24],[24],[24],[24],[24]] instead of the expected [[0,1,2,3,4],[7],[8,9],[10,11,12],[16, 17, 18, 19, 20, 21],[24]]

single_events = [1,1,1,1,1,0,0,-1,1,1,-1,-1,-1,0,0,0,-1,-1,-1,-1,-1,-1,0,0,1]

events_list = []
current_event = []

for i, event in enumerate(single_events):
    print('\nRecord: ', i, ',\tEvent Type: ', event)
    if (current_event == []) and (event != 0):
        current_event.append(i)
        print('Current Event: ', current_event)

    elif (current_event == []) and (acc == 0):
        pass

    elif (current_event != []) and (event == single_events[current_event[-1]]):
        current_event.append(i)
        print('Current Event: ', current_event)

    elif (current_event != []) and (event != single_events[current_event[-1]]):
        print('Event to be appended: ', current_event)
        events_list.append(current_event)
        print('\nNEW EVENT LIST!!!: ', events_list)
        current_event[:] = []
        if event == 0:
            pass
        else:
            current_event.append(i)
        print('Current Event: ', current_event)

print('\n', events_list)

Body:
You're reusing the same reference for current_event for every iteration.

That:

current_event[:] = []

empties the list, but keeps the same reference. You need to create a new reference to avoid modifying the previously stored lists, like this:

current_event = []

by changing just that I get: [[0, 1, 2, 3, 4], [7], [8, 9], [10, 11, 12], [16, 17, 18, 19, 20, 21]] as a result

Aside: conditions like elif (current_event == []) and (acc == 0): can be better rewritten like:

elif not current_event and acc==0:

empty list is considered as "Falsy", no need to compare to empty (same thing for acc but comparing to 0 is clearer).


问:
BASH_REMATCH empty
I'm trying capture the some input regex in Bash but BASH_REMATCH comes EMPTY

```<code>#!/usr/bin/env /bin/bash
INPUT=$(cat input.txt)
TASK_NAME="MailAccountFetch"

MATCH_PATTERN="(${TASK_NAME})\s+([0-9]{4}-[0-9]{2}-[0-9]{2}\s[0-9]{2}:[0-9]{2}:[0-9]{2})"

while read -r line; do
    if [[ $line =~ $MATCH_PATTERN ]]; then
        TASK_RESULT=${BASH_REMATCH[3]}
        TASK_LAST_RUN=${BASH_REMATCH[2]}
        TASK_EXECUTION_DURATION=${BASH_REMATCH[4]}
    fi
done <<< "$INPUT"
</code>```

My input is:

```<code>    MailAccountFetch                         2017-03-29 19:00:00  Success      5.0 Second(s)      2017-03-29 19:03:00
</code>```

By debugging the script (VS Code+Bash ext) I can see the INPUT string matches as the code goes inside the IF but BASH_REMATCH is not populated with my two capture groups.

I'm on:

```<code>GNU bash, version 4.4.0(1)-release (x86_64-pc-linux-gnu)
</code>```

What could be the issue?

LATER EDIT

Accepted Answer

Accepting most explanatory answer.

What finally resolved the issue:

bashdb/VS Code environment are causing the empty BASH_REMATCH. The code works OK when ran alone.

答:
Bash uses system libraries to parse regular expressions, and different parsers implement different features. You've come across a place where regex class shorthand strings do not work.  Note the following:

```<code>$ s="one12345   two"
$ [[ $s =~ ^([a-z]+[0-9]{4})\S*\s+(.*) ]] && echo yep; declare -p BASH_REMATCH
declare -ar BASH_REMATCH=()
$ [[ $s =~ ^([a-z]+[0-9]{4})[^[:space:]]*[[:space:]]+(.*) ]] && echo yep; declare -p BASH_REMATCH
yep
declare -ar BASH_REMATCH=([0]="one12345   two" [1]="one1234" [2]="two")
</code>```

I'm doing this on macOS as well, but I get the same behaviour on FreeBSD.

Simply replace \s with [[:space:]], \d with [[:digit:]], etc, and you should be good to go. If you avoid using RE shortcuts, your expressions will be more widely understood.

Title: BASH_REMATCH empty

Body:
I'm trying capture the some input regex in Bash but BASH_REMATCH comes EMPTY

#!/usr/bin/env /bin/bash
INPUT=$(cat input.txt)
TASK_NAME="MailAccountFetch"

MATCH_PATTERN="(${TASK_NAME})\s+([0-9]{4}-[0-9]{2}-[0-9]{2}\s[0-9]{2}:[0-9]{2}:[0-9]{2})"

while read -r line; do
    if [[ $line =~ $MATCH_PATTERN ]]; then
        TASK_RESULT=${BASH_REMATCH[3]}
        TASK_LAST_RUN=${BASH_REMATCH[2]}
        TASK_EXECUTION_DURATION=${BASH_REMATCH[4]}
    fi
done <<< "$INPUT"

My input is:

    MailAccountFetch                         2017-03-29 19:00:00  Success      5.0 Second(s)      2017-03-29 19:03:00

By debugging the script (VS Code+Bash ext) I can see the INPUT string matches as the code goes inside the IF but BASH_REMATCH is not populated with my two capture groups.

I'm on:

GNU bash, version 4.4.0(1)-release (x86_64-pc-linux-gnu)

What could be the issue?

LATER EDIT

Accepted Answer

Accepting most explanatory answer.

What finally resolved the issue:

bashdb/VS Code environment are causing the empty BASH_REMATCH. The code works OK when ran alone.

Body:
Bash uses system libraries to parse regular expressions, and different parsers implement different features. You've come across a place where regex class shorthand strings do not work.  Note the following:

$ s="one12345   two"
$ [[ $s =~ ^([a-z]+[0-9]{4})\S*\s+(.*) ]] && echo yep; declare -p BASH_REMATCH
declare -ar BASH_REMATCH=()
$ [[ $s =~ ^([a-z]+[0-9]{4})[^[:space:]]*[[:space:]]+(.*) ]] && echo yep; declare -p BASH_REMATCH
yep
declare -ar BASH_REMATCH=([0]="one12345   two" [1]="one1234" [2]="two")

I'm doing this on macOS as well, but I get the same behaviour on FreeBSD.

Simply replace \s with [[:space:]], \d with [[:digit:]], etc, and you should be good to go. If you avoid using RE shortcuts, your expressions will be more widely understood.


问:
jQuery post POST became GET
Strange situation

i send date with jQuery post

```<code>$.post('/headline/', {date : 'some content'});
</code>```

But server header show that request is GET instead POST.

Local version works fine, but when upload to server then POST became GET

Other post requests works fine, just this one not working

P.s. backed is Laravel

答: Can you try to remove the trailing slash on server side? This is just on a whim though</p>

Title: jQuery post POST became GET

Body:
Strange situation

i send date with jQuery post

$.post('/headline/', {date : 'some content'});

But server header show that request is GET instead POST.

Local version works fine, but when upload to server then POST became GET

Other post requests works fine, just this one not working

P.s. backed is Laravel


问:
Is Javamail asynchronous or synchronous?
Is Javamail asynchronous or synchronous?  That is, if I send off an email, do I continue processing immediately afterwards, or do I wait until it's complete?

Furthermore, are there any ways that I could catch that an email failed to be delivered for any reason?

I'd also like to know these answers for Spring's MailSender abstraction.

Thanks.

答:
It is synchronous, since it transfers the message to the server and processes the server's response before returning.  The send docs explain in further detail.  The message will throw a SendFailedException, or another MessagingException,
 if the send fails immediately.  But "success does not imply that the message was delivered to the ultimate recipient, as failures may occur in later stages of delivery."


问:
rsync files from inside a docker container?
We are using Docker for the build/deploy of a NodeJS app. We have a test container that is built by Jenkins, and executes our unit tests. The Dockerfile looks like this:

```<code>FROM node:boron

# <snip> some misc unimportant config here

# Run the tests
ENTRYPOINT npm test
</code>```

I would like to modify this step so that we run npm run test:cov, which runs the unit tests + generates a coverage report HTML file. I've modified the Dockerfile to say:

```<code># Run the tests + generate coverage
ENTRYPOINT npm run test:cov
</code>```

... which works. Yay!

...But now I'm unsure how to rsync the coverage report ( generated by the above command inside the Dockerfile ) to a remote server.

In Jenkins, the above config is invoked this way:

```<code>docker run -t test --rm
</code>```

which, again, runs the above test and exists the container.

how can I add some additional steps after the entrypoint command executes, to (for example) rsync some results out to a remote server?

答:
Make a script to execute as the entrypoint and put the commands in the script.  You pass in args when calling docker run and they get passed to the script.

The docs have an example of the postgres image's script.  You can build off that.

Docker Entrypoint Docs

Body:
We are using Docker for the build/deploy of a NodeJS app. We have a test container that is built by Jenkins, and executes our unit tests. The Dockerfile looks like this:

FROM node:boron

# <snip> some misc unimportant config here

# Run the tests
ENTRYPOINT npm test

I would like to modify this step so that we run npm run test:cov, which runs the unit tests + generates a coverage report HTML file. I've modified the Dockerfile to say:

# Run the tests + generate coverage
ENTRYPOINT npm run test:cov

... which works. Yay!

...But now I'm unsure how to rsync the coverage report ( generated by the above command inside the Dockerfile ) to a remote server.

In Jenkins, the above config is invoked this way:

docker run -t test --rm

which, again, runs the above test and exists the container.

how can I add some additional steps after the entrypoint command executes, to (for example) rsync some results out to a remote server?


问:
Why does StringVar().get() return a blank value in python?
I cannot figure out why the 'save' button is pressed, the value that gets put into the 'ChildName' variable is blank?

```<code>def AddClassMember():
    global ChildNameEntryVariable
    global AddClassMemberWindow

    AddClassMemberWindow = Tk()

    ChildNameEntryVariable = StringVar()
    ChildNameEntry = Entry(AddClassMemberWindow, textvariable = ChildNameEntryVariable)
    ChildNameEntry.grid(row=2,column=1)
    ChildNameEntrySave = Button(AddClassMemberWindow, text = "save", command = SaveChildName)
    ChildNameEntrySave.grid(row=1,column=1)

def SaveChildName():
    PupilName = ChildNameEntryVariable.get()

    with db:
        cursor.execute(''' INSERT INTO 'Pupil Information' (PupilNames) VALUES (?)''', ([PupilName, ]))
</code>```

I've been trying to figure this out for hours. Thanks in advance.

答:
This is a popup, isn't it? You have another tk window open somewhere, right? If so, the quick fix is to provide StringVar with the correct master:

```<code>AddClassMemberWindow = Tk()

ChildNameEntryVariable = StringVar(AddClassMemberWindow)
</code>```

The proper fix is to remember never to use Tk() more than once in a program. If you need more windows, use the Toplevel widget to make them.

Body:
I cannot figure out why the 'save' button is pressed, the value that gets put into the 'ChildName' variable is blank?

def AddClassMember():
    global ChildNameEntryVariable
    global AddClassMemberWindow

    AddClassMemberWindow = Tk()

    ChildNameEntryVariable = StringVar()
    ChildNameEntry = Entry(AddClassMemberWindow, textvariable = ChildNameEntryVariable)
    ChildNameEntry.grid(row=2,column=1)
    ChildNameEntrySave = Button(AddClassMemberWindow, text = "save", command = SaveChildName)
    ChildNameEntrySave.grid(row=1,column=1)

def SaveChildName():
    PupilName = ChildNameEntryVariable.get()

    with db:
        cursor.execute(''' INSERT INTO 'Pupil Information' (PupilNames) VALUES (?)''', ([PupilName, ]))

I've been trying to figure this out for hours. Thanks in advance.

Body:
This is a popup, isn't it? You have another tk window open somewhere, right? If so, the quick fix is to provide StringVar with the correct master:

AddClassMemberWindow = Tk()

ChildNameEntryVariable = StringVar(AddClassMemberWindow)

The proper fix is to remember never to use Tk() more than once in a program. If you need more windows, use the Toplevel widget to make them.


问:
Using Unicode Icons in Icon Picker
I'm attempting to implement an icon picker in my app which will allow the user to chose a mathematical operator for data comparison.

I've been able to get the fontawesome-iconpicker working on the page but I'm having trouble with the icons themselves. I can use glyphicons without issue but the icons I want to use are in the Unicode set and I'm not sure how to refer to them in a way that the icon picker will understand.

In my code which defines the data-set for the icon picker, I'm able to get the glyphicons to load by referring to them by their class:

```<code>icons: ['glyphicon glyphicon-home', 'glyphicon glyphicon-repeat', 'glyphicon glyphicon-search',
        'glyphicon glyphicon-arrow-left', 'glyphicon glyphicon-arrow-right', 'glyphicon glyphicon-star', '<'],
</code>```

This works the same way that I would be adding them into my index.jade file, where I would put an icon on the page using .glyphicon.glyphicon-arrow-left

However, I can't get the unicode item to appear and if I click on the blank icon where the '<' should be, I get this error:

```<code>Uncaught Error: Syntax error, unrecognized expression: .<
at Function.Sizzle.error (jquery.js:1580)
at Sizzle.tokenize (jquery.js:2232)
at Function.Sizzle [as find] (jquery.js:854)
at jQuery.fn.init.find (jquery.js:2922)
at c._updateComponents (fontawesome-iconpicker.js:796)
at c.update (fontawesome-iconpicker.js:972)
at HTMLAnchorElement.c (fontawesome-iconpicker.js:522)
at HTMLAnchorElement.dispatch (jquery.js:5206)
at HTMLAnchorElement.elemData.handle (jquery.js:5014)
</code>```

I think the issue is that the icon picker needs to refer to icons by their class but I have no clue what the class would be for the Unicode icons (I'm trying to use a couple of these) and I haven't been able to find any information from searching. Do I need to create some custom CSS to assign classes to the Unicode icons? If so, how would I go about doing that?

Thanks!

答:
I ended up finding a solution. I created CSS classes for each symbol I needed and used the :before selector to specify content that would appear before the element. I then passed the escaped hexadecimal values of the Unicode characters in as strings to the content attribute within the style. The code ended up looking like this:

```<code>/* Unicode icons for mathematical operators */
.lessThan:before {
  content: "\3c";
}
.greaterThan:before {
  content: "\3e";
}
.lessThanEqual:before {
  content: "\2264";
}
.greaterThanEqual:before {
  content: "\2265";
}
.equalTo:before {
  content: "==";
}
.notEqualTo:before {
  content: "\2260";
}
</code>```

and was then able to pass these class names to the 'icons' array.

Title: Using Unicode Icons in Icon Picker

Body:
I'm attempting to implement an icon picker in my app which will allow the user to chose a mathematical operator for data comparison.

I've been able to get the fontawesome-iconpicker working on the page but I'm having trouble with the icons themselves. I can use glyphicons without issue but the icons I want to use are in the Unicode set and I'm not sure how to refer to them in a way that the icon picker will understand.

In my code which defines the data-set for the icon picker, I'm able to get the glyphicons to load by referring to them by their class:

icons: ['glyphicon glyphicon-home', 'glyphicon glyphicon-repeat', 'glyphicon glyphicon-search',
        'glyphicon glyphicon-arrow-left', 'glyphicon glyphicon-arrow-right', 'glyphicon glyphicon-star', '<'],

This works the same way that I would be adding them into my index.jade file, where I would put an icon on the page using .glyphicon.glyphicon-arrow-left

However, I can't get the unicode item to appear and if I click on the blank icon where the '<' should be, I get this error:

Uncaught Error: Syntax error, unrecognized expression: .<
at Function.Sizzle.error (jquery.js:1580)
at Sizzle.tokenize (jquery.js:2232)
at Function.Sizzle [as find] (jquery.js:854)
at jQuery.fn.init.find (jquery.js:2922)
at c._updateComponents (fontawesome-iconpicker.js:796)
at c.update (fontawesome-iconpicker.js:972)
at HTMLAnchorElement.c (fontawesome-iconpicker.js:522)
at HTMLAnchorElement.dispatch (jquery.js:5206)
at HTMLAnchorElement.elemData.handle (jquery.js:5014)

I think the issue is that the icon picker needs to refer to icons by their class but I have no clue what the class would be for the Unicode icons (I'm trying to use a couple of these) and I haven't been able to find any information from searching. Do I need to create some custom CSS to assign classes to the Unicode icons? If so, how would I go about doing that?

Thanks!

Body:
I ended up finding a solution. I created CSS classes for each symbol I needed and used the :before selector to specify content that would appear before the element. I then passed the escaped hexadecimal values of the Unicode characters in as strings to the content attribute within the style. The code ended up looking like this:

/* Unicode icons for mathematical operators */
.lessThan:before {
  content: "\3c";
}
.greaterThan:before {
  content: "\3e";
}
.lessThanEqual:before {
  content: "\2264";
}
.greaterThanEqual:before {
  content: "\2265";
}
.equalTo:before {
  content: "==";
}
.notEqualTo:before {
  content: "\2260";
}

and was then able to pass these class names to the 'icons' array.


问:
trigger react-native-router-flux from presentational components or passing react native router flux functions to components as props
I am using react native router flux for my navigation in an app, I have container folder and a components folder in which I created a button component.

This is my Register.js file in the container folder, I also have a Verify.js file which only renders a 'hello world'

```<code>import React, { Component } from 'react';
import { View, Text, TextInput,StyleSheet} from 'react-native';
import {Actions} from 'react-native-router-flux';

import Button from '../../components/button/Button';

import styles from '../../styles/styles';

export default class Register extends Component{

    constructor(){
        super();

        this.onPressButton = this.onPressButton.bind(this);
    }

    onPressButton(){
        return ()=>Actions.verify();
    }

    render() {
        return (
            <View style={styles.global}>

                <View style={styles.registerContainer}>
                    <Text style={styles.registerText}>Input your mobile number</Text>
                </View>

                <View style={styles.inputRow}>
                    <TextInput keyboardType={'numeric'} underlineColorAndroid={'transparent'} style={styles.zipCode}/>
                    <TextInput multiline={true} underlineColorAndroid={'transparent'} style={styles.number}/>
                </View>
                <Button text="REGISTER" onPressButton={this.onPressButton}/>
            </View>
        );
    }
}
</code>```

The Button component is below

```<code>import React,{Component,PropTypes} from 'react';
import {View,Text,TouchableHighlight,StyleSheet} from 'react-native';

export default class Button extends Component{
    static propTypes={
        text: PropTypes.string.isRequired,
        onPressButton: PropTypes.func.isRequired
    };

    render(){
        return(

            <TouchableHighlight onPress={this.props.onPressButton}>
                <View style={styles.btn}>
                    <Text style={styles.btn_text}>{this.props.text}</Text>
                </View>
            </TouchableHighlight>
        );
    }
}
</code>```

Also, below is my abridged app file for routing, just to show the scenes That I want to route from and to.

```<code><Scene key="root">

        <Scene key="register" title="Register" hideNavBar component={Register} />
        <Scene key="verify" title="Verify" hideNavBar component={Verify} />

/>
</code>```

How do I pass my navigation function as a prop to the Button component so that the onPressButton triggers the navigation?

答:
Wow! I really feel dumb for asking this question. I was unnecessarily over-thinking things. I did not even need to make an extra function. All i needed to do was pass an {Actions.verify} to the onPressButton prop and kept the proptype validation as a function in the presentational component. a second way was to return Actions.verify() in my onPressButton function instead of returning ()=>Actions.verify().

Below I removed the onPressButton function completely and just passed in {Actions.verify} where verify is the key passed to my component scene.

```<code>import React, { Component } from 'react';
import { View, Text, TextInput,StyleSheet} from 'react-native';
import {Actions} from 'react-native-router-flux';

import Button from '../../components/button/Button';

import styles from '../../styles/styles';

export default class Register extends Component{

    constructor(){
        super();
    }

    render() {
        return (
            <View style={styles.global}>

                <View style={styles.registerContainer}>
                    <Text style={styles.registerText}>Input your mobile number</Text>
                </View>

                <View style={styles.inputRow}>
                    <TextInput keyboardType={'numeric'} underlineColorAndroid={'transparent'} style={styles.zipCode}/>
                    <TextInput multiline={true} underlineColorAndroid={'transparent'} style={styles.number}/>
                </View>
                <Button text="REGISTER" onPressButton={Actions.verify}/>
            </View>
        );
    }
}
</code>```

In the presentational document, the proptype validation remains thesame.

```<code>import React,{Component,PropTypes} from 'react';
import {View,Text,TouchableHighlight,StyleSheet} from 'react-native';

export default class Button extends Component{
    static propTypes={
        text: PropTypes.string.isRequired,
        onPressButton: PropTypes.func.isRequired
    };

    render(){
        return(

            <TouchableHighlight onPress={this.props.onPressButton}>
                <View style={styles.btn}>
                    <Text style={styles.btn_text}>{this.props.text}</Text>
                </View>
            </TouchableHighlight>
        );
    }
}
</code>```

The second way

```<code>import React, { Component } from 'react';
import { View, Text, TextInput,StyleSheet} from 'react-native';
import {Actions} from 'react-native-router-flux';

import Button from '../../components/button/Button';

import styles from '../../styles/styles';

export default class Register extends Component{

    constructor(){
        super();

        this.onPressButton = this.onPressButton.bind(this);
    }

    onPressButton(){
        return Actions.verify();
    }

    render() {
        return (
            <View style={styles.global}>

                <View style={styles.registerContainer}>
                    <Text style={styles.registerText}>Input your mobile number</Text>
                </View>

                <View style={styles.inputRow}>
                    <TextInput keyboardType={'numeric'} underlineColorAndroid={'transparent'} style={styles.zipCode}/>
                    <TextInput multiline={true} underlineColorAndroid={'transparent'} style={styles.number}/>
                </View>
                <Button text="REGISTER" onPressButton={this.onPressButton}/>
            </View>
        );
    }
}
</code>```

Body:
I am using react native router flux for my navigation in an app, I have container folder and a components folder in which I created a button component.

This is my Register.js file in the container folder, I also have a Verify.js file which only renders a 'hello world'

import React, { Component } from 'react';
import { View, Text, TextInput,StyleSheet} from 'react-native';
import {Actions} from 'react-native-router-flux';

import Button from '../../components/button/Button';

import styles from '../../styles/styles';

export default class Register extends Component{

    constructor(){
        super();

        this.onPressButton = this.onPressButton.bind(this);
    }

    onPressButton(){
        return ()=>Actions.verify();
    }

    render() {
        return (
            <View style={styles.global}>

                <View style={styles.registerContainer}>
                    <Text style={styles.registerText}>Input your mobile number</Text>
                </View>

                <View style={styles.inputRow}>
                    <TextInput keyboardType={'numeric'} underlineColorAndroid={'transparent'} style={styles.zipCode}/>
                    <TextInput multiline={true} underlineColorAndroid={'transparent'} style={styles.number}/>
                </View>
                <Button text="REGISTER" onPressButton={this.onPressButton}/>
            </View>
        );
    }
}

The Button component is below

import React,{Component,PropTypes} from 'react';
import {View,Text,TouchableHighlight,StyleSheet} from 'react-native';

export default class Button extends Component{
    static propTypes={
        text: PropTypes.string.isRequired,
        onPressButton: PropTypes.func.isRequired
    };

    render(){
        return(

            <TouchableHighlight onPress={this.props.onPressButton}>
                <View style={styles.btn}>
                    <Text style={styles.btn_text}>{this.props.text}</Text>
                </View>
            </TouchableHighlight>
        );
    }
}

Also, below is my abridged app file for routing, just to show the scenes That I want to route from and to.

<Scene key="root">

        <Scene key="register" title="Register" hideNavBar component={Register} />
        <Scene key="verify" title="Verify" hideNavBar component={Verify} />

/>

How do I pass my navigation function as a prop to the Button component so that the onPressButton triggers the navigation?

Body:
Wow! I really feel dumb for asking this question. I was unnecessarily over-thinking things. I did not even need to make an extra function. All i needed to do was pass an {Actions.verify} to the onPressButton prop and kept the proptype validation as a function in the presentational component. a second way was to return Actions.verify() in my onPressButton function instead of returning ()=>Actions.verify().

Below I removed the onPressButton function completely and just passed in {Actions.verify} where verify is the key passed to my component scene.

import React, { Component } from 'react';
import { View, Text, TextInput,StyleSheet} from 'react-native';
import {Actions} from 'react-native-router-flux';

import Button from '../../components/button/Button';

import styles from '../../styles/styles';

export default class Register extends Component{

    constructor(){
        super();
    }

    render() {
        return (
            <View style={styles.global}>

                <View style={styles.registerContainer}>
                    <Text style={styles.registerText}>Input your mobile number</Text>
                </View>

                <View style={styles.inputRow}>
                    <TextInput keyboardType={'numeric'} underlineColorAndroid={'transparent'} style={styles.zipCode}/>
                    <TextInput multiline={true} underlineColorAndroid={'transparent'} style={styles.number}/>
                </View>
                <Button text="REGISTER" onPressButton={Actions.verify}/>
            </View>
        );
    }
}

In the presentational document, the proptype validation remains thesame.

import React,{Component,PropTypes} from 'react';
import {View,Text,TouchableHighlight,StyleSheet} from 'react-native';

export default class Button extends Component{
    static propTypes={
        text: PropTypes.string.isRequired,
        onPressButton: PropTypes.func.isRequired
    };

    render(){
        return(

            <TouchableHighlight onPress={this.props.onPressButton}>
                <View style={styles.btn}>
                    <Text style={styles.btn_text}>{this.props.text}</Text>
                </View>
            </TouchableHighlight>
        );
    }
}

The second way

import React, { Component } from 'react';
import { View, Text, TextInput,StyleSheet} from 'react-native';
import {Actions} from 'react-native-router-flux';

import Button from '../../components/button/Button';

import styles from '../../styles/styles';

export default class Register extends Component{

    constructor(){
        super();

        this.onPressButton = this.onPressButton.bind(this);
    }

    onPressButton(){
        return Actions.verify();
    }

    render() {
        return (
            <View style={styles.global}>

                <View style={styles.registerContainer}>
                    <Text style={styles.registerText}>Input your mobile number</Text>
                </View>

                <View style={styles.inputRow}>
                    <TextInput keyboardType={'numeric'} underlineColorAndroid={'transparent'} style={styles.zipCode}/>
                    <TextInput multiline={true} underlineColorAndroid={'transparent'} style={styles.number}/>
                </View>
                <Button text="REGISTER" onPressButton={this.onPressButton}/>
            </View>
        );
    }
}