问:
Not able to access Spring H2 Console
I' working in a Spring standalone project. I' trying to use the H2 DB for fast testing. I'm having two problems that must have the same root:

First I'm not able to access to the H2 console which by default should be mapped to http://localhost:8080/h2-console.

I have H2 dependency in the pom.xml file:

```<code><?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.2.1.RELEASE</version>
        <relativePath /> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.dreamseeker</groupId>
    <artifactId>CondoAdmin</artifactId>
    <version>1.0.0</version>
    <name>CondoAdmin</name>
    <description>Standalone project for condo administration</description>

    <properties>
        <java.version>1.8</java.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>net.rgielen</groupId>
            <artifactId>javafx-weaver-spring-boot-starter</artifactId>
            <version>1.3.0</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>
        <dependency>
            <groupId>com.h2database</groupId>
            <artifactId>h2</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.junit.vintage</groupId>
                    <artifactId>junit-vintage-engine</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

</project>

</code>```

I added this line in the application.properties too: spring.h2.console.enabled=true

I suspect this is due the fact this is not a web app but I can't find in the internet any information which approves my hipotesys.

Secondly, I added a script to the resource directory to populate my H2 DB but an exception is jumping, which basically is complaining about an inexisting column:

Caused by: org.h2.jdbc.JdbcSQLSyntaxErrorException: Columna "LASTNAME" no encontrada
Column "LASTNAME" not found; SQL statement:
INSERT INTO Person (id, name, lastname, dni, apartmentID) VALUES (1, 'Edgar', 'Hernandez', '26659514-k', '701') [42122-200]

Here is the code of my entity class:

```<code>/**
 *
 */
package com.dreamseeker.models.entity;

import java.io.Serializable;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;

/**
 * @author Edgar Hernández
 *
 */
@Entity
public class Person implements Serializable {

    private static final long serialVersionUID = 1L;

    @Id
    @GeneratedValue(strategy=GenerationType.AUTO)
    private Long id;
    private String name;
    private String lastName;
    private String dni;
    private String apartmentID;

    public Person(String name, String lastName, String dni, String apartmentID) {
        this.name = name;
        this.lastName = lastName;
        this.dni = dni;
        this.apartmentID = apartmentID;
    }

    public Long getId() {
        return id;
    }
    public String getName() {
        return name;
    }
    public String getLastName() {
        return lastName;
    }
    public String getDNI() {
        return dni;
    }
    public String getApartmentID() {
        return apartmentID;
    }

    @Override
    public String toString() {
        return String.format(
                "Person[name=%d, last name='%s', dni='%s', apartmentID='%s']",
                name, lastName, dni, apartmentID);
    }

}
</code>```

The script has this statement:

INSERT INTO Person (id, name, lastname, dni, apartmentID) VALUES (1, 'Edgar', 'Hernandez', '26659514-k', '701');

I can't see an error here. The field is declared correctly and referenced with the same name in the query...

This is the entire log:

