Friday 29 May 2020

Adding MariaDB JDBC Connector to Paraya 5 - Followup

Just decided to do a followup on Adding MariaDB JDBC Connector to Payara 51.

I wanted to see if it was possibly very easy to do this using the command line.

Installing a MariaDB driver

$ ./asadmin add-library /home/mrbear/software/mariadb-java-client-2.3.0.jar
Command add-library executed successfully.

Creating a new JDBC Connection pool

The syntax:

Usage: asadmin [asadmin-utility-options] create-jdbc-connection-pool
        [--datasourceclassname ] [--restype ]
        [--steadypoolsize ]
        [--maxpoolsize ]
        [--maxwait ]
        [--poolresize ]
        [--idletimeout ] [--initsql ]
        [--isolationlevel ]
        [--isisolationguaranteed[=]]
        [--isconnectvalidatereq[=]]
        [--validationmethod ]
        [--validationtable ]
        [--failconnection[=]]
        [--allownoncomponentcallers[=]]
        [--nontransactionalconnections[=]]
        [--validateatmostonceperiod ]
        [--leaktimeout ]
        [--leakreclaim[=]]
        [--creationretryattempts ]
        [--creationretryinterval ]
        [--sqltracelisteners ]
        [--statementtimeout ]
        [--statementleaktimeout ]
        [--statementleakreclaim[=]]
        [--lazyconnectionenlistment[=]]
        [--lazyconnectionassociation[=]]
        [--associatewiththread[=]]
        [--driverclassname ]
        [--matchconnections[=]]
        [--maxconnectionusagecount ]
        [--ping[=]] [--pooling[=]]
        [--statementcachesize ]
        [--validationclassname ]
        [--wrapjdbcobjects[=]]
        [--description ] [--property ]
        [-?|--help[=]] jdbc_connection_pool_id

Note the following:

  • The escape character backslash (\) is used in the --property option to distinguish the semicolon (;).
  • Two backslashes (\\) are used to distinguish the equal sign (=).
  • Two backslashes (\\) are used to distinguish the colon (:).
./asadmin create-jdbc-connection-pool --driverclassname org.mariadb.jdbc.Driver --restype java.sql.Driver --property databaseName=mmud:password=topsecretpassword:user=root:URL=jdbc\\:mariadb\\://localhost\\:3306/mmud:serverName=localhost mmudpool

Let's test it!

./asadmin ping-connection-pool mmudpool

In case you wish to delete it, try:

./asadmin delete-jdbc-connection-pool mmudpool

Creating the JNDI

./asadmin create-jdbc-resource --connectionpoolid mmudpool jdbc/mmud

References

[1] Adding MariaDB JDBC Connector to Payara 5

https://randomthoughtsonjavaprogramming.blogspot.com/2018/12/adding-mariadb-jdbc-connector-to-paraya.html
[2] Payara Blog - An intro to connection pools in payar server 5
https://blog.payara.fish/an-intro-to-connection-pools-in-payara-server-5

Friday 22 May 2020

From JavaEE 8 to JakartaEE 8

So, trying to transition my little hobby project from Java EE to Jakarta EE.

It seems to be going well, mostly because the only thing that has changed are the names of the Maven dependencies1. (for now)

So for now the only changes take place in the pom.xml files.

Here are the changes:

<dependency>
  <groupId>javax</groupId>
  <artifactId>javaee-api</artifactId>
  <version>${javaee.version}</version>
  <scope>provided</scope>
</dependency>
<dependency>
  <groupId>jakarta.platform</groupId>
  <artifactId>jakarta.jakartaee-api</artifactId>
  <version>${jakartaee.version}</version>
  <scope>provided</scope>
</dependency>

I did notice that I could remove one Java EE spec in one of my Maven modules. The servlet-spec. Perhaps because I am using something special in there that's included in the default by now?

<dependency>
  <groupId>javax.servlet</groupId>
  <artifactId>javax.servlet-api</artifactId>
  <version>4.0.1</version>
  <scope>provided</scope>
</dependency>

Superfluous stuff

Noticed some stuff I no longer need. Probable leftovers from early days.

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-dependency-plugin</artifactId>
    <version>2.6</version>
    <executions>
        <execution>
            <phase>validate</phase>
            <goals>
                <goal>copy</goal>
            </goals>
            <configuration>
                <outputDirectory>${endorsed.dir}</outputDirectory>
                <silent>true</silent>
                <artifactItems>
                    <artifactItem>
                        <groupId>javax</groupId>
                        <artifactId>javaee-endorsed-api</artifactId>
                        <version>7.0</version>
                        <type>jar</type>
                    </artifactItem>
                </artifactItems>
            </configuration>
        </execution>
    </executions>
