Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include Postgres JDBC driver in pom.xml #6819

Closed
poikilotherm opened this issue Apr 14, 2020 · 3 comments · Fixed by #7420
Closed

Include Postgres JDBC driver in pom.xml #6819

poikilotherm opened this issue Apr 14, 2020 · 3 comments · Fixed by #7420

Comments

@poikilotherm
Copy link
Contributor

poikilotherm commented Apr 14, 2020

(I looked everywhere, but I could not find an existing issue for this, thus creating a new. This is related to my old epic #5292 and had a commit for it, see df2b8cc)

Modern app servers are capable to load the JDBC driver from the deployed WAR when setting up database connections.

This makes manual installation of the Postgres driver obsolete and enables usage during integration tests with Testcontainers.

The addition to pom.xml is very simple:

<dependency>
    <groupId>org.postgresql</groupId>
    <artifactId>postgresql</artifactId>
    <version>42.2.12</version>
</dependency>

In addition, instead of letting the installer configure the database connection in domain.xml, we can provide the connection details either from annotations (Java EE standard compliant, should be preferred) or provide them from glassfish-resources.xml (which also support variables substitution from domain, environment or alias).

Note: the above has been skipped as beyond scope for now. Small steps.

Obviously, this affects a lot of places. Docs (#6593), installer (#6761), container images, ...
It makes updating and testing much easier: there is only ONE place to change the version, ideally by using a Maven property.

I already tested this a while ago, see links below.
What I don't remember: it's not clear if the timers database can be used for this, too. IIRC this is why I created #5345...

See also:

@poikilotherm
Copy link
Contributor Author

The timers are re-using the applications data source. Even complaining about preexisting tables. 🐌

[#|2020-07-01T18:57:58.086+0000ESC[1;92m|INFO|ESC[0mPayara 5.201|ESC[1;94morg.eclipse.persistence.session./file:/opt/pa
yara/appserver/glassfish/domains/production/applications/ejb-timer-service-app/WEB-INF/classes/___EJB__Timer__App.conne
ction|ESC[0m_ThreadID=1;_ThreadName=main;_TimeMillis=1593629878086;_LevelValue=800;|
/file:/opt/payara/appserver/glassfish/domains/production/applications/ejb-timer-service-app/WEB-INF/classes/___EJB__Timer__App login successful|#]

[#|2020-07-01T18:57:58.092+0000ESC[1;93m|WARNING|ESC[0mPayara 5.201|ESC[1;94mjavax.org.glassfish.persistence.org.glassfish.persistence.common|ESC[0m_ThreadID=1;_ThreadName=main;_TimeMillis=1593629878092;_LevelValue=900;|
PER01000: Got SQLException executing statement "CREATE TABLE "EJB__TIMER__TBL" ("TIMERID" VARCHAR(255) NOT NULL, "APPLICATIONID" BIGINT, "BLOB" BYTEA, "CONTAINERID" BIGINT, "CREATIONTIMERAW" BIGINT, "INITIALEXPIRATIONRAW" BIGINT, "INTERVALDURATION" BIGINT, "LASTEXPIRATIONRAW" BIGINT, "OWNERID" VARCHAR(255), "PKHASHCODE" INTEGER, "SCHEDULE" VARCHAR(255), "STATE" INTEGER, PRIMARY KEY ("TIMERID"))": org.postgresql.util.PSQLException: ERROR: relation "EJB__TIMER__TBL" already exists|#]

[#|2020-07-01T18:57:58.112+0000ESC[1;92m|INFO|ESC[0mPayara 5.201|ESC[1;94mjavax.enterprise.ejb.container|ESC[0m_ThreadID=1;_ThreadName=main;_TimeMillis=1593629878112;_LevelValue=800;_MessageID=AS-EJB-00054;|
Portable JNDI names for EJB TimerBean: [java:global/ejb-timer-service-app/TimerBean, java:global/ejb-timer-service-app/TimerBean!org.glassfish.ejb.persistent.timer.TimerLocal]|#]

[#|2020-07-01T18:57:58.164+0000ESC[1;92m|INFO|ESC[0mPayara 5.201|ESC[1;94mjavax.enterprise.web|ESC[0m_ThreadID=1;_ThreadName=main;_TimeMillis=1593629878164;_LevelValue=800;_MessageID=AS-WEB-GLUE-00172;|
Loading application [ejb-timer-service-app] at [/ejb-timer-service-app]|#]

[#|2020-07-01T18:57:58.578+0000ESC[1;92m|INFO|ESC[0mPayara 5.201|ESC[1;94mjavax.enterprise.system.container.ejb.com.sun.ejb.containers|ESC[0m_ThreadID=1;_ThreadName=main;_TimeMillis=1593629878578;_LevelValue=800;|
EJB5109:EJB Timer Service started successfully for data source [jdbc/VDCNetDS]|#]

[#|2020-07-01T18:57:58.579+0000ESC[1;92m|INFO|ESC[0mPayara 5.201|ESC[1;94mjavax.enterprise.system.container.ejb.com.sun.ejb.containers|ESC[0m_ThreadID=1;_ThreadName=main;_TimeMillis=1593629878579;_LevelValue=800;|
==> Restoring Timers ... |#]

poikilotherm added a commit to poikilotherm/dataverse that referenced this issue Jul 1, 2020
poikilotherm added a commit to poikilotherm/dataverse that referenced this issue Jul 1, 2020
poikilotherm added a commit to poikilotherm/dataverse that referenced this issue Jul 1, 2020
poikilotherm added a commit to poikilotherm/dataverse that referenced this issue Jul 1, 2020
poikilotherm added a commit to poikilotherm/dataverse that referenced this issue Jul 13, 2020
poikilotherm added a commit to poikilotherm/dataverse that referenced this issue Jul 13, 2020
poikilotherm added a commit to poikilotherm/dataverse that referenced this issue Jul 13, 2020
This commit is a first test to apply database configuration and
credentials to the application server without using a config
on domain level but on application level. It is not very configurable yet.

The JNDI names have been changed to be conform with Java EE 7.
See https://github.com/javaee-samples/javaee7-samples/tree/master/jpa/datasourcedefinition-applicationxml-pu
and others for working examples. (Staying with the old name was not successfull.)

We had to use the "global" scope, so the persistent EJB timers are successfully created
and stored in the database. Using the "app" scope crashes the deployment.
poikilotherm added a commit to poikilotherm/dataverse that referenced this issue Jul 13, 2020
poikilotherm added a commit to poikilotherm/dataverse that referenced this issue Aug 3, 2020
poikilotherm added a commit to poikilotherm/dataverse that referenced this issue Aug 3, 2020
@xoroz
Copy link

xoroz commented Oct 12, 2020

any news on this ?

@pdurbin
Copy link
Member

pdurbin commented Oct 13, 2020

@xoroz back in July I did a quick test of a pull request by @poikilotherm and left a review here: #7048 (review)

There's additional conversation in that pull request.

poikilotherm added a commit to poikilotherm/dataverse that referenced this issue Oct 26, 2020
poikilotherm added a commit to poikilotherm/dataverse that referenced this issue Oct 26, 2020
poikilotherm added a commit to poikilotherm/dataverse that referenced this issue Nov 4, 2020
poikilotherm added a commit to poikilotherm/dataverse that referenced this issue Nov 6, 2020
poikilotherm added a commit to poikilotherm/dataverse that referenced this issue Nov 9, 2020
poikilotherm added a commit to poikilotherm/dataverse that referenced this issue Nov 9, 2020
poikilotherm added a commit to poikilotherm/dataverse that referenced this issue Nov 9, 2020
poikilotherm added a commit to poikilotherm/dataverse that referenced this issue Nov 10, 2020
poikilotherm added a commit to poikilotherm/dataverse that referenced this issue Nov 10, 2020
poikilotherm added a commit to poikilotherm/dataverse that referenced this issue Nov 17, 2020
poikilotherm added a commit to poikilotherm/dataverse that referenced this issue Nov 17, 2020
poikilotherm added a commit to poikilotherm/dataverse that referenced this issue Nov 17, 2020
poikilotherm added a commit to poikilotherm/dataverse that referenced this issue Nov 17, 2020
pdurbin added a commit to poikilotherm/dataverse that referenced this issue Nov 20, 2020
Conflicts:
pom.xml (payara version .2 vs .6)
poikilotherm added a commit to poikilotherm/dataverse that referenced this issue Dec 1, 2020
poikilotherm added a commit to poikilotherm/dataverse that referenced this issue Jun 11, 2021
poikilotherm added a commit to poikilotherm/dataverse that referenced this issue Aug 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants