Failed to load property source from location 'classpath:/application.yaml'

Hi all, I’m trying to integrate the PostgreSQL database into a camunda application. I’ve followed the instruction describes here. However, when I build and run the application I receive the following error stack-trace.

The complete source code is available here.

17:49:44.192 [main] DEBUG org.springframework.boot.context.logging.ClasspathLoggingApplicationListener - Application failed to start with classpath: unknown
17:49:44.198 [main] ERROR org.springframework.boot.SpringApplication - Application run failed
java.lang.IllegalStateException: Failed to load property source from location 'classpath:/application.yaml'
	at org.springframework.boot.context.config.ConfigFileApplicationListener$Loader.load(ConfigFileApplicationListener.java:545)
	at org.springframework.boot.context.config.ConfigFileApplicationListener$Loader.loadForFileExtension(ConfigFileApplicationListener.java:494)
	at org.springframework.boot.context.config.ConfigFileApplicationListener$Loader.load(ConfigFileApplicationListener.java:464)
	at org.springframework.boot.context.config.ConfigFileApplicationListener$Loader.lambda$null$7(ConfigFileApplicationListener.java:443)
	at java.base/java.lang.Iterable.forEach(Iterable.java:75)
	at org.springframework.boot.context.config.ConfigFileApplicationListener$Loader.lambda$load$8(ConfigFileApplicationListener.java:443)
	at java.base/java.lang.Iterable.forEach(Iterable.java:75)
	at org.springframework.boot.context.config.ConfigFileApplicationListener$Loader.load(ConfigFileApplicationListener.java:440)
	at org.springframework.boot.context.config.ConfigFileApplicationListener$Loader.lambda$load$0(ConfigFileApplicationListener.java:335)
	at org.springframework.boot.context.config.FilteredPropertySource.apply(FilteredPropertySource.java:54)
	at org.springframework.boot.context.config.ConfigFileApplicationListener$Loader.load(ConfigFileApplicationListener.java:323)
	at org.springframework.boot.context.config.ConfigFileApplicationListener.addPropertySources(ConfigFileApplicationListener.java:214)
	at org.springframework.boot.context.config.ConfigFileApplicationListener.postProcessEnvironment(ConfigFileApplicationListener.java:198)
	at org.springframework.boot.context.config.ConfigFileApplicationListener.onApplicationEnvironmentPreparedEvent(ConfigFileApplicationListener.java:188)
	at org.springframework.boot.context.config.ConfigFileApplicationListener.onApplicationEvent(ConfigFileApplicationListener.java:176)
	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.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:127)
	at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:76)
	at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:53)
	at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:345)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:308)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1215)
	at com.example.workflow.Application.main(Application.java:10)
Caused by: org.yaml.snakeyaml.parser.ParserException: expected '<document start>', but found '<block mapping start>'
 in 'reader', line 19, column 1:
    camunda.bpm.admin-user:
    ^

	at org.yaml.snakeyaml.parser.ParserImpl$ParseDocumentStart.produce(ParserImpl.java:226)
	at org.yaml.snakeyaml.parser.ParserImpl.peekEvent(ParserImpl.java:158)
	at org.yaml.snakeyaml.parser.ParserImpl.checkEvent(ParserImpl.java:148)
	at org.yaml.snakeyaml.composer.Composer.checkNode(Composer.java:68)
	at org.yaml.snakeyaml.constructor.BaseConstructor.checkData(BaseConstructor.java:114)
	at org.yaml.snakeyaml.Yaml$1.hasNext(Yaml.java:543)
	at org.springframework.beans.factory.config.YamlProcessor.process(YamlProcessor.java:160)
	at org.springframework.beans.factory.config.YamlProcessor.process(YamlProcessor.java:134)
	at org.springframework.boot.env.OriginTrackedYamlLoader.load(OriginTrackedYamlLoader.java:75)
	at org.springframework.boot.env.YamlPropertySourceLoader.load(YamlPropertySourceLoader.java:50)
	at org.springframework.boot.context.config.ConfigFileApplicationListener$Loader.loadDocuments(ConfigFileApplicationListener.java:562)
	at org.springframework.boot.context.config.ConfigFileApplicationListener$Loader.load(ConfigFileApplicationListener.java:518)
	... 25 common frames omitted

Process finished with exit code 1

Here’s how my pom.xml file looks like.

