问:
Roblox Studio Lua : Clone with local script
I created a template or when someone touches that template, it's destroyed, but it's only for that person. I try to clone the model with a local script, but it does not work.</p>

```<code>local part2 = script.Parent.MarioBrick:Clone()
part2.Parent = game.Workspace.Camera
</code>```

答:
I believe cloning the script's parent will also clone the script itself, and run the script again. Are you doing this intentionally? If not then it can cause strange side effects to happen.

Edit: Sorry, I misread your code.

Body:
I created a template or when someone touches that template, it's destroyed, but it's only for that person. I try to clone the model with a local script, but it does not work.

local part2 = script.Parent.MarioBrick:Clone()
part2.Parent = game.Workspace.Camera


来源: stackexchange

问:
Select one row inside a group according to a criteria in PostgreSQL
I have a table as such (tbl):

```<code>+----+-----+------+-----+
| pk | grp | attr | val |
+----+-----+------+-----+
|  0 |   0 | ohif |   4 |
|  1 |   0 | foha |  56 |
|  2 |   0 | slns |   2 |
|  3 |   1 | faso |  11 |
|  4 |   1 | tepj |   4 |
|  5 |   2 | bnda |  12 |
|  6 |   2 | ojdf |   9 |
|  7 |   2 | anaw |   1 |
+----+-----+------+-----+
</code>```

I would like to select one row from each group, in particular that with the maximum val for each group.

I can easily select grp and val:

```<code>SELECT grp, MAX(val)
FROM tbl
GROUP BY grp
</code>```

Yielding this table (tbl2):

```<code>+-----+-----+
| grp | val |
+-----+-----+
|   0 |  56 |
|   1 |  11 |
|   2 |  12 |
+-----+-----+
</code>```

However, I want this table:

```<code>+----+-----+------+-----+
| pk | grp | attr | val |
+----+-----+------+-----+
|  1 |   0 | foha |  56 |
|  3 |   1 | faso |  11 |
|  5 |   2 | bnda |  12 |
+----+-----+------+-----+
</code>```

Since (grp, val) constitutes a key, I could left-join tbl2 with tbl on same grp and val.

However, I was wondering if there was any other solution: in my real-world situation tbl is a pretty complex and heavy derived table, and I have the design constrain of not being able to use temp tables. Is there any way to order the rows inside each group according to val and to then take the first record for each group?

I'm on PostgreSQL 10, but a standard SQL solution would be the best.

答:
In Postgres, the best approach is distinct on:

```<code>SELECT DISTINCT ON (t.grp) t.*
FROM tbl
ORDER BY grp, val DESC;
</code>```

In particular, this can take advantage of an index on (grp, val desc).

ContentLicense: CC BY-SA 4.0

Body:
I have a table as such (tbl):

+----+-----+------+-----+
| pk | grp | attr | val |
+----+-----+------+-----+
|  0 |   0 | ohif |   4 |
|  1 |   0 | foha |  56 |
|  2 |   0 | slns |   2 |
|  3 |   1 | faso |  11 |
|  4 |   1 | tepj |   4 |
|  5 |   2 | bnda |  12 |
|  6 |   2 | ojdf |   9 |
|  7 |   2 | anaw |   1 |
+----+-----+------+-----+

I would like to select one row from each group, in particular that with the maximum val for each group.

I can easily select grp and val:

SELECT grp, MAX(val)
FROM tbl
GROUP BY grp

Yielding this table (tbl2):

+-----+-----+
| grp | val |
+-----+-----+
|   0 |  56 |
|   1 |  11 |
|   2 |  12 |
+-----+-----+

However, I want this table:

+----+-----+------+-----+
| pk | grp | attr | val |
+----+-----+------+-----+
|  1 |   0 | foha |  56 |
|  3 |   1 | faso |  11 |
|  5 |   2 | bnda |  12 |
+----+-----+------+-----+

Since (grp, val) constitutes a key, I could left-join tbl2 with tbl on same grp and val.

However, I was wondering if there was any other solution: in my real-world situation tbl is a pretty complex and heavy derived table, and I have the design constrain of not being able to use temp tables. Is there any way to order the rows inside each group according to val and to then take the first record for each group?

I'm on PostgreSQL 10, but a standard SQL solution would be the best.

Body:
In Postgres, the best approach is distinct on:

SELECT DISTINCT ON (t.grp) t.*
FROM tbl
ORDER BY grp, val DESC;

In particular, this can take advantage of an index on (grp, val desc).


问:
How to avoid Collection Error Python Numpy
I am trying to train a Linear Regression Qualifier to continue a grap.
I have a couple of thousand lines of data in my csv file that I import into numpy arrays. Here is my code :

```<code>import pandas as pd
import numpy as np
from matplotlib import pyplot as plt
import csv
import math
from sklearn import preprocessing, svm
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LinearRegression

def predict():
    sample_data = pd.read_csv("includes\\csv.csv")
    x = np.array(sample_data["day"])
    y = np.array(sample_data["balance"])

    for x in x:
        x = x.reshape(1, -1)
        #lol

    for y in y:
        y.reshape(1, -1)
        #lol

    X_train, X_test, y_train, y_test = train_test_split(x, y, test_size=0.2)

    clf = LinearRegression()
    clf.fit(x_train, y_train)
    clf.score(x_test, y_test)
</code>```

When I run this, the error is:

```<code>TypeError: Singleton array 6014651 cannot be considered a valid collection.
</code>```

Any ideas why that's a thing?

答: X_train, X_test should be capitals, python variables are case sensitive</p>

Body:
I am trying to train a Linear Regression Qualifier to continue a grap.
I have a couple of thousand lines of data in my csv file that I import into numpy arrays. Here is my code :

import pandas as pd
import numpy as np
from matplotlib import pyplot as plt
import csv
import math
from sklearn import preprocessing, svm
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LinearRegression

def predict():
    sample_data = pd.read_csv("includes\\csv.csv")
    x = np.array(sample_data["day"])
    y = np.array(sample_data["balance"])

    for x in x:
        x = x.reshape(1, -1)
        #lol

    for y in y:
        y.reshape(1, -1)
        #lol

    X_train, X_test, y_train, y_test = train_test_split(x, y, test_size=0.2)

    clf = LinearRegression()
    clf.fit(x_train, y_train)
    clf.score(x_test, y_test)

When I run this, the error is:

TypeError: Singleton array 6014651 cannot be considered a valid collection.

Any ideas why that's a thing?


问:
how can i add a rest angular custom login page to spring app using DaoAuthenticationProvider
i am making an full-stack web application using angular , spring boot and database in witch i there is a login form for admin and users i defined the roles for both. based on a tutorial that i found i created the spring boot login configuration and it works now i need to link it to my angular app but i am stack i don't know how can i set the angular form instead of the one provided with angular because they are not in the same application and i have been using REST Controllers between them  .so is it possible for me to do so if yes how can i.
 here is the code for the login configuration

```<code>@Configuration
@EnableWebSecurity
public class SecurityConfiguration extends WebSecurityConfigurerAdapter {

private UserprincipalDetailSerice userprincipalDetailSerice;
 public SecurityConfiguration(UserprincipalDetailSerice userprincipalDetailSerice){
     this.userprincipalDetailSerice=userprincipalDetailSerice;
 }

    @Override
    protected void configure(AuthenticationManagerBuilder auth) throws Exception {
        auth.authenticationProvider(authenticationProvider());

    }

@Bean
    DaoAuthenticationProvider authenticationProvider(){
        DaoAuthenticationProvider daoAuthenticationProvider =new DaoAuthenticationProvider();
         daoAuthenticationProvider.setPasswordEncoder(passwordEncoder());
         daoAuthenticationProvider.setUserDetailsService(this.userprincipalDetailSerice);
return daoAuthenticationProvider;
 }
    @Override
    protected void configure(HttpSecurity http) throws Exception {
        http
                .cors()
                .and()
                .authorizeRequests().antMatchers("/allproduits/**").permitAll()
                .antMatchers("/getallusers/personnels").hasAnyRole("ADMIN","ANY")
                .antMatchers("/getallusers/personnelsbyid/{id}").hasAnyRole("ADMIN","ANY")
                .antMatchers("/getallusers/updatepersonnel").hasAnyRole("ADMIN","ANY")
                .antMatchers("/getallusers/deletepersonnel/{id}").hasAnyRole("ADMIN")
                .antMatchers("/getallusers/encode").permitAll()
                .antMatchers("/getallusers/addcpersonnel").hasRole("ADMIN")
                .antMatchers("/getallcadres/**").hasAnyRole("ADMIN","ANY")
                .and()
                .httpBasic()
                .and()

                .csrf().disable();
      //  http.csrf().csrfTokenRepository(this.csrfRepo());

    }

    @Override
    public void configure(WebSecurity web ) throws Exception
    {
        web.ignoring().antMatchers( HttpMethod.OPTIONS, "/**" );
    }

    @Bean
    CorsConfigurationSource corsConfigurationSource() {
        CorsConfiguration configuration = new CorsConfiguration();
        configuration.setAllowedOrigins(Arrays.asList("*"));
        configuration.setAllowedMethods(Arrays.asList("GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS"));
        configuration.setAllowedHeaders(Arrays.asList("authorization", "content-type", "x-auth-token"));
        configuration.setExposedHeaders(Arrays.asList("x-auth-token"));
        UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
        source.registerCorsConfiguration("/**", configuration);
        return source;
    }

    @Bean
   public PasswordEncoder passwordEncoder() {
        return new BCryptPasswordEncoder();
    }
}
</code>```

UserDetailsService class:

```<code>@Service
public class UserprincipalDetailSerice implements UserDetailsService {

   private personnelReposotry personnelReposotry;
   public UserprincipalDetailSerice(personnelReposotry pR){
this.personnelReposotry=pR;
   }
    @Override
    public UserDetails loadUserByUsername(String s) throws UsernameNotFoundException {
        personnel personnel=this.personnelReposotry.findByMatricule(s);
        UserPrincipal userPrincipal=new UserPrincipal(personnel);
        System.out.println(personnel.getMatricule()+personnel.getPsw()+"role:"+personnel.getRole());
        return userPrincipal;
    }
}
</code>```

UserDetails class :

```<code>public class UserPrincipal implements UserDetails {
    private personnel personnel;
    public UserPrincipal(personnel personnel){
        this.personnel=personnel;
    }
    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        List<GrantedAuthority> authorities= new ArrayList<>();
        this.personnel.getRoleList().forEach(p->{
            GrantedAuthority authority = new SimpleGrantedAuthority("ROLE_" +p)  ;
            authorities.add(authority);

        });

        return authorities;
    }

    @Override
    public String getPassword() {
        return this.personnel.getPsw();
    }

    @Override
    public String getUsername() {
        return this.personnel.getMatricule();
    }

    @Override
    public boolean isAccountNonExpired() {
        return true;
    }

    @Override
    public boolean isAccountNonLocked() {
        return true;
    }

    @Override
    public boolean isCredentialsNonExpired() {
        return true;
    }

    @Override
    public boolean isEnabled() {
        return true;
    }
}
</code>```

答: Your current code may work for a standalone application, but not for this situation. You can instead use that code to return a secret JWT(JSON Web Token) when an authentication is successful, that the user can later send with each request, there are plenty of tutorials on the internet.</p>

Body:
i am making an full-stack web application using angular , spring boot and database in witch i there is a login form for admin and users i defined the roles for both. based on a tutorial that i found i created the spring boot login configuration and it works now i need to link it to my angular app but i am stack i don't know how can i set the angular form instead of the one provided with angular because they are not in the same application and i have been using REST Controllers between them  .so is it possible for me to do so if yes how can i.
 here is the code for the login configuration

@Configuration
@EnableWebSecurity
public class SecurityConfiguration extends WebSecurityConfigurerAdapter {

private UserprincipalDetailSerice userprincipalDetailSerice;
 public SecurityConfiguration(UserprincipalDetailSerice userprincipalDetailSerice){
     this.userprincipalDetailSerice=userprincipalDetailSerice;
 }

