Java 11 configured but not reflected in TC web interface

Answered

I have received this warning message about Java:

This TeamCity server is using a deprecated version of Java (8). Please upgrade to Java 11 as future versions of TeamCity will be incompatible with Java 8. Note: at the moment TeamCity does not support Java versions > 11

And have followed the instructions here on how to update it. I have tried changing JAVA_HOME and TEAMCITY_JRE variables in /etc/environment, /etc/profile.d/jdk.sh, the .profile and .bashrc of teamcity and root, used the update-alternatives tool to select correct Java, and have dug into the TC config files and executable logic itself. I found that in the findJava.sh script, the $FJ_JAVA_EXEC and $FJ_JAVA_VERSION show /usr/lib/jvm/jdk-11/bin/java and 11.0.13 respectively, as they should. When I restart TC and go to the interface and reset TC server, I don't see the variables in Administration -> Diagnostics -> Internal Properties as changed and the warning message is still there: 

I know there have been questions about this, but I haven't found anything to help this issue. Please let me know what I can do. 

Thanks!

7 comments
Comment actions Permalink

Where and what to set depends on how you start the service. If you are starting it through systemd, you should set it in the unit file, it won't help setting them elsewhere. This is due to how systemd manages sessions, so there's not much we can do there. 

Environment=JRE_HOME=/usr/lib/jvm/java-11-openjdk

Please refer to systemd's documentation for more details on this.

If you are starting it through the console, the best suggestion would be to start the process through adding the envvar declaration directly to the command, such as:

JRE_HOME=/path/to/java/11 /opt/jetbrains/TeamCity/bin/teamcity-server.sh start

 

As a reminder, the JRE_HOME should point to the base folder of the installation and not to the java executable

 

This said, you seem to have a pretty old release of java 8 installed. If you are not using it for anything else in the server, it might be simpler to simply uninstall it entirely. Of course, the tips above should work but just removing java 8, unless you have manually modified the startup scripts should be just easier

0
Comment actions Permalink

Hi Denis, thanks for getting back. 
I went in and changed /etc/init.d/teamcity line from

sudo /opt/jetbrains/TeamCity/bin/teamcity-server.sh start

to

sudo JRE_HOME=/usr/lib/jvm/jdk-11 /opt/jetbrains/TeamCity/bin/teamcity-server.sh start

as suggested. When I do this and reboot, the web interface shows me this error

TeamCity server is connecting to MYSQL database. The database server is not started yet, or the database specified in '<TeamCity Data Directory>/config/database.properties' file is inaccessible.

Let me know if there is anything else I can try. Thanks

0
Comment actions Permalink

Here is the last bit from the teamcity-server.log

[2022-01-06 11:38:30,160]   WARN -  jetbrains.buildServer.STARTUP - Database connection error: jetbrains.buildServer.serverSide.db.DatabaseIsNotReachableException: Could not connect to MySQL server: SQL error when doing 'Taking a connection from the data source': com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server. Caused by: com.mysql.cj.exceptions.CJCommunicationsException: Communications link failureThe last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server. (enable debug to see stacktrace)
[2022-01-06 11:38:30,160]   INFO -  jetbrains.buildServer.STARTUP - Could not reach the database, it may be the database server is not started yet or connection properties are not valid.
[2022-01-06 11:38:30,160]   INFO -  jetbrains.buildServer.STARTUP - Current stage: Continuing attempts to connect to the database
[2022-01-06 11:38:30,160]   INFO -  jetbrains.buildServer.STARTUP - Administrator can login from web UI using super user authentication token
[2022-01-06 11:38:30,160]   INFO -   jetbrains.buildServer.SERVER - Super user authentication token: *** (use empty username with the token as the password to access the server)
0
Comment actions Permalink

Hi Denis, 

Any more insight you can give me? I attempted some things from other posts here, creating the <Teamcity Home>/jre directory and moving the installed jdk-11 there. I'm still seeing an issue where the server won't start. Please let me know, thanks!

0
Comment actions Permalink

Sorry for the delay. If the issue was the JRE you would not be seeing any issue in the logs as the logs are written by java. You can check the first few lines after restarting the server to see which version of java is being run right now.

 

It seems like the database does not work properly. As the error states, you should:

-check that the database is actually running. TeamCity won't run without a database

-make sure that the jdbc connector works with both java 11 and your database version. You can find more about the connector here: https://www.jetbrains.com/help/teamcity/set-up-external-database.html#On+TeamCity+Server+Side+(with+MySQL) . Usually just downloading the latest available and putting it in place is likely to work

-check that the data in the database.properties is correct. I assume it is correct since you probably didn't change it with the java switch, but just in case.

0
Comment actions Permalink

Here are the versions of the JDBC and MySQL.

[2022-02-01 14:32:50,393]   INFO -  jetbrains.buildServer.STARTUP - JDBC driver version: 8.0 (MySQL Connector/J)
[2022-02-01 14:32:50,393]   INFO -  jetbrains.buildServer.STARTUP - Database system version: 5.7.36 (MySQL)

