docker - Connecting ApacheJames to an external Postgresql databese - Stack Overflow

I will try to provide as much information to avoid misunderstanding. Please bare with me.I am trying t

I will try to provide as much information to avoid misunderstanding. Please bare with me.

I am trying to run two docker containers, one running Apache/James and one PostgreSQL. The Apache/James instance is supposed to use the PostgreSQL instance. I have succeeded to run the setup using linagora/james-jpa-spring image of James. I followed the instruction that is provided by Apache/James official website.

According to the documentation, I just need to download PostgreSQL JDBC Driver from here and mount it in /conf/lib folder and update the database address and credentials in /conf/james-database.properties file. I followed the instruction and it works.

However since Linagora image seems to be too old I decided that I want to switch to one of the original Apache/James:jpa* images. (based on the docker hub, I feel :jpa is the right choice but if you feel I am mistaken, please let me know)

I therefore followed the same instruction (mount JDBC Driver and update james-database.properties) and I expected to have a smooth transition to JPA image but it wasn't.

I figured out that recent JPA images require a key-pair that is supposed to save as "keystore" file and mounted in /config/ folder. The keypair must be made with code "james72laBalle". this step is made successfully.

However I am getting one error that is running me creasy. James (not the container) says that it cannot reach to my PostgreSQL container. It say: There were errors initializing your configuration: <openjpa-3.2.0-r6f721f6 fatal user error> UserException: A connection could not be obtained for driver class ".postgresql.Driver" and URL "jdbc:postgresql://post/jamesdb". You may have specified an invalid URL.

This is the full error message:

1) [Guice/ErrorInjectingConstructor]: <openjpa-3.2.0-r6f721f6 nonfatal general error> PersistenceException: There were errors initializing your configuration: <openjpa-3.2.0-r6f721f6 fatal user error> UserException: A connection could not be obtained for driver class ".postgresql.Driver" and URL "jdbc:postgresql://post/jamesdb".  You may have specified an invalid URL.
    at DataSourceFactory.newConnectException(DataSourceFactory.java:271)
    at DataSourceFactory.newDataSource(DataSourceFactory.java:121)
    at JDBCConfigurationImpl.createConnectionFactory(JDBCConfigurationImpl.java:925)
    at JDBCConfigurationImpl.getConnectionFactory(JDBCConfigurationImpl.java:805)
    at java.base/NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/NativeMethodAccessorImpl.invoke(Unknown Source)
    at java.base/DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.base/Method.invoke(Unknown Source)
    at ConfigurationImpl.instantiateAll(ConfigurationImpl.java:331)
    at OpenJPAConfigurationImpl.instantiateAll(OpenJPAConfigurationImpl.java:1963)
    at AbstractBrokerFactory.makeReadOnly(AbstractBrokerFactory.java:665)
    at AbstractBrokerFactory.newBroker(AbstractBrokerFactory.java:207)
    at DelegatingBrokerFactory.newBroker(DelegatingBrokerFactory.java:166)
    at EntityManagerFactoryImpl.doCreateEM(EntityManagerFactoryImpl.java:282)
    at EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:201)

This is my james-database.properties file:

database.driverClassName=.postgresql.Driver
database.url=jdbc:postgresql://post/jamesdb
database.username=admin
database.password=password
vendorAdapter.database=POSTGRESQL

I have also tried the followings for database url: database.url=jdbc:postgresql://post:5432/jamesdb database.url=jdbc:postgresql://post/jamesdb;create=true database.url=jdbc:postgresql://post:5432/jamesdb;create=true

No success!

I have made a docker network and both containers are running on that "docker network"

I am sure that my James container can access my Postgres container (when I try to run it with its internal Derby database and do not force it to connect to external database.) cause I have Docker-exec bash of James container and pinged my Postgres container (ping post) and it responded successfully. I even installed a psql database manager inside my James container and could successfully connect to the database on my Postgres container and manipulated the data on the database.

I simply do not understand why James says that it cannot see my PostgreSQL database while it should have access.

I will try to provide as much information to avoid misunderstanding. Please bare with me.