    @Override
    protected void configure(AuthenticationManagerBuilder auth) throws Exception {
        auth.authenticationProvider(authenticationProvider());

    }

@Bean
    DaoAuthenticationProvider authenticationProvider(){
        DaoAuthenticationProvider daoAuthenticationProvider =new DaoAuthenticationProvider();
         daoAuthenticationProvider.setPasswordEncoder(passwordEncoder());
         daoAuthenticationProvider.setUserDetailsService(this.userprincipalDetailSerice);
return daoAuthenticationProvider;
 }
    @Override
    protected void configure(HttpSecurity http) throws Exception {
        http
                .cors()
                .and()
                .authorizeRequests().antMatchers("/allproduits/**").permitAll()
                .antMatchers("/getallusers/personnels").hasAnyRole("ADMIN","ANY")
                .antMatchers("/getallusers/personnelsbyid/{id}").hasAnyRole("ADMIN","ANY")
                .antMatchers("/getallusers/updatepersonnel").hasAnyRole("ADMIN","ANY")
                .antMatchers("/getallusers/deletepersonnel/{id}").hasAnyRole("ADMIN")
                .antMatchers("/getallusers/encode").permitAll()
                .antMatchers("/getallusers/addcpersonnel").hasRole("ADMIN")
                .antMatchers("/getallcadres/**").hasAnyRole("ADMIN","ANY")
                .and()
                .httpBasic()
                .and()

                .csrf().disable();
      //  http.csrf().csrfTokenRepository(this.csrfRepo());

    }

    @Override
    public void configure(WebSecurity web ) throws Exception
    {
        web.ignoring().antMatchers( HttpMethod.OPTIONS, "/**" );
    }

    @Bean
    CorsConfigurationSource corsConfigurationSource() {
        CorsConfiguration configuration = new CorsConfiguration();
        configuration.setAllowedOrigins(Arrays.asList("*"));
        configuration.setAllowedMethods(Arrays.asList("GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS"));
        configuration.setAllowedHeaders(Arrays.asList("authorization", "content-type", "x-auth-token"));
        configuration.setExposedHeaders(Arrays.asList("x-auth-token"));
        UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
        source.registerCorsConfiguration("/**", configuration);
        return source;
    }

    @Bean
   public PasswordEncoder passwordEncoder() {
        return new BCryptPasswordEncoder();
    }
}

UserDetailsService class:

@Service
public class UserprincipalDetailSerice implements UserDetailsService {

   private personnelReposotry personnelReposotry;
   public UserprincipalDetailSerice(personnelReposotry pR){
this.personnelReposotry=pR;
   }
    @Override
    public UserDetails loadUserByUsername(String s) throws UsernameNotFoundException {
        personnel personnel=this.personnelReposotry.findByMatricule(s);
        UserPrincipal userPrincipal=new UserPrincipal(personnel);
        System.out.println(personnel.getMatricule()+personnel.getPsw()+"role:"+personnel.getRole());
        return userPrincipal;
    }
}

UserDetails class :

public class UserPrincipal implements UserDetails {
    private personnel personnel;
    public UserPrincipal(personnel personnel){
        this.personnel=personnel;
    }
    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        List<GrantedAuthority> authorities= new ArrayList<>();
        this.personnel.getRoleList().forEach(p->{
            GrantedAuthority authority = new SimpleGrantedAuthority("ROLE_" +p)  ;
            authorities.add(authority);

        });

        return authorities;
    }

    @Override
    public String getPassword() {
        return this.personnel.getPsw();
    }

    @Override
    public String getUsername() {
        return this.personnel.getMatricule();
    }

    @Override
    public boolean isAccountNonExpired() {
        return true;
    }

    @Override
    public boolean isAccountNonLocked() {
        return true;
    }

    @Override
    public boolean isCredentialsNonExpired() {
        return true;
    }

    @Override
    public boolean isEnabled() {
        return true;
    }
}


问:
64-bit VM on 32 bit Windows XP
When I try to run a 64-bit VM on 32 bit Windows XP, I get the following message:

You have configured this virtual
  machine to use a 64-bit guest
  operating system.  However, 64-bit
  operation is not possible. This host
  does not support VT.

I have activated VP, VMM compatibility on my host but I still have the error.

Any idea on what might be going wrong?

答:
You can not run a 64-bit program in a 32-bit operating system, whether your cpu is 64-bit or not.

VT is only supported by 64-bit processors, so a PC without a 64-bit processor can not run a 64-bit virtual machine in 32-bit XP.

That is really what the error says.

ContentLicense: CC BY-SA 3.0

Title: 64-bit VM on 32 bit Windows XP


问:
ActiveMQ has correct dialect but the SQL statements are incorrect AUTO_INCREMENT instead of IDENTITY tables creation
I'm using the following:

JBoss Wildfly 15.0.1.Final

MSSQL JDBC connector (i.e. mssql-jdbc-7.2.2.jre11.jar)

standalone-full.xml

I believe I have setup everything correctly.  The MSSQL JDBC jar is in the modules directory with its associated module.xml.  The datasource is correctly defined and functional. ActiveMQ Artemis has been setup (works fine using the file system). However when I attempt to have it use JDBC it fails trying to create the necessary tables with the following error:

```<code>SQLState: S0001 ErrorCode: 102 Message: Incorrect syntax near AUTO_INCREMENT'.
</code>```

So I'm wondering what is wrong.  ActiveMQ says it supports SQL Server, and it automatically figures out which SQL dialect to use based on the return value of the driver (I've checked that name with an 6.0 version of the driver and it is the same), also in the debug output it says

```<code>[org.apache.activemq.artemis.jdbc.store.journal.JDBCJournalImpl] ServerService Thread Pool -- 80) Detect database dialect as 'MSSQL'".
</code>```

So that looks good.  So I'm a bit confused on what is wrong and would like to get it to work.  I'm providing the critical elements that I have in the standalone-full.xml.  Is there any other setup I need or is this a bug?

Is this also a symptom of a problem?  (i.e. see the log output...the broker is not initialized with correct driver/url that was specified by the datasource definition)

```<code>AMQ221000: live Message Broker is starting with configuration Broker Configuration (clustered=false,jdbcDriverClassName=org.apache.derby.jdbc.EmbeddedDriver,jdbcConnectionUrl=null,messageTableName=AMQ_MESSAGES,bindingsTableName=AMQ_BINDINGS,largeMessageTableName=AMQ_LARGE_MESSAGES,pageStoreTableName=AMQ_PSTORE,)
</code>```

excerpts from the standalone-full.xml settings

```<code><extensions>
   <extension module="org.wildfly.extension.messaging-activemq"/>
</extensions>

<datasources>

<datasource jndi-name="java:/RMBM-DEFAULT-DS" pool-name="RMBM-DEFAULT-DS" enabled="true">
 <connection-url>jdbc:sqlserver://${rmbm.default.ds.host}:${rmbm.default.ds.port:1433};DatabaseName=${rmbm.default.ds.dbname}
 </connection-url>
<driver>SQLSVR</driver>
</datasource>

<drivers>
   <driver name="SQLSVR" module="com.microsoft.sqlserver.jdbc">
      <driver-class>com.microsoft.sqlserver.jdbc.SQLServerDriver</driver- class>
   </driver>
</drivers>

<subsystem xmlns="urn:jboss:domain:messaging-activemq:5.0">
  <server name="default">
    <journal datasource="RMBM-DEFAULT-DS" messages-table="AMQ_MESSAGES" bindings-table="AMQ_BINDINGS"
      jms-bindings-table="AMQ_JMS_BINDINGS" large-messages-table="AMQ_LARGE_MESSAGES" page-store-table="AMQ_PGSTORE"/>
</server>
</subsystem>
</code>```

Here is a portion of the log output:

```<code>18:36:27,116 INFO  [org.wildfly.extension.messaging-activemq] (MSC service thread 1-8) WFLYMSGAMQ0001: AIO wasn't located on this platform, it will fall back to using pure Java NIO.
18:36:27,665 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-1) WFLYUT0006: Undertow HTTPS listener https listening on 127.0.0.1:443
18:36:27,808 INFO  [org.jboss.ws.common.management] (MSC service thread 1-7) JBWS022052: Starting JBossWS 5.2.4.Final (Apache CXF 3.2.5.jbossorg-1)
18:36:27,964 DEBUG [org.apache.activemq.artemis.jdbc.store.journal.JDBCJournalImpl] (MSC service thread 1-8) Detect database dialect as 'MSSQL'.
18:36:27,968 INFO  [org.wildfly.extension.messaging-activemq] (MSC service thread 1-8) use JDBC store for Artemis server, bindingsTable:AMQ_BINDINGS
18:36:28,065 DEBUG [org.apache.activemq.artemis.core.server.impl.ActiveMQServerImpl] (ServerService Thread Pool -- 80) Starting server ActiveMQServerImpl::
18:36:28,069 DEBUG [org.apache.activemq.artemis.core.server.impl.ActiveMQServerImpl] (ServerService Thread Pool -- 80) Detected no Shared Store HA options on JDBC store
18:36:28,121 INFO  [org.apache.activemq.artemis.core.server] (ServerService Thread Pool -- 80) AMQ221000: live Message Broker is starting with configuration Broker Configuration (clustered=false,jdbcDriverClassName=org.apache.derby.jdbc.EmbeddedDriver,jdbcConnectionUrl=null,messageTableName=AMQ_MESSAGES,bindingsTableName=AMQ_BINDINGS,largeMessageTableName=AMQ_LARGE_MESSAGES,pageStoreTableName=AMQ_PSTORE,)
18:36:28,306 DEBUG [org.apache.activemq.artemis.jdbc.store.journal.JDBCJournalImpl] (ServerService Thread Pool -- 80) Detect database dialect as 'MSSQL'.
18:36:28,398 ERROR [org.apache.activemq.artemis.jdbc.store.drivers.AbstractJDBCDriver] (ServerService Thread Pool -- 80)
SQL STATEMENTS:
CREATE TABLE AMQ_LARGE_MESSAGES (ID BIGINT AUTO_INCREMENT, FILENAME VARCHAR(255), EXTENSION VARCHAR(10), DATA BLOB, PRIMARY KEY(ID))
SQL EXCEPTIONS:
SQLState: S0001 ErrorCode: 102 Message: Incorrect syntax near 'AUTO_INCREMENT'.
18:36:28,425 WARN  [org.apache.activemq.artemis.core.server] (ServerService Thread Pool -- 80) AMQ222010: Critical IO Error, shutting down the server. file=NULL, message=Unable to start database driver: com.microsoft.sqlserver.jdbc.SQLServerException: Incorrect syntax near 'AUTO_INCREMENT'.
    at com.microsoft.sqlserver.jdbc//com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(SQLServerException.java:262)
    at com.microsoft.sqlserver.jdbc//com.microsoft.sqlserver.jdbc.SQLServerStatement.getNextResult(SQLServerStatement.java:1621)
    at com.microsoft.sqlserver.jdbc//com.microsoft.sqlserver.jdbc.SQLServerStatement.doExecuteStatement(SQLServerStatement.java:868)
    at com.microsoft.sqlserver.jdbc//com.microsoft.sqlserver.jdbc.SQLServerStatement$StmtExecCmd.doExecute(SQLServerStatement.java:768)
    at com.microsoft.sqlserver.jdbc//com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:7194)
    at com.microsoft.sqlserver.jdbc//com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:2935)
    at com.microsoft.sqlserver.jdbc//com.microsoft.sqlserver.jdbc.SQLServerStatement.executeCommand(SQLServerStatement.java:248)
    at com.microsoft.sqlserver.jdbc//com.microsoft.sqlserver.jdbc.SQLServerStatement.executeStatement(SQLServerStatement.java:223)
    at com.microsoft.sqlserver.jdbc//com.microsoft.sqlserver.jdbc.SQLServerStatement.executeUpdate(SQLServerStatement.java:711)
    at org.jboss.ironjacamar.jdbcadapters@1.4.11.Final//org.jboss.jca.adapters.jdbc.WrappedStatement.executeUpdate(WrappedStatement.java:430)
    at org.apache.activemq.artemis@2.6.3.jbossorg-00014//org.apache.activemq.artemis.jdbc.store.drivers.AbstractJDBCDriver.createTableIfNotExists(AbstractJDBCDriver.java:258)
    at org.apache.activemq.artemis@2.6.3.jbossorg-00014//org.apache.activemq.artemis.jdbc.store.drivers.AbstractJDBCDriver.createTable(AbstractJDBCDriver.java:118)
    at org.apache.activemq.artemis@2.6.3.jbossorg-00014//org.apache.activemq.artemis.jdbc.store.file.JDBCSequentialFileFactoryDriver.createSchema(JDBCSequentialFileFactoryDriver.java:69)
    at org.apache.activemq.artemis@2.6.3.jbossorg-00014//org.apache.activemq.artemis.jdbc.store.drivers.AbstractJDBCDriver.start(AbstractJDBCDriver.java:83)
    at org.apache.activemq.artemis@2.6.3.jbossorg-00014//org.apache.activemq.artemis.jdbc.store.file.JDBCSequentialFileFactory.start(JDBCSequentialFileFactory.java:131)
    at org.apache.activemq.artemis@2.6.3.jbossorg-00014//org.apache.activemq.artemis.core.persistence.impl.journal.JDBCJournalStorageManager.init(JDBCJournalStorageManager.java:92)
    at org.apache.activemq.artemis@2.6.3.jbossorg-00014//org.apache.activemq.artemis.core.persistence.impl.journal.AbstractJournalStorageManager.<init>(AbstractJournalStorageManager.java:229)
    at org.apache.activemq.artemis@2.6.3.jbossorg-00014//org.apache.activemq.artemis.core.persistence.impl.journal.JournalStorageManager.<init>(JournalStorageManager.java:106)
    at org.apache.activemq.artemis@2.6.3.jbossorg-00014//org.apache.activemq.artemis.core.persistence.impl.journal.JDBCJournalStorageManager.<init>(JDBCJournalStorageManager.java:55)
    at org.apache.activemq.artemis@2.6.3.jbossorg-00014//org.apache.activemq.artemis.core.server.impl.ActiveMQServerImpl.createStorageManager(ActiveMQServerImpl.java:2155)
    at org.apache.activemq.artemis@2.6.3.jbossorg-00014//org.apache.activemq.artemis.core.server.impl.ActiveMQServerImpl.initialisePart1(ActiveMQServerImpl.java:2296)
    at org.apache.activemq.artemis@2.6.3.jbossorg-00014//org.apache.activemq.artemis.core.server.impl.LiveOnlyActivation.run(LiveOnlyActivation.java:64)
    at org.apache.activemq.artemis@2.6.3.jbossorg-00014//org.apache.activemq.artemis.core.server.impl.ActiveMQServerImpl.internalStart(ActiveMQServerImpl.java:535)
    at org.apache.activemq.artemis@2.6.3.jbossorg-00014//org.apache.activemq.artemis.core.server.impl.ActiveMQServerImpl.start(ActiveMQServerImpl.java:474)
    at org.apache.activemq.artemis@2.6.3.jbossorg-00014//org.apache.activemq.artemis.jms.server.impl.JMSServerManagerImpl.start(JMSServerManagerImpl.java:376)
    at org.wildfly.extension.messaging-activemq//org.wildfly.extension.messaging.activemq.jms.JMSService.doStart(JMSService.java:206)
    at org.wildfly.extension.messaging-activemq//org.wildfly.extension.messaging.activemq.jms.JMSService.access$000(JMSService.java:65)
    at org.wildfly.extension.messaging-activemq//org.wildfly.extension.messaging.activemq.jms.JMSService$1.run(JMSService.java:100)
</code>```

