I have created a new environment for my application and called it docker. I'm trying stuff out so I set it like this:
application-docker.yml
micronaut:
application:
name: time
server:
netty:
access-logger:
enabled: true
logger-name: access-logger
datasources:
default:
url: jdbc:postgresql://db:5432/postgres
driverClassName: org.postgresql.Driver
username: postgres
password: postgres
schema-generate: CREATE_DROP
dialect: POSTGRES
schema: time
jpa.default.properties.hibernate.hbm2ddl.auto: update
flyway:
datasources:
default:
enabled: true
schemas: time
...
However when I try to run my app like this:
java -jar target/timeshare-0.1.jar -Dmicronaut.environments=docker -Dcom.sun.management.jmxremote -Xmx128m
If fails... because it can't connect to localhost!
08:11:00.949 [main] INFO com.zaxxer.hikari.HikariDataSource - HikariPool-1 - Starting...
08:11:02.013 [main] ERROR com.zaxxer.hikari.pool.HikariPool - HikariPool-1 - Exception during pool initialization.
org.postgresql.util.PSQLException: Connection to localhost:5432 refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections.
at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:285)
Why is it trying to connect to localhost? What am i missing?
It seems that Micronaut is not able to locate application-docker.yml file and then it is using the default one.
Because you can use for example -Dmicronaut.environments=not-existing-profile and even if it does not exist, it does not show any error.
So, make sure you have application-docker.yml file in the src/main/resources directory and also that the file is really exported into the result jar during build and is located in the root of the jar archive:
target/timeshare-0.1-all.jar
├── com
├── META-INF
├── org
├── application-docker.yml
├── application.yml
├── logback.xml
...
How are you building the result jar? When you use the shadowJar task then it must contain everything.
Another option is to use MICRONAUT_ENVIRONMENTS system variable:
export MICRONAUT_ENVIRONMENTS=docker
But this behaves the same way as -Dmicronaut.environments=docker startup option.
Another option is to specify exact path to the application-docker.yml configuration file by the micronaut.config.files startup option:
java -jar target/timeshare-0.1-all.jar -Dmicronaut.config.files=/some/external/location/application-docker.yml
Related
I have a docker-compose file with two services: odoo:latest and postgres:13.
I try to update app list in debug mode http://localhost:8070/web?debug=1
but nothing happens.
odoo service has volumes section:
`volumes:
- ./extra-addons:/mnt/extra-addons
- data:/var/lib/odoo
- ./config:/etc/odoo`
that corresponds to a this directory:
.
├── config
│ └── odoo.conf
├── docker-compose.yml
└── extra-addons
├── __init__.py
└── __manifest__.py
Content of of oodo.conf file:
[options]
addons_path = /mnt/extra-addons
data_dir = /var/lib/odoo
Content of manifest.py
{
'name': 'estate',
'depends': [
'base_setup',
],
"installable": True,
"application": True,
"auto_install": False,
}
I also tried to update app list in the terminal.
When I exec in odoo service and issue this command:
/usr/bin/odoo -p 8071 --db_host=172.17.0.2 --db_user=odoo --db_password=odoo -d odoo -u estate
I get:
odoo: Odoo version 16.0-20221025
odoo: Using configuration file at /etc/odoo/odoo.conf
odoo: addons paths: ['/usr/lib/python3/dist-packages/odoo/addons', '/var/lib/odoo/addons/16.0', '/mnt/extra-addons']
odoo: database: odoo#172.17.0.2:default
odoo.sql_db: Connection to the database failed
Traceback (most recent call last):
File "/usr/bin/odoo", line 8, in
odoo.cli.main()
...
File "/usr/lib/python3/dist-packages/odoo/sql_db.py", line 638, in borrow
result = psycopg2.connect(
File "/usr/lib/python3/dist-packages/psycopg2/__init__.py", line 127, in connect
conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
psycopg2.OperationalError: connection to server at "172.17.0.2", port 5432 failed: Connection timed out
Is the server running on that host and accepting TCP/IP connections?
THANK YOU!
Every module needs it's own directory.
As i see, you've put __init__.py and __manifest__.py inside extra_addons folder.
extra_addons should contain module folders, so correct structure should be:
.
├── config
│ └── odoo.conf
├── docker-compose.yml
└── extra-addons
└── estate
├── __init__.py
└── __manifest__.py
where estate is your module code (which for best practice should be the same as "name" key in manifest dictionary)
Furthermore, if you added ./extra-addons:/mnt/extra-addons volume after you ran your docker-compose, you should run it again.
This will only re-create your odoo container since postgres container has not changed, meaning you won't lose any data.
I wrote a Quarkus JPA/Hibernate app with PostgreSQL DB perfectly working with a JVM - run by 'quarkusDev' gradle task.
When I compile the native application with
#!/usr/bin/env bash
export QUARKUS_PROFILE=****
export PG_USERNAME=*****
export PG_PASSWORD=*****
export JAVA_HOME=/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home
./gradlew build -Dquarkus.package.type=native
the compilation goes fine, but when I run the native image I get:
14:41:23 WARN [io.ag.pool] Datasource '<default>': FATAL: no pg_hba.conf entry for host "***.***.***.***", user "xxxxxxxxxxxxxx", database "*****", SSL on
14:41:23 WARN [or.hi.en.jd.sp.SqlExceptionHelper] SQL Error: 0, SQLState: 28000
14:41:23 ERROR [or.hi.en.jd.sp.SqlExceptionHelper] FATAL: no pg_hba.conf entry for host "***.***.***.***", user "xxxxxxxxxxxxxx", database "*****", SSL on
14:41:23 ERROR [io.qu.application] Failed to start application: javax.persistence.PersistenceException: [PersistenceUnit: default] Unable to build Hibernate SessionFactory
I tried to add a pg_hba.conf file:
# TYPE DATABASE USER ADDRESS METHOD
host all all 0.0.0.0/0 md5
and put it to
/src/main/resources
and/or to the native image directory, but without luck.
Also, I configured the resources for my native image adding a 'resources-config.json' to '/src/main/resources':
{
"resources": [
{
"pattern": ".*\\.yaml$"
},
{
"pattern": ".*\\.conf$"
},
{
"pattern": ".*\\.txt$"
},
{
"pattern": ".*\\.html$"
}
]
}
I added the following line to 'application.yml'
quarkus:
native:
additional-build-args: -H:ResourceConfigurationFiles=resources-config.json
But even doing so, the pga_hba.conf is not found, and when run, the native image keeps on complaining.
The issue is with the pg_hba.conf being used by the Postgres server. You need to find it and add an entry that will match the connection parameters you are sending to the server.
It turned out that I missed to pass environment variables to the executable.
Of course - obvious after realizing what the problem was! - you not only need to pass DB Environment Variables when you compile the native image - so the tests can be run - but you also need to pass them when you launch it.
So, a script like this solves the issue:
#!/usr/bin/env bash
export PG_USERNAME=*****
export PG_PASSWORD=*****
./build/my-native-image.runner
i tried to make a
liquibase xml with liquibase diff
command.
I want to do this based on this documentation: http://www.liquibase.org/documentation/diff.html
If I try to exec the example command with my custom properties,
with
--driver:org.postgresql.Driver,
I got this problem:
"Unexpected error running Liquibase: java.lang.RuntimeException:
Cannot find database driver: org.postgresql.Driver"
You have to specify the classpath where the driver jar file is located using the classpath key (liquibase documentation).
Your properties file should look like:
driver: org.postgresql.Driver
classpath: postgresql-driver.jar
url: jdbc:postgres#localhost:5432
username: scott
password: tiger
I want to initialise my datasource with a DLL script in my spring boot project (only during dev of course). As mentioned in the docs here I set the spring.datasource.schema property to the DLL scripts which is in src/main/resources/postgresql/define-schema.sql.
spring:
profiles: dev
datasource:
platform: postgresql
driver-class-name: org.postgresql.Driver
url: jdbc:postgresql://localhost:5432/postgres
username: postgres
password: ****
initialize: true
schema: ./postgresql/define-schema.sql
continue-on-error: false
jpa:
hibernate:
ddl-auto: validate
generate-ddl: false
show-sql: true
But the script won't be executed. I also tried to put it on the class path root and call it schema.sql ... Nothing happens.
The dev profile is selected, at least I see it in the log: The following profiles are active: dev
The application than fails on the JPA schema validation.
The only warning I get from hibernate:
Found use of deprecated [org.hibernate.id.SequenceGenerator] sequence-based id generator; use org.hibernate.id.enhanced.SequenceStyleGenerator instead. See Hibernate Domain Model Mapping Guide for details.
But I don't think this has any to do with the initialise problem.
I've got spring-boot-security-starter in my dependencies but not configured yet, could that be a problem source?
Does anybody recognise an obivous typo, mistake anything else?
Looking forward hearing from you!
Amp
Prefix the path to your sql script with classpath
Example:
spring.datasource.schema=classpath:/postgresql/define-schema.sql
I am trying to start Odoo v8 server from Eclipse ide. I have set the debug configurations and have given the config file path in the arguments as
-c /etc/odoo-server.conf.
When I do debug as python run, I do not get any error. The log file also does not show any error. But when I open localhost:8069 from the browser.
I get server not found error. This does not happen when I start the server through the terminal. Can anyone please tell me what could be the problem?
Below is the odoo-server.conf content:
[options]
; This is the password that allows database operations:
admin_passwd = admin
db_host = False
db_port = False
db_user = odoo
db_password = odoo
addons_path = /opt/odoo/addons
logfile = /var/log/odoo/odoo-server.log
Below is the server traceback:
2014-11-15 07:47:06,205 3875 INFO ? openerp: OpenERP version 8.0
2014-11-15 07:47:06,206 3875 INFO ? openerp: addons paths: ['/home/hassan/.local/share/Odoo/addons/8.0', u'/opt/odoo/addons', '/opt/odoo/openerp/addons']
2014-11-15 07:47:06,207 3875 INFO ? openerp: database hostname: localhost
2014-11-15 07:47:06,207 3875 INFO ? openerp: database port: 5432
2014-11-15 07:47:06,207 3875 INFO ? openerp: database user: odoo
2014-11-15 07:47:07,046 3875 INFO ? openerp.service.server: Evented Service (longpolling) running on 0.0.0.0:8072
Try to check whether the configuration file that you have set is having appropriate access rights. And try not to log the errors into a file, instead allow it show it on the console on Eclipse IDE.
There's nothing wrong with your "traceback": is a normal log, with only INFO messages and it tells you that the server is running and waiting for requests on port 8072.
Point a browser at http://localhost:8072 and you should see a login page.
I know my answer is late, but i ran into this problem today, and got the server running, so thought I should share :
Do not start the openerp server as : Debug as -> Python run.
It only starts the longpolling service.
Try running as : Run as -> Python run
This will start the Http service at your defined port or by default at 8069.