```
  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
[32m :: Spring Boot :: [39m      [2m (v2.2.1.RELEASE)[0;39m

[2m2020-02-19 21:10:37.851[0;39m [32m INFO[0;39m [35m9236[0;39m [2m---[0;39m [2m[JavaFX-Launcher][0;39m [36mo.s.boot.SpringApplication              [0;39m [2m:[0;39m Starting application on DESKTOP-I4H91H1 with PID 9236 (started by Edgar Hernández in C:\Users\Edgar Hernández\Documents\Programacion\GIT repos\CondoAdmin\Spring)
[2m2020-02-19 21:10:37.854[0;39m [32m INFO[0;39m [35m9236[0;39m [2m---[0;39m [2m[JavaFX-Launcher][0;39m [36mo.s.boot.SpringApplication              [0;39m [2m:[0;39m No active profile set, falling back to default profiles: default
[2m2020-02-19 21:10:38.155[0;39m [32m INFO[0;39m [35m9236[0;39m [2m---[0;39m [2m[JavaFX-Launcher][0;39m [36m.s.d.r.c.RepositoryConfigurationDelegate[0;39m [2m:[0;39m Bootstrapping Spring Data repositories in DEFAULT mode.
[2m2020-02-19 21:10:38.201[0;39m [32m INFO[0;39m [35m9236[0;39m [2m---[0;39m [2m[JavaFX-Launcher][0;39m [36m.s.d.r.c.RepositoryConfigurationDelegate[0;39m [2m:[0;39m Finished Spring Data repository scanning in 39ms. Found 2 repository interfaces.
[2m2020-02-19 21:10:38.465[0;39m [32m INFO[0;39m [35m9236[0;39m [2m---[0;39m [2m[JavaFX-Launcher][0;39m [36mcom.zaxxer.hikari.HikariDataSource      [0;39m [2m:[0;39m HikariPool-1 - Starting...
[2m2020-02-19 21:10:38.539[0;39m [32m INFO[0;39m [35m9236[0;39m [2m---[0;39m [2m[JavaFX-Launcher][0;39m [36mcom.zaxxer.hikari.HikariDataSource      [0;39m [2m:[0;39m HikariPool-1 - Start completed.
[2m2020-02-19 21:10:38.576[0;39m [32m INFO[0;39m [35m9236[0;39m [2m---[0;39m [2m[JavaFX-Launcher][0;39m [36mo.hibernate.jpa.internal.util.LogHelper [0;39m [2m:[0;39m HHH000204: Processing PersistenceUnitInfo [name: default]
[2m2020-02-19 21:10:38.627[0;39m [32m INFO[0;39m [35m9236[0;39m [2m---[0;39m [2m[JavaFX-Launcher][0;39m [36morg.hibernate.Version                   [0;39m [2m:[0;39m HHH000412: Hibernate Core {5.4.8.Final}
[2m2020-02-19 21:10:38.731[0;39m [32m INFO[0;39m [35m9236[0;39m [2m---[0;39m [2m[JavaFX-Launcher][0;39m [36mo.hibernate.annotations.common.Version  [0;39m [2m:[0;39m HCANN000001: Hibernate Commons Annotations {5.1.0.Final}
[2m2020-02-19 21:10:38.831[0;39m [32m INFO[0;39m [35m9236[0;39m [2m---[0;39m [2m[JavaFX-Launcher][0;39m [36morg.hibernate.dialect.Dialect           [0;39m [2m:[0;39m HHH000400: Using dialect: org.hibernate.dialect.H2Dialect
[2m2020-02-19 21:10:39.232[0;39m [32m INFO[0;39m [35m9236[0;39m [2m---[0;39m [2m[JavaFX-Launcher][0;39m [36morg.hibernate.tuple.PojoInstantiator    [0;39m [2m:[0;39m HHH000182: No default (no-argument) constructor for class: com.dreamseeker.models.entity.Person (class must be instantiated by Interceptor)
[2m2020-02-19 21:10:39.315[0;39m [32m INFO[0;39m [35m9236[0;39m [2m---[0;39m [2m[JavaFX-Launcher][0;39m [36mo.h.e.t.j.p.i.JtaPlatformInitiator      [0;39m [2m:[0;39m HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
[2m2020-02-19 21:10:39.320[0;39m [32m INFO[0;39m [35m9236[0;39m [2m---[0;39m [2m[JavaFX-Launcher][0;39m [36mj.LocalContainerEntityManagerFactoryBean[0;39m [2m:[0;39m Initialized JPA EntityManagerFactory for persistence unit 'default'
[2m2020-02-19 21:10:39.341[0;39m [33m WARN[0;39m [35m9236[0;39m [2m---[0;39m [2m[JavaFX-Launcher][0;39m [36ms.c.a.AnnotationConfigApplicationContext[0;39m [2m:[0;39m Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Initialization of bean failed; nested exception is org.springframework.jdbc.datasource.init.ScriptStatementFailedException: Failed to execute SQL script statement #1 of URL [file:/C:/Users/Edgar%20Hern%c3%a1ndez/Documents/Programacion/GIT%20repos/CondoAdmin/Spring/target/classes/data.sql]: INSERT INTO Person (id, name, lastname, dni, apartmentID) VALUES (1, 'Edgar', 'Hernandez', '26659514-k', '701'); nested exception is org.h2.jdbc.JdbcSQLSyntaxErrorException: Columna "LASTNAME" no encontrada
Column "LASTNAME" not found; SQL statement:
INSERT INTO Person (id, name, lastname, dni, apartmentID) VALUES (1, 'Edgar', 'Hernandez', '26659514-k', '701') [42122-200]
[2m2020-02-19 21:10:39.342[0;39m [32m INFO[0;39m [35m9236[0;39m [2m---[0;39m [2m[JavaFX-Launcher][0;39m [36mcom.zaxxer.hikari.HikariDataSource      [0;39m [2m:[0;39m HikariPool-1 - Shutdown initiated...
[2m2020-02-19 21:10:39.343[0;39m [32m INFO[0;39m [35m9236[0;39m [2m---[0;39m [2m[JavaFX-Launcher][0;39m [36mcom.zaxxer.hikari.HikariDataSource      [0;39m [2m:[0;39m HikariPool-1 - Shutdown completed.
[2m2020-02-19 21:10:39.348[0;39m [32m INFO[0;39m [35m9236[0;39m [2m---[0;39m [2m[JavaFX-Launcher][0;39m [36mConditionEvaluationReportLoggingListener[0;39m [2m:[0;39m

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
[2m2020-02-19 21:10:39.357[0;39m [31mERROR[0;39m [35m9236[0;39m [2m---[0;39m [2m[JavaFX-Launcher][0;39m [36mo.s.boot.SpringApplication              [0;39m [2m:[0;39m Application run failed

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Initialization of bean failed; nested exception is org.springframework.jdbc.datasource.init.ScriptStatementFailedException: Failed to execute SQL script statement #1 of URL [file:/C:/Users/Edgar%20Hern%c3%a1ndez/Documents/Programacion/GIT%20repos/CondoAdmin/Spring/target/classes/data.sql]: INSERT INTO Person (id, name, lastname, dni, apartmentID) VALUES (1, 'Edgar', 'Hernandez', '26659514-k', '701'); nested exception is org.h2.jdbc.JdbcSQLSyntaxErrorException: Columna "LASTNAME" no encontrada
Column "LASTNAME" not found; SQL statement:
INSERT INTO Person (id, name, lastname, dni, apartmentID) VALUES (1, 'Edgar', 'Hernandez', '26659514-k', '701') [42122-200]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:603) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:517) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:323) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:321) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1108) ~[spring-context-5.2.1.RELEASE.jar:5.2.1.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:868) ~[spring-context-5.2.1.RELEASE.jar:5.2.1.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:550) ~[spring-context-5.2.1.RELEASE.jar:5.2.1.RELEASE]
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:747) ~[spring-boot-2.2.1.RELEASE.jar:2.2.1.RELEASE]
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397) ~[spring-boot-2.2.1.RELEASE.jar:2.2.1.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) ~[spring-boot-2.2.1.RELEASE.jar:2.2.1.RELEASE]
    at org.springframework.boot.builder.SpringApplicationBuilder.run(SpringApplicationBuilder.java:140) [spring-boot-2.2.1.RELEASE.jar:2.2.1.RELEASE]
    at com.dreamseeker.JavaFxApplication.init(JavaFxApplication.java:28) [classes/:na]
    at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:841) [jfxrt.jar:na]
    at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$1(LauncherImpl.java:182) [jfxrt.jar:na]
    at java.lang.Thread.run(Unknown Source) ~[na:1.8.0_231]
Caused by: org.springframework.jdbc.datasource.init.ScriptStatementFailedException: Failed to execute SQL script statement #1 of URL [file:/C:/Users/Edgar%20Hern%c3%a1ndez/Documents/Programacion/GIT%20repos/CondoAdmin/Spring/target/classes/data.sql]: INSERT INTO Person (id, name, lastname, dni, apartmentID) VALUES (1, 'Edgar', 'Hernandez', '26659514-k', '701'); nested exception is org.h2.jdbc.JdbcSQLSyntaxErrorException: Columna "LASTNAME" no encontrada
Column "LASTNAME" not found; SQL statement:
INSERT INTO Person (id, name, lastname, dni, apartmentID) VALUES (1, 'Edgar', 'Hernandez', '26659514-k', '701') [42122-200]
    at org.springframework.jdbc.datasource.init.ScriptUtils.executeSqlScript(ScriptUtils.java:626) ~[spring-jdbc-5.2.1.RELEASE.jar:5.2.1.RELEASE]
    at org.springframework.jdbc.datasource.init.ResourceDatabasePopulator.populate(ResourceDatabasePopulator.java:254) ~[spring-jdbc-5.2.1.RELEASE.jar:5.2.1.RELEASE]
    at org.springframework.jdbc.datasource.init.DatabasePopulatorUtils.execute(DatabasePopulatorUtils.java:49) ~[spring-jdbc-5.2.1.RELEASE.jar:5.2.1.RELEASE]
    at org.springframework.boot.autoconfigure.jdbc.DataSourceInitializer.runScripts(DataSourceInitializer.java:202) ~[spring-boot-autoconfigure-2.2.1.RELEASE.jar:2.2.1.RELEASE]
    at org.springframework.boot.autoconfigure.jdbc.DataSourceInitializer.initSchema(DataSourceInitializer.java:119) ~[spring-boot-autoconfigure-2.2.1.RELEASE.jar:2.2.1.RELEASE]
    at org.springframework.boot.autoconfigure.jdbc.DataSourceInitializerInvoker.onApplicationEvent(DataSourceInitializerInvoker.java:91) ~[spring-boot-autoconfigure-2.2.1.RELEASE.jar:2.2.1.RELEASE]
    at org.springframework.boot.autoconfigure.jdbc.DataSourceInitializerInvoker.onApplicationEvent(DataSourceInitializerInvoker.java:38) ~[spring-boot-autoconfigure-2.2.1.RELEASE.jar:2.2.1.RELEASE]
    at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172) ~[spring-context-5.2.1.RELEASE.jar:5.2.1.RELEASE]
    at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165) ~[spring-context-5.2.1.RELEASE.jar:5.2.1.RELEASE]
    at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139) ~[spring-context-5.2.1.RELEASE.jar:5.2.1.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:403) ~[spring-context-5.2.1.RELEASE.jar:5.2.1.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:360) ~[spring-context-5.2.1.RELEASE.jar:5.2.1.RELEASE]
    at org.springframework.boot.autoconfigure.orm.jpa.DataSourceInitializedPublisher.publishEventIfRequired(DataSourceInitializedPublisher.java:99) ~[spring-boot-autoconfigure-2.2.1.RELEASE.jar:2.2.1.RELEASE]
    at org.springframework.boot.autoconfigure.orm.jpa.DataSourceInitializedPublisher.postProcessAfterInitialization(DataSourceInitializedPublisher.java:90) ~[spring-boot-autoconfigure-2.2.1.RELEASE.jar:2.2.1.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsAfterInitialization(AbstractAutowireCapableBeanFactory.java:431) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1807) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:595) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]
    ... 16 common frames omitted
Caused by: org.h2.jdbc.JdbcSQLSyntaxErrorException: Columna "LASTNAME" no encontrada
Column "LASTNAME" not found; SQL statement:
INSERT INTO Person (id, name, lastname, dni, apartmentID) VALUES (1, 'Edgar', 'Hernandez', '26659514-k', '701') [42122-200]
    at org.h2.message.DbException.getJdbcSQLException(DbException.java:453) ~[h2-1.4.200.jar:1.4.200]
    at org.h2.message.DbException.getJdbcSQLException(DbException.java:429) ~[h2-1.4.200.jar:1.4.200]
    at org.h2.message.DbException.get(DbException.java:205) ~[h2-1.4.200.jar:1.4.200]
    at org.h2.message.DbException.get(DbException.java:181) ~[h2-1.4.200.jar:1.4.200]
    at org.h2.table.Table.getColumn(Table.java:703) ~[h2-1.4.200.jar:1.4.200]
    at org.h2.command.Parser.parseColumn(Parser.java:1450) ~[h2-1.4.200.jar:1.4.200]
    at org.h2.command.Parser.parseColumnList(Parser.java:1435) ~[h2-1.4.200.jar:1.4.200]
    at org.h2.command.Parser.parseInsertGivenTable(Parser.java:1804) ~[h2-1.4.200.jar:1.4.200]
    at org.h2.command.Parser.parseInsert(Parser.java:1749) ~[h2-1.4.200.jar:1.4.200]
    at org.h2.command.Parser.parsePrepared(Parser.java:954) ~[h2-1.4.200.jar:1.4.200]
    at org.h2.command.Parser.parse(Parser.java:843) ~[h2-1.4.200.jar:1.4.200]
    at org.h2.command.Parser.parse(Parser.java:815) ~[h2-1.4.200.jar:1.4.200]
    at org.h2.command.Parser.prepareCommand(Parser.java:738) ~[h2-1.4.200.jar:1.4.200]
    at org.h2.engine.Session.prepareLocal(Session.java:657) ~[h2-1.4.200.jar:1.4.200]
    at org.h2.engine.Session.prepareCommand(Session.java:595) ~[h2-1.4.200.jar:1.4.200]
    at org.h2.jdbc.JdbcConnection.prepareCommand(JdbcConnection.java:1235) ~[h2-1.4.200.jar:1.4.200]
    at org.h2.jdbc.JdbcStatement.executeInternal(JdbcStatement.java:212) ~[h2-1.4.200.jar:1.4.200]
    at org.h2.jdbc.JdbcStatement.execute(JdbcStatement.java:201) ~[h2-1.4.200.jar:1.4.200]
    at com.zaxxer.hikari.pool.ProxyStatement.execute(ProxyStatement.java:95) ~[HikariCP-3.4.1.jar:na]
    at com.zaxxer.hikari.pool.HikariProxyStatement.execute(HikariProxyStatement.java) ~[HikariCP-3.4.1.jar:na]
    at org.springframework.jdbc.datasource.init.ScriptUtils.executeSqlScript(ScriptUtils.java:605) ~[spring-jdbc-5.2.1.RELEASE.jar:5.2.1.RELEASE]
    ... 32 common frames omitted

Exception in Application init method
Exception in thread "main" java.lang.RuntimeException: Exception in Application init method
    at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:912)
    at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$1(LauncherImpl.java:182)
    at java.lang.Thread.run(Unknown Source)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Initialization of bean failed; nested exception is org.springframework.jdbc.datasource.init.ScriptStatementFailedException: Failed to execute SQL script statement #1 of URL [file:/C:/Users/Edgar%20Hern%c3%a1ndez/Documents/Programacion/GIT%20repos/CondoAdmin/Spring/target/classes/data.sql]: INSERT INTO Person (id, name, lastname, dni, apartmentID) VALUES (1, 'Edgar', 'Hernandez', '26659514-k', '701'); nested exception is org.h2.jdbc.JdbcSQLSyntaxErrorException: Columna "LASTNAME" no encontrada
Column "LASTNAME" not found; SQL statement:
INSERT INTO Person (id, name, lastname, dni, apartmentID) VALUES (1, 'Edgar', 'Hernandez', '26659514-k', '701') [42122-200]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:603)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:517)
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:323)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:321)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
    at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1108)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:868)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:550)
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:747)
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:315)
    at org.springframework.boot.builder.SpringApplicationBuilder.run(SpringApplicationBuilder.java:140)
    at com.dreamseeker.JavaFxApplication.init(JavaFxApplication.java:28)
    at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:841)
    ... 2 more
Caused by: org.springframework.jdbc.datasource.init.ScriptStatementFailedException: Failed to execute SQL script statement #1 of URL [file:/C:/Users/Edgar%20Hern%c3%a1ndez/Documents/Programacion/GIT%20repos/CondoAdmin/Spring/target/classes/data.sql]: INSERT INTO Person (id, name, lastname, dni, apartmentID) VALUES (1, 'Edgar', 'Hernandez', '26659514-k', '701'); nested exception is org.h2.jdbc.JdbcSQLSyntaxErrorException: Columna "LASTNAME" no encontrada
Column "LASTNAME" not found; SQL statement:
INSERT INTO Person (id, name, lastname, dni, apartmentID) VALUES (1, 'Edgar', 'Hernandez', '26659514-k', '701') [42122-200]
    at org.springframework.jdbc.datasource.init.ScriptUtils.executeSqlScript(ScriptUtils.java:626)
    at org.springframework.jdbc.datasource.init.ResourceDatabasePopulator.populate(ResourceDatabasePopulator.java:254)
    at org.springframework.jdbc.datasource.init.DatabasePopulatorUtils.execute(DatabasePopulatorUtils.java:49)
    at org.springframework.boot.autoconfigure.jdbc.DataSourceInitializer.runScripts(DataSourceInitializer.java:202)
    at org.springframework.boot.autoconfigure.jdbc.DataSourceInitializer.initSchema(DataSourceInitializer.java:119)
    at org.springframework.boot.autoconfigure.jdbc.DataSourceInitializerInvoker.onApplicationEvent(DataSourceInitializerInvoker.java:91)
    at org.springframework.boot.autoconfigure.jdbc.DataSourceInitializerInvoker.onApplicationEvent(DataSourceInitializerInvoker.java:38)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139)
    at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:403)
    at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:360)
    at org.springframework.boot.autoconfigure.orm.jpa.DataSourceInitializedPublisher.publishEventIfRequired(DataSourceInitializedPublisher.java:99)
    at org.springframework.boot.autoconfigure.orm.jpa.DataSourceInitializedPublisher.postProcessAfterInitialization(DataSourceInitializedPublisher.java:90)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsAfterInitialization(AbstractAutowireCapableBeanFactory.java:431)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1807)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:595)
    ... 16 more
Caused by: org.h2.jdbc.JdbcSQLSyntaxErrorException: Columna "LASTNAME" no encontrada
Column "LASTNAME" not found; SQL statement:
INSERT INTO Person (id, name, lastname, dni, apartmentID) VALUES (1, 'Edgar', 'Hernandez', '26659514-k', '701') [42122-200]
    at org.h2.message.DbException.getJdbcSQLException(DbException.java:453)
    at org.h2.message.DbException.getJdbcSQLException(DbException.java:429)
    at org.h2.message.DbException.get(DbException.java:205)
    at org.h2.message.DbException.get(DbException.java:181)
    at org.h2.table.Table.getColumn(Table.java:703)
    at org.h2.command.Parser.parseColumn(Parser.java:1450)
    at org.h2.command.Parser.parseColumnList(Parser.java:1435)
    at org.h2.command.Parser.parseInsertGivenTable(Parser.java:1804)
    at org.h2.command.Parser.parseInsert(Parser.java:1749)
    at org.h2.command.Parser.parsePrepared(Parser.java:954)
    at org.h2.command.Parser.parse(Parser.java:843)
    at org.h2.command.Parser.parse(Parser.java:815)
    at org.h2.command.Parser.prepareCommand(Parser.java:738)
    at org.h2.engine.Session.prepareLocal(Session.java:657)
    at org.h2.engine.Session.prepareCommand(Session.java:595)
    at org.h2.jdbc.JdbcConnection.prepareCommand(JdbcConnection.java:1235)
    at org.h2.jdbc.JdbcStatement.executeInternal(JdbcStatement.java:212)
    at org.h2.jdbc.JdbcStatement.execute(JdbcStatement.java:201)
    at com.zaxxer.hikari.pool.ProxyStatement.execute(ProxyStatement.java:95)
    at com.zaxxer.hikari.pool.HikariProxyStatement.execute(HikariProxyStatement.java)
    at org.springframework.jdbc.datasource.init.ScriptUtils.executeSqlScript(ScriptUtils.java:605)
    ... 32 more

```