答:
It appears that even though the dialect is correctly detected as MSSQL the broker doesn't have the corresponding SQL statements to properly support it. The SQL statements for MSSQL were added in ActiveMQ Artemis 2.6.4 via ARTEMIS-2202. You're using 2.6.3 so you don't have those.

Upgrading ActiveMQ Artemis in Wildfly can sometimes fail due to the tight coupling between the two so if you don't want to try upgrading you could theoretically crack open the artemis-jdbc-store jar file and add/replace these lines to journal-sql.properties

```<code># MSSQL SQL statements
create-file-table.mssql=CREATE TABLE %s (ID BIGINT NOT NULL IDENTITY, FILENAME VARCHAR(255), EXTENSION VARCHAR(10), DATA VARBINARY(max), PRIMARY KEY(ID))
create-journal-table.mssql=CREATE TABLE %s(id BIGINT,recordType SMALLINT,compactCount SMALLINT,txId BIGINT,userRecordType SMALLINT,variableSize INTEGER,record VARBINARY(max),txDataSize INTEGER,txData VARBINARY(max),txCheckNoRecords INTEGER,seq BIGINT NOT NULL, PRIMARY KEY(seq))
max-blob-size.mssql=2147483647
</code>```

Regarding the AMQ221000 log message that indicates there is an incorrect JDBC driver configuration...This is due to the fact that the ActiveMQ Artemis broker has its own JDBC driver configuration for when it's running standalone. When it's embedded in Wildfly and configured to use a datasource via JNDI then the standalone JDBC driver configuration isn't used. It will simply look up the specified datasource and use that.

Body:
I'm using the following:

JBoss Wildfly 15.0.1.Final

MSSQL JDBC connector (i.e. mssql-jdbc-7.2.2.jre11.jar)

standalone-full.xml

I believe I have setup everything correctly.  The MSSQL JDBC jar is in the modules directory with its associated module.xml.  The datasource is correctly defined and functional. ActiveMQ Artemis has been setup (works fine using the file system). However when I attempt to have it use JDBC it fails trying to create the necessary tables with the following error:

SQLState: S0001 ErrorCode: 102 Message: Incorrect syntax near AUTO_INCREMENT'.

So I'm wondering what is wrong.  ActiveMQ says it supports SQL Server, and it automatically figures out which SQL dialect to use based on the return value of the driver (I've checked that name with an 6.0 version of the driver and it is the same), also in the debug output it says

[org.apache.activemq.artemis.jdbc.store.journal.JDBCJournalImpl] ServerService Thread Pool -- 80) Detect database dialect as 'MSSQL'".

So that looks good.  So I'm a bit confused on what is wrong and would like to get it to work.  I'm providing the critical elements that I have in the standalone-full.xml.  Is there any other setup I need or is this a bug?

Is this also a symptom of a problem?  (i.e. see the log output...the broker is not initialized with correct driver/url that was specified by the datasource definition)

AMQ221000: live Message Broker is starting with configuration Broker Configuration (clustered=false,jdbcDriverClassName=org.apache.derby.jdbc.EmbeddedDriver,jdbcConnectionUrl=null,messageTableName=AMQ_MESSAGES,bindingsTableName=AMQ_BINDINGS,largeMessageTableName=AMQ_LARGE_MESSAGES,pageStoreTableName=AMQ_PSTORE,)

excerpts from the standalone-full.xml settings

<extensions>
   <extension module="org.wildfly.extension.messaging-activemq"/>
</extensions>

<datasources>

<datasource jndi-name="java:/RMBM-DEFAULT-DS" pool-name="RMBM-DEFAULT-DS" enabled="true">
 <connection-url>jdbc:sqlserver://${rmbm.default.ds.host}:${rmbm.default.ds.port:1433};DatabaseName=${rmbm.default.ds.dbname}
 </connection-url>
<driver>SQLSVR</driver>
</datasource>

<drivers>
   <driver name="SQLSVR" module="com.microsoft.sqlserver.jdbc">
      <driver-class>com.microsoft.sqlserver.jdbc.SQLServerDriver</driver- class>
   </driver>
</drivers>

<subsystem xmlns="urn:jboss:domain:messaging-activemq:5.0">
  <server name="default">
    <journal datasource="RMBM-DEFAULT-DS" messages-table="AMQ_MESSAGES" bindings-table="AMQ_BINDINGS"
      jms-bindings-table="AMQ_JMS_BINDINGS" large-messages-table="AMQ_LARGE_MESSAGES" page-store-table="AMQ_PGSTORE"/>
</server>
</subsystem>

Here is a portion of the log output:

18:36:27,116 INFO  [org.wildfly.extension.messaging-activemq] (MSC service thread 1-8) WFLYMSGAMQ0001: AIO wasn't located on this platform, it will fall back to using pure Java NIO.
18:36:27,665 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-1) WFLYUT0006: Undertow HTTPS listener https listening on 127.0.0.1:443
18:36:27,808 INFO  [org.jboss.ws.common.management] (MSC service thread 1-7) JBWS022052: Starting JBossWS 5.2.4.Final (Apache CXF 3.2.5.jbossorg-1)
18:36:27,964 DEBUG [org.apache.activemq.artemis.jdbc.store.journal.JDBCJournalImpl] (MSC service thread 1-8) Detect database dialect as 'MSSQL'.
18:36:27,968 INFO  [org.wildfly.extension.messaging-activemq] (MSC service thread 1-8) use JDBC store for Artemis server, bindingsTable:AMQ_BINDINGS
18:36:28,065 DEBUG [org.apache.activemq.artemis.core.server.impl.ActiveMQServerImpl] (ServerService Thread Pool -- 80) Starting server ActiveMQServerImpl::
18:36:28,069 DEBUG [org.apache.activemq.artemis.core.server.impl.ActiveMQServerImpl] (ServerService Thread Pool -- 80) Detected no Shared Store HA options on JDBC store
18:36:28,121 INFO  [org.apache.activemq.artemis.core.server] (ServerService Thread Pool -- 80) AMQ221000: live Message Broker is starting with configuration Broker Configuration (clustered=false,jdbcDriverClassName=org.apache.derby.jdbc.EmbeddedDriver,jdbcConnectionUrl=null,messageTableName=AMQ_MESSAGES,bindingsTableName=AMQ_BINDINGS,largeMessageTableName=AMQ_LARGE_MESSAGES,pageStoreTableName=AMQ_PSTORE,)
18:36:28,306 DEBUG [org.apache.activemq.artemis.jdbc.store.journal.JDBCJournalImpl] (ServerService Thread Pool -- 80) Detect database dialect as 'MSSQL'.
18:36:28,398 ERROR [org.apache.activemq.artemis.jdbc.store.drivers.AbstractJDBCDriver] (ServerService Thread Pool -- 80)
SQL STATEMENTS:
CREATE TABLE AMQ_LARGE_MESSAGES (ID BIGINT AUTO_INCREMENT, FILENAME VARCHAR(255), EXTENSION VARCHAR(10), DATA BLOB, PRIMARY KEY(ID))
SQL EXCEPTIONS:
SQLState: S0001 ErrorCode: 102 Message: Incorrect syntax near 'AUTO_INCREMENT'.
18:36:28,425 WARN  [org.apache.activemq.artemis.core.server] (ServerService Thread Pool -- 80) AMQ222010: Critical IO Error, shutting down the server. file=NULL, message=Unable to start database driver: com.microsoft.sqlserver.jdbc.SQLServerException: Incorrect syntax near 'AUTO_INCREMENT'.
    at com.microsoft.sqlserver.jdbc//com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(SQLServerException.java:262)
    at com.microsoft.sqlserver.jdbc//com.microsoft.sqlserver.jdbc.SQLServerStatement.getNextResult(SQLServerStatement.java:1621)
    at com.microsoft.sqlserver.jdbc//com.microsoft.sqlserver.jdbc.SQLServerStatement.doExecuteStatement(SQLServerStatement.java:868)
    at com.microsoft.sqlserver.jdbc//com.microsoft.sqlserver.jdbc.SQLServerStatement$StmtExecCmd.doExecute(SQLServerStatement.java:768)
    at com.microsoft.sqlserver.jdbc//com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:7194)
    at com.microsoft.sqlserver.jdbc//com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:2935)
    at com.microsoft.sqlserver.jdbc//com.microsoft.sqlserver.jdbc.SQLServerStatement.executeCommand(SQLServerStatement.java:248)
    at com.microsoft.sqlserver.jdbc//com.microsoft.sqlserver.jdbc.SQLServerStatement.executeStatement(SQLServerStatement.java:223)
    at com.microsoft.sqlserver.jdbc//com.microsoft.sqlserver.jdbc.SQLServerStatement.executeUpdate(SQLServerStatement.java:711)
    at org.jboss.ironjacamar.jdbcadapters@1.4.11.Final//org.jboss.jca.adapters.jdbc.WrappedStatement.executeUpdate(WrappedStatement.java:430)
    at org.apache.activemq.artemis@2.6.3.jbossorg-00014//org.apache.activemq.artemis.jdbc.store.drivers.AbstractJDBCDriver.createTableIfNotExists(AbstractJDBCDriver.java:258)
    at org.apache.activemq.artemis@2.6.3.jbossorg-00014//org.apache.activemq.artemis.jdbc.store.drivers.AbstractJDBCDriver.createTable(AbstractJDBCDriver.java:118)
    at org.apache.activemq.artemis@2.6.3.jbossorg-00014//org.apache.activemq.artemis.jdbc.store.file.JDBCSequentialFileFactoryDriver.createSchema(JDBCSequentialFileFactoryDriver.java:69)
    at org.apache.activemq.artemis@2.6.3.jbossorg-00014//org.apache.activemq.artemis.jdbc.store.drivers.AbstractJDBCDriver.start(AbstractJDBCDriver.java:83)
    at org.apache.activemq.artemis@2.6.3.jbossorg-00014//org.apache.activemq.artemis.jdbc.store.file.JDBCSequentialFileFactory.start(JDBCSequentialFileFactory.java:131)
    at org.apache.activemq.artemis@2.6.3.jbossorg-00014//org.apache.activemq.artemis.core.persistence.impl.journal.JDBCJournalStorageManager.init(JDBCJournalStorageManager.java:92)
    at org.apache.activemq.artemis@2.6.3.jbossorg-00014//org.apache.activemq.artemis.core.persistence.impl.journal.AbstractJournalStorageManager.<init>(AbstractJournalStorageManager.java:229)
    at org.apache.activemq.artemis@2.6.3.jbossorg-00014//org.apache.activemq.artemis.core.persistence.impl.journal.JournalStorageManager.<init>(JournalStorageManager.java:106)
    at org.apache.activemq.artemis@2.6.3.jbossorg-00014//org.apache.activemq.artemis.core.persistence.impl.journal.JDBCJournalStorageManager.<init>(JDBCJournalStorageManager.java:55)
    at org.apache.activemq.artemis@2.6.3.jbossorg-00014//org.apache.activemq.artemis.core.server.impl.ActiveMQServerImpl.createStorageManager(ActiveMQServerImpl.java:2155)
    at org.apache.activemq.artemis@2.6.3.jbossorg-00014//org.apache.activemq.artemis.core.server.impl.ActiveMQServerImpl.initialisePart1(ActiveMQServerImpl.java:2296)
    at org.apache.activemq.artemis@2.6.3.jbossorg-00014//org.apache.activemq.artemis.core.server.impl.LiveOnlyActivation.run(LiveOnlyActivation.java:64)
    at org.apache.activemq.artemis@2.6.3.jbossorg-00014//org.apache.activemq.artemis.core.server.impl.ActiveMQServerImpl.internalStart(ActiveMQServerImpl.java:535)
    at org.apache.activemq.artemis@2.6.3.jbossorg-00014//org.apache.activemq.artemis.core.server.impl.ActiveMQServerImpl.start(ActiveMQServerImpl.java:474)
    at org.apache.activemq.artemis@2.6.3.jbossorg-00014//org.apache.activemq.artemis.jms.server.impl.JMSServerManagerImpl.start(JMSServerManagerImpl.java:376)
    at org.wildfly.extension.messaging-activemq//org.wildfly.extension.messaging.activemq.jms.JMSService.doStart(JMSService.java:206)
    at org.wildfly.extension.messaging-activemq//org.wildfly.extension.messaging.activemq.jms.JMSService.access$000(JMSService.java:65)
    at org.wildfly.extension.messaging-activemq//org.wildfly.extension.messaging.activemq.jms.JMSService$1.run(JMSService.java:100)

