This article contains description and explanation on the situation triggered the error message specified in the title of this article. The error is an error retrieved from Wildfly server.log located in the Wildfly Java Application Server’s folder installation. It is an error which can be shown detail as follows :
Caused by: java.sql.SQLException: Unsupported character encoding 'UTF'
The full error message retrieved from server.log’s Wildfly Java Application Server is shown below :
WFLYCTL0186: Services which failed to start: service jboss.deployment.unit."webapp-1.0-SNAPSHOT.war".PARSE: WFLYSRV0153: Failed to process phase PARSE of deployment "webapp-1.0-SNAPSHOT.war" 2018-06-11 00:01:25,620 WARN [org.jboss.jca.core.connectionmanager.pool.strategy.OnePool] (management-handler-thread - 1) IJ000604: Throwable while attempting to get a new connection: null: javax.resource.ResourceException: IJ031084: Unable to create connection at org.jboss.jca.adapters.jdbc.local.LocalManagedConnectionFactory.createLocalManagedConnection(LocalManagedConnectionFactory.java:345) at org.jboss.jca.adapters.jdbc.local.LocalManagedConnectionFactory.getLocalManagedConnection(LocalManagedConnectionFactory.java:352) at org.jboss.jca.adapters.jdbc.local.LocalManagedConnectionFactory.createManagedConnection(LocalManagedConnectionFactory.java:287) at org.jboss.jca.core.connectionmanager.pool.mcp.SemaphoreConcurrentLinkedDequeManagedConnectionPool.createConnectionEventListener(SemaphoreConcurrentLinkedDequeManagedConnectionPool.java:1327) at org.jboss.jca.core.connectionmanager.pool.mcp.SemaphoreConcurrentLinkedDequeManagedConnectionPool.getConnection(SemaphoreConcurrentLinkedDequeManagedConnectionPool.java:499) at org.jboss.jca.core.connectionmanager.pool.AbstractPool.internalTestConnection(AbstractPool.java:1067) at org.jboss.jca.core.connectionmanager.pool.strategy.OnePool.testConnection(OnePool.java:93) at org.jboss.as.connector.subsystems.common.pool.PoolOperations$TestConnectionInPool.invokeCommandOn(PoolOperations.java:240) at org.jboss.as.connector.subsystems.common.pool.PoolOperations$1.execute(PoolOperations.java:97) at org.jboss.as.controller.AbstractOperationContext.executeStep(AbstractOperationContext.java:982) at org.jboss.as.controller.AbstractOperationContext.processStages(AbstractOperationContext.java:726) at org.jboss.as.controller.AbstractOperationContext.executeOperation(AbstractOperationContext.java:450) at org.jboss.as.controller.OperationContextImpl.executeOperation(OperationContextImpl.java:1408) at org.jboss.as.controller.ModelControllerImpl.internalExecute(ModelControllerImpl.java:423) at org.jboss.as.controller.ModelControllerImpl.lambda$execute$1(ModelControllerImpl.java:243) at org.wildfly.security.auth.server.SecurityIdentity.runAs(SecurityIdentity.java:263) at org.wildfly.security.auth.server.SecurityIdentity.runAs(SecurityIdentity.java:229) at org.jboss.as.controller.ModelControllerImpl.execute(ModelControllerImpl.java:243) at org.jboss.as.controller.remote.ModelControllerClientOperationHandler$ExecuteRequestHandler.doExecute(ModelControllerClientOperationHandler.java:240) at org.jboss.as.controller.remote.ModelControllerClientOperationHandler$ExecuteRequestHandler.access$400(ModelControllerClientOperationHandler.java:138) at org.jboss.as.controller.remote.ModelControllerClientOperationHandler$ExecuteRequestHandler$1$1.run(ModelControllerClientOperationHandler.java:162) at org.jboss.as.controller.remote.ModelControllerClientOperationHandler$ExecuteRequestHandler$1$1.run(ModelControllerClientOperationHandler.java:158) at org.wildfly.security.auth.server.SecurityIdentity.runAs(SecurityIdentity.java:287) at org.wildfly.security.auth.server.SecurityIdentity.runAs(SecurityIdentity.java:244) at org.jboss.as.controller.AccessAuditContext.doAs(AccessAuditContext.java:254) at org.jboss.as.controller.AccessAuditContext.doAs(AccessAuditContext.java:225) at org.jboss.as.controller.remote.ModelControllerClientOperationHandler$ExecuteRequestHandler$1.execute(ModelControllerClientOperationHandler.java:158) at org.jboss.as.protocol.mgmt.ManagementRequestContextImpl$1.doExecute(ManagementRequestContextImpl.java:70) at org.jboss.as.protocol.mgmt.ManagementRequestContextImpl$AsyncTaskRunner.run(ManagementRequestContextImpl.java:160) at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35) at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:1985) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1487) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1378) at java.lang.Thread.run(Thread.java:748) at org.jboss.threads.JBossThread.run(JBossThread.java:485) Caused by: java.sql.SQLException: Unsupported character encoding 'UTF' at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:127) at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:95) at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:87) at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:61) at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:71) at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:85) at com.mysql.cj.jdbc.ConnectionImpl.(ConnectionImpl.java:440) at com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:230) at com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:226) at org.jboss.jca.adapters.jdbc.local.LocalManagedConnectionFactory.createLocalManagedConnection(LocalManagedConnectionFactory.java:321) ... 34 more Caused by: com.mysql.cj.exceptions.WrongArgumentException: Unsupported character encoding 'UTF' at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:423) at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:59) at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:103) at com.mysql.cj.util.StringUtils.getBytes(StringUtils.java:287) at com.mysql.cj.jdbc.JdbcPropertySetImpl.postInitialization(JdbcPropertySetImpl.java:75) at com.mysql.cj.conf.DefaultPropertySet.initializeProperties(DefaultPropertySet.java:206) at com.mysql.cj.jdbc.ConnectionImpl.(ConnectionImpl.java:382) ... 37 more Caused by: java.io.UnsupportedEncodingException: UTF at java.lang.StringCoding.encode(StringCoding.java:341) at java.lang.String.getBytes(String.java:918) at com.mysql.cj.util.StringUtils.getBytes(StringUtils.java:285)
It is when a new driver class of MySQL Database Driver is being registered. The MySQL Database Driver connector is the new old so the driver name is not ‘com.mysql.jdbc.Driver’ since it is deprecated. The new driver’s name is ‘com.mysql.cj.jdbc.Driver’ but there is an error specified above upon using the driver which is ‘Caused by: java.io.UnsupportedEncodingException: UTF’. It is because the JDBC JNDI URL datasource used contains the parameter with the value of UTF. Below is the actual JDBC JNDI URL used :
jdbc:mysql://localhost:3306/testing?useSSL=false&useUnicode=yes&characterEncoding=UTF-8&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC
The value specified above is the characterEncoding attribute which has the value of ‘UTF’. Since it is creating an error, it must be changed. The JDBC JNDI URL datasource itself is actually specified or defined in the file named standalone.xml. The file named standalone.xml is a Wildfly configuration file located in the folder named ‘configuration’ located in the Wildfly Java Application folder’s installation. Below is the location of the folder :
hamdi@soulreaper:/opt/wildfly-12.0.0.Final$ tree -L 3 . ... ├── standalone │ ├── configuration │ │ ├── application-roles.properties │ │ ├── application-users.properties │ │ ├── logging.properties │ │ ├── mgmt-groups.properties │ │ ├── mgmt-users.properties │ │ ├── nohup.out │ │ ├── standalone-ee8.xml │ │ ├── standalone-full-ha.xml │ │ ├── standalone-full.xml │ │ ├── standalone-ha.xml │ │ ├── standalone-load-balancer.xml │ │ ├── standalone.xml │ │ └── standalone_xml_history
<datasource jndi-name="java:/jdbc/testing-database" pool-name="my-datasource"> <connection-url>jdbc:mysql://localhost:3306/testing?useSSL=false&useUnicode=yes&characterEncoding=UTF-8&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC
</connection-url> ... </datasource>
So, in order to solve the error message, just edit the connection-url specified in the datasource tag. After trying several times, below is the correct JNDI with the correct value of connection-url :
jdbc:mysql://localhost:3306/testing?useUnicode=yes&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC
So, rather than using characterEncoding=UTF, specifying useUnicode=yes is enough to make sure the unicode character is used upon using the com.mysql.cj.jdbc.Driver. Save the standalone.xml file, stop the Wildfly Java Application Server and then start it again. Below is the actual connection-url after edited :
<datasource jndi-name="java:/jdbc/testing-database" pool-name="my-datasource"> <connection-url>jdbc:mysql://localhost:3306/testing?useUnicode=yes&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC
</connection-url> ... </datasource>
For more information, read the reference in this article titled ‘How to Load MySQL Database Driver in Wildfly Java Application Server’ in this link and also the article titled ‘How to Solve Error Message : Loading class `com.mysql.jdbc.Driver’. This is deprecated. The new driver class is `com.mysql.cj.jdbc.Driver’.’ in this link. Those articles mentioned before are quite related with this article.