In conclusion, H2 console works just for web projects? Am I missing a configuration?

RESOLVED:
In the comments someone passed me a link to Spring Docs where I found this piece of information:

So these are the pre-requisites to use the H2 console. In my case, this is not a web-based app, so no way José.

答:
Column "LASTNAME" not found

Change lastName tolastname and try again.

I think it would have been created as LAST_NAME in the database schema.

EDITED:
Or you could add before lastname field declaration the @Column(name = "lastname") tag to ensure this will be the name the column will get.

Title: Not able to access Spring H2 Console

Body:
I' working in a Spring standalone project. I' trying to use the H2 DB for fast testing. I'm having two problems that must have the same root:

First I'm not able to access to the H2 console which by default should be mapped to http://localhost:8080/h2-console.

I have H2 dependency in the pom.xml file:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.2.1.RELEASE</version>
        <relativePath />
    </parent>
    <groupId>com.dreamseeker</groupId>
    <artifactId>CondoAdmin</artifactId>
    <version>1.0.0</version>
    <name>CondoAdmin</name>
    <description>Standalone project for condo administration</description>

    <properties>
        <java.version>1.8</java.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>net.rgielen</groupId>
            <artifactId>javafx-weaver-spring-boot-starter</artifactId>
            <version>1.3.0</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>
        <dependency>
            <groupId>com.h2database</groupId>
            <artifactId>h2</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.junit.vintage</groupId>
                    <artifactId>junit-vintage-engine</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

</project>

I added this line in the application.properties too: spring.h2.console.enabled=true

I suspect this is due the fact this is not a web app but I can't find in the internet any information which approves my hipotesys.

Secondly, I added a script to the resource directory to populate my H2 DB but an exception is jumping, which basically is complaining about an inexisting column:

Caused by: org.h2.jdbc.JdbcSQLSyntaxErrorException: Columna "LASTNAME" no encontrada
Column "LASTNAME" not found; SQL statement:
INSERT INTO Person (id, name, lastname, dni, apartmentID) VALUES (1, 'Edgar', 'Hernandez', '26659514-k', '701') [42122-200]

Here is the code of my entity class:

/**
 *
 */
package com.dreamseeker.models.entity;

import java.io.Serializable;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;

/**
 * @author Edgar Hernández
 *
 */
@Entity
public class Person implements Serializable {

    private static final long serialVersionUID = 1L;

    @Id
    @GeneratedValue(strategy=GenerationType.AUTO)
    private Long id;
    private String name;
    private String lastName;
    private String dni;
    private String apartmentID;

    public Person(String name, String lastName, String dni, String apartmentID) {
        this.name = name;
        this.lastName = lastName;
        this.dni = dni;
        this.apartmentID = apartmentID;
    }

    public Long getId() {
        return id;
    }
    public String getName() {
        return name;
    }
    public String getLastName() {
        return lastName;
    }
    public String getDNI() {
        return dni;
    }
    public String getApartmentID() {
        return apartmentID;
    }

    @Override
    public String toString() {
        return String.format(
                "Person[name=%d, last name='%s', dni='%s', apartmentID='%s']",
                name, lastName, dni, apartmentID);
    }

}

The script has this statement:

INSERT INTO Person (id, name, lastname, dni, apartmentID) VALUES (1, 'Edgar', 'Hernandez', '26659514-k', '701');

I can't see an error here. The field is declared correctly and referenced with the same name in the query...