Body:
It appears that even though the dialect is correctly detected as MSSQL the broker doesn't have the corresponding SQL statements to properly support it. The SQL statements for MSSQL were added in ActiveMQ Artemis 2.6.4 via ARTEMIS-2202. You're using 2.6.3 so you don't have those.

Upgrading ActiveMQ Artemis in Wildfly can sometimes fail due to the tight coupling between the two so if you don't want to try upgrading you could theoretically crack open the artemis-jdbc-store jar file and add/replace these lines to journal-sql.properties

# MSSQL SQL statements
create-file-table.mssql=CREATE TABLE %s (ID BIGINT NOT NULL IDENTITY, FILENAME VARCHAR(255), EXTENSION VARCHAR(10), DATA VARBINARY(max), PRIMARY KEY(ID))
create-journal-table.mssql=CREATE TABLE %s(id BIGINT,recordType SMALLINT,compactCount SMALLINT,txId BIGINT,userRecordType SMALLINT,variableSize INTEGER,record VARBINARY(max),txDataSize INTEGER,txData VARBINARY(max),txCheckNoRecords INTEGER,seq BIGINT NOT NULL, PRIMARY KEY(seq))
max-blob-size.mssql=2147483647

Regarding the AMQ221000 log message that indicates there is an incorrect JDBC driver configuration...This is due to the fact that the ActiveMQ Artemis broker has its own JDBC driver configuration for when it's running standalone. When it's embedded in Wildfly and configured to use a datasource via JNDI then the standalone JDBC driver configuration isn't used. It will simply look up the specified datasource and use that.


问:
java.util.NoSuchElementException: Columns not found in table abc.company_vals: companyId, companyName
Using libs , spark-cassandra-connector_2-11.jar and spark-sql-2.4.1.jar

Have Cassandra table as below

```<code>CREATE TABLE abc.company_vals(
    companyId int,
    companyName text,
    year int,
    quarter text,
    revenue int,
    PRIMARY KEY (companyId, year)
) WITH CLUSTERING ORDER BY ( year DESC );
</code>```

Trying to insert data into the above using spark-structured streaming as below

```<code>List<Row> data  = Arrays.asList(
                    RowFactory.create(10002 , "TCS",2004,"Q4",7800),
                    RowFactory.create(10003, "GE",2004,"Q4",7800),
                    RowFactory.create(10004, "Oracle",2004,"Q4",7800),
                    RowFactory.create(10005, "epam",2004,"Q4",7800),
                    RowFactory.create(10006, "Dhfl",2004,"Q4",7800),
                    RowFactory.create(10007, "Infosys",2004,"Q4",7800)
               )

StructType schema = new StructType()
                      .add("companyId", DataTypes.IntegerType)
                      .add("companyName", DataTypes.StringType)
                      .add("year", DataTypes.IntegerType)
                      .add("quarter", DataTypes.StringType)
                      .add("revenue", DataTypes.IntegerType);

             Dataset<Row> companyDf = sparkSession.createDataFrame(data, schema).toDF();

             companyDf
             .write()
             .format("org.apache.spark.sql.cassandra")
                .option("table","company_vals")
                .option("keyspace",  "abc")
                .mode(SaveMode.Append)
                .save();
</code>```

I changed the order of the table like pk , cluster key and rest of the columns, changed StructType & input accordingly...but still same error.

Getting error :

```<code>java.util.NoSuchElementException: Columns not found in table abc.company_vals: companyId, companyName
at com.datastax.spark.connector.SomeColumns.selectFrom(ColumnSelector.scala:44)
at com.datastax.spark.connector.writer.TableWriter$.apply(TableWriter.scala:385)
at com.datastax.spark.connector.RDDFunctions.saveToCassandra(RDDFunctions.scala:35)
at org.apache.spark.sql.cassandra.CassandraSourceRelation.insert(CassandraSourceRelation.scala:76)
at org.apache.spark.sql.cassandra.DefaultSource.createRelation(DefaultSource.scala:86)
at org.apache.spark.sql.execution.datasources.SaveIntoDataSourceCommand.run(SaveIntoDataSourceCommand.scala:45)
at org.apache.spark.sql.execution.command.ExecutedCommandExec.sideEffectResult$lzycompute(commands.scala:70)
at org.apache.spark.sql.execution.command.ExecutedCommandExec.sideEffectResult(commands.scala:68)
at org.apache.spark.sql.execution.command.ExecutedCommandExec.doExecute(commands.scala:86)
at org.apache.spark.sql.execution.SparkPlan$$anonfun$execute$1.apply(SparkPlan.scala:131)
at org.apache.spark.sql.execution.SparkPlan$$anonfun$execute$1.apply(SparkPlan.scala:127)
at org.apache.spark.sql.execution.SparkPlan$$anonfun$executeQuery$1.apply(SparkPlan.scala:155)
at org.apache.spark.rdd.RDDOperationScope$.withScope(RDDOperationScope.scala:151)
at org.apache.spark.sql.execution.SparkPlan.executeQuery(SparkPlan.scala:152)
at org.apache.spark.sql.execution.SparkPlan.execute(SparkPlan.scala:127)
at org.apache.spark.sql.execution.QueryExecution.toRdd$lzycompute(QueryExecution.scala:80)
at org.apache.spark.sql.execution.QueryExecution.toRdd(QueryExecution.scala:80)
at org.apache.spark.sql.DataFrameWriter$$anonfun$runCommand$1.apply(DataFrameWriter.scala:668)
at org.apache.spark.sql.DataFrameWriter$$anonfun$runCommand$1.apply(DataFrameWriter.scala:668)
at org.apache.spark.sql.execution.SQLExecution$$anonfun$withNewExecutionId$1.apply(SQLExecution.scala:78)
at org.apache.spark.sql.execution.SQLExecution$.withSQLConfPropagated(SQLExecution.scala:125)
at org.apache.spark.sql.execution.SQLExecution$.withNewExecutionId(SQLExecution.scala:73)
at org.apache.spark.sql.DataFrameWriter.runCommand(DataFrameWriter.scala:668)
at org.apache.spark.sql.DataFrameWriter.saveToV1Source(DataFrameWriter.scala:276)
at org.apache.spark.sql.DataFrameWriter.save(DataFrameWriter.scala:270)
</code>```

What am I doing wrong here ? how to fix this?

答: The problem is that Spark Connector is using case sensitive names, while in CQL they are case insensitive until the columns names are put into double quotes. So you either need to declare fields in the table as case-sensitive as "companyId" and "companyName" correspondingly, or use lowercased names in your Spark app.

Body:
Using libs , spark-cassandra-connector_2-11.jar and spark-sql-2.4.1.jar

Have Cassandra table as below

CREATE TABLE abc.company_vals(
    companyId int,
    companyName text,
    year int,
    quarter text,
    revenue int,
    PRIMARY KEY (companyId, year)
) WITH CLUSTERING ORDER BY ( year DESC );

Trying to insert data into the above using spark-structured streaming as below

List<Row> data  = Arrays.asList(
                    RowFactory.create(10002 , "TCS",2004,"Q4",7800),
                    RowFactory.create(10003, "GE",2004,"Q4",7800),
                    RowFactory.create(10004, "Oracle",2004,"Q4",7800),
                    RowFactory.create(10005, "epam",2004,"Q4",7800),
                    RowFactory.create(10006, "Dhfl",2004,"Q4",7800),
                    RowFactory.create(10007, "Infosys",2004,"Q4",7800)
               )

StructType schema = new StructType()
                      .add("companyId", DataTypes.IntegerType)
                      .add("companyName", DataTypes.StringType)
                      .add("year", DataTypes.IntegerType)
                      .add("quarter", DataTypes.StringType)
                      .add("revenue", DataTypes.IntegerType);

             Dataset<Row> companyDf = sparkSession.createDataFrame(data, schema).toDF();

             companyDf
             .write()
             .format("org.apache.spark.sql.cassandra")
                .option("table","company_vals")
                .option("keyspace",  "abc")
                .mode(SaveMode.Append)
                .save();

I changed the order of the table like pk , cluster key and rest of the columns, changed StructType & input accordingly...but still same error.

Getting error :

