on 05-02-2020 11:00 PM
Hello community,
I started a CAP Java project and turned it into a MTA project, you can find it here.
I deployed my db module and my srv module with cf deploy command to my CF account and used cf env to create my default-env.json.
The deployment is running without any errors.
If I start my srv application my service is still running against my local sqllite database:
I attched the compete log file.cockpitcap-srv-2020-05-02-22-10-458430000.txt
What must I do, that my HANA database is used on CF and not my local sqlite database?
Before I turned my project into a MTA project I used cf push and a manifest.yaml for the deployment and it was working fine.
Best Regards,
Chris
Not sure why you are using default-env.json when you are running the srv module on cf.
Seeing your package.json, Hana will be linked if the production profile is active, which should be the case however on cf. Could you check the environment variable NODE_ENV in your srv app on cf? What is it’s value?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I set the variable and restarted my application and still get sqllite errors 😞
I checked the application from gregorw and the variable is not set there as well...
Any other suggestions?
This is changing nothing.
I just started a new cap project with
cds init
Then I turned it into a MTA project as described here.
If I deploy the project with
cf deploy
I get the same error as in my project.
So what is the correc way to switch a basic cap project to a working MTA project?
klaus.kopecz : this is a Java project, so NODE_ENV, requires.db, etc won't help here as this is Node.js-specfic.
The root cause seems to be an incomplete Java configuration that always activates sqlite. Take a look at a standard configuration and note how the empty `cloud` profile, which gets automatically activated on CF, overwrites the sqlite config with 'nothing', This leads to SAP HANA being used if its bound through a service binding on CF. Learn more on the Java configuration in the docs.
Hi christian.georgi ,
I was wrong, it is not working yet. If I build my project with
mbt build
the default profile is read from application.yaml and not the cloud profile.
---
spring:
resources.static-locations: "file:./app"
cds:
odata-v4.endpoint.path: "/api"
security.mock.users:
- name: admin
password: admin
roles:
- admin
- name: user
password: user
---
spring:
profiles: cloud
---
spring:
profiles: sqlite
datasource:
url: "jdbc:sqlite:sqlite.db"
driver-class-name: org.sqlite.JDBC
initialization-mode: never
hikari:
maximum-pool-size: 1
---
spring:
profiles: default
datasource:
url: "jdbc:sqlite:file::memory:?cache=shared"
driver-class-name: org.sqlite.JDBC
initialization-mode: always
hikari:
maximum-pool-size: 1
In addition the mbt build is not reading the [production] part of my package.json.
"db": {
"kind": "sqlite",
"model": [
"db",
"srv"
],
"[production]": {
"kind": "hana"
}
}
What is needed to configure the MTA build tool to use the production profile?
Best Regards,
Chris
For the build: to activate the `production` profile, try with `CDS_ENV=production mbt build` (in bash) and check that the HANA files are created in db/gen. Alternatively, change package.json so that it has `kind:hana` as default entry.
For the `cloud` profile: check your startup logs of the Spring Boot app. There it should mention, which profiles got activated. If you really see only `default` being activated, you could add `SPRING_PROFILES_ACTIVE=cloud` environment variable to e.g. mta.yaml in the `properties` section of the `cockpitcap` module.
Hi Christoffer,
You should try the --no-save option for the deploy commands:
cds deploy --to hana --no-save
cds deploy --to sqlite --no-save
This prevents that package.json is changed.
Regards
In package.json, I'm using:
"requires": {
"db": {
"[production]": {"kind":"hana"},
"[development]": {"kind": "sqlite"}
}
}
Then, depending on where I want to deploy to, I'm setting NODE_ENV to "" (or "development"), or to "poduction").
'cds deploy --no-save' is doing the right thing then.
You might want to follow my Github issue on this topic:
User | Count |
---|---|
81 | |
24 | |
11 | |
9 | |
7 | |
5 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.