<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 http://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.5.RELEASE</version>
    <relativePath/>
  </parent>

  <properties>
    <java.version>8</java.version>
  </properties>

  <groupId>com.example.workflow</groupId>
  <artifactId>psql</artifactId>
  <version>1.0.0-SNAPSHOT</version>

  <dependencies>
    <dependency>
      <groupId>org.camunda.bpm.springboot</groupId>
      <artifactId>camunda-bpm-spring-boot-starter-rest</artifactId>
      <version>7.13.0</version>
    </dependency>

    <dependency>
      <groupId>org.camunda.bpm.springboot</groupId>
      <artifactId>camunda-bpm-spring-boot-starter-webapp</artifactId>
      <version>7.13.0</version>
    </dependency>
	<dependency>
      <groupId>org.postgresql</groupId>
      <artifactId>postgresql</artifactId>
        <scope>runtime</scope>
    </dependency>


    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-data-jpa</artifactId>
    </dependency>

  </dependencies>

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

</project>

and here’s how my application.yaml file looks like.

# spring.datasource.url: jdbc:h2:file:./camunda-h2-database

  # Database
  datasource:
    driver-class-name: org.postgresql.Driver
    url: jdbc:postgresql://localhost:5432/camunda
    username: postgres
    password: sa
  # JPA properties
  jpa:
    hibernate:
      ddl-auto: none
    show-sql: true
    database: postgresql
    database-platform: org.hibernate.dialect.PostgreSQLDialect
    open-in-view: false
    generate-ddl: false 

camunda.bpm.admin-user:
  id: demo
  password: demo

I would appreciate any help or guidance to fix the issue and make the PostgreSQL integration works.

@hello.aliasad how do you generate the project? Generate a project using https://start.camunda.com

Yes, I did generate the project using that link.

@aravindhrs I would highly appreciate it if you could share any sample project that uses PostgreSQL as a database and not H2.

Not sure the problem I’m facing while compiling the empty project is because of configuration or something else. For reference you may look at the project, I’ve uploaded on the g-drive here.

@hello.aliasad your datasource configuration and project setup was incorrect. I was able to setup and run the application.

You can download the project from https://drive.google.com/file/d/1Zek_pL-uQtWREL56MgVNLx8D4WJb22Zl/view?usp=sharing.

From root path of the project run this command:

mvn clean install

Then import the project as existing maven project to STS (Spring tool suite) and run the application as spring boot application. Change the db credentials in application.yml file.

Camunda server logs

 ____                                 _         ____  ____  __  __