java.util.NoSuchElementException: Columns not found in table abc.company_vals: companyId, companyName
at com.datastax.spark.connector.SomeColumns.selectFrom(ColumnSelector.scala:44)
at com.datastax.spark.connector.writer.TableWriter$.apply(TableWriter.scala:385)
at com.datastax.spark.connector.RDDFunctions.saveToCassandra(RDDFunctions.scala:35)
at org.apache.spark.sql.cassandra.CassandraSourceRelation.insert(CassandraSourceRelation.scala:76)
at org.apache.spark.sql.cassandra.DefaultSource.createRelation(DefaultSource.scala:86)
at org.apache.spark.sql.execution.datasources.SaveIntoDataSourceCommand.run(SaveIntoDataSourceCommand.scala:45)
at org.apache.spark.sql.execution.command.ExecutedCommandExec.sideEffectResult$lzycompute(commands.scala:70)
at org.apache.spark.sql.execution.command.ExecutedCommandExec.sideEffectResult(commands.scala:68)
at org.apache.spark.sql.execution.command.ExecutedCommandExec.doExecute(commands.scala:86)
at org.apache.spark.sql.execution.SparkPlan$$anonfun$execute$1.apply(SparkPlan.scala:131)
at org.apache.spark.sql.execution.SparkPlan$$anonfun$execute$1.apply(SparkPlan.scala:127)
at org.apache.spark.sql.execution.SparkPlan$$anonfun$executeQuery$1.apply(SparkPlan.scala:155)
at org.apache.spark.rdd.RDDOperationScope$.withScope(RDDOperationScope.scala:151)
at org.apache.spark.sql.execution.SparkPlan.executeQuery(SparkPlan.scala:152)
at org.apache.spark.sql.execution.SparkPlan.execute(SparkPlan.scala:127)
at org.apache.spark.sql.execution.QueryExecution.toRdd$lzycompute(QueryExecution.scala:80)
at org.apache.spark.sql.execution.QueryExecution.toRdd(QueryExecution.scala:80)
at org.apache.spark.sql.DataFrameWriter$$anonfun$runCommand$1.apply(DataFrameWriter.scala:668)
at org.apache.spark.sql.DataFrameWriter$$anonfun$runCommand$1.apply(DataFrameWriter.scala:668)
at org.apache.spark.sql.execution.SQLExecution$$anonfun$withNewExecutionId$1.apply(SQLExecution.scala:78)
at org.apache.spark.sql.execution.SQLExecution$.withSQLConfPropagated(SQLExecution.scala:125)
at org.apache.spark.sql.execution.SQLExecution$.withNewExecutionId(SQLExecution.scala:73)
at org.apache.spark.sql.DataFrameWriter.runCommand(DataFrameWriter.scala:668)
at org.apache.spark.sql.DataFrameWriter.saveToV1Source(DataFrameWriter.scala:276)
at org.apache.spark.sql.DataFrameWriter.save(DataFrameWriter.scala:270)

What am I doing wrong here ? how to fix this?


问:
How to get Page/Post Featured Images to show on Twitter Card? Hugo (Academic Theme)
I have been having difficulty getting Twitter Cards to work for my posts featured images. The featured images appear for post url's on both Facebook and Linkedin, yet I can't get the twitter card to work.

I have tried reviewing the twitter card code in the academic header and also by following the Hugo documentation. I am unsure if its something that missing or overlooking? Any help or advice would be greatly appreciated.

I found this code in the academic header.html partial, yet I am still unsure as to why it is not working:

```<code>
  {{ $featured_image := (.Resources.ByType "image").GetMatch "*featured*" }}
  {{ $og_image := "" }}
  {{ $twitter_card := "summary_large_image" }}
  {{ if $featured_image }}
    {{ $og_image = $featured_image.Permalink }}
  {{ else if .Params.header.image }}
    {{ $og_image = printf "img/%s" .Params.header.image | absURL }}
  {{ else if .Site.Params.sharing_image }}
    {{ $og_image = printf "img/%s" .Site.Params.sharing_image | absURL }}
  {{ else if .Site.Params.avatar }}
    {{ $og_image = (printf "img/%s" site.Params.avatar) | absURL }}
    {{ $twitter_card = "summary" }}
  {{ else }}
    {{ $og_image = "img/icon-192.png" | absURL }}
    {{ $twitter_card = "summary" }}
  {{ end }}
  <meta property="twitter:card" content="{{ $twitter_card }}">
  {{ with .Site.Params.twitter }}
  <meta property="twitter:site" content="@{{ . }}">
  <meta property="twitter:creator" content="@{{ . }}">
  {{ end }}
  <meta property="og:site_name" content="{{ .Site.Title }}">
  <meta property="og:url" content="{{ .Permalink }}">
  <meta property="og:title" content="{{ if not .IsHome }}{{ .Title }} | {{ end }}{{ .Site.Title }}">
  <meta property="og:description" content="{{ $desc }}">
  {{- with $og_image }}<meta property="og:image" content="{{ . }}">{{end}}
  <meta property="og:locale" content="{{ .Site.LanguageCode | default "en-us" }}">
  {{ if .IsPage }}
  {{ if not .PublishDate.IsZero }}<meta property="article:published_time" content="{{ .PublishDate.Format "2006-01-02T15:04:05-07:00" | safeHTML }}">
  {{ else if not .Date.IsZero }}<meta property="article:published_time" content="{{ .Date.Format "2006-01-02T15:04:05-07:00" | safeHTML }}">{{ end }}
  {{ if not .Lastmod.IsZero }}<meta property="article:modified_time" content="{{ .Lastmod.Format "2006-01-02T15:04:05-07:00" | safeHTML }}">{{ end }}
  {{ else }}
  {{ if not .Date.IsZero }}<meta property="og:updated_time" content="{{ .Date.Format "2006-01-02T15:04:05-07:00" | safeHTML }}">{{ end }}
  {{ end }}
</code>```

The twitter card validator log says the following:

```<code>INFO:  Page fetched successfully
INFO:  18 metatags were found
INFO:  twitter:card = summary_large_image tag found
INFO:  Card loaded successfully
</code>```

Yet, no image appears. Any help or tips on resolving this would be greatly appreciated?

答: As it happens the problem I experienced was due to an incorrect baseURL in the config.toml file in Hugo. Once, I corrected this error, the Twitter summary card began to appear as normal.

Body:
I have been having difficulty getting Twitter Cards to work for my posts featured images. The featured images appear for post url's on both Facebook and Linkedin, yet I can't get the twitter card to work.

I have tried reviewing the twitter card code in the academic header and also by following the Hugo documentation. I am unsure if its something that missing or overlooking? Any help or advice would be greatly appreciated.

I found this code in the academic header.html partial, yet I am still unsure as to why it is not working:

  {{ $featured_image := (.Resources.ByType "image").GetMatch "*featured*" }}
  {{ $og_image := "" }}
  {{ $twitter_card := "summary_large_image" }}
  {{ if $featured_image }}
    {{ $og_image = $featured_image.Permalink }}
  {{ else if .Params.header.image }}
    {{ $og_image = printf "img/%s" .Params.header.image | absURL }}
  {{ else if .Site.Params.sharing_image }}
    {{ $og_image = printf "img/%s" .Site.Params.sharing_image | absURL }}
  {{ else if .Site.Params.avatar }}
    {{ $og_image = (printf "img/%s" site.Params.avatar) | absURL }}
    {{ $twitter_card = "summary" }}
  {{ else }}
    {{ $og_image = "img/icon-192.png" | absURL }}
    {{ $twitter_card = "summary" }}
  {{ end }}
  <meta property="twitter:card" content="{{ $twitter_card }}">
  {{ with .Site.Params.twitter }}
  <meta property="twitter:site" content="@{{ . }}">
  <meta property="twitter:creator" content="@{{ . }}">
  {{ end }}
  <meta property="og:site_name" content="{{ .Site.Title }}">
  <meta property="og:url" content="{{ .Permalink }}">
  <meta property="og:title" content="{{ if not .IsHome }}{{ .Title }} | {{ end }}{{ .Site.Title }}">
  <meta property="og:description" content="{{ $desc }}">
  {{- with $og_image }}<meta property="og:image" content="{{ . }}">{{end}}
  <meta property="og:locale" content="{{ .Site.LanguageCode | default "en-us" }}">
  {{ if .IsPage }}
  {{ if not .PublishDate.IsZero }}<meta property="article:published_time" content="{{ .PublishDate.Format "2006-01-02T15:04:05-07:00" | safeHTML }}">
  {{ else if not .Date.IsZero }}<meta property="article:published_time" content="{{ .Date.Format "2006-01-02T15:04:05-07:00" | safeHTML }}">{{ end }}
  {{ if not .Lastmod.IsZero }}<meta property="article:modified_time" content="{{ .Lastmod.Format "2006-01-02T15:04:05-07:00" | safeHTML }}">{{ end }}
  {{ else }}
  {{ if not .Date.IsZero }}<meta property="og:updated_time" content="{{ .Date.Format "2006-01-02T15:04:05-07:00" | safeHTML }}">{{ end }}
  {{ end }}

The twitter card validator log says the following:

INFO:  Page fetched successfully
INFO:  18 metatags were found
INFO:  twitter:card = summary_large_image tag found
INFO:  Card loaded successfully

Yet, no image appears. Any help or tips on resolving this would be greatly appreciated?


问:
how to revert/rebase for second time?
Sorry this is very confusing.
I have local branch A, i did some work on it and pushed it. I saw a merge conflict so i pulled from master but after merging i saw “your branch A and origin/A are detached”. I did a rebase to fix the issue but now this is what i see:

```<code>A branch: a - b - c
Master commits: 1 - 2 - 3
After pull i got:
A: a - b - c - 1 - 2 - 3
</code>```

Then i did rebase but i messed up somehow and i ended up having:

```<code> A: a- b - c -[1 - 2 - 3 - a - b - c - 1 - 2 - 3]
</code>```

Which 1-2-3 are other people’s commits to master.
a-b-c are my commits.
I only want my commits: a - b - c. How can i revert all the  parts inside brackets?
Goal:
A: a - b - c

答:
You can use following command to revert to a particular commit or branch or tag:
git reset --hard <tag/branch/commit id>

In your case, you need to provide commit id of your latest commit which you want to keep (for example commit id of commit c).

Title: how to revert/rebase for second time?

Body:
Sorry this is very confusing.
I have local branch A, i did some work on it and pushed it. I saw a merge conflict so i pulled from master but after merging i saw “your branch A and origin/A are detached”. I did a rebase to fix the issue but now this is what i see:

A branch: a - b - c
Master commits: 1 - 2 - 3
After pull i got:
A: a - b - c - 1 - 2 - 3

Then i did rebase but i messed up somehow and i ended up having:

 A: a- b - c -[1 - 2 - 3 - a - b - c - 1 - 2 - 3]

Which 1-2-3 are other people’s commits to master.
a-b-c are my commits.
I only want my commits: a - b - c. How can i revert all the  parts inside brackets?
Goal:
A: a - b - c


问:
Eclipse error upon start up
Eclipse won't work after my PC shutdown unexpectedly. Here is the error that corresponds to the log file written when I tried to run Eclipse. </p>