It looks like they are compatible

Here is some compatibility information for Connector/J 8.0:

  • JDBC versions: Connector/J 8.0 implements JDBC 4.2. While Connector/J 8.0 works with libraries of higher JDBC versions, it returns aSQLFeatureNotSupportedException for any calls of methods supported only by JDBC 4.3 and higher.
  • MySQL Server versions: Connector/J 8.0 supports MySQL 5.7 and 8.0.
  • JRE versions: Connector/J 8.0 supports JRE 8 or higher.
  • JDK Required for Compilation: JDK 8.0 or higher is required for compiling Connector/J 8.0. Also, a customized JSSE provider might be required to use some later TLS versions and cipher suites when connecting to MySQL servers. For example, because Oracle's Java 8 releases before 8u261 were shipped with JSSE implementations that support TLS up to version 1.2 only, you need a customized JSSE implementation to use TLSv1.3 on those Java 8 platforms. Oracle Java 8u261 and above do support TLSv1.3, so no customized JSSE implementation is needed.

    And going back into the logs when I get the error message, it looks like Java 11 is running, and I'm not seeing anything different from a boot where the server runs. Here is the log:

    Starting TeamCity server
    [2022-02-01 15:41:01,934]   INFO -  jetbrains.buildServer.STARTUP - TeamCity version: 2021.2 (build 99542), data format version 976
    [2022-02-01 15:41:01,937]   INFO -  jetbrains.buildServer.STARTUP - OS: Linux, version 4.15.0-166-generic, amd64, Current user: root, Time zone: MST (UTC-07:00)
    [2022-02-01 15:41:01,937]   INFO -  jetbrains.buildServer.STARTUP - Java: 11.0.14, Java HotSpot(TM) 64-Bit Server VM (11.0.14+8-LTS-263, mixed mode), Java(TM) SE Runtime Environment (11.0.$
    [2022-02-01 15:41:01,939]   INFO -  jetbrains.buildServer.STARTUP - Garbage collection: G1 Young Generation, G1 Old Generation
    [2022-02-01 15:41:01,939]   INFO -  jetbrains.buildServer.STARTUP - Web server version: Apache Tomcat/8.5.72

    [2022-02-01 15:06:52,703]   INFO -  jetbrains.buildServer.STARTUP - Server IP address: ****
    [2022-02-01 15:06:52,705]   INFO -  jetbrains.buildServer.STARTUP - Web server ports: 8111 (protocol: HTTP/1.1, scheme: http), 8105 (shutdown port)
    [2022-02-01 15:06:52,705]   INFO -  jetbrains.buildServer.STARTUP - Context path: "/", servlet real path: "/opt/jetbrains/TeamCity/webapps/ROOT"
    [2022-02-01 15:06:52,850]   INFO -  jetbrains.buildServer.STARTUP - TeamCity distribution type: tar.gz
    [2022-02-01 15:06:52,877]   INFO -  jetbrains.buildServer.STARTUP - TeamCity server node id: MAIN_SERVER
    [2022-02-01 15:06:53,000]   INFO -  jetbrains.buildServer.STARTUP - Version file lock was successfully obtained: /opt/jetbrains/TeamCity/webapps/ROOT/BUILD_99542
    [2022-02-01 15:06:53,029]   INFO -  jetbrains.buildServer.STARTUP - Current stage: Looking for the TeamCity Data Directory
    [2022-02-01 15:06:53,030]   INFO -  jetbrains.buildServer.STARTUP - The TeamCity Data Directory path is determined using the startup configuration from '/opt/jetbrains/TeamCity/conf/teamcity-startup.properties' file
    [2022-02-01 15:06:53,053]   INFO -  jetbrains.buildServer.STARTUP - The TeamCity Data Directory "/opt/jetbrains/TeamCity/.BuildServer" exists
    [2022-02-01 15:06:53,092]   INFO -  jetbrains.buildServer.STARTUP - Node specific data directory location: /opt/jetbrains/TeamCity/.BuildServer
    [2022-02-01 15:06:53,092]   INFO -  jetbrains.buildServer.STARTUP - Will use custom path for the database properties file: /opt/jetbrains/TeamCity/.BuildServer/config/database.properties
    [2022-02-01 15:06:53,093]   INFO -  jetbrains.buildServer.STARTUP - The TeamCity server caches directory is set to the path: /opt/jetbrains/TeamCity/.BuildServer/system/caches
    [2022-02-01 15:06:53,094]   INFO -  jetbrains.buildServer.STARTUP - The main configuration file "/opt/jetbrains/TeamCity/.BuildServer/config/main-config.xml" exists
    [2022-02-01 15:06:53,094]   INFO -  jetbrains.buildServer.STARTUP - The database properties file "/opt/jetbrains/TeamCity/.BuildServer/config/database.properties" exists
    [2022-02-01 15:06:53,094]   INFO -  jetbrains.buildServer.STARTUP - The internal database data file "/opt/jetbrains/TeamCity/.BuildServer/system/buildserver.data" doesn't exist
    [2022-02-01 15:06:53,113]   INFO -  jetbrains.buildServer.STARTUP - Data Directory version: 976
    [2022-02-01 15:06:53,130]   INFO -  jetbrains.buildServer.STARTUP - TeamCity main node (id: MAIN_SERVER) is starting...
    [2022-02-01 15:06:53,131]   INFO -  jetbrains.buildServer.STARTUP - Current stage: Looking for the database configuration
    [2022-02-01 15:06:53,131]   INFO -  jetbrains.buildServer.STARTUP - Database properties file "/opt/jetbrains/TeamCity/.BuildServer/config/database.properties" exists
    [2022-02-01 15:06:53,131]   INFO -  jetbrains.buildServer.STARTUP - Internal HSQL database file (/opt/jetbrains/TeamCity/.BuildServer/system/buildserver.data) doesn't exist
    [2022-02-01 15:06:53,131]   INFO -  jetbrains.buildServer.STARTUP - Database connection URL: jdbc:mysql:///teamcity
    [2022-02-01 15:06:53,132]   INFO -  jetbrains.buildServer.STARTUP - Using database connection URL from the database properties file. The URL is: jdbc:mysql:///teamcity
    [2022-02-01 15:06:53,132]   INFO -  jetbrains.buildServer.STARTUP - Using external (MYSQL) database
    [2022-02-01 15:06:53,132]   INFO -  jetbrains.buildServer.STARTUP - Current stage: Connecting to the database
    [2022-02-01 15:06:53,153]   INFO -  jetbrains.buildServer.STARTUP - JDBC loader: loading JDBC drivers (for the first time)
    [2022-02-01 15:06:53,470]   INFO -  jetbrains.buildServer.STARTUP - Effective database connection properties:
    [2022-02-01 15:06:53,470]   INFO -  jetbrains.buildServer.STARTUP -     alwaysSendSetIsolation=false [defaults]
    [2022-02-01 15:06:53,470]   INFO -  jetbrains.buildServer.STARTUP -     cachePrepStmts=true [defaults]
    [2022-02-01 15:06:53,471]   INFO -  jetbrains.buildServer.STARTUP -     characterEncoding=UTF-8 [defaults]
    [2022-02-01 15:06:53,471]   INFO -  jetbrains.buildServer.STARTUP -     defaultAutoCommit=true [defaults]
    [2022-02-01 15:06:53,471]   INFO -  jetbrains.buildServer.STARTUP -     elideSetAutoCommits=true [defaults]
    [2022-02-01 15:06:53,471]   INFO -  jetbrains.buildServer.STARTUP -     noTimezoneConversionForDateType=false [defaults]
    [2022-02-01 15:06:53,471]   INFO -  jetbrains.buildServer.STARTUP -     noTimezoneConversionForTimeType=false [defaults]
    [2022-02-01 15:06:53,471]   INFO -  jetbrains.buildServer.STARTUP -     prepStmtCacheSize=300 [defaults]
    [2022-02-01 15:06:53,471]   INFO -  jetbrains.buildServer.STARTUP -     serverTimezone=America/Phoenix [defaults]
    [2022-02-01 15:06:53,471]   INFO -  jetbrains.buildServer.STARTUP -     useGmtMillisForDatetimes=true [defaults]
    [2022-02-01 15:06:53,471]   INFO -  jetbrains.buildServer.STARTUP -     useJDBCCompliantTimezoneShift=true [defaults]
    [2022-02-01 15:06:53,471]   INFO -  jetbrains.buildServer.STARTUP -     useLegacyDatetimeCode=false [defaults]
    [2022-02-01 15:06:53,471]   INFO -  jetbrains.buildServer.STARTUP -     useLocalSessionState=true [defaults]
    [2022-02-01 15:06:53,472]   INFO -  jetbrains.buildServer.STARTUP -     useTimezone=true [defaults]
    [2022-02-01 15:06:53,472]   INFO -  jetbrains.buildServer.STARTUP -     userServerPrepStmts=true [defaults]
    [2022-02-01 15:06:55,366]   WARN -  jetbrains.buildServer.STARTUP - Database connection error: jetbrains.buildServer.serverSide.db.DatabaseIsNotReachableException: Could not connect to MyS
    QL server: SQL error when doing 'Taking a connection from the data source': com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server. Caused by: com.mysql.cj.exceptions.CJCommunicationsException: Communications link failure
    The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server. (enable debug to see stacktrace)
    [2022-02-01 15:06:55,366]   INFO -  jetbrains.buildServer.STARTUP - Could not reach the database, it may be the database server is not started yet or connection properties are not valid.
    [2022-02-01 15:06:55,366]   INFO -  jetbrains.buildServer.STARTUP - Current stage: Continuing attempts to connect to the database

    How do I check if the database is actually running?

0
Comment actions Permalink

Looks like updating the jdbc connector worked! I see in your documentation from the link it has to be the same version. Thanks for all your help!

0

Please sign in to leave a comment.