This is the entire log:

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
[32m :: Spring Boot :: [39m      [2m (v2.2.1.RELEASE)[0;39m

[2m2020-02-19 21:10:37.851[0;39m [32m INFO[0;39m [35m9236[0;39m [2m---[0;39m [2m[JavaFX-Launcher][0;39m [36mo.s.boot.SpringApplication              [0;39m [2m:[0;39m Starting application on DESKTOP-I4H91H1 with PID 9236 (started by Edgar Hernández in C:\Users\Edgar Hernández\Documents\Programacion\GIT repos\CondoAdmin\Spring)
[2m2020-02-19 21:10:37.854[0;39m [32m INFO[0;39m [35m9236[0;39m [2m---[0;39m [2m[JavaFX-Launcher][0;39m [36mo.s.boot.SpringApplication              [0;39m [2m:[0;39m No active profile set, falling back to default profiles: default
[2m2020-02-19 21:10:38.155[0;39m [32m INFO[0;39m [35m9236[0;39m [2m---[0;39m [2m[JavaFX-Launcher][0;39m [36m.s.d.r.c.RepositoryConfigurationDelegate[0;39m [2m:[0;39m Bootstrapping Spring Data repositories in DEFAULT mode.
[2m2020-02-19 21:10:38.201[0;39m [32m INFO[0;39m [35m9236[0;39m [2m---[0;39m [2m[JavaFX-Launcher][0;39m [36m.s.d.r.c.RepositoryConfigurationDelegate[0;39m [2m:[0;39m Finished Spring Data repository scanning in 39ms. Found 2 repository interfaces.
[2m2020-02-19 21:10:38.465[0;39m [32m INFO[0;39m [35m9236[0;39m [2m---[0;39m [2m[JavaFX-Launcher][0;39m [36mcom.zaxxer.hikari.HikariDataSource      [0;39m [2m:[0;39m HikariPool-1 - Starting...
[2m2020-02-19 21:10:38.539[0;39m [32m INFO[0;39m [35m9236[0;39m [2m---[0;39m [2m[JavaFX-Launcher][0;39m [36mcom.zaxxer.hikari.HikariDataSource      [0;39m [2m:[0;39m HikariPool-1 - Start completed.
[2m2020-02-19 21:10:38.576[0;39m [32m INFO[0;39m [35m9236[0;39m [2m---[0;39m [2m[JavaFX-Launcher][0;39m [36mo.hibernate.jpa.internal.util.LogHelper [0;39m [2m:[0;39m HHH000204: Processing PersistenceUnitInfo [name: default]
[2m2020-02-19 21:10:38.627[0;39m [32m INFO[0;39m [35m9236[0;39m [2m---[0;39m [2m[JavaFX-Launcher][0;39m [36morg.hibernate.Version                   [0;39m [2m:[0;39m HHH000412: Hibernate Core {5.4.8.Final}
[2m2020-02-19 21:10:38.731[0;39m [32m INFO[0;39m [35m9236[0;39m [2m---[0;39m [2m[JavaFX-Launcher][0;39m [36mo.hibernate.annotations.common.Version  [0;39m [2m:[0;39m HCANN000001: Hibernate Commons Annotations {5.1.0.Final}
[2m2020-02-19 21:10:38.831[0;39m [32m INFO[0;39m [35m9236[0;39m [2m---[0;39m [2m[JavaFX-Launcher][0;39m [36morg.hibernate.dialect.Dialect           [0;39m [2m:[0;39m HHH000400: Using dialect: org.hibernate.dialect.H2Dialect
[2m2020-02-19 21:10:39.232[0;39m [32m INFO[0;39m [35m9236[0;39m [2m---[0;39m [2m[JavaFX-Launcher][0;39m [36morg.hibernate.tuple.PojoInstantiator    [0;39m [2m:[0;39m HHH000182: No default (no-argument) constructor for class: com.dreamseeker.models.entity.Person (class must be instantiated by Interceptor)
[2m2020-02-19 21:10:39.315[0;39m [32m INFO[0;39m [35m9236[0;39m [2m---[0;39m [2m[JavaFX-Launcher][0;39m [36mo.h.e.t.j.p.i.JtaPlatformInitiator      [0;39m [2m:[0;39m HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
[2m2020-02-19 21:10:39.320[0;39m [32m INFO[0;39m [35m9236[0;39m [2m---[0;39m [2m[JavaFX-Launcher][0;39m [36mj.LocalContainerEntityManagerFactoryBean[0;39m [2m:[0;39m Initialized JPA EntityManagerFactory for persistence unit 'default'
[2m2020-02-19 21:10:39.341[0;39m [33m WARN[0;39m [35m9236[0;39m [2m---[0;39m [2m[JavaFX-Launcher][0;39m [36ms.c.a.AnnotationConfigApplicationContext[0;39m [2m:[0;39m Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Initialization of bean failed; nested exception is org.springframework.jdbc.datasource.init.ScriptStatementFailedException: Failed to execute SQL script statement #1 of URL [file:/C:/Users/Edgar%20Hern%c3%a1ndez/Documents/Programacion/GIT%20repos/CondoAdmin/Spring/target/classes/data.sql]: INSERT INTO Person (id, name, lastname, dni, apartmentID) VALUES (1, 'Edgar', 'Hernandez', '26659514-k', '701'); nested exception is org.h2.jdbc.JdbcSQLSyntaxErrorException: Columna "LASTNAME" no encontrada
Column "LASTNAME" not found; SQL statement:
INSERT INTO Person (id, name, lastname, dni, apartmentID) VALUES (1, 'Edgar', 'Hernandez', '26659514-k', '701') [42122-200]
[2m2020-02-19 21:10:39.342[0;39m [32m INFO[0;39m [35m9236[0;39m [2m---[0;39m [2m[JavaFX-Launcher][0;39m [36mcom.zaxxer.hikari.HikariDataSource      [0;39m [2m:[0;39m HikariPool-1 - Shutdown initiated...
[2m2020-02-19 21:10:39.343[0;39m [32m INFO[0;39m [35m9236[0;39m [2m---[0;39m [2m[JavaFX-Launcher][0;39m [36mcom.zaxxer.hikari.HikariDataSource      [0;39m [2m:[0;39m HikariPool-1 - Shutdown completed.
[2m2020-02-19 21:10:39.348[0;39m [32m INFO[0;39m [35m9236[0;39m [2m---[0;39m [2m[JavaFX-Launcher][0;39m [36mConditionEvaluationReportLoggingListener[0;39m [2m:[0;39m

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
[2m2020-02-19 21:10:39.357[0;39m [31mERROR[0;39m [35m9236[0;39m [2m---[0;39m [2m[JavaFX-Launcher][0;39m [36mo.s.boot.SpringApplication              [0;39m [2m:[0;39m Application run failed

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Initialization of bean failed; nested exception is org.springframework.jdbc.datasource.init.ScriptStatementFailedException: Failed to execute SQL script statement #1 of URL [file:/C:/Users/Edgar%20Hern%c3%a1ndez/Documents/Programacion/GIT%20repos/CondoAdmin/Spring/target/classes/data.sql]: INSERT INTO Person (id, name, lastname, dni, apartmentID) VALUES (1, 'Edgar', 'Hernandez', '26659514-k', '701'); nested exception is org.h2.jdbc.JdbcSQLSyntaxErrorException: Columna "LASTNAME" no encontrada
Column "LASTNAME" not found; SQL statement:
INSERT INTO Person (id, name, lastname, dni, apartmentID) VALUES (1, 'Edgar', 'Hernandez', '26659514-k', '701') [42122-200]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:603) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:517) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:323) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:321) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1108) ~[spring-context-5.2.1.RELEASE.jar:5.2.1.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:868) ~[spring-context-5.2.1.RELEASE.jar:5.2.1.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:550) ~[spring-context-5.2.1.RELEASE.jar:5.2.1.RELEASE]
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:747) ~[spring-boot-2.2.1.RELEASE.jar:2.2.1.RELEASE]
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397) ~[spring-boot-2.2.1.RELEASE.jar:2.2.1.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) ~[spring-boot-2.2.1.RELEASE.jar:2.2.1.RELEASE]
    at org.springframework.boot.builder.SpringApplicationBuilder.run(SpringApplicationBuilder.java:140) [spring-boot-2.2.1.RELEASE.jar:2.2.1.RELEASE]
    at com.dreamseeker.JavaFxApplication.init(JavaFxApplication.java:28) [classes/:na]
    at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:841) [jfxrt.jar:na]
    at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$1(LauncherImpl.java:182) [jfxrt.jar:na]
    at java.lang.Thread.run(Unknown Source) ~[na:1.8.0_231]
Caused by: org.springframework.jdbc.datasource.init.ScriptStatementFailedException: Failed to execute SQL script statement #1 of URL [file:/C:/Users/Edgar%20Hern%c3%a1ndez/Documents/Programacion/GIT%20repos/CondoAdmin/Spring/target/classes/data.sql]: INSERT INTO Person (id, name, lastname, dni, apartmentID) VALUES (1, 'Edgar', 'Hernandez', '26659514-k', '701'); nested exception is org.h2.jdbc.JdbcSQLSyntaxErrorException: Columna "LASTNAME" no encontrada
Column "LASTNAME" not found; SQL statement:
INSERT INTO Person (id, name, lastname, dni, apartmentID) VALUES (1, 'Edgar', 'Hernandez', '26659514-k', '701') [42122-200]
    at org.springframework.jdbc.datasource.init.ScriptUtils.executeSqlScript(ScriptUtils.java:626) ~[spring-jdbc-5.2.1.RELEASE.jar:5.2.1.RELEASE]
    at org.springframework.jdbc.datasource.init.ResourceDatabasePopulator.populate(ResourceDatabasePopulator.java:254) ~[spring-jdbc-5.2.1.RELEASE.jar:5.2.1.RELEASE]
    at org.springframework.jdbc.datasource.init.DatabasePopulatorUtils.execute(DatabasePopulatorUtils.java:49) ~[spring-jdbc-5.2.1.RELEASE.jar:5.2.1.RELEASE]
    at org.springframework.boot.autoconfigure.jdbc.DataSourceInitializer.runScripts(DataSourceInitializer.java:202) ~[spring-boot-autoconfigure-2.2.1.RELEASE.jar:2.2.1.RELEASE]
    at org.springframework.boot.autoconfigure.jdbc.DataSourceInitializer.initSchema(DataSourceInitializer.java:119) ~[spring-boot-autoconfigure-2.2.1.RELEASE.jar:2.2.1.RELEASE]
    at org.springframework.boot.autoconfigure.jdbc.DataSourceInitializerInvoker.onApplicationEvent(DataSourceInitializerInvoker.java:91) ~[spring-boot-autoconfigure-2.2.1.RELEASE.jar:2.2.1.RELEASE]
    at org.springframework.boot.autoconfigure.jdbc.DataSourceInitializerInvoker.onApplicationEvent(DataSourceInitializerInvoker.java:38) ~[spring-boot-autoconfigure-2.2.1.RELEASE.jar:2.2.1.RELEASE]
    at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172) ~[spring-context-5.2.1.RELEASE.jar:5.2.1.RELEASE]
    at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165) ~[spring-context-5.2.1.RELEASE.jar:5.2.1.RELEASE]
    at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139) ~[spring-context-5.2.1.RELEASE.jar:5.2.1.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:403) ~[spring-context-5.2.1.RELEASE.jar:5.2.1.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:360) ~[spring-context-5.2.1.RELEASE.jar:5.2.1.RELEASE]
    at org.springframework.boot.autoconfigure.orm.jpa.DataSourceInitializedPublisher.publishEventIfRequired(DataSourceInitializedPublisher.java:99) ~[spring-boot-autoconfigure-2.2.1.RELEASE.jar:2.2.1.RELEASE]
    at org.springframework.boot.autoconfigure.orm.jpa.DataSourceInitializedPublisher.postProcessAfterInitialization(DataSourceInitializedPublisher.java:90) ~[spring-boot-autoconfigure-2.2.1.RELEASE.jar:2.2.1.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsAfterInitialization(AbstractAutowireCapableBeanFactory.java:431) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1807) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:595) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]
    ... 16 common frames omitted
Caused by: org.h2.jdbc.JdbcSQLSyntaxErrorException: Columna "LASTNAME" no encontrada
Column "LASTNAME" not found; SQL statement:
INSERT INTO Person (id, name, lastname, dni, apartmentID) VALUES (1, 'Edgar', 'Hernandez', '26659514-k', '701') [42122-200]
    at org.h2.message.DbException.getJdbcSQLException(DbException.java:453) ~[h2-1.4.200.jar:1.4.200]
    at org.h2.message.DbException.getJdbcSQLException(DbException.java:429) ~[h2-1.4.200.jar:1.4.200]
    at org.h2.message.DbException.get(DbException.java:205) ~[h2-1.4.200.jar:1.4.200]
    at org.h2.message.DbException.get(DbException.java:181) ~[h2-1.4.200.jar:1.4.200]
    at org.h2.table.Table.getColumn(Table.java:703) ~[h2-1.4.200.jar:1.4.200]
    at org.h2.command.Parser.parseColumn(Parser.java:1450) ~[h2-1.4.200.jar:1.4.200]
    at org.h2.command.Parser.parseColumnList(Parser.java:1435) ~[h2-1.4.200.jar:1.4.200]
    at org.h2.command.Parser.parseInsertGivenTable(Parser.java:1804) ~[h2-1.4.200.jar:1.4.200]
    at org.h2.command.Parser.parseInsert(Parser.java:1749) ~[h2-1.4.200.jar:1.4.200]
    at org.h2.command.Parser.parsePrepared(Parser.java:954) ~[h2-1.4.200.jar:1.4.200]
    at org.h2.command.Parser.parse(Parser.java:843) ~[h2-1.4.200.jar:1.4.200]
    at org.h2.command.Parser.parse(Parser.java:815) ~[h2-1.4.200.jar:1.4.200]
    at org.h2.command.Parser.prepareCommand(Parser.java:738) ~[h2-1.4.200.jar:1.4.200]
    at org.h2.engine.Session.prepareLocal(Session.java:657) ~[h2-1.4.200.jar:1.4.200]
    at org.h2.engine.Session.prepareCommand(Session.java:595) ~[h2-1.4.200.jar:1.4.200]
    at org.h2.jdbc.JdbcConnection.prepareCommand(JdbcConnection.java:1235) ~[h2-1.4.200.jar:1.4.200]
    at org.h2.jdbc.JdbcStatement.executeInternal(JdbcStatement.java:212) ~[h2-1.4.200.jar:1.4.200]
    at org.h2.jdbc.JdbcStatement.execute(JdbcStatement.java:201) ~[h2-1.4.200.jar:1.4.200]
    at com.zaxxer.hikari.pool.ProxyStatement.execute(ProxyStatement.java:95) ~[HikariCP-3.4.1.jar:na]
    at com.zaxxer.hikari.pool.HikariProxyStatement.execute(HikariProxyStatement.java) ~[HikariCP-3.4.1.jar:na]
    at org.springframework.jdbc.datasource.init.ScriptUtils.executeSqlScript(ScriptUtils.java:605) ~[spring-jdbc-5.2.1.RELEASE.jar:5.2.1.RELEASE]
    ... 32 common frames omitted

Exception in Application init method
Exception in thread "main" java.lang.RuntimeException: Exception in Application init method
    at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:912)
    at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$1(LauncherImpl.java:182)
    at java.lang.Thread.run(Unknown Source)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Initialization of bean failed; nested exception is org.springframework.jdbc.datasource.init.ScriptStatementFailedException: Failed to execute SQL script statement #1 of URL [file:/C:/Users/Edgar%20Hern%c3%a1ndez/Documents/Programacion/GIT%20repos/CondoAdmin/Spring/target/classes/data.sql]: INSERT INTO Person (id, name, lastname, dni, apartmentID) VALUES (1, 'Edgar', 'Hernandez', '26659514-k', '701'); nested exception is org.h2.jdbc.JdbcSQLSyntaxErrorException: Columna "LASTNAME" no encontrada
Column "LASTNAME" not found; SQL statement:
INSERT INTO Person (id, name, lastname, dni, apartmentID) VALUES (1, 'Edgar', 'Hernandez', '26659514-k', '701') [42122-200]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:603)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:517)
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:323)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:321)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
    at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1108)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:868)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:550)
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:747)
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:315)
    at org.springframework.boot.builder.SpringApplicationBuilder.run(SpringApplicationBuilder.java:140)
    at com.dreamseeker.JavaFxApplication.init(JavaFxApplication.java:28)
    at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:841)
    ... 2 more
Caused by: org.springframework.jdbc.datasource.init.ScriptStatementFailedException: Failed to execute SQL script statement #1 of URL [file:/C:/Users/Edgar%20Hern%c3%a1ndez/Documents/Programacion/GIT%20repos/CondoAdmin/Spring/target/classes/data.sql]: INSERT INTO Person (id, name, lastname, dni, apartmentID) VALUES (1, 'Edgar', 'Hernandez', '26659514-k', '701'); nested exception is org.h2.jdbc.JdbcSQLSyntaxErrorException: Columna "LASTNAME" no encontrada
Column "LASTNAME" not found; SQL statement:
INSERT INTO Person (id, name, lastname, dni, apartmentID) VALUES (1, 'Edgar', 'Hernandez', '26659514-k', '701') [42122-200]
    at org.springframework.jdbc.datasource.init.ScriptUtils.executeSqlScript(ScriptUtils.java:626)
    at org.springframework.jdbc.datasource.init.ResourceDatabasePopulator.populate(ResourceDatabasePopulator.java:254)
    at org.springframework.jdbc.datasource.init.DatabasePopulatorUtils.execute(DatabasePopulatorUtils.java:49)
    at org.springframework.boot.autoconfigure.jdbc.DataSourceInitializer.runScripts(DataSourceInitializer.java:202)
    at org.springframework.boot.autoconfigure.jdbc.DataSourceInitializer.initSchema(DataSourceInitializer.java:119)
    at org.springframework.boot.autoconfigure.jdbc.DataSourceInitializerInvoker.onApplicationEvent(DataSourceInitializerInvoker.java:91)
    at org.springframework.boot.autoconfigure.jdbc.DataSourceInitializerInvoker.onApplicationEvent(DataSourceInitializerInvoker.java:38)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139)
    at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:403)
    at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:360)
    at org.springframework.boot.autoconfigure.orm.jpa.DataSourceInitializedPublisher.publishEventIfRequired(DataSourceInitializedPublisher.java:99)
    at org.springframework.boot.autoconfigure.orm.jpa.DataSourceInitializedPublisher.postProcessAfterInitialization(DataSourceInitializedPublisher.java:90)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsAfterInitialization(AbstractAutowireCapableBeanFactory.java:431)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1807)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:595)
    ... 16 more
Caused by: org.h2.jdbc.JdbcSQLSyntaxErrorException: Columna "LASTNAME" no encontrada
Column "LASTNAME" not found; SQL statement:
INSERT INTO Person (id, name, lastname, dni, apartmentID) VALUES (1, 'Edgar', 'Hernandez', '26659514-k', '701') [42122-200]
    at org.h2.message.DbException.getJdbcSQLException(DbException.java:453)
    at org.h2.message.DbException.getJdbcSQLException(DbException.java:429)
    at org.h2.message.DbException.get(DbException.java:205)
    at org.h2.message.DbException.get(DbException.java:181)
    at org.h2.table.Table.getColumn(Table.java:703)
    at org.h2.command.Parser.parseColumn(Parser.java:1450)
    at org.h2.command.Parser.parseColumnList(Parser.java:1435)
    at org.h2.command.Parser.parseInsertGivenTable(Parser.java:1804)
    at org.h2.command.Parser.parseInsert(Parser.java:1749)
    at org.h2.command.Parser.parsePrepared(Parser.java:954)
    at org.h2.command.Parser.parse(Parser.java:843)
    at org.h2.command.Parser.parse(Parser.java:815)
    at org.h2.command.Parser.prepareCommand(Parser.java:738)
    at org.h2.engine.Session.prepareLocal(Session.java:657)
    at org.h2.engine.Session.prepareCommand(Session.java:595)
    at org.h2.jdbc.JdbcConnection.prepareCommand(JdbcConnection.java:1235)
    at org.h2.jdbc.JdbcStatement.executeInternal(JdbcStatement.java:212)
    at org.h2.jdbc.JdbcStatement.execute(JdbcStatement.java:201)
    at com.zaxxer.hikari.pool.ProxyStatement.execute(ProxyStatement.java:95)
    at com.zaxxer.hikari.pool.HikariProxyStatement.execute(HikariProxyStatement.java)
    at org.springframework.jdbc.datasource.init.ScriptUtils.executeSqlScript(ScriptUtils.java:605)
    ... 32 more

In conclusion, H2 console works just for web projects? Am I missing a configuration?

RESOLVED:
In the comments someone passed me a link to Spring Docs where I found this piece of information:

So these are the pre-requisites to use the H2 console. In my case, this is not a web-based app, so no way José.


来源: stackexchange

问:
Cant find Avro schema in divolte and kafka docker
I have 3 dockers kafka, divolt and streamsets (https://github.com/divolte/docker-divolte) started by compose-up. I want to convert the topic messages to avro files. I created the pipeline in streamset and paste the avro schema, but got an error:

```<code>com.streamsets.pipeline.api.base.OnRecordErrorException: KAFKA_37 - Cannot parse record from message 'divolte::3::0': java.io.IOException: Invalid int encoding
        at com.streamsets.pipeline.stage.origin.multikafka.MultiKafkaSource$MultiTopicCallable.createRecord(MultiKafkaSource.java:192)
        at com.streamsets.pipeline.stage.origin.multikafka.MultiKafkaSource$MultiTopicCallable.sendBatch(MultiKafkaSource.java:158)
        at com.streamsets.pipeline.stage.origin.multikafka.MultiKafkaSource$MultiTopicCallable.call(MultiKafkaSource.java:135)
        at com.streamsets.pipeline.stage.origin.multikafka.MultiKafkaSource$MultiTopicCallable.call(MultiKafkaSource.java:79)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:748)
Caused by: java.io.IOException: Invalid int encoding
</code>```

I red that problem is in incorrect avro schema. Could you tell where I can find the correct avro schema for this? I cant find it in dockers and github.

答: Looks like it might be in the Divolte GitHub repo, at https://github.com/divolte/divolte-schema/blob/master/src/main/resources/DefaultEventRecord.avsc</p>

ContentLicense: CC BY-SA 4.0

Body:
I have 3 dockers kafka, divolt and streamsets (https://github.com/divolte/docker-divolte) started by compose-up. I want to convert the topic messages to avro files. I created the pipeline in streamset and paste the avro schema, but got an error:

com.streamsets.pipeline.api.base.OnRecordErrorException: KAFKA_37 - Cannot parse record from message 'divolte::3::0': java.io.IOException: Invalid int encoding
        at com.streamsets.pipeline.stage.origin.multikafka.MultiKafkaSource$MultiTopicCallable.createRecord(MultiKafkaSource.java:192)
        at com.streamsets.pipeline.stage.origin.multikafka.MultiKafkaSource$MultiTopicCallable.sendBatch(MultiKafkaSource.java:158)
        at com.streamsets.pipeline.stage.origin.multikafka.MultiKafkaSource$MultiTopicCallable.call(MultiKafkaSource.java:135)
        at com.streamsets.pipeline.stage.origin.multikafka.MultiKafkaSource$MultiTopicCallable.call(MultiKafkaSource.java:79)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:748)
Caused by: java.io.IOException: Invalid int encoding

I red that problem is in incorrect avro schema. Could you tell where I can find the correct avro schema for this? I cant find it in dockers and github.


问:
Functional Dependencies clarification
If I have XY->Z is it true that we can infer that X->Z because:

XY->ZY so

XY->Z and XY->Y

XY->Y can be decomposed to X->Y

and since X->Y we can decompose XY->Z to X->Z

Is this correct?

答:
No, it isn't correct.  It would mean that there can never be a compound key.

Consider X = order number, Y = order item number, and Z = item price.  If your reduction was correct, the order number alone would determine the item price, but in most order systems, there can be multiple items in an order with different item prices.  It makes sense for XY⟶Z, but X⟶Z is fallacious in general.

Title: Functional Dependencies clarification


问:
Trying to make a BLE app with Ionic and Angular using the cordova plugin
I am struggling installing everything properly. It seems that cordova and Ionic are not compatible anymore? I don't know.

I am following along with the docs from ionic, and the github they link there https://github.com/don/cordova-plugin-ble-central .
Installing the cordova BLE plugin using the command line ionic cordova plugin add cordova-plugin-ble-central lets the program recognize the BLE import from here
import { BLE } from '@ionic-native/ble/ngx';, but then the app stops building anything. I just get a blank screen.

Can someone walk me through setting up an ionic/angular project and adding the cordova plugin for BLE. I think I understand how to use the plugin, the docs are pretty thorough there, but the installing part is difficult.

答:
Try using this plugin instead. https://ionicframework.com/docs/native/bluetooth-le.
I've been using that plugin for a few years on ionic v3.</p>


问:
What is Amazon S3 Staging Directory relevant for?
I am trying to understand what is the relevance of "S3 staging directory".

Connect to your S3 data with the Amazon Athena connector in Tableau 10.3 | Tableau Software

It is a mandatory field in order to connect Tableau with Amazon Athena, but changing it doesn't affect the Catalogue and Database listing (which comes after successful Signin) at all as I tried multiple directories for the same set of Access Key ID and Secret Access Key.

Not just that, it allows to put any arbitrary directory path in there (add garbage path). Signin passes on solely based on valid credentials.

答:
The article you linked says that the Amazon S3 Staging Directory is called Query Result Location in AWS.

From Working with Query Results, Output Files, and Query History - Amazon Athena:

Amazon Athena automatically stores query results and metadata information for each query that runs in a query result location that you can specify in Amazon S3. If necessary, you can access the files in this location to work with them. You can also download query result files directly from the Athena console.

Basically, Athena stores output in that Amazon S3 bucket. If it isn't specified, Athena can raise errors.

It is handy for retrieving query history, and can also be used to chain the result of one query as the input into another query.


问:
View primary key in DBeaver
Is there a quick way to view the primary key of a table in DBeaver? Like e.g. in the Eclipse data source explorer, where primary key rows are marked with "PK" and a special symbol.

答:
As per this github post, some database types (at least MySQL and PostgreSQL) show a small lightbulb to the left of the column name. This is visible in the Properties, Data and ER Diagram tabs.

Example with PostgreSQL:

Title: View primary key in DBeaver


问:
I have an array contains string values, in that same name i have image in drawable.so i want to add in integer array how to do that?
I have an array contains string values, in that same name i have image in drawable.so i want to add in integer array how to do that? ex string newarray[]={"jj","kk","ll"};
i want to access R.drawable.jj ,R.drwable.kk,R.drawable.ll</p>

答:
To access the drawables you need an int. Instead of saving the names in a String array, save the IDs in an int array:

```<code>int[] drawables = {R.drawable.jj, R.drawable.kk, R.drawable.ll};
</code>```

Then all you need to do to access them is call:

```<code>getResources().getDrawable(drawables[0]);
</code>```

ContentLicense: CC BY-SA 3.0

Body:
To access the drawables you need an int. Instead of saving the names in a String array, save the IDs in an int array:

int[] drawables = {R.drawable.jj, R.drawable.kk, R.drawable.ll};

Then all you need to do to access them is call:

getResources().getDrawable(drawables[0]);


问:
C++ forward declarations with multiple classes, derived class
Currently I have 3 classes, set up like this:

World.h

```<code>include "WorldObject.h"
class WorldObject;
class TextObject; // when this is added, compiles fine, but tobj is incomplete when accessed
//(world->tobj->function()).  if #include "TextObject.h" is added, numerous errors occur within TextObject.h
class World {
public:
      WorldObject* wobj; // works fine
      TextObject* tobj; //trying to get this to be functional
};
</code>```

WorldObject.h

```<code>#include "World.h"
class World;
class WorldObject {
public:
      WorldObject(World* world){...} // works fine, world can be accessed from world objects
};
</code>```

TextObject.h

```<code>#include "WorldObject.h"
#include "World.h"
class TextObject : WorldObject {
public:
      TextObject(World* world) : WorldObject(w){...};
};
</code>```

How can I use forward declaration so that tobj will be accessible from World.h, as obj is, with no errors?  I am also using #pragma once at the beginning of each class.  I have attempted to add "class World" to TextObject.h and "class TextObject" to World.h, but none of the seemingly standard procedures are working.  Any suggestions?

答:
#include <WorldObject.h> in your .cpp file rather than your header and you can access it from there.

Your header includes are causing circular dependencies, which you avoid through forward declarations.

Body:
Currently I have 3 classes, set up like this:

World.h

include "WorldObject.h"
class WorldObject;
class TextObject; // when this is added, compiles fine, but tobj is incomplete when accessed
//(world->tobj->function()).  if #include "TextObject.h" is added, numerous errors occur within TextObject.h
class World {
public:
      WorldObject* wobj; // works fine
      TextObject* tobj; //trying to get this to be functional
};

WorldObject.h

#include "World.h"
class World;
class WorldObject {
public:
      WorldObject(World* world){...} // works fine, world can be accessed from world objects
};

TextObject.h

#include "WorldObject.h"
#include "World.h"
class TextObject : WorldObject {
public:
      TextObject(World* world) : WorldObject(w){...};
};

How can I use forward declaration so that tobj will be accessible from World.h, as obj is, with no errors?  I am also using #pragma once at the beginning of each class.  I have attempted to add "class World" to TextObject.h and "class TextObject" to World.h, but none of the seemingly standard procedures are working.  Any suggestions?


问:
AspectJ autoproxy fails with GigaSpaces 8 and Spring 3 because class is loaded by different classloader
We're using GigaSpaces version 8.0.0 (yes it's old) along with Spring 3 (yes it's also old). There are two modules A and B. A is the "main" module that reads and writes to the space and exposes some remote services. A and B run separately. B creates an instance of an entity that has a field that is a class object. This class only exists in B; A does not know about it. It then makes a remote call to A that ends up writing the instance to the space.

Later, A loads up this entity and creates an instance of the remote class by doing entity.getClassObject().newInstance(). This works even though this class doesn't exist in the A's runtime classloader, because the classloader for this class is the LRMI (light remote-method invocation) classloader that comes with GigaSpaces. I guess it knows how to instantiate it.

The problem arose when we added an aspect to A. We have existing code that autowires an instance of the remote class using A's application context and also initializes it using initializeBean. The autowiring and initialization worked fine until we added the aspect. Now, during initialization, it attempts to see if the advices in the aspect apply to the bean that is being initialized. As part of this process, it attempts to create an instance of the class using Class.forName and the bean's class' name. This results in a ClassNotFoundException because the class obviously does not exist in the runtime class loader. So AspectJ resolves the type as MissingResolvedTypeWithKnownSignature instead of failing immediately. But eventually there is a failure when AspectJ tries to find the superclass of the class because it doesn't have that information, and it throws the following exception:

```<code>org.aspectj.weaver.reflect.ReflectionWorld$ReflectionWorldException: warning can't determine implemented interfaces of missing type com.mypackage.MyRemoteClass
 [Xlint:cantFindType]
        at org.aspectj.weaver.reflect.ReflectionWorld$ExceptionBasedMessageHandler.handleMessage(ReflectionWorld.java:129)
        at org.aspectj.weaver.Lint$Kind.signal(Lint.java:328)
        at org.aspectj.weaver.MissingResolvedTypeWithKnownSignature.raiseCantFindType(MissingResolvedTypeWithKnownSignature.java:232)
        at org.aspectj.weaver.MissingResolvedTypeWithKnownSignature.getDeclaredInterfaces(MissingResolvedTypeWithKnownSignature.java:86)
        at org.aspectj.weaver.ResolvedType.getDirectSupertypes(ResolvedType.java:82)
        at org.aspectj.weaver.patterns.TypePattern.matchesSubtypes(TypePattern.java:178)
        at org.aspectj.weaver.patterns.ExactTypePattern.matchesSubtypes(ExactTypePattern.java:74)
        at org.aspectj.weaver.patterns.TypePattern.matchesStatically(TypePattern.java:130)
        at org.aspectj.weaver.patterns.KindedPointcut.fastMatch(KindedPointcut.java:141)
        at org.aspectj.weaver.internal.tools.PointcutExpressionImpl.couldMatchJoinPointsInType(PointcutExpressionImpl.java:84)
        at org.springframework.aop.aspectj.AspectJExpressionPointcut.matches(AspectJExpressionPointcut.java:238)
        at org.springframework.aop.support.AopUtils.canApply(AopUtils.java:200)
        at org.springframework.aop.support.AopUtils.canApply(AopUtils.java:254)
        at org.springframework.aop.support.AopUtils.findAdvisorsThatCanApply(AopUtils.java:286)
        at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.findAdvisorsThatCanApply(AbstractAdvisorAutoProxyCreator.java:117)
        at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.findEligibleAdvisors(AbstractAdvisorAutoProxyCreator.java:87)
        at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.getAdvicesAndAdvisorsForBean(AbstractAdvisorAutoProxyCreator.java:68)
        at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.wrapIfNecessary(AbstractAutoProxyCreator.java:359)
        at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.postProcessAfterInitialization(AbstractAutoProxyCreator.java:322)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsAfterInitialization(AbstractAutowireCapableBeanFactory.java:407)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1426)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:386)
...
</code>```

Is there any way around this? I can think of two approaches, but I'm not exactly sure how to go about it. One is to somehow prevent Spring from checking to see if the aspect applies, and the other is perhaps to swap out the runtime classloader with one that delegates to the LRMI classloader if it can't find a class in the runtime class loader. But I'm not sure if I can even get an instance of the LRMI classloader.

Has anyone run into this sort of issue?

答: This is a known issue in the version of AspectJ that I was using (1.6.12). It appears to have been fixed in later versions -- at least since 1.8.14 (which is what I upgraded it to). So upgrading my version of AspectJ fixed this issue.</p>

Body:
We're using GigaSpaces version 8.0.0 (yes it's old) along with Spring 3 (yes it's also old). There are two modules A and B. A is the "main" module that reads and writes to the space and exposes some remote services. A and B run separately. B creates an instance of an entity that has a field that is a class object. This class only exists in B; A does not know about it. It then makes a remote call to A that ends up writing the instance to the space.

Later, A loads up this entity and creates an instance of the remote class by doing entity.getClassObject().newInstance(). This works even though this class doesn't exist in the A's runtime classloader, because the classloader for this class is the LRMI (light remote-method invocation) classloader that comes with GigaSpaces. I guess it knows how to instantiate it.

The problem arose when we added an aspect to A. We have existing code that autowires an instance of the remote class using A's application context and also initializes it using initializeBean. The autowiring and initialization worked fine until we added the aspect. Now, during initialization, it attempts to see if the advices in the aspect apply to the bean that is being initialized. As part of this process, it attempts to create an instance of the class using Class.forName and the bean's class' name. This results in a ClassNotFoundException because the class obviously does not exist in the runtime class loader. So AspectJ resolves the type as MissingResolvedTypeWithKnownSignature instead of failing immediately. But eventually there is a failure when AspectJ tries to find the superclass of the class because it doesn't have that information, and it throws the following exception:

org.aspectj.weaver.reflect.ReflectionWorld$ReflectionWorldException: warning can't determine implemented interfaces of missing type com.mypackage.MyRemoteClass
 [Xlint:cantFindType]
        at org.aspectj.weaver.reflect.ReflectionWorld$ExceptionBasedMessageHandler.handleMessage(ReflectionWorld.java:129)
        at org.aspectj.weaver.Lint$Kind.signal(Lint.java:328)
        at org.aspectj.weaver.MissingResolvedTypeWithKnownSignature.raiseCantFindType(MissingResolvedTypeWithKnownSignature.java:232)
        at org.aspectj.weaver.MissingResolvedTypeWithKnownSignature.getDeclaredInterfaces(MissingResolvedTypeWithKnownSignature.java:86)
        at org.aspectj.weaver.ResolvedType.getDirectSupertypes(ResolvedType.java:82)
        at org.aspectj.weaver.patterns.TypePattern.matchesSubtypes(TypePattern.java:178)
        at org.aspectj.weaver.patterns.ExactTypePattern.matchesSubtypes(ExactTypePattern.java:74)
        at org.aspectj.weaver.patterns.TypePattern.matchesStatically(TypePattern.java:130)
        at org.aspectj.weaver.patterns.KindedPointcut.fastMatch(KindedPointcut.java:141)
        at org.aspectj.weaver.internal.tools.PointcutExpressionImpl.couldMatchJoinPointsInType(PointcutExpressionImpl.java:84)
        at org.springframework.aop.aspectj.AspectJExpressionPointcut.matches(AspectJExpressionPointcut.java:238)
        at org.springframework.aop.support.AopUtils.canApply(AopUtils.java:200)
        at org.springframework.aop.support.AopUtils.canApply(AopUtils.java:254)
        at org.springframework.aop.support.AopUtils.findAdvisorsThatCanApply(AopUtils.java:286)
        at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.findAdvisorsThatCanApply(AbstractAdvisorAutoProxyCreator.java:117)
        at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.findEligibleAdvisors(AbstractAdvisorAutoProxyCreator.java:87)
        at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.getAdvicesAndAdvisorsForBean(AbstractAdvisorAutoProxyCreator.java:68)
        at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.wrapIfNecessary(AbstractAutoProxyCreator.java:359)
        at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.postProcessAfterInitialization(AbstractAutoProxyCreator.java:322)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsAfterInitialization(AbstractAutowireCapableBeanFactory.java:407)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1426)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:386)
...

Is there any way around this? I can think of two approaches, but I'm not exactly sure how to go about it. One is to somehow prevent Spring from checking to see if the aspect applies, and the other is perhaps to swap out the runtime classloader with one that delegates to the LRMI classloader if it can't find a class in the runtime class loader. But I'm not sure if I can even get an instance of the LRMI classloader.

Has anyone run into this sort of issue?


问:
Foreign key mismatch when insert (SQLite)
So here's my sqlite code..

```<code>CREATE TABLE "performance" (
    "title" TEXT,
    "date"  date,
    "theaterID" INTEGER,

PRIMARY KEY("title","date","theaterID"),

    FOREIGN KEY("title") REFERENCES "movies"("title"),
    FOREIGN KEY("theaterID") REFERENCES "theater"("theaterID")
);

CREATE TABLE "reservation" (
    "userName"  TEXT,
    "reservationID" INTEGER auto_increment,
    "date"  date,
    "theaterID" INTEGER,
    PRIMARY KEY("userName","reservationID","date","theaterID"),
    FOREIGN KEY("date") REFERENCES "performance"("date"),
    FOREIGN KEY("userName") REFERENCES "user"("userName"),
    FOREIGN KEY("theaterID") REFERENCES "theater"("theaterID")
);
</code>```

And I make following inserts in specific order:

```<code>INSERT INTO performance(title,date,theaterID)
VALUES("The Godfather", 20200230, 9);

INSERT INTO reservation(userName,reservationID,date,theaterID)
VALUES("user1", 1 , 20200230, 9);
</code>```

Everything works until I try to insert a reservation. I get the following error:

"foreign key mismatch error - 'reservation' referencing 'performance'"

I can't seem to find the reason for it? What changes do I have to do?

答:
You have:

```<code>FOREIGN KEY("date") REFERENCES "performance"("date"),
</code>```

However, the primary key on performance has THREE parts:

```<code>PRIMARY KEY("title", "date", "theaterID"),
</code>```

You need to reference all three -- in the correct order -- in the foreign key declaration:

```<code>FOREIGN KEY("date") REFERENCES "performance"("title", "date", "theaterID"),
</code>```

However, "title" is not in the table, so you have to add that.

OR, just add an auto-incrementing primary key to "performance" and use that for the reference.

Also, drop the double quotes.  They just make SQL harder to write and read.  And answers harder to write.

Body:
So here's my sqlite code..

CREATE TABLE "performance" (
    "title" TEXT,
    "date"  date,
    "theaterID" INTEGER,

PRIMARY KEY("title","date","theaterID"),

    FOREIGN KEY("title") REFERENCES "movies"("title"),
    FOREIGN KEY("theaterID") REFERENCES "theater"("theaterID")
);

CREATE TABLE "reservation" (
    "userName"  TEXT,
    "reservationID" INTEGER auto_increment,
    "date"  date,
    "theaterID" INTEGER,
    PRIMARY KEY("userName","reservationID","date","theaterID"),
    FOREIGN KEY("date") REFERENCES "performance"("date"),
    FOREIGN KEY("userName") REFERENCES "user"("userName"),
    FOREIGN KEY("theaterID") REFERENCES "theater"("theaterID")
);

And I make following inserts in specific order:

INSERT INTO performance(title,date,theaterID)
VALUES("The Godfather", 20200230, 9);

INSERT INTO reservation(userName,reservationID,date,theaterID)
VALUES("user1", 1 , 20200230, 9);

Everything works until I try to insert a reservation. I get the following error:

"foreign key mismatch error - 'reservation' referencing 'performance'"

I can't seem to find the reason for it? What changes do I have to do?

Body:
You have:

FOREIGN KEY("date") REFERENCES "performance"("date"),

However, the primary key on performance has THREE parts:

PRIMARY KEY("title", "date", "theaterID"),

You need to reference all three -- in the correct order -- in the foreign key declaration:

FOREIGN KEY("date") REFERENCES "performance"("title", "date", "theaterID"),

However, "title" is not in the table, so you have to add that.

OR, just add an auto-incrementing primary key to "performance" and use that for the reference.

Also, drop the double quotes.  They just make SQL harder to write and read.  And answers harder to write.


问:
PHP bind_param save number as i or s what difference does it make?
When we do PHP prepare statement, we need to specify bind type such as i, s, d, b.  What difference does it make if I bind a number as "s" string?  </p>

答:
It makes a difference in how the database driver (i.e. php) sends the data to your DBMS. When binding a type the data is first cast to that specific type and then sent along the wire to your DBMS. For example, say the value you have in PHP is the string "9223372036854775808". If you bind it as a string the data is sent along to the DBMS as a string and the DBMS is free to do whatever internal casting it needs to pack and store the value under the specified column type. However, if you bind it as an integer PHP is the one to do the cast first, before sending it over the wire. This means the value first becomes (int) "9223372036854775808" which results in the value 9223372036854775807 and is then packed as binary payload of 0xffffffff. The result is the DBMS will accept the data as is without further changes.

This, of course, creates different side effects. For example, integer size (32 bit vs 64 bit vs arbitrary precision) can vary depending on who controls the cast and pack operations. Further more, the onus on checking for integer overflow/wrap precision falls on the side of who does the cast and pack (the driver versus the DBMS). Additional side effects include payload size that goes over the wire. A string is larger than a packed binary integer.

Ideally, specificity is a good thing in this case. Because mostly the database can only communicate with php by sending it everything as a string. Though the driver can make smarter decisions about how to represent that data inside of PHP (which should matter to the programmer) given a more specific representation of how this data is bound between the two ends.


问:
Hovering over the legend will hide all lines except the corresponding line
When you hover over the legend, all lines except the corresponding line will be hidden. How to achieve this via bokeh, python or javascript. I have no idea what to do to achieve this function. It would be great if we could provide a simple example with three lines.Thanks for your help.My code example is as follows:</p>

```<code>import bokeh.palettes as bp
from bokeh.plotting import figure, output_file, show, ColumnDataSource
from bokeh.models import LinearAxis, Range1d, NumeralTickFormatter, Legend
from bokeh.layouts import column
import numpy as np

if __name__ == '__main__':
    num = 5
    color_list2 = bp.magma(num)
    color_list1 = bp.viridis(num)
    plotTools = 'box_zoom, wheel_zoom, pan, tap, crosshair, hover, reset, save'
    p = figure(plot_width=800, plot_height=400, x_range=(0, 1000), y_range=(-2.5, -1.5),
               tools=plotTools, toolbar_location='right', active_scroll='wheel_zoom', )
    p.title.text = 'Hover and Hide'
    items_c1 = []
    i = 0
    pictures = []
    labels = ['a', 'b', 'c', 'd', 'e']
    for label in labels:
        n = np.random.randint(low=3, high=6)
        xs = np.random.random(n) * 1000
        y1s = np.random.random(n) - 2.5
        temp_line = p.line(xs, y1s, line_width=2, color=color_list1[i % num],
                           alpha=0.3, hover_color='red', hover_alpha=0.9)  # , legend_label=label
        items_c1.append((label + '_BER', [temp_line]))
        i = i + 1
        if i % num == 0:
            legend_1 = Legend(items=items_c1)
            p.add_layout(legend_1, 'left')
            p.xaxis.axis_label = 'run_time'
            p.yaxis[0].axis_label = 'BER'
            p.legend[0].orientation = 'vertical'
            p.legend[0].location = 'bottom_center'
            p.legend[0].click_policy = 'hide'
            pictures.append(p)

            p = figure(plot_width=800, plot_height=400, x_range=(0, 1000), y_range=(-2.5, -1.5),
                       tools=plotTools, toolbar_location='right', active_scroll='wheel_zoom', )
            items_c1 = []
    file = "test_ask_5"
    file_path = file + '.html'
    output_file(file_path)
    show(column(pictures))
</code>```

答:
The solution below hides all lines but the one that is being clicked (not hovered). This code works for Bokeh v1.3.4

```<code>import numpy as np
from bokeh.plotting import figure, show
from bokeh.models import CustomJS

colors = ['orange', 'cyan', 'lightgreen']

p = figure()
lines = [p.line(np.arange(10), np.random.random(10), line_color = colors[i], line_width = 3, legend=colors[i], name=colors[i]) for i in range(3)]

code = '''if(Bokeh != 'undefined' && (Bokeh.active_line === 'undefined' || Bokeh.active_line == null))
          {
              Bokeh.active_line = cb_obj.name;
          }'''
[line.js_on_change('visible', CustomJS(code = code)) for line in lines]

code = ''' for(i = 0; i < lines.length; i++) {
                if (lines[i].name == Bokeh.active_line) {
                    lines[i].visible = true
                }
                else {
                    lines[i].visible = false
                }
            }
            Bokeh.active_line = null'''
p.js_on_event('tap', CustomJS(args = {'lines' : lines}, code = code))

code = '''  for(i = 0; i < lines.length; i++) {
                lines[i].visible = true
            }
            Bokeh.active_line = null'''
p.js_on_event('reset', CustomJS(args = dict(lines = lines), code = code))

p.legend.click_policy = 'hide'

show(p)
</code>```

The first callback is applied to all glyph renderers (lines) and is being triggered when the line must be hidden, that is when a user clicks a legend item. The callback just sets the global variable Bokeh.active_line which remembers the renderer (line) name, e.g. "orange" or "cyan"

The second callback is attached to the plot canvas and is triggered every time the user clicks anywhere on the plot. What is basically does is inverting the glyphs (lines) visibility. It only shows the line specified by
Bokeh.active_line

The third callback is attached to the plot and is triggered when user clicks on the reset tool in the toolbar. It restores visibility of all lines.

Body:
When you hover over the legend, all lines except the corresponding line will be hidden. How to achieve this via bokeh, python or javascript. I have no idea what to do to achieve this function. It would be great if we could provide a simple example with three lines.Thanks for your help.My code example is as follows:

import bokeh.palettes as bp
from bokeh.plotting import figure, output_file, show, ColumnDataSource
from bokeh.models import LinearAxis, Range1d, NumeralTickFormatter, Legend
from bokeh.layouts import column
import numpy as np

if __name__ == '__main__':
    num = 5
    color_list2 = bp.magma(num)
    color_list1 = bp.viridis(num)
    plotTools = 'box_zoom, wheel_zoom, pan, tap, crosshair, hover, reset, save'
    p = figure(plot_width=800, plot_height=400, x_range=(0, 1000), y_range=(-2.5, -1.5),
               tools=plotTools, toolbar_location='right', active_scroll='wheel_zoom', )
    p.title.text = 'Hover and Hide'
    items_c1 = []
    i = 0
    pictures = []
    labels = ['a', 'b', 'c', 'd', 'e']
    for label in labels:
        n = np.random.randint(low=3, high=6)
        xs = np.random.random(n) * 1000
        y1s = np.random.random(n) - 2.5
        temp_line = p.line(xs, y1s, line_width=2, color=color_list1[i % num],
                           alpha=0.3, hover_color='red', hover_alpha=0.9)  # , legend_label=label
        items_c1.append((label + '_BER', [temp_line]))
        i = i + 1
        if i % num == 0:
            legend_1 = Legend(items=items_c1)
            p.add_layout(legend_1, 'left')
            p.xaxis.axis_label = 'run_time'
            p.yaxis[0].axis_label = 'BER'
            p.legend[0].orientation = 'vertical'
            p.legend[0].location = 'bottom_center'
            p.legend[0].click_policy = 'hide'
            pictures.append(p)

            p = figure(plot_width=800, plot_height=400, x_range=(0, 1000), y_range=(-2.5, -1.5),
                       tools=plotTools, toolbar_location='right', active_scroll='wheel_zoom', )
            items_c1 = []
    file = "test_ask_5"
    file_path = file + '.html'
    output_file(file_path)
    show(column(pictures))

Body:
The solution below hides all lines but the one that is being clicked (not hovered). This code works for Bokeh v1.3.4

import numpy as np
from bokeh.plotting import figure, show
from bokeh.models import CustomJS

colors = ['orange', 'cyan', 'lightgreen']

p = figure()
lines = [p.line(np.arange(10), np.random.random(10), line_color = colors[i], line_width = 3, legend=colors[i], name=colors[i]) for i in range(3)]

code = '''if(Bokeh != 'undefined' && (Bokeh.active_line === 'undefined' || Bokeh.active_line == null))
          {
              Bokeh.active_line = cb_obj.name;
          }'''
[line.js_on_change('visible', CustomJS(code = code)) for line in lines]

code = ''' for(i = 0; i < lines.length; i++) {
                if (lines[i].name == Bokeh.active_line) {
                    lines[i].visible = true
                }
                else {
                    lines[i].visible = false
                }
            }
            Bokeh.active_line = null'''
p.js_on_event('tap', CustomJS(args = {'lines' : lines}, code = code))

code = '''  for(i = 0; i < lines.length; i++) {
                lines[i].visible = true
            }
            Bokeh.active_line = null'''
p.js_on_event('reset', CustomJS(args = dict(lines = lines), code = code))

p.legend.click_policy = 'hide'

show(p)

The first callback is applied to all glyph renderers (lines) and is being triggered when the line must be hidden, that is when a user clicks a legend item. The callback just sets the global variable Bokeh.active_line which remembers the renderer (line) name, e.g. "orange" or "cyan"

The second callback is attached to the plot canvas and is triggered every time the user clicks anywhere on the plot. What is basically does is inverting the glyphs (lines) visibility. It only shows the line specified by
Bokeh.active_line

The third callback is attached to the plot and is triggered when user clicks on the reset tool in the toolbar. It restores visibility of all lines.


问:
Not able to reference local WSDL file when using PEX
I have a question about pex  build. So we have this project structure and we are trying to build a pex file off of it.  It has a WSDL file which needs to be referenced in the code. No matter what I do, when I run the pex  file, it throws an exception: File Not Found . Does anyone have any idea how to fix it? I am fairly new to Python.

Below is the folder structure -

```<code>Main_Folder
  Util
    util1.py
      main.py
        WebService.xml
</code>```

I tried this:

```<code>path = os.path.join(os.path.abspath(__file__), 'WebService.xml')
url = urllib.parse.urljoin('file:', urllib.request.pathname2url(os.path.abspath(path)))
</code>```

答:
Welcome to StackOverflow. As the error indicates, the path is not set correctly.

os.path.abspath(__file__) -> Gives you the absolute path of the file. If I run this code from a file named main.py I get the following output.

C:\Users\User1\Desktop\main.py

Example of os.path.join

```<code># Path
path = "/home"

# Join various path components
print(os.path.join(path, "User/Public/", "Documents", ""))
</code>```

Outputs

/home/User/Public/Documents/-> As you can see it joins the directories.

So you should now be able to see the problem you have. You path variable will hold something like this
C:\Users\User1\Desktop\main.py\WebService.xml

So just change it to this  `path = os.path.abspath('WebService.xml')

You can read more about the os module here

Body:
I have a question about pex  build. So we have this project structure and we are trying to build a pex file off of it.  It has a WSDL file which needs to be referenced in the code. No matter what I do, when I run the pex  file, it throws an exception: File Not Found . Does anyone have any idea how to fix it? I am fairly new to Python.

Below is the folder structure -

Main_Folder
  Util
    util1.py
      main.py
        WebService.xml

I tried this:

path = os.path.join(os.path.abspath(__file__), 'WebService.xml')
url = urllib.parse.urljoin('file:', urllib.request.pathname2url(os.path.abspath(path)))

Body:
Welcome to StackOverflow. As the error indicates, the path is not set correctly.

os.path.abspath(__file__) -> Gives you the absolute path of the file. If I run this code from a file named main.py I get the following output.

C:\Users\User1\Desktop\main.py

Example of os.path.join

# Path
path = "/home"

# Join various path components
print(os.path.join(path, "User/Public/", "Documents", ""))

Outputs

/home/User/Public/Documents/-> As you can see it joins the directories.

So you should now be able to see the problem you have. You path variable will hold something like this
C:\Users\User1\Desktop\main.py\WebService.xml

So just change it to this  `path = os.path.abspath('WebService.xml')

You can read more about the os module here


问:
How to return custom data with Access and Refresh Tokens to identify users in Django Rest Framework simple JWT?
In Django, superuser can add more user according to their roll. I'm using simple JWT with DRF for authentication. But it is impossible to detect the type of user only by seeing the Access and Refresh Tokens.

Here are my settings.py file

```<code>REST_FRAMEWORK = {
    'DEFAULT_PERMISSION_CLASSES': ('rest_framework.permissions.IsAuthenticated',),
    'DEFAULT_AUTHENTICATION_CLASSES': ('rest_framework_simplejwt.authentication.JWTAuthentication',),

}
</code>```

urls.py

```<code>from django.contrib import admin
from django.urls import path, include
from rest_framework_simplejwt.views import TokenObtainPairView, TokenRefreshView

urlpatterns = [

    path('admin/', admin.site.urls),
    path('', include('Manage_Merchants.urls')),

    path('api-auth', include('rest_framework.urls')),
    path('api/token/', TokenObtainPairView.as_view(), name='token_obtain_pair'),
    path('api/token/refresh/', TokenRefreshView.as_view(), name='token_refresh'),

]
</code>```

when I hit on 127.0.0.1:8000/api/token/ through Postman it asks for username and password. When I put Username and Password it generates a Refresh and Access Token.
Generate JWT with DRF using Postman

So how can I identify the token is generated for super user or other user created bu superuser? How can I pass more value as a dictionary along with Access and Refresh Tokens to identify the type of user?

答:
In the version djangorestframework-simplejwt==4.4.0 it's the method validate instead of to_representation, meaning:

In your serializer.py you need to override the TokenObtainPairSerializer in order to include all the data you want to send in the response

from rest_framework_simplejwt.serializers import TokenObtainPairSerializer

class CustomTokenObtainPairSerializer(TokenObtainPairSerializer):
    def validate(self, attrs):
        # The default result (access/refresh tokens)
        data = super(CustomTokenObtainPairSerializer, self).validate(attrs)
        # Custom data you want to include
        data.update({'user': self.user.username})
        data.update({'id': self.user.id})
        # and everything else you want to send in the response
        return data
```

<p>Now in your <code>views.py</code> you need to override the TokenObtainPairView in order to pair it with the new serializer.</p>

<pre class="lang-py prettyprint-override"><code>from .serializers import CustomTokenObtainPairSerializer

class CustomTokenObtainPairView(TokenObtainPairView):
    # Replace the serializer with your custom
    serializer_class = CustomTokenObtainPairSerializer
</code>```

Now map your it in your url.py

from rest_framework_simplejwt.views import TokenRefreshView, TokenVerifyView
from . import views

urlpatterns = [
    # This one now has the custom view mapped with the custom serializer that includes the desired data
    path('token/', views.CustomTokenObtainPairView.as_view(), name='token_obtain_pair'),
    path('token/refresh/', TokenRefreshView.as_view(), name='token_refresh'),
    path('token/verify/', TokenVerifyView.as_view(), name='token_verify')
]

```

Body:
In Django, superuser can add more user according to their roll. I'm using simple JWT with DRF for authentication. But it is impossible to detect the type of user only by seeing the Access and Refresh Tokens.

Here are my settings.py file

REST_FRAMEWORK = {
    'DEFAULT_PERMISSION_CLASSES': ('rest_framework.permissions.IsAuthenticated',),
    'DEFAULT_AUTHENTICATION_CLASSES': ('rest_framework_simplejwt.authentication.JWTAuthentication',),

}

urls.py

from django.contrib import admin
from django.urls import path, include
from rest_framework_simplejwt.views import TokenObtainPairView, TokenRefreshView

urlpatterns = [

    path('admin/', admin.site.urls),
    path('', include('Manage_Merchants.urls')),

    path('api-auth', include('rest_framework.urls')),
    path('api/token/', TokenObtainPairView.as_view(), name='token_obtain_pair'),
    path('api/token/refresh/', TokenRefreshView.as_view(), name='token_refresh'),

]

when I hit on 127.0.0.1:8000/api/token/ through Postman it asks for username and password. When I put Username and Password it generates a Refresh and Access Token.
Generate JWT with DRF using Postman

So how can I identify the token is generated for super user or other user created bu superuser? How can I pass more value as a dictionary along with Access and Refresh Tokens to identify the type of user?

Body:
In the version djangorestframework-simplejwt==4.4.0 it's the method validate instead of to_representation, meaning:

In your serializer.py you need to override the TokenObtainPairSerializer in order to include all the data you want to send in the response

from rest_framework_simplejwt.serializers import TokenObtainPairSerializer

class CustomTokenObtainPairSerializer(TokenObtainPairSerializer):
    def validate(self, attrs):
        # The default result (access/refresh tokens)
        data = super(CustomTokenObtainPairSerializer, self).validate(attrs)
        # Custom data you want to include
        data.update({'user': self.user.username})
        data.update({'id': self.user.id})
        # and everything else you want to send in the response
        return data

Now in your views.py you need to override the TokenObtainPairView in order to pair it with the new serializer.

from .serializers import CustomTokenObtainPairSerializer

class CustomTokenObtainPairView(TokenObtainPairView):
    # Replace the serializer with your custom
    serializer_class = CustomTokenObtainPairSerializer

Now map your it in your url.py

from rest_framework_simplejwt.views import TokenRefreshView, TokenVerifyView
from . import views

urlpatterns = [
    # This one now has the custom view mapped with the custom serializer that includes the desired data
    path('token/', views.CustomTokenObtainPairView.as_view(), name='token_obtain_pair'),
    path('token/refresh/', TokenRefreshView.as_view(), name='token_refresh'),
    path('token/verify/', TokenVerifyView.as_view(), name='token_verify')
]