```<code>!SESSION 2014-08-20 14:05:14.763 -----------------------------------------------
eclipse.buildId=4.3.0.M20130911-1000
java.version=1.7.0_45
java.vendor=Oracle Corporation
BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=en_US
Framework arguments:  -product org.eclipse.epp.package.jee.product
Command-line arguments:  -os win32 -ws win32 -arch x86 -product
org.eclipse.epp.package.jee.product

!ENTRY org.eclipse.osgi 4 0 2014-08-20 14:05:18.319
!MESSAGE An error occurred while automatically activating bundle
org.eclipse.core.resources (82).
!STACK 0
org.osgi.framework.BundleException: Exception in org.eclipse.core.resources.ResourcesPlugin.start() of bundle org.eclipse.core.resources.
    at org.eclipse.osgi.framework.internal.core.BundleContextImpl.startActivator(BundleContextImpl.java:734)
    at org.eclipse.osgi.framework.internal.core.BundleContextImpl.start(BundleContextImpl.java:683)
    at org.eclipse.osgi.framework.internal.core.BundleHost.startWorker(BundleHost.java:381)
    at org.eclipse.osgi.framework.internal.core.AbstractBundle.start(AbstractBundle.java:300)
    at org.eclipse.osgi.framework.util.SecureAction.start(SecureAction.java:478)
    at org.eclipse.osgi.internal.loader.BundleLoader.setLazyTrigger(BundleLoader.java:263)
    at org.eclipse.core.runtime.internal.adaptor.EclipseLazyStarter.postFindLocalClass(EclipseLazyStarter.java:109)
    at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.findLocalClass(ClasspathManager.java:469)
    at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.findLocalClass(DefaultClassLoader.java:216)
    at org.eclipse.osgi.internal.loader.BundleLoader.findLocalClass(BundleLoader.java:395)
    at org.eclipse.osgi.internal.loader.SingleSourcePackage.loadClass(SingleSourcePackage.java:35)
    at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:461)
    at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:421)
    at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:412)
    at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:125)
    at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:354)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:181)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:636)
    at org.eclipse.equinox.launcher.Main.basicRun(Main.java:591)
    at org.eclipse.equinox.launcher.Main.run(Main.java:1450)
Caused by: org.eclipse.core.internal.resources.ResourceException: Problems reading project tree.
    at org.eclipse.core.internal.resources.WorkspaceTreeReader_2.readTree(WorkspaceTreeReader_2.java:125)
    at org.eclipse.core.internal.resources.SaveManager.restoreTree(SaveManager.java:1000)
    at org.eclipse.core.internal.resources.SaveManager.restore(SaveManager.java:687)
    at org.eclipse.core.internal.resources.SaveManager.startup(SaveManager.java:1530)
    at org.eclipse.core.internal.resources.Workspace.startup(Workspace.java:2503)
    at org.eclipse.core.internal.resources.Workspace.open(Workspace.java:2252)
    at org.eclipse.core.resources.ResourcesPlugin.start(ResourcesPlugin.java:439)
    at org.eclipse.osgi.framework.internal.core.BundleContextImpl$1.run(BundleContextImpl.java:711)
    at java.security.AccessController.doPrivileged(Native Method)
    at org.eclipse.osgi.framework.internal.core.BundleContextImpl.startActivator(BundleContextImpl.java:702)
    ... 28 more
Caused by: java.io.IOException: Unknown format.
    at org.eclipse.core.internal.watson.ElementTreeReader.getReader(ElementTreeReader.java:76)
    at org.eclipse.core.internal.watson.ElementTreeReader.readDelta(ElementTreeReader.java:85)
    at org.eclipse.core.internal.watson.ElementTreeReaderImpl_1.readDeltaChain(ElementTreeReaderImpl_1.java:88)
    at org.eclipse.core.internal.watson.ElementTreeReader.readDeltaChain(ElementTreeReader.java:110)
    at org.eclipse.core.internal.resources.WorkspaceTreeReader_1.readTrees(WorkspaceTreeReader_1.java:233)
    at org.eclipse.core.internal.resources.WorkspaceTreeReader_2.readTree(WorkspaceTreeReader_2.java:104)
    ... 37 more
Root exception:
org.eclipse.core.internal.resources.ResourceException(null)[567]: java.io.IOException: Unknown format.
    at org.eclipse.core.internal.watson.ElementTreeReader.getReader(ElementTreeReader.java:76)
    at org.eclipse.core.internal.watson.ElementTreeReader.readDelta(ElementTreeReader.java:85)
    at org.eclipse.core.internal.watson.ElementTreeReaderImpl_1.readDeltaChain(ElementTreeReaderImpl_1.java:88)
    at org.eclipse.core.internal.watson.ElementTreeReader.readDeltaChain(ElementTreeReader.java:110)
    at org.eclipse.core.internal.resources.WorkspaceTreeReader_1.readTrees(WorkspaceTreeReader_1.java:233)
    at org.eclipse.core.internal.resources.WorkspaceTreeReader_2.readTree(WorkspaceTreeReader_2.java:104)
    at org.eclipse.core.internal.resources.SaveManager.restoreTree(SaveManager.java:1000)
    at org.eclipse.core.internal.resources.SaveManager.restore(SaveManager.java:687)
    at org.eclipse.core.internal.resources.SaveManager.startup(SaveManager.java:1530)
    at org.eclipse.core.internal.resources.Workspace.startup(Workspace.java:2503)
    at org.eclipse.core.internal.resources.Workspace.open(Workspace.java:2252)
    at org.eclipse.core.resources.ResourcesPlugin.start(ResourcesPlugin.java:439)
    at org.eclipse.osgi.framework.internal.core.BundleContextImpl$1.run(BundleContextImpl.java:711)
    at java.security.AccessController.doPrivileged(Native Method)
    at org.eclipse.osgi.framework.internal.core.BundleContextImpl.startActivator(BundleContextImpl.java:702)
    at org.eclipse.osgi.framework.internal.core.BundleContextImpl.start(BundleContextImpl.java:683)
    at org.eclipse.osgi.framework.internal.core.BundleHost.startWorker(BundleHost.java:381)
    at org.eclipse.osgi.framework.internal.core.AbstractBundle.start(AbstractBundle.java:300)
    at org.eclipse.osgi.framework.util.SecureAction.start(SecureAction.java:478)
    at org.eclipse.osgi.internal.loader.BundleLoader.setLazyTrigger(BundleLoader.java:263)
    at org.eclipse.core.runtime.internal.adaptor.EclipseLazyStarter.postFindLocalClass(EclipseLazyStarter.java:109)
    at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.findLocalClass(ClasspathManager.java:469)
    at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.findLocalClass(DefaultClassLoader.java:216)
    at org.eclipse.osgi.internal.loader.BundleLoader.findLocalClass(BundleLoader.java:395)
    at org.eclipse.osgi.internal.loader.SingleSourcePackage.loadClass(SingleSourcePackage.java:35)
    at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:461)
    at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:421)
    at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:412)
    at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:125)
    at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:354)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:181)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:636)
    at org.eclipse.equinox.launcher.Main.basicRun(Main.java:591)
    at org.eclipse.equinox.launcher.Main.run(Main.java:1450)

!ENTRY org.eclipse.osgi 4 0 2014-08-20 14:05:18.336
!MESSAGE Application error
!STACK 1
java.lang.NoClassDefFoundError: org/eclipse/core/resources/IContainer
    at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:125)
    at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:354)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:181)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:636)
    at org.eclipse.equinox.launcher.Main.basicRun(Main.java:591)
    at org.eclipse.equinox.launcher.Main.run(Main.java:1450)
Caused by: org.eclipse.core.runtime.internal.adaptor.EclipseLazyStarter$TerminatingClassNotFoundException: An error occurred while automatically activating bundle org.eclipse.core.resources (82).
    at org.eclipse.core.runtime.internal.adaptor.EclipseLazyStarter.postFindLocalClass(EclipseLazyStarter.java:124)
    at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.findLocalClass(ClasspathManager.java:469)
    at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.findLocalClass(DefaultClassLoader.java:216)
    at org.eclipse.osgi.internal.loader.BundleLoader.findLocalClass(BundleLoader.java:395)
    at org.eclipse.osgi.internal.loader.SingleSourcePackage.loadClass(SingleSourcePackage.java:35)
    at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:461)
    at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:421)
    at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:412)
    at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    ... 13 more
Caused by: org.osgi.framework.BundleException: Exception in org.eclipse.core.resources.ResourcesPlugin.start() of bundle org.eclipse.core.resources.
    at org.eclipse.osgi.framework.internal.core.BundleContextImpl.startActivator(BundleContextImpl.java:734)
    at org.eclipse.osgi.framework.internal.core.BundleContextImpl.start(BundleContextImpl.java:683)
    at org.eclipse.osgi.framework.internal.core.BundleHost.startWorker(BundleHost.java:381)
    at org.eclipse.osgi.framework.internal.core.AbstractBundle.start(AbstractBundle.java:300)
    at org.eclipse.osgi.framework.util.SecureAction.start(SecureAction.java:478)
    at org.eclipse.osgi.internal.loader.BundleLoader.setLazyTrigger(BundleLoader.java:263)
    at org.eclipse.core.runtime.internal.adaptor.EclipseLazyStarter.postFindLocalClass(EclipseLazyStarter.java:109)
    ... 22 more
Caused by: org.eclipse.core.internal.resources.ResourceException: Problems reading project tree.
    at org.eclipse.core.internal.resources.WorkspaceTreeReader_2.readTree(WorkspaceTreeReader_2.java:125)
    at org.eclipse.core.internal.resources.SaveManager.restoreTree(SaveManager.java:1000)
    at org.eclipse.core.internal.resources.SaveManager.restore(SaveManager.java:687)
    at org.eclipse.core.internal.resources.SaveManager.startup(SaveManager.java:1530)
    at org.eclipse.core.internal.resources.Workspace.startup(Workspace.java:2503)
    at org.eclipse.core.internal.resources.Workspace.open(Workspace.java:2252)
    at org.eclipse.core.resources.ResourcesPlugin.start(ResourcesPlugin.java:439)
    at org.eclipse.osgi.framework.internal.core.BundleContextImpl$1.run(BundleContextImpl.java:711)
    at java.security.AccessController.doPrivileged(Native Method)
    at org.eclipse.osgi.framework.internal.core.BundleContextImpl.startActivator(BundleContextImpl.java:702)
    ... 28 more
Caused by: java.io.IOException: Unknown format.
    at org.eclipse.core.internal.watson.ElementTreeReader.getReader(ElementTreeReader.java:76)
    at org.eclipse.core.internal.watson.ElementTreeReader.readDelta(ElementTreeReader.java:85)
    at org.eclipse.core.internal.watson.ElementTreeReaderImpl_1.readDeltaChain(ElementTreeReaderImpl_1.java:88)
    at org.eclipse.core.internal.watson.ElementTreeReader.readDeltaChain(ElementTreeReader.java:110)
    at org.eclipse.core.internal.resources.WorkspaceTreeReader_1.readTrees(WorkspaceTreeReader_1.java:233)
    at org.eclipse.core.internal.resources.WorkspaceTreeReader_2.readTree(WorkspaceTreeReader_2.java:104)
    ... 37 more
</code>```

答:
I had this same problem, option 1 from user1401472s answer worked for me
Restoring the projects from the corrupted workspace was as simple as re-importing them from the old workspace into the new workspace via: file -> import -> General -> "Existing Projects From Workspace" and selecting the old workspace folder as the root-directory.

EDIT: this was on windows 10

Title: Eclipse error upon start up

Body:
Eclipse won't work after my PC shutdown unexpectedly. Here is the error that corresponds to the log file written when I tried to run Eclipse.

!SESSION 2014-08-20 14:05:14.763 -----------------------------------------------
eclipse.buildId=4.3.0.M20130911-1000
java.version=1.7.0_45
java.vendor=Oracle Corporation
BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=en_US
Framework arguments:  -product org.eclipse.epp.package.jee.product
Command-line arguments:  -os win32 -ws win32 -arch x86 -product
org.eclipse.epp.package.jee.product

!ENTRY org.eclipse.osgi 4 0 2014-08-20 14:05:18.319
!MESSAGE An error occurred while automatically activating bundle
org.eclipse.core.resources (82).
!STACK 0
org.osgi.framework.BundleException: Exception in org.eclipse.core.resources.ResourcesPlugin.start() of bundle org.eclipse.core.resources.
    at org.eclipse.osgi.framework.internal.core.BundleContextImpl.startActivator(BundleContextImpl.java:734)
    at org.eclipse.osgi.framework.internal.core.BundleContextImpl.start(BundleContextImpl.java:683)
    at org.eclipse.osgi.framework.internal.core.BundleHost.startWorker(BundleHost.java:381)
    at org.eclipse.osgi.framework.internal.core.AbstractBundle.start(AbstractBundle.java:300)
    at org.eclipse.osgi.framework.util.SecureAction.start(SecureAction.java:478)
    at org.eclipse.osgi.internal.loader.BundleLoader.setLazyTrigger(BundleLoader.java:263)
    at org.eclipse.core.runtime.internal.adaptor.EclipseLazyStarter.postFindLocalClass(EclipseLazyStarter.java:109)
    at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.findLocalClass(ClasspathManager.java:469)
    at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.findLocalClass(DefaultClassLoader.java:216)
    at org.eclipse.osgi.internal.loader.BundleLoader.findLocalClass(BundleLoader.java:395)
    at org.eclipse.osgi.internal.loader.SingleSourcePackage.loadClass(SingleSourcePackage.java:35)
    at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:461)
    at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:421)
    at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:412)
    at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:125)
    at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:354)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:181)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:636)
    at org.eclipse.equinox.launcher.Main.basicRun(Main.java:591)
    at org.eclipse.equinox.launcher.Main.run(Main.java:1450)
