bd2kccd / causal-rest-api

Causal REST API
1 stars 2 forks source link

Database engine #25

Open azzaea opened 5 years ago

azzaea commented 5 years ago

Hello again, I'm wondering if causal-rest-api could also work with h2 instead of mySQL and HSQL? I'm asking because it was easiest to set up h2 while setting up causal-web, while adding a configuration file and a dependency to the pom.xml file as in here.

With the same settings running causal-rest-api generates the error below:

$ java -jar causal-rest-api-1.0.0.jar
2019-09-03 18:15:05.488  INFO 10011 --- [           main] e.p.d.c.c.r.a.CausalRestApiApplication   : Starting CausalRestApiApplication v1.0.0 on fwn-bborg-129-125-75-99 with PID 10011 (/home/p287664/software/causal-rest-api/target/causal-rest-api-1.0.0.jar started by p287664 in /home/p287664/software/causal-rest-api/target)
2019-09-03 18:15:05.496  INFO 10011 --- [           main] e.p.d.c.c.r.a.CausalRestApiApplication   : The following profiles are active: scheduler,h2
2019-09-03 18:15:05.640  INFO 10011 --- [           main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@619a5dff: startup date [Tue Sep 03 18:15:05 CEST 2019]; root of context hierarchy
2019-09-03 18:15:07.449  INFO 10011 --- [           main] o.s.b.f.s.DefaultListableBeanFactory     : Overriding bean definition for bean 'requestContextFilter' with a different definition: replacing [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.boot.autoconfigure.jersey.JerseyAutoConfiguration; factoryMethodName=requestContextFilter; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/boot/autoconfigure/jersey/JerseyAutoConfiguration.class]] with [Root bean: class [org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration$WebMvcAutoConfigurationAdapter]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=requestContextFilter; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/boot/autoconfigure/web/WebMvcAutoConfiguration$WebMvcAutoConfigurationAdapter.class]]
2019-09-03 18:15:07.663  INFO 10011 --- [           main] o.s.b.f.s.DefaultListableBeanFactory     : Overriding bean definition for bean 'managementServletContext' with a different definition: replacing [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.boot.actuate.autoconfigure.EndpointWebMvcHypermediaManagementContextConfiguration; factoryMethodName=managementServletContext; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/boot/actuate/autoconfigure/EndpointWebMvcHypermediaManagementContextConfiguration.class]] with [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.boot.actuate.autoconfigure.EndpointWebMvcAutoConfiguration; factoryMethodName=managementServletContext; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/boot/actuate/autoconfigure/EndpointWebMvcAutoConfiguration.class]]
2019-09-03 18:15:08.779  INFO 10011 --- [           main] f.a.AutowiredAnnotationBeanPostProcessor : JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
2019-09-03 18:15:09.160  INFO 10011 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$ce16ab12] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2019-09-03 18:15:09.799  INFO 10011 --- [           main] org.eclipse.jetty.util.log               : Logging initialized @5895ms to org.eclipse.jetty.util.log.Slf4jLog
2019-09-03 18:15:09.992  INFO 10011 --- [           main] e.j.JettyEmbeddedServletContainerFactory : Server initialized with port: 9000
2019-09-03 18:15:09.999  INFO 10011 --- [           main] org.eclipse.jetty.server.Server          : jetty-9.4.7.v20170914
2019-09-03 18:15:10.559  INFO 10011 --- [           main] org.eclipse.jetty.server.session         : DefaultSessionIdManager workerName=node0
2019-09-03 18:15:10.560  INFO 10011 --- [           main] org.eclipse.jetty.server.session         : No SessionScavenger set, using defaults
2019-09-03 18:15:10.566  INFO 10011 --- [           main] org.eclipse.jetty.server.session         : Scavenging every 660000ms
2019-09-03 18:15:10.575  INFO 10011 --- [           main] o.e.j.s.h.ContextHandler.application     : Initializing Spring embedded WebApplicationContext
2019-09-03 18:15:10.577  INFO 10011 --- [           main] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 4941 ms
2019-09-03 18:15:11.518  INFO 10011 --- [           main] o.s.b.w.servlet.ServletRegistrationBean  : Mapping servlet: 'edu.pitt.dbmi.ccd.causal.rest.api.conf.JerseyConfig' to [/*]
2019-09-03 18:15:11.523  INFO 10011 --- [           main] o.s.b.w.servlet.ServletRegistrationBean  : Mapping servlet: 'dispatcherServlet' to [/]
2019-09-03 18:15:11.525  INFO 10011 --- [           main] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'metricsFilter' to: [/*]
2019-09-03 18:15:11.525  INFO 10011 --- [           main] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'characterEncodingFilter' to: [/*]
2019-09-03 18:15:11.525  INFO 10011 --- [           main] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2019-09-03 18:15:11.527  INFO 10011 --- [           main] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2019-09-03 18:15:11.527  INFO 10011 --- [           main] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'requestContextFilter' to: [/*]
2019-09-03 18:15:11.527  INFO 10011 --- [           main] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'webRequestLoggingFilter' to: [/*]
2019-09-03 18:15:11.527  INFO 10011 --- [           main] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'applicationContextIdFilter' to: [/*]
2019-09-03 18:15:11.536  INFO 10011 --- [           main] o.e.jetty.server.handler.ContextHandler  : Started o.s.b.c.e.j.JettyEmbeddedWebAppContext@6c779568{/ccd-api,[file:///tmp/jetty-docbase.4294236600939947476.9000/],AVAILABLE}
2019-09-03 18:15:11.537  INFO 10011 --- [           main] org.eclipse.jetty.server.Server          : Started @7635ms
2019-09-03 18:15:12.682  INFO 10011 --- [           main] j.LocalContainerEntityManagerFactoryBean : Building JPA container EntityManagerFactory for persistence unit 'default'
2019-09-03 18:15:15.713  WARN 10011 --- [           main] ationConfigEmbeddedWebApplicationContext : 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/HibernateJpaAutoConfiguration.class]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: default] Unable to build Hibernate SessionFactory
2019-09-03 18:15:15.722  INFO 10011 --- [           main] org.eclipse.jetty.server.session         : Stopped scavenging
2019-09-03 18:15:15.726  INFO 10011 --- [           main] o.e.jetty.server.handler.ContextHandler  : Stopped o.s.b.c.e.j.JettyEmbeddedWebAppContext@6c779568{/ccd-api,[file:///tmp/jetty-docbase.4294236600939947476.9000/],UNAVAILABLE}
2019-09-03 18:15:15.755  INFO 10011 --- [           main] utoConfigurationReportLoggingInitializer : 

Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled.
2019-09-03 18:15:15.777 ERROR 10011 --- [           main] o.s.boot.SpringApplication               : Application startup failed

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfiguration.class]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: default] Unable to build Hibernate SessionFactory
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1628) ~[spring-beans-4.3.13.RELEASE.jar!/:4.3.13.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:555) ~[spring-beans-4.3.13.RELEASE.jar!/:4.3.13.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483) ~[spring-beans-4.3.13.RELEASE.jar!/:4.3.13.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) ~[spring-beans-4.3.13.RELEASE.jar!/:4.3.13.RELEASE]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.3.13.RELEASE.jar!/:4.3.13.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.3.13.RELEASE.jar!/:4.3.13.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) ~[spring-beans-4.3.13.RELEASE.jar!/:4.3.13.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1080) ~[spring-context-4.3.13.RELEASE.jar!/:4.3.13.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:857) ~[spring-context-4.3.13.RELEASE.jar!/:4.3.13.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:543) ~[spring-context-4.3.13.RELEASE.jar!/:4.3.13.RELEASE]
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) ~[spring-boot-1.5.9.RELEASE.jar!/:1.5.9.RELEASE]
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:693) [spring-boot-1.5.9.RELEASE.jar!/:1.5.9.RELEASE]
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:360) [spring-boot-1.5.9.RELEASE.jar!/:1.5.9.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:303) [spring-boot-1.5.9.RELEASE.jar!/:1.5.9.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1118) [spring-boot-1.5.9.RELEASE.jar!/:1.5.9.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1107) [spring-boot-1.5.9.RELEASE.jar!/:1.5.9.RELEASE]
    at edu.pitt.dbmi.ccd.causal.rest.api.CausalRestApiApplication.main(CausalRestApiApplication.java:41) [classes!/:1.0.0]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_222]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_222]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_222]
    at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_222]
    at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48) [causal-rest-api-1.0.0.jar:1.0.0]
    at org.springframework.boot.loader.Launcher.launch(Launcher.java:87) [causal-rest-api-1.0.0.jar:1.0.0]
    at org.springframework.boot.loader.Launcher.launch(Launcher.java:50) [causal-rest-api-1.0.0.jar:1.0.0]
    at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:51) [causal-rest-api-1.0.0.jar:1.0.0]
Caused by: javax.persistence.PersistenceException: [PersistenceUnit: default] Unable to build Hibernate SessionFactory
    at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.persistenceException(EntityManagerFactoryBuilderImpl.java:954) ~[hibernate-entitymanager-5.0.12.Final.jar!/:5.0.12.Final]
    at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:882) ~[hibernate-entitymanager-5.0.12.Final.jar!/:5.0.12.Final]
    at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:60) ~[spring-orm-4.3.13.RELEASE.jar!/:4.3.13.RELEASE]
    at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:360) ~[spring-orm-4.3.13.RELEASE.jar!/:4.3.13.RELEASE]
    at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:382) ~[spring-orm-4.3.13.RELEASE.jar!/:4.3.13.RELEASE]
    at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:371) ~[spring-orm-4.3.13.RELEASE.jar!/:4.3.13.RELEASE]
    at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.afterPropertiesSet(LocalContainerEntityManagerFactoryBean.java:336) ~[spring-orm-4.3.13.RELEASE.jar!/:4.3.13.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1687) ~[spring-beans-4.3.13.RELEASE.jar!/:4.3.13.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1624) ~[spring-beans-4.3.13.RELEASE.jar!/:4.3.13.RELEASE]
    ... 24 common frames omitted
Caused by: org.hibernate.tool.schema.spi.SchemaManagementException: Unable to execute schema management to JDBC target [create table "oauth_client_details" ("client_id" varchar(255) not null, "access_token_validity" "INT(11)", "additional_information" varchar(4096), "authorities" varchar(255), "authorized_grant_types" varchar(255), "autoapprove" varchar(255), "client_secret" varchar(255), "refresh_token_validity" "INT(11)", "resource_ids" varchar(255), "scope" varchar(255), "web_server_redirect_uri" varchar(255), primary key ("client_id"))]
    at org.hibernate.tool.schema.internal.TargetDatabaseImpl.accept(TargetDatabaseImpl.java:59) ~[hibernate-core-5.0.12.Final.jar!/:5.0.12.Final]
    at org.hibernate.tool.schema.internal.SchemaMigratorImpl.applySqlString(SchemaMigratorImpl.java:431) ~[hibernate-core-5.0.12.Final.jar!/:5.0.12.Final]
    at org.hibernate.tool.schema.internal.SchemaMigratorImpl.applySqlStrings(SchemaMigratorImpl.java:420) ~[hibernate-core-5.0.12.Final.jar!/:5.0.12.Final]
    at org.hibernate.tool.schema.internal.SchemaMigratorImpl.createTable(SchemaMigratorImpl.java:236) ~[hibernate-core-5.0.12.Final.jar!/:5.0.12.Final]
    at org.hibernate.tool.schema.internal.SchemaMigratorImpl.doMigrationToTargets(SchemaMigratorImpl.java:167) ~[hibernate-core-5.0.12.Final.jar!/:5.0.12.Final]
    at org.hibernate.tool.schema.internal.SchemaMigratorImpl.doMigration(SchemaMigratorImpl.java:60) ~[hibernate-core-5.0.12.Final.jar!/:5.0.12.Final]
    at org.hibernate.tool.hbm2ddl.SchemaUpdate.execute(SchemaUpdate.java:134) ~[hibernate-core-5.0.12.Final.jar!/:5.0.12.Final]
    at org.hibernate.tool.hbm2ddl.SchemaUpdate.execute(SchemaUpdate.java:101) ~[hibernate-core-5.0.12.Final.jar!/:5.0.12.Final]
    at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:472) ~[hibernate-core-5.0.12.Final.jar!/:5.0.12.Final]
    at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:444) ~[hibernate-core-5.0.12.Final.jar!/:5.0.12.Final]
    at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:879) ~[hibernate-entitymanager-5.0.12.Final.jar!/:5.0.12.Final]
    ... 31 common frames omitted
Caused by: org.h2.jdbc.JdbcSQLNonTransientException: Unknown data type: "INT(11)"; SQL statement:
create table "oauth_client_details" ("client_id" varchar(255) not null, "access_token_validity" "INT(11)", "additional_information" varchar(4096), "authorities" varchar(255), "authorized_grant_types" varchar(255), "autoapprove" varchar(255), "client_secret" varchar(255), "refresh_token_validity" "INT(11)", "resource_ids" varchar(255), "scope" varchar(255), "web_server_redirect_uri" varchar(255), primary key ("client_id")) [50004-199]
    at org.h2.message.DbException.getJdbcSQLException(DbException.java:502) ~[h2-1.4.199.jar!/:na]
    at org.h2.message.DbException.getJdbcSQLException(DbException.java:427) ~[h2-1.4.199.jar!/:na]
    at org.h2.message.DbException.get(DbException.java:205) ~[h2-1.4.199.jar!/:na]
    at org.h2.message.DbException.get(DbException.java:181) ~[h2-1.4.199.jar!/:na]
    at org.h2.command.Parser.parseColumnWithType(Parser.java:5524) ~[h2-1.4.199.jar!/:na]
    at org.h2.command.Parser.parseColumnForTable(Parser.java:5254) ~[h2-1.4.199.jar!/:na]
    at org.h2.command.Parser.parseTableColumnDefinition(Parser.java:7932) ~[h2-1.4.199.jar!/:na]
    at org.h2.command.Parser.parseCreateTable(Parser.java:7832) ~[h2-1.4.199.jar!/:na]
    at org.h2.command.Parser.parseCreate(Parser.java:5818) ~[h2-1.4.199.jar!/:na]
    at org.h2.command.Parser.parsePrepared(Parser.java:846) ~[h2-1.4.199.jar!/:na]
    at org.h2.command.Parser.parse(Parser.java:788) ~[h2-1.4.199.jar!/:na]
    at org.h2.command.Parser.parse(Parser.java:760) ~[h2-1.4.199.jar!/:na]
    at org.h2.command.Parser.prepareCommand(Parser.java:683) ~[h2-1.4.199.jar!/:na]
    at org.h2.engine.Session.prepareLocal(Session.java:627) ~[h2-1.4.199.jar!/:na]
    at org.h2.engine.Session.prepareCommand(Session.java:565) ~[h2-1.4.199.jar!/:na]
    at org.h2.jdbc.JdbcConnection.prepareCommand(JdbcConnection.java:1292) ~[h2-1.4.199.jar!/:na]
    at org.h2.jdbc.JdbcStatement.executeUpdateInternal(JdbcStatement.java:165) ~[h2-1.4.199.jar!/:na]
    at org.h2.jdbc.JdbcStatement.executeUpdate(JdbcStatement.java:126) ~[h2-1.4.199.jar!/:na]
    at sun.reflect.GeneratedMethodAccessor24.invoke(Unknown Source) ~[na:na]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_222]
    at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_222]
    at org.apache.tomcat.jdbc.pool.StatementFacade$StatementProxy.invoke(StatementFacade.java:114) ~[tomcat-jdbc-8.5.23.jar!/:na]
    at com.sun.proxy.$Proxy116.executeUpdate(Unknown Source) ~[na:na]
    at org.hibernate.tool.schema.internal.TargetDatabaseImpl.accept(TargetDatabaseImpl.java:56) ~[hibernate-core-5.0.12.Final.jar!/:5.0.12.Final]
    ... 41 common frames omitted

If it is not much to ask, a workaround with h2 would really be appreciated, as it has been quite straight forward to work with it thus far. Else, would you kindly be able to provide a hint into configuring mySQL? I tried to download a server from here, but I see this application (MySQL Workbench) in my PC (shared university PC, so no root access); but I'm not sure where to go

image

My due gratitudes, and apologies for the volume of these issues.

Kind regards, Azza

kvb2univpitt commented 5 years ago

@azzaea Did you create a application-h2.properties like this one https://github.com/bd2kccd/causal-web/issues/78#issuecomment-523624927 ?

azzaea commented 5 years ago

Yes, I copied the exact same file application-h2.properties over, modified the application.properties entry: spring.profiles.active=scheduler,h2 and added the same dependency lines (repeated below) to the pom.xml file

        <dependency>
            <groupId>com.h2database</groupId>
            <artifactId>h2</artifactId>
            <version>1.4.199</version>
        </dependency>
kvb2univpitt commented 5 years ago

@azzaea Sorry for the late reply. I have been busy with other projects.

By the way, you don't need the version tag. H2 is already part of Spring Boot. You can just add the following to the POM.xml:

<dependency>
    <groupId>com.h2database</groupId>
    <artifactId>h2</artifactId>
</dependency>

Remove the following line from the JPA section in the application.properties file:

spring.jpa.properties.hibernate.globally_quoted_identifiers=true

The application.properties file should look like this:

# APPLICATION SETTINGS (SpringApplication)
spring.main.banner-mode=off

# PROFILES
# scheduler, slurm
# hsqldb, mysql
spring.profiles.active=scheduler,h2

# LOGGING
logging.file=causal_rest_api.log
logging.level.*=INFO
logging.level.org.springframework.web=INFO
logging.level.org.hibernate=ERROR

# EMBEDDED SERVER CONFIGURATION (ServerProperties)
server.port=9000
server.session-timeout=-1
server.context-path=/ccd-api/

# JPA (JpaBaseConfiguration, HibernateJpaAutoConfiguration)
# Hibernate ddl auto (create, create-drop, update)
spring.jpa.hibernate.ddl-auto=update
spring.jpa.show-sql=false

# MULTIPART (MultipartProperties)
# Enable support of multi-part uploads
spring.http.multipart.enabled=true
spring.http.multipart.max-file-size=-1
spring.http.multipart.max-request-size=-1
azzaea commented 5 years ago

Thank you much for your patience @kvb2univpitt !

The API server now works- the last few lines in the log are below. However, I'm not able to move from this step forward. I understand this sets the server at: 0.0.0.0:9000 (which is what I should use instead of the Pittsburgh supercomputer server https://ccd4.vm.bridges.psc.edu demonstrated in the documentation here).

As a starter, the GET command returns back authentication error, and the POST doesn't give anything. Would you kindly advise?

Time and again, very grateful for you help indeed. Azza


$ GET 0.0.0.0:9000/ccd-api/jwt
{"timestamp":1567622489648,"status":401,"error":"Unauthorized","message":"User credentials are required.","path":"/jwt"} 

$ POST /ccd-api/jwt HTTP/1.1                                                                                                                                                
Please enter content (application/x-www-form-urlencoded) to be POSTed:
Host: 0.0.0.0:9000
Authorization: Basic ZGVtb0BwaXR0LmVkdToxMjM=

# Nothing happens- I have to manually cancel the command

And, on a different terminal- the causal-rest-api is on:

$ java -jar causal-rest-api.jar
:
:
019-09-04 20:29:52.055  INFO 21653 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Registering beans for JMX exposure on startup
2019-09-04 20:29:52.094  INFO 21653 --- [           main] o.s.c.support.DefaultLifecycleProcessor  : Starting beans in phase 0
2019-09-04 20:29:53.563  INFO 21653 --- [           main] o.e.j.s.h.ContextHandler.application     : Initializing Spring FrameworkServlet 'dispatcherServlet'
2019-09-04 20:29:53.565  INFO 21653 --- [           main] o.s.web.servlet.DispatcherServlet        : FrameworkServlet 'dispatcherServlet': initialization started
2019-09-04 20:29:53.607  INFO 21653 --- [           main] o.s.web.servlet.DispatcherServlet        : FrameworkServlet 'dispatcherServlet': initialization completed in 42 ms
2019-09-04 20:29:53.656  INFO 21653 --- [           main] o.e.jetty.server.AbstractConnector       : Started ServerConnector@2cdd0d4b{HTTP/1.1,[http/1.1]}{0.0.0.0:9000}
2019-09-04 20:29:53.659  INFO 21653 --- [           main] .s.b.c.e.j.JettyEmbeddedServletContainer : Jetty started on port(s) 9000 (http/1.1)
2019-09-04 20:29:53.667  INFO 21653 --- [           main] e.p.d.c.c.r.a.CausalRestApiApplication   : Started CausalRestApiApplication in 18.04 seconds (JVM running for 18.888)
kvb2univpitt commented 5 years ago

@azzaea You will need to create a user account in the database first. Use causal-web to create a user account. Causal web and causal rest api should be connecting to the same database.

azzaea commented 5 years ago

Glad to hear from you @kvb2univpitt ! Thank you! Yes, I'm connecting to the same database, but not sure how to feed the data. I'm using my email and 123456 password, and at loss as to proceeding further

azzaea commented 5 years ago

image I tried feeding the username from this window, or using the email instead, but neither worked

kvb2univpitt commented 5 years ago

@azzaea Sorry for the delay. Let me set this up on my local computer. I'll get back to you on this.

kvb2univpitt commented 5 years ago

First you need to the jwt token using basic authentication, as mentioned here : Getting JSON Web Token(JWT)

Below is the screenshot of how you would get the jwt token: auth

Note that you need the userId and the jwt token to make other REST calls.

Let's say you want to retrieve a list of dataset, List all dataset files of a user. Below is the screenshot on how you would make the call: dataset

Note that your userId, in this particular example, is 1. Based on this example, you must add the Authorization header with value Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOi8vbG9jYWxob3N0LyIsInVpZCI6MSwiZXhwIjoxNTY4MTM1NTM5NjU0LCJpYXQiOjE1NjgxMzE5Mzk2NTR9.JVI-U2BHd1IFoOY0WrPOX0fIy_2KHAubvHCJKMhTM7M.

azzaea commented 5 years ago

Thank you. Appreciated. I apologize in advance if it seems stupid, but what interface provide these snapshots? I can't access similar content from the causal-web interface, and neither putting the GET command on the terminal directly

kvb2univpitt commented 5 years ago

This is a REST plugin for Firefox: https://github.com/odin-public/RESTED-APS Just search for REST client plugin in Firefox and you will see it.

kvb2univpitt commented 5 years ago

By the way, if you don't mind me asking, what are you using causal-web and causal-rest-api for? I am just curious.

azzaea commented 5 years ago

That's handy- thanks! It still give the same error though:

image

The database server is up, causal-web is up and causal-rest-api too (the 3 panels in this terminal window)

image

I'm working with a large dataset (snp data/GWAS), and interested in exploring the fGES-MB method in that setting. Results from the paper look promising, so trying to replicate for a starter at that scale

kvb2univpitt commented 5 years ago

If you're working with large dataset, I suggest you use causal-cmd, a command-line version of Tetrad search algorithms. The documentation for it is here. With causal-cmd you can run fGES-MB on a High Performance Computing (HPC) cluster.

If you're using H2, an in-memory database, you will lose everything in the database if you shut down the service. If you shutdown and start your services again, you will need to recreate your user account. Also, H2 database can only accept one connection at a time. So, if you run causal-web with H2 and causal-rest-api with H2, you're basically running two different instances of H2 database, each can only take one connection. H2 database will not work with this set up. You will need a database with non-volatile storage and can handle multiple connection such as MySQL, SQL Server, MariaDB, etc.

azzaea commented 5 years ago

Akh! Yes, I was using causal-cmd, but understood that I should be using causal-web-api to submit jobs to the cluster as per this comment. Packaging causal-cmd commands in a usual batch script doesn't quite scale up (fGES-MB took good 10 days on a dataset of 50k feature and 8000 samples; with 10 threads- without actually finishing).

kvb2univpitt commented 5 years ago

Let me ask Dr Ramsey if he has any suggestion on what parameters to use for your dataset.

@jdramsey Do you have any suggestion for running fGES-MB on SNP data with 50k variables and 8k cases?

azzaea commented 5 years ago

Thank you much! This is really appreciated

jdramsey commented 5 years ago

@azzaea @kvb2univpitt The danger is always that the underlying model might be very dense; FGES can bog down a lot with dense graphs. The thing to do is to start with a very high penalty, see if you can get an answer, then if you can, try again with lower penalties until you see what is feasible for you.

azzaea commented 5 years ago

Thank you much @jdramsey A couple of remarks:

image

I'm very very appreciative and open to suggestions, especially that even with smaller dataset (eg 5k features, of which 250 are causal; along 400 samples), the command works, but with rather disappointing results (a 2 node graph, neither of which is from the causal set)

kvb2univpitt commented 5 years ago

@azzaea Please use sem-bic score.

azzaea commented 5 years ago

@kvb2univpitt I thought the Conditional Gaussian score, ( based on this paper ) is the right score to use with mixed data (in my application the predictors are discrete, and the target is continuous), while the sem bic is appropriate for purely continuous data.

Is this not the case?

kvb2univpitt commented 5 years ago

@azzaea You are correct. Sorry. I wasn't being clear. The sem-bic score has penaltyDiscount parameter. That's why you're getting that error.

azzaea commented 5 years ago

Oh- I see. Thank you. But, it wouldn't be applicable to the data I'm working with