/ ___| __ _ _ __ ___  _   _ _ __   __| | __ _  | __ )|  _ \|  \/  |
| |   / _` | '_ ` _ \| | | | '_ \ / _` |/ _` | |  _ \| |_) | |\/| |
| |__| (_| | | | | | | |_| | | | | (_| | (_| | | |_) |  __/| |  | |
\____/\__,_|_| |_| |_|\__,_|_| |_|\__,_|\__,_| |____/|_|   |_|  |_|

  Spring-Boot:  (v2.2.5.RELEASE)
  Camunda BPM: (v7.13.0)
  Camunda BPM Spring Boot Starter: (v7.13.0)

2020-05-27 22:33:27.993  INFO 7452 --- [           main] com.example.workflow.Application         : Starting Application on BLRT450-W8-R171 with PID 7452 (C:\Users\aravindhr\Desktop\camundapostgres\target\classes started by aravindhr in C:\Users\aravindhr\Desktop\camundapostgres)
2020-05-27 22:33:28.014  INFO 7452 --- [           main] com.example.workflow.Application         : No active profile set, falling back to default profiles: default
2020-05-27 22:33:30.573  INFO 7452 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode.
2020-05-27 22:33:30.653  INFO 7452 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 45ms. Found 0 JPA repository interfaces.
2020-05-27 22:33:32.533  INFO 7452 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 9091 (http)
2020-05-27 22:33:32.560  INFO 7452 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2020-05-27 22:33:32.561  INFO 7452 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet engine: [Apache Tomcat/9.0.31]
2020-05-27 22:33:33.344  INFO 7452 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2020-05-27 22:33:33.344  INFO 7452 --- [           main] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 5124 ms
2020-05-27 22:33:33.416  INFO 7452 --- [           main] .c.b.s.b.s.r.CamundaJerseyResourceConfig : Configuring camunda rest api.
2020-05-27 22:33:33.480  INFO 7452 --- [           main] .c.b.s.b.s.r.CamundaJerseyResourceConfig : Finished configuring camunda rest api.
2020-05-27 22:33:34.349  WARN 7452 --- [           main] com.zaxxer.hikari.HikariConfig           : HikariCP - idleTimeout has been set but has no effect because the pool is operating as a fixed size pool.
2020-05-27 22:33:34.350  INFO 7452 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariCP - Starting...
2020-05-27 22:33:34.841  INFO 7452 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariCP - Start completed.
2020-05-27 22:33:35.384  INFO 7452 --- [           main] o.hibernate.jpa.internal.util.LogHelper  : HHH000204: Processing PersistenceUnitInfo [name: default]
2020-05-27 22:33:35.967  INFO 7452 --- [           main] org.hibernate.Version                    : HHH000412: Hibernate ORM core version 5.4.12.Final
2020-05-27 22:33:36.690  INFO 7452 --- [           main] o.hibernate.annotations.common.Version   : HCANN000001: Hibernate Commons Annotations {5.1.0.Final}
2020-05-27 22:33:37.501  INFO 7452 --- [           main] org.hibernate.dialect.Dialect            : HHH000400: Using dialect: org.hibernate.dialect.PostgreSQL9Dialect
2020-05-27 22:33:38.712  INFO 7452 --- [           main] o.h.e.t.j.p.i.JtaPlatformInitiator       : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
2020-05-27 22:33:38.739  INFO 7452 --- [           main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2020-05-27 22:33:39.359  INFO 7452 --- [           main] org.camunda.bpm.spring.boot              : STARTER-SB040 Setting up jobExecutor with corePoolSize=3, maxPoolSize:10
2020-05-27 22:33:39.364  INFO 7452 --- [           main] o.s.s.concurrent.ThreadPoolTaskExecutor  : Initializing ExecutorService 'camundaTaskExecutor'
2020-05-27 22:33:39.594  INFO 7452 --- [           main] org.camunda.bpm.engine.cfg               : ENGINE-12003 Plugin 'CompositeProcessEnginePlugin[genericPropertiesConfiguration, camundaProcessEngineConfiguration, camundaDatasourceConfiguration, camundaJpaConfiguration, camundaJobConfiguration, camundaHistoryConfiguration, camundaMetricsConfiguration, camundaAuthorizationConfiguration, CreateAdminUserConfiguration[adminUser=AdminUserProperty[id=demo, firstName=Demo, lastName=Demo, email=demo@localhost, password=******]], failedJobConfiguration, disableDeploymentResourcePattern, eventPublisherPlugin]' activated on process engine 'default'
2020-05-27 22:33:39.606  INFO 7452 --- [           main] org.camunda.bpm.spring.boot              : STARTER-SB020 ProcessApplication enabled: autoDeployment via springConfiguration#deploymentResourcePattern is disabled
2020-05-27 22:33:39.608  INFO 7452 --- [           main] o.c.b.s.b.s.event.EventPublisherPlugin   : EVENTING-001: Initialized Camunda Spring Boot Eventing Engine Plugin.
2020-05-27 22:33:39.609  INFO 7452 --- [           main] o.c.b.s.b.s.event.EventPublisherPlugin   : EVENTING-003: Task events will be published as Spring Events.
2020-05-27 22:33:39.609  INFO 7452 --- [           main] o.c.b.s.b.s.event.EventPublisherPlugin   : EVENTING-005: Execution events will be published as Spring Events.
2020-05-27 22:33:39.618  INFO 7452 --- [           main] o.c.b.s.b.s.event.EventPublisherPlugin   : EVENTING-007: History events will be published as Spring events.
2020-05-27 22:33:40.219  INFO 7452 --- [           main] org.camunda.feel.FeelEngine              : Engine created. [value-mapper: CompositeValueMapper(List(org.camunda.feel.impl.JavaValueMapper@64aeaf29)), function-provider: org.camunda.bpm.dmn.feel.impl.scala.function.CustomFunctionTransformer@261bd7b, configuration: Configuration(false)]
2020-05-27 22:33:57.052  INFO 7452 --- [           main] org.camunda.bpm.engine                   : ENGINE-00001 Process Engine default created.
2020-05-27 22:33:57.168  INFO 7452 --- [           main] org.camunda.bpm.spring.boot              : STARTER-SB011 skip creating initial Admin User, user does exist: UserEntity[id=demo, revision=1, firstName=Demo, lastName=Demo, email=demo@localhost, password={SHA-512}pGQbV0zk7SvXPauQPeBKfPZmXwaTrtdy4eYNvyxPdv0T6f4Y3wKAxS8jMRTP+nDZoKvqTBTlJv683F0wDIHyzQ==, salt=1pKmKw87//mhWt7lZApy9g==, lockExpirationTime=null, attempts=0]
2020-05-27 22:33:57.188  WARN 7452 --- [           main] JpaBaseConfiguration$JpaWebConfiguration : spring.jpa.open-in-view is enabled by default. Therefore, database queries may be performed during view rendering. Explicitly configure spring.jpa.open-in-view to disable this warning
2020-05-27 22:33:58.128  INFO 7452 --- [           main] o.c.b.s.b.s.w.f.LazyInitRegistration     : lazy initialized org.camunda.bpm.spring.boot.starter.webapp.filter.LazyProcessEnginesFilter@58e85c6f
2020-05-27 22:33:58.316  INFO 7452 --- [           main] o.c.b.s.b.s.w.f.LazyInitRegistration     : lazy initialized org.camunda.bpm.spring.boot.starter.webapp.filter.LazySecurityFilter@2264e43c
2020-05-27 22:34:00.466  INFO 7452 --- [           main] org.camunda.bpm.container                : ENGINE-08026 No processes.xml file found in process application 'application'
2020-05-27 22:34:00.481  INFO 7452 --- [           main] org.camunda.bpm.container                : ENGINE-08050 Process application application successfully deployed
2020-05-27 22:34:00.572  INFO 7452 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 9091 (http) with context path ''
2020-05-27 22:34:00.585  INFO 7452 --- [           main] com.example.workflow.Application         : Started Application in 34.3 seconds (JVM running for 38.739)
2020-05-27 22:34:00.592  INFO 7452 --- [           main] org.camunda.bpm.engine.jobexecutor       : ENGINE-14014 Starting up the JobExecutor[org.camunda.bpm.engine.spring.components.jobexecutor.SpringJobExecutor].
2020-05-27 22:34:00.598  INFO 7452 --- [ingJobExecutor]] org.camunda.bpm.engine.jobexecutor       : ENGINE-14018 JobExecutor[org.camunda.bpm.engine.spring.components.jobexecutor.SpringJobExecutor] starting to acquire jobs
2020-05-27 22:34:11.959  INFO 7452 --- [nio-9091-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring DispatcherServlet 'dispatcherServlet'
2020-05-27 22:34:11.959  INFO 7452 --- [nio-9091-exec-1] o.s.web.servlet.DispatcherServlet        : Initializing Servlet 'dispatcherServlet'
2020-05-27 22:34:11.985  INFO 7452 --- [nio-9091-exec-1] o.s.web.servlet.DispatcherServlet        : Completed initialization in 25 ms
1 Like

Thank you really appreciate it. However, I have a question, the project structure doesn’t look alike the one that we generate from start.camunda.com. Because it doesn’t generate .classpath and .project file. (I’m using Intellij compiler by the way)

Please tell how I can generate such project structure that you have in the google drive above. Lots of thanks.

@hello.aliasad, application.yml is same as generated from start.camunda.com. I have just added few properties for hikari datasource setup.

For example,

camunda:
  bpm:
    admin-user:
      id: demo
      password: demo

is same as writing like below:

camunda.bpm.admin-user:
 id: demo
 password: demo

you can remove those files. I was just directly archived the project and uploaded it. When you import the maven project in eclipse, those file will get generated. You can delete those files and import it in your eclipse.

1 Like

I see thank you, let me make this project on my local machine. appreciate the great help.

I have few questions about pom.xml to understand it better. I’m coming from C# and .net background so all these camunda and java things are new to me. Appreciate your patience and support.

image

Can you explain the following please.

  • What’s ‘datasource: type: com.zaxxer.hikari.HikariDataSource’ means? what kind of value I should provide here.

  • Whats’s ‘hikari: jdbc-url: jdbc:postgresql://localhost:5432/camundaworkflow’ means here?

  • What’s ‘pool-name: HikariCP’ means and what value should I provide here?

@hello.aliasad you need to update only the placeholder values. Other properties values you can retain.

server:
  port: 9091 

camunda:
  bpm:
    admin-user:
      id: demo
      password: demo
      
    database:
      schema-update: true
      
spring:
  application:
    name: camundapostgres
    
  jpa:
    database-platform: org.hibernate.dialect.PostgreSQL9Dialect
    
  datasource:
    type: com.zaxxer.hikari.HikariDataSource
    url: jdbc:postgresql://localhost:5432/<databasename>
    username: <dbusername>
    password: <dbpassword>
    hikari:
      jdbc-url: jdbc:postgresql://localhost:5432/<databasename>
      username: <dbusername>
      password: <dbpassword>
      driver-class-name: org.postgresql.Driver
      pool-name: HikariCP
      idle-timeout: 3000
      minimum-idle: 30
      maximum-pool-size: 10
      connection-timeout: 2000
      connection-test-query: select 1
      transaction-isolation: TRANSACTION_READ_COMMITTED 
1 Like

You’re such a gem. Wish I could hug you. lot of thanks.

2 Likes

@hello.aliasad You can find the same project from github. Camunda basic auth added and auto deployment enabled.

1 Like

@hello.aliasad, you can checkout the Camunda BPM Run.

This was out of the box solution provided by camunda. For non java developers, its easy to setup by just adjusting few properties in the configuration file. You can refer Install Camunda BPM Run.

1 Like