</plugin>

Versions

So my versions have changed as follows:

The old:

<javaee.version>8.0.1</javaee.version>

The new:

<jakartaee.version>8.0.0</jakartaee.version>

That seems to be all.

References

[1] Java Magazine - Transition from Java EE to Jakarta EE
https://blogs.oracle.com/javamagazine/transition-from-java-ee-to-jakarta-ee
Rieckpil - Bootstrap your first Jakarta EE 8 application
https://rieckpil.de/howto-bootstrap-your-first-jakarta-ee-8-application/
Jakarta EE - Jakarta EE Compatible Products
https://jakarta.ee/compatibility/

Thursday 14 May 2020

How to Debug a Cake

So, I've been baking cakes for a long time. I got the recipe from my mum, who has also been baking cakes for a long time.

This recipe is basically flower, eggs, butter, bakingpowder, and lots of sugar. You know, the old fashioned way.

Well, a couple of years ago, suddenly my cakes started failing mysteriously.

So I started trying to fix this, by changing stuff randomly. I started downloading recipes from the Internet, to see if they worked better. I bought a cake-flour package from the supermarket, perhaps that worked. I even changed ovens.

None of these things worked.

So, I sat down, and thought about it. And then I realised, I didn't try and find the problem as I would have if I looked at the problem as a bloody Software Designer (which is what I am).

Well, debugging a cake turns out to be hard. System.out.println or logging or breakpoints are quite impossible.

As they say, you have to find the problem during actual production.

Some conclusions

If you did not make any changes to your recipe, and suddenly your cakes start to fail, either one of your ingredients has changed or your process/tools for making the cake. This is an obvious conclusion.

I was going to assume that my tools and process were more or less the same.


The only thing that really works, is to change one ingredient at a time.


In other words:

“How often have I said to you that when you have eliminated the impossible, whatever remains, however improbable, must be the truth? ”- Sherlock Holmes, The Sign of the Four (1890)

It also helps to understand the process. What kind of ingredients in a cake are essential and what kind of role do they play?

Addendum

Well, after a lot of experimenting, and, quite frankly, a lot of dismal ruined cakes, I found the cause to be the butter.

The butter I used, Blue Band, must have changed at the time. So I did a little digging.

I noticed that there are no longer any dairy products in this butter.

And when I use butter made from dairy products, the cakes turn out fine.

Also, when I started checking the supermarket, I did notice that Blue Band also (at around the same time) came out with a new product called "Butter for cookies and cake". I checked, and it did indeed contain dairy products.

Am I just being paranoid in thinking this is not a coincidence?

Tuesday 5 May 2020

Upgrading to Angular 9

I've used the guide in [1].

Just writing down my notes on what I encountered.

$ ng version

Angular CLI: 8.3.23
Node: 10.13.0
OS: linux x64
Angular: 8.2.14
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.803.23
@angular-devkit/build-angular     0.803.23
@angular-devkit/build-optimizer   0.803.23
@angular-devkit/build-webpack     0.803.23
@angular-devkit/core              8.3.23
@angular-devkit/schematics        8.3.23
@angular/cli                      8.3.23
@ngtools/webpack                  8.3.23
@schematics/angular               8.3.23
@schematics/update                0.803.23
rxjs                              6.4.0
typescript                        3.4.5
webpack                           4.39.2

So let's try to update using [2].

Update to the latest 8 version.

ng update @angular/core@8 @angular/cli@8

This upgraded my version of Angular from 8.3.23 to 8.3.26

Update to the 9 version.

ng update @angular/core @angular/cli

This upgraded my version from 8.3.26 (obviously) to 9.1.3 .

Of course, this means it's probably a good idea to upgrade to the lastest libraries I also use.

npm install npm@latest -g
npm upgrade

These are (in no particular order):

  • ckeditor (1.1.2 to 1.2.3)
  • @ng-bootstrap/ng-bootstrap (5.1.5 to 6.1.0)
  • ngx-cookie-service (2.3.0 to 2.4.0)

I've removed jquery and popper.js, these are no longer necessary as I am using ng-bootstrap.

References

[1] Upgrade Angular 8/7 to Angular 9 With Ng Update & Angular CLI v9
https://www.techiediaries.com/angular/upgrade-angular-8-7-to-angular-9-with-cli-ng-update/
[2] Official Angular Updater Tool on the Web
https://update.angular.io/