Caused by: org.eclipse.core.internal.resources.ResourceException: Problems reading project tree.
    at org.eclipse.core.internal.resources.WorkspaceTreeReader_2.readTree(WorkspaceTreeReader_2.java:125)
    at org.eclipse.core.internal.resources.SaveManager.restoreTree(SaveManager.java:1000)
    at org.eclipse.core.internal.resources.SaveManager.restore(SaveManager.java:687)
    at org.eclipse.core.internal.resources.SaveManager.startup(SaveManager.java:1530)
    at org.eclipse.core.internal.resources.Workspace.startup(Workspace.java:2503)
    at org.eclipse.core.internal.resources.Workspace.open(Workspace.java:2252)
    at org.eclipse.core.resources.ResourcesPlugin.start(ResourcesPlugin.java:439)
    at org.eclipse.osgi.framework.internal.core.BundleContextImpl$1.run(BundleContextImpl.java:711)
    at java.security.AccessController.doPrivileged(Native Method)
    at org.eclipse.osgi.framework.internal.core.BundleContextImpl.startActivator(BundleContextImpl.java:702)
    ... 28 more
Caused by: java.io.IOException: Unknown format.
    at org.eclipse.core.internal.watson.ElementTreeReader.getReader(ElementTreeReader.java:76)
    at org.eclipse.core.internal.watson.ElementTreeReader.readDelta(ElementTreeReader.java:85)
    at org.eclipse.core.internal.watson.ElementTreeReaderImpl_1.readDeltaChain(ElementTreeReaderImpl_1.java:88)
    at org.eclipse.core.internal.watson.ElementTreeReader.readDeltaChain(ElementTreeReader.java:110)
    at org.eclipse.core.internal.resources.WorkspaceTreeReader_1.readTrees(WorkspaceTreeReader_1.java:233)
    at org.eclipse.core.internal.resources.WorkspaceTreeReader_2.readTree(WorkspaceTreeReader_2.java:104)
    ... 37 more
Root exception:
org.eclipse.core.internal.resources.ResourceException(null)[567]: java.io.IOException: Unknown format.
    at org.eclipse.core.internal.watson.ElementTreeReader.getReader(ElementTreeReader.java:76)
    at org.eclipse.core.internal.watson.ElementTreeReader.readDelta(ElementTreeReader.java:85)
    at org.eclipse.core.internal.watson.ElementTreeReaderImpl_1.readDeltaChain(ElementTreeReaderImpl_1.java:88)
    at org.eclipse.core.internal.watson.ElementTreeReader.readDeltaChain(ElementTreeReader.java:110)
    at org.eclipse.core.internal.resources.WorkspaceTreeReader_1.readTrees(WorkspaceTreeReader_1.java:233)
    at org.eclipse.core.internal.resources.WorkspaceTreeReader_2.readTree(WorkspaceTreeReader_2.java:104)
    at org.eclipse.core.internal.resources.SaveManager.restoreTree(SaveManager.java:1000)
    at org.eclipse.core.internal.resources.SaveManager.restore(SaveManager.java:687)
    at org.eclipse.core.internal.resources.SaveManager.startup(SaveManager.java:1530)
    at org.eclipse.core.internal.resources.Workspace.startup(Workspace.java:2503)
    at org.eclipse.core.internal.resources.Workspace.open(Workspace.java:2252)
    at org.eclipse.core.resources.ResourcesPlugin.start(ResourcesPlugin.java:439)
    at org.eclipse.osgi.framework.internal.core.BundleContextImpl$1.run(BundleContextImpl.java:711)
    at java.security.AccessController.doPrivileged(Native Method)
    at org.eclipse.osgi.framework.internal.core.BundleContextImpl.startActivator(BundleContextImpl.java:702)
    at org.eclipse.osgi.framework.internal.core.BundleContextImpl.start(BundleContextImpl.java:683)
    at org.eclipse.osgi.framework.internal.core.BundleHost.startWorker(BundleHost.java:381)
    at org.eclipse.osgi.framework.internal.core.AbstractBundle.start(AbstractBundle.java:300)
    at org.eclipse.osgi.framework.util.SecureAction.start(SecureAction.java:478)
    at org.eclipse.osgi.internal.loader.BundleLoader.setLazyTrigger(BundleLoader.java:263)
    at org.eclipse.core.runtime.internal.adaptor.EclipseLazyStarter.postFindLocalClass(EclipseLazyStarter.java:109)
    at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.findLocalClass(ClasspathManager.java:469)
    at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.findLocalClass(DefaultClassLoader.java:216)
    at org.eclipse.osgi.internal.loader.BundleLoader.findLocalClass(BundleLoader.java:395)
    at org.eclipse.osgi.internal.loader.SingleSourcePackage.loadClass(SingleSourcePackage.java:35)
    at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:461)
    at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:421)
    at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:412)
    at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:125)
    at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:354)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:181)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:636)
    at org.eclipse.equinox.launcher.Main.basicRun(Main.java:591)
    at org.eclipse.equinox.launcher.Main.run(Main.java:1450)

!ENTRY org.eclipse.osgi 4 0 2014-08-20 14:05:18.336
!MESSAGE Application error
!STACK 1
java.lang.NoClassDefFoundError: org/eclipse/core/resources/IContainer
    at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:125)
    at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:354)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:181)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:636)
    at org.eclipse.equinox.launcher.Main.basicRun(Main.java:591)
    at org.eclipse.equinox.launcher.Main.run(Main.java:1450)
Caused by: org.eclipse.core.runtime.internal.adaptor.EclipseLazyStarter$TerminatingClassNotFoundException: An error occurred while automatically activating bundle org.eclipse.core.resources (82).
    at org.eclipse.core.runtime.internal.adaptor.EclipseLazyStarter.postFindLocalClass(EclipseLazyStarter.java:124)
    at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.findLocalClass(ClasspathManager.java:469)
    at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.findLocalClass(DefaultClassLoader.java:216)
    at org.eclipse.osgi.internal.loader.BundleLoader.findLocalClass(BundleLoader.java:395)
    at org.eclipse.osgi.internal.loader.SingleSourcePackage.loadClass(SingleSourcePackage.java:35)
    at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:461)
    at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:421)
    at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:412)
    at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    ... 13 more
Caused by: org.osgi.framework.BundleException: Exception in org.eclipse.core.resources.ResourcesPlugin.start() of bundle org.eclipse.core.resources.
    at org.eclipse.osgi.framework.internal.core.BundleContextImpl.startActivator(BundleContextImpl.java:734)
    at org.eclipse.osgi.framework.internal.core.BundleContextImpl.start(BundleContextImpl.java:683)
    at org.eclipse.osgi.framework.internal.core.BundleHost.startWorker(BundleHost.java:381)
    at org.eclipse.osgi.framework.internal.core.AbstractBundle.start(AbstractBundle.java:300)
    at org.eclipse.osgi.framework.util.SecureAction.start(SecureAction.java:478)
    at org.eclipse.osgi.internal.loader.BundleLoader.setLazyTrigger(BundleLoader.java:263)
    at org.eclipse.core.runtime.internal.adaptor.EclipseLazyStarter.postFindLocalClass(EclipseLazyStarter.java:109)
    ... 22 more
Caused by: org.eclipse.core.internal.resources.ResourceException: Problems reading project tree.
    at org.eclipse.core.internal.resources.WorkspaceTreeReader_2.readTree(WorkspaceTreeReader_2.java:125)
    at org.eclipse.core.internal.resources.SaveManager.restoreTree(SaveManager.java:1000)
    at org.eclipse.core.internal.resources.SaveManager.restore(SaveManager.java:687)
    at org.eclipse.core.internal.resources.SaveManager.startup(SaveManager.java:1530)
    at org.eclipse.core.internal.resources.Workspace.startup(Workspace.java:2503)
    at org.eclipse.core.internal.resources.Workspace.open(Workspace.java:2252)
    at org.eclipse.core.resources.ResourcesPlugin.start(ResourcesPlugin.java:439)
    at org.eclipse.osgi.framework.internal.core.BundleContextImpl$1.run(BundleContextImpl.java:711)
    at java.security.AccessController.doPrivileged(Native Method)
    at org.eclipse.osgi.framework.internal.core.BundleContextImpl.startActivator(BundleContextImpl.java:702)
    ... 28 more
Caused by: java.io.IOException: Unknown format.
    at org.eclipse.core.internal.watson.ElementTreeReader.getReader(ElementTreeReader.java:76)
    at org.eclipse.core.internal.watson.ElementTreeReader.readDelta(ElementTreeReader.java:85)
    at org.eclipse.core.internal.watson.ElementTreeReaderImpl_1.readDeltaChain(ElementTreeReaderImpl_1.java:88)
    at org.eclipse.core.internal.watson.ElementTreeReader.readDeltaChain(ElementTreeReader.java:110)
    at org.eclipse.core.internal.resources.WorkspaceTreeReader_1.readTrees(WorkspaceTreeReader_1.java:233)
    at org.eclipse.core.internal.resources.WorkspaceTreeReader_2.readTree(WorkspaceTreeReader_2.java:104)
    ... 37 more


问:
CXF 2.2.12: How to turn off schema validation on the client side
I would like to turn off schema validation for JAXB-bound messages.  I am dealing with the client-side CXF code (WSDL first generation).  I have tried using

```<code><jaxws:client name="{http://apache.org/hello_world_soap_http}SoapPort"
    createdFromAPI="true">
    <jaxws:properties>
        <entry key="schema-validation-enabled" value="true" />
    </jaxws:properties>
</jaxws:client>
</code>```

Without success (see reference CXF FAQ ).  I've had difficulty finding a programmatic way of settings this property.  I've also explored short-circuiting CXF and accessing the parser, unmarshaller, etc.

Thanks for your help.

答: @SchemaValidation(type = SchemaValidation.SchemaValidationType.NONE) put this annotation to your endpoint implementation class

Body:
I would like to turn off schema validation for JAXB-bound messages.  I am dealing with the client-side CXF code (WSDL first generation).  I have tried using

<jaxws:client name="{http://apache.org/hello_world_soap_http}SoapPort"
    createdFromAPI="true">
    <jaxws:properties>
        <entry key="schema-validation-enabled" value="true" />
    </jaxws:properties>
</jaxws:client>

Without success (see reference CXF FAQ ).  I've had difficulty finding a programmatic way of settings this property.  I've also explored short-circuiting CXF and accessing the parser, unmarshaller, etc.

Thanks for your help.


问:
R - image of a pixel matrix?
How would you you make an image from a matrix in R?

Matrix values would correspond to pixel intensity on image (although I am just interested in 0,1 values white or black at the moment.), while column and row numbers correspond to vertical and horizontal location on the image.

By make an image I mean display it on the screen and save it as a jpg.

答:
Here's the second way (again, where the vertical axis increases going down).   This method is easier to layout, but has less control over the format of the numeric values displayed in the plot.

```<code> library(plotrix)

 #Build the matrix data to look like a correlation matrix
 n <- 8
 x <- matrix(runif(n*n), nrow=n)
 xmin <- 0
 xmax <- 1
 for (i in 1:n) x[i, i] <- 1.0 #Make the diagonal all 1's

 #Generate the palette for the matrix and the legend.  Generate labels for the legend
 palmat <- color.scale(x, c(1, 0.4), c(1, 0.4), c(0.96, 1))
 palleg <- color.gradient(c(1, 0.4), c(1, 0.4), c(0.96, 1), nslices=100)
 lableg <- c(formatC(xmin, format="f", digits=2), formatC(1*(xmax-xmin)/4, format="f", digits=2), formatC(2*(xmax-xmin)/4, format="f", digits=2), formatC(3*(xmax-xmin)/4, format="f", digits=2), formatC(xmax, format="f", digits=2))

 #Set up the plot area and plot the matrix
 par(mar=c(5, 5, 5, 8))
 color2D.matplot(x, cellcolors=palmat, main=paste(n, " X ", n, " Matrix Using Color2D.matplot", sep=""), show.values=2, vcol=rgb(0,0,0), axes=FALSE, vcex=0.7)
 axis(1, at=seq(1, n, 1)-0.5, labels=seq(1, n, 1), tck=-0.01, padj=-1)

 #In the axis() statement below, note that the labels are decreasing.  This is because
 #the above color2D.matplot() statement has "axes=FALSE" and a normal axis()
 #statement was used.
 axis(2, at=seq(1, n, 1)-0.5, labels=seq(n, 1, -1), tck=-0.01, padj=0.7)

 #Plot the legend
 pardat <- par()
 color.legend(pardat$usr[2]+0.5, 0, pardat$usr[2]+1, pardat$usr[2], paste(" ", lableg, sep=""), palleg, align="rb", gradient="y", cex=0.7)
</code>```