I am trying to run two docker containers, one running Apache/James and one PostgreSQL. The Apache/James instance is supposed to use the PostgreSQL instance. I have succeeded to run the setup using linagora/james-jpa-spring image of James. I followed the instruction that is provided by Apache/James official website.

According to the documentation, I just need to download PostgreSQL JDBC Driver from here and mount it in /conf/lib folder and update the database address and credentials in /conf/james-database.properties file. I followed the instruction and it works.

However since Linagora image seems to be too old I decided that I want to switch to one of the original Apache/James:jpa* images. (based on the docker hub, I feel :jpa is the right choice but if you feel I am mistaken, please let me know)

I therefore followed the same instruction (mount JDBC Driver and update james-database.properties) and I expected to have a smooth transition to JPA image but it wasn't.

I figured out that recent JPA images require a key-pair that is supposed to save as "keystore" file and mounted in /config/ folder. The keypair must be made with code "james72laBalle". this step is made successfully.

However I am getting one error that is running me creasy. James (not the container) says that it cannot reach to my PostgreSQL container. It say: There were errors initializing your configuration: <openjpa-3.2.0-r6f721f6 fatal user error> UserException: A connection could not be obtained for driver class ".postgresql.Driver" and URL "jdbc:postgresql://post/jamesdb". You may have specified an invalid URL.

This is the full error message:

1) [Guice/ErrorInjectingConstructor]: <openjpa-3.2.0-r6f721f6 nonfatal general error> PersistenceException: There were errors initializing your configuration: <openjpa-3.2.0-r6f721f6 fatal user error> UserException: A connection could not be obtained for driver class ".postgresql.Driver" and URL "jdbc:postgresql://post/jamesdb".  You may have specified an invalid URL.
    at DataSourceFactory.newConnectException(DataSourceFactory.java:271)
    at DataSourceFactory.newDataSource(DataSourceFactory.java:121)
    at JDBCConfigurationImpl.createConnectionFactory(JDBCConfigurationImpl.java:925)
    at JDBCConfigurationImpl.getConnectionFactory(JDBCConfigurationImpl.java:805)
    at java.base/NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/NativeMethodAccessorImpl.invoke(Unknown Source)
    at java.base/DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.base/Method.invoke(Unknown Source)
    at ConfigurationImpl.instantiateAll(ConfigurationImpl.java:331)
    at OpenJPAConfigurationImpl.instantiateAll(OpenJPAConfigurationImpl.java:1963)
    at AbstractBrokerFactory.makeReadOnly(AbstractBrokerFactory.java:665)
    at AbstractBrokerFactory.newBroker(AbstractBrokerFactory.java:207)
    at DelegatingBrokerFactory.newBroker(DelegatingBrokerFactory.java:166)
    at EntityManagerFactoryImpl.doCreateEM(EntityManagerFactoryImpl.java:282)
    at EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:201)

This is my james-database.properties file:

database.driverClassName=.postgresql.Driver
database.url=jdbc:postgresql://post/jamesdb
database.username=admin
database.password=password
vendorAdapter.database=POSTGRESQL

I have also tried the followings for database url: database.url=jdbc:postgresql://post:5432/jamesdb database.url=jdbc:postgresql://post/jamesdb;create=true database.url=jdbc:postgresql://post:5432/jamesdb;create=true

No success!

I have made a docker network and both containers are running on that "docker network"

I am sure that my James container can access my Postgres container (when I try to run it with its internal Derby database and do not force it to connect to external database.) cause I have Docker-exec bash of James container and pinged my Postgres container (ping post) and it responded successfully. I even installed a psql database manager inside my James container and could successfully connect to the database on my Postgres container and manipulated the data on the database.

I simply do not understand why James says that it cannot see my PostgreSQL database while it should have access.

Share asked Mar 3 at 22:24 AdmWintherAdmWinther 313 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

I could solve the issue. The problem was the mistake in Apache/James documnation. On James website, it says that the JDBC driver must be placed under /conf/lib/ while in their github repo, they have mentioned that the JDBC driver must be placed under /root/libs/

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745069326a4609448.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信