Title: R - image of a pixel matrix?

Body:
Here's the second way (again, where the vertical axis increases going down).   This method is easier to layout, but has less control over the format of the numeric values displayed in the plot.

 library(plotrix)

 #Build the matrix data to look like a correlation matrix
 n <- 8
 x <- matrix(runif(n*n), nrow=n)
 xmin <- 0
 xmax <- 1
 for (i in 1:n) x[i, i] <- 1.0 #Make the diagonal all 1's

 #Generate the palette for the matrix and the legend.  Generate labels for the legend
 palmat <- color.scale(x, c(1, 0.4), c(1, 0.4), c(0.96, 1))
 palleg <- color.gradient(c(1, 0.4), c(1, 0.4), c(0.96, 1), nslices=100)
 lableg <- c(formatC(xmin, format="f", digits=2), formatC(1*(xmax-xmin)/4, format="f", digits=2), formatC(2*(xmax-xmin)/4, format="f", digits=2), formatC(3*(xmax-xmin)/4, format="f", digits=2), formatC(xmax, format="f", digits=2))

 #Set up the plot area and plot the matrix
 par(mar=c(5, 5, 5, 8))
 color2D.matplot(x, cellcolors=palmat, main=paste(n, " X ", n, " Matrix Using Color2D.matplot", sep=""), show.values=2, vcol=rgb(0,0,0), axes=FALSE, vcex=0.7)
 axis(1, at=seq(1, n, 1)-0.5, labels=seq(1, n, 1), tck=-0.01, padj=-1)

 #In the axis() statement below, note that the labels are decreasing.  This is because
 #the above color2D.matplot() statement has "axes=FALSE" and a normal axis()
 #statement was used.
 axis(2, at=seq(1, n, 1)-0.5, labels=seq(n, 1, -1), tck=-0.01, padj=0.7)

 #Plot the legend
 pardat <- par()
 color.legend(pardat$usr[2]+0.5, 0, pardat$usr[2]+1, pardat$usr[2], paste(" ", lableg, sep=""), palleg, align="rb", gradient="y", cex=0.7)


问:
Print text after last slash
I have a Data => File1.txt

Data

```<code>@demo/file/wk/Fil0.fk
@demo/file/wk/Fil1.fk
@demo/file/wk/Fil2.fk
@demo/file/wk/Fil3.fk
@demo/file/wk/Fil4.fk
</code>```

Want to Print the data to Another File2.txt in below Format

```<code>Fil0.fk
Fil1.fk
Fil2.fk
Fil3.fk
Fil4.fk
</code>```

答:
Try below code :</p>

```<code>cat File1.txt | cut -d'/' -f 4 > File2.txt
</code>```

Title: Print text after last slash

Body:
I have a Data => File1.txt

Data

@demo/file/wk/Fil0.fk
@demo/file/wk/Fil1.fk
@demo/file/wk/Fil2.fk
@demo/file/wk/Fil3.fk
@demo/file/wk/Fil4.fk

Want to Print the data to Another File2.txt in below Format

Fil0.fk
Fil1.fk
Fil2.fk
Fil3.fk
Fil4.fk

Body:
Try below code :

cat File1.txt | cut -d'/' -f 4 > File2.txt


问:
Cloud Connector problem. Cloud To On-Premise
I created in SAP Logon OData Service and Registed it.

I cheked it and it works good. Now, I want to create cloud connector using the link which I got when tested my Odata Service. It looks like:

http://mylink.com:1234/sap/opu/odata/sap/***_SRV/.

In cloud connector setting I put:

Internal host:mylink.com

Internal port:1234.

But, everytime when I try to check my connection in Cloud Connector it show to me Not Reachable.

Can anybody advice to me something about that and explain to me the reasons of it?
Thanks a lot.

答:
Cloud connector requires two different addresses:

Internal Host and port: this should be the real network address of your on premise system. Typically the SAP Netweaver Gateway where the service URL is in. The address must be reachable from the Cloud Connector server

Virtual Host and port: this should be a non real (virtual) address. It’s a must that this address match the URL address of a destination configured in SAP Cloud Platform.

Moreover, apart from the on premise configuration you must enable which URL paths are allowed to be accessed from the cloud


问:
Can not connect to remote database
Local config:
Node.js 12.2.0

Server config:
VPS
Ubuntu 18.04
MongoDB 3.2.22

There is basic script to connect to remote mongodb database. This returns error -  Cannot read property 'db' of null.

There are admin and test databases.
For admin DB I created an user

```<code>db.createUser(
  {
    user: "root",
    pwd: "passw0rd",
    roles: [ { role: "root", db: "admin" } ]
  }
)

</code>```

node app.js

```<code>// app.js

const MongoClient = require("mongodb").MongoClient;

// const url = "mongodb://root:passw0rd@46.173.213.195:27017/admin";
const url = "mongodb://46.173.213.195:27017/test";
const mongoClient = new MongoClient(url, { useNewUrlParser: true });

mongoClient.connect(function(err, client){
    const db = client.db("admin");
    const collection = db.collection("users");
    let user = {name: "Tomy", age: 23};
    collection.insertOne(user, function(err, result){
        if(err){
            return console.log(err);
        }
        console.log(result.ops);
        client.close();
    });
});
</code>```

```<code>// package.json

{
   "name": "mongoapp",
   "version": "1.0.0",
   "dependencies": {
      "express": "^4.16.0",
      "body-parser": "^1.18.0",
      "mongodb": "^3.1.0"
   }
}
</code>```

Both urls returns errors.

What I tried:

Changed bindIp to any

```<code>///nano etc/mongod.conf

# network interfaces
net:
  port: 27017
#  bindIp: 127.0.0.1
  bindIp: 0.0.0.0

</code>```

sudo netstat -ntlp | grep LISTEN

```<code>tcp    0    0 0.0.0.0:27017      0.0.0.0:*    LISTEN      17184/mongod
...
...
</code>```

Applied this code for iptables

```<code>iptables -A INPUT -s 185.228.232.150 -p tcp --destination-port 27017 -m state --state NEW,ESTABLISHED -j ACCEPT
iptables -A OUTPUT -d 185.228.232.150 -p tcp --source-port 27017 -m state --state ESTABLISHED -j ACCEPT
</code>```

sudo systemctl status mongodb tells that db works good

Can anyone help?..
The code can be tested from your computer.

Update:
Accoringly to that post https://www.mkyong.com/mongodb/mongodb-bind-failed-errno99-cannot-assign-requested-address-for-socket/ bindIp shouldn't be equals to server IP.

答:
I don't know how - it just started working.
bindIp: 0.0.0.0

I think, after a bunch of reloads and config updating

Title: Can not connect to remote database

Body:
Local config:
Node.js 12.2.0

Server config:
VPS
Ubuntu 18.04
MongoDB 3.2.22

There is basic script to connect to remote mongodb database. This returns error -  Cannot read property 'db' of null.

There are admin and test databases.
For admin DB I created an user

db.createUser(
  {
    user: "root",
    pwd: "passw0rd",
    roles: [ { role: "root", db: "admin" } ]
  }
)

node app.js

// app.js

const MongoClient = require("mongodb").MongoClient;

// const url = "mongodb://root:passw0rd@46.173.213.195:27017/admin";
const url = "mongodb://46.173.213.195:27017/test";
const mongoClient = new MongoClient(url, { useNewUrlParser: true });

mongoClient.connect(function(err, client){
    const db = client.db("admin");
    const collection = db.collection("users");
    let user = {name: "Tomy", age: 23};
    collection.insertOne(user, function(err, result){
        if(err){
            return console.log(err);
        }
        console.log(result.ops);
        client.close();
    });
});

// package.json

{
   "name": "mongoapp",
   "version": "1.0.0",
   "dependencies": {
      "express": "^4.16.0",
      "body-parser": "^1.18.0",
      "mongodb": "^3.1.0"
   }
}

Both urls returns errors.

What I tried:

Changed bindIp to any

///nano etc/mongod.conf

# network interfaces
net:
  port: 27017
#  bindIp: 127.0.0.1
  bindIp: 0.0.0.0

sudo netstat -ntlp | grep LISTEN

tcp    0    0 0.0.0.0:27017      0.0.0.0:*    LISTEN      17184/mongod
...
...

Applied this code for iptables

iptables -A INPUT -s 185.228.232.150 -p tcp --destination-port 27017 -m state --state NEW,ESTABLISHED -j ACCEPT
iptables -A OUTPUT -d 185.228.232.150 -p tcp --source-port 27017 -m state --state ESTABLISHED -j ACCEPT

sudo systemctl status mongodb tells that db works good

Can anyone help?..
The code can be tested from your computer.

Update:
Accoringly to that post https://www.mkyong.com/mongodb/mongodb-bind-failed-errno99-cannot-assign-requested-address-for-socket/ bindIp shouldn't be equals to server IP.


问:
How do I override Backbone.Router.execute function in its coffeescript child class?
I have a class which is extending Backbone.Router using the extends keyword in coffeescript. How can I override the Backbone.Router.execute method in my class?

I tried adding a execute in my child class with the same method signature but it's still calling the parent class method instead of my custom method.

```<code>jQuery ->
  class MyRouter extends Backbone.Router

    routes:
      "path/:id"          : "myFunction"

    execute: (callback, args, name) ->
      console.log('hello')
      console.log(args)
      # do stuff

      args.push(parseQueryString(args.pop()));
      if callback
         callback.apply(@, args);

   myFunction: (id) ->
     # do stuff
</code>```

I want to add some checks on args before myFunction gets called but somehow not able to override the execute method. What am I doing wrong here?

答:
It looks like you simply cannot mix backbone's objects and ES6 classes.

Here is a post which explains it in great detail.

it turns out that ES6 classes don’t support adding properties directly to the class instance, only functions/methods. This makes sense when you understand what is actually happening. With JavaScript inheritance, properties are generally meant to be set on an instance when its created, while methods are set on the prototype object and shared between every instance. If properties are added to the prototype directly they will also get shared between every instance, creating problems if the property is an object with mutable state like an array

You will have to stick to the backbone way of using Object.extends(). Here is an example for your code in coffeescript:

```<code>MyRouter = Backbone.Router.extend
    routes:
      "path/:id"          : "myFunction"

    execute: (callback, args, name) ->
      console.log('hello')
      console.log(args)
      # do stuff

      args.push(parseQueryString(args.pop()));
      if callback
         callback.apply(@, args);

   myFunction: (id) ->
     # do stuff
</code>```

Body:
I have a class which is extending Backbone.Router using the extends keyword in coffeescript. How can I override the Backbone.Router.execute method in my class?

I tried adding a execute in my child class with the same method signature but it's still calling the parent class method instead of my custom method.

jQuery ->
  class MyRouter extends Backbone.Router

    routes:
      "path/:id"          : "myFunction"

    execute: (callback, args, name) ->
      console.log('hello')
      console.log(args)
      # do stuff

      args.push(parseQueryString(args.pop()));
      if callback
         callback.apply(@, args);

   myFunction: (id) ->
     # do stuff

I want to add some checks on args before myFunction gets called but somehow not able to override the execute method. What am I doing wrong here?

Body:
It looks like you simply cannot mix backbone's objects and ES6 classes.

Here is a post which explains it in great detail.

it turns out that ES6 classes don’t support adding properties directly to the class instance, only functions/methods. This makes sense when you understand what is actually happening. With JavaScript inheritance, properties are generally meant to be set on an instance when its created, while methods are set on the prototype object and shared between every instance. If properties are added to the prototype directly they will also get shared between every instance, creating problems if the property is an object with mutable state like an array

You will have to stick to the backbone way of using Object.extends(). Here is an example for your code in coffeescript:

MyRouter = Backbone.Router.extend
    routes:
      "path/:id"          : "myFunction"

    execute: (callback, args, name) ->
      console.log('hello')
      console.log(args)
      # do stuff

      args.push(parseQueryString(args.pop()));
      if callback
         callback.apply(@, args);

   myFunction: (id) ->
     # do stuff