I am trying to connect to google cloud SQL. I was able to successfully do that a couple of days ago but right now I am facing some issues with that.
The problem that is occurring is
Loading class com.mysql.jdbc.Driver'. This is deprecated. The new driver class iscom.mysql.cj.jdbc.Driver'. The driver is automatically registered via the SPI and manual loading of the driver class is generally unnecessary.
since it automatically loads com.mysql.cj.jdbc.Driver I am getting the following error:
java.sql.SQLNonTransientConnectionException: Could not create connection to database server.
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:676)
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:663)
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:653)
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:638)
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:606)
at com.mysql.cj.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:1837)
at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:1653)
at com.mysql.cj.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:662)
at com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:352)
at com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:221)
at java.sql.DriverManager.getConnection(DriverManager.java:664)
at java.sql.DriverManager.getConnection(DriverManager.java:270)
at com.example.endpoints.insertUser.doPost(insertUser.java:160)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:821)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:583)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143)
at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:548)
at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:226)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1158)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:511)
at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:185)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1090)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:213)
at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:109)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:119)
at org.eclipse.jetty.server.Server.handle(Server.java:517)
at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:306)
at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:242)
at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:261)
at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:95)
at org.eclipse.jetty.io.SelectChannelEndPoint$2.run(SelectChannelEndPoint.java:75)
at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.produceAndRun(ExecuteProduceConsume.java:213)
at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.run(ExecuteProduceConsume.java:147)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:654)
at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:572)
at java.lang.Thread.run(Thread.java:745)
**Caused by: java.lang.ClassCastException: com.google.cloud.sql.mysql.SocketFactory cannot be cast to com.mysql.cj.api.io.SocketFactory**
at com.mysql.cj.core.io.AbstractSocketConnection.createSocketFactory(AbstractSocketConnection.java:129)
at com.mysql.cj.mysqla.io.MysqlaSocketConnection.connect(MysqlaSocketConnection.java:56)
at com.mysql.cj.mysqla.MysqlaSession.connect(MysqlaSession.java:144)
at com.mysql.cj.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:1783)
... 33 more
check the bold part....
the url I am using to make connection is this:-
"jdbc:mysql://google/*****?cloudSqlInstance=******&socketFactory=com.google.cloud.sql.mysql.SocketFactory&user=****&password=****&useSSL=true"
I think the problem is that you are using mysql-socket-factory which have class com.google.cloud.sql.mysql.SocketFactory implements com.mysql.jdbc.SocketFactory
Try this one: mysql-socket-factory-connector-j-6
If you are using the following dependencies
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>*.*.*</version>
</dependency>
<dependency>
<groupId>com.google.cloud.sql</groupId>
<artifactId>mysql-socket-factory</artifactId>
<version>*.*.*</version>
</dependency>
use this starter instead
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-gcp-starter-sql-mysql</artifactId>
<version>1.0.0.RELEASE</version>
</dependency>
I had a Very similar issue that may have the same root cause
com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Could not create socket factory 'com.google.cloud.sql.mysql.SocketFactory' due to underlying exception:
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
...
Caused by: java.lang.ClassCastException: com.google.cloud.sql.mysql.SocketFactory cannot be cast to com.mysql.jdbc.SocketFactory
at com.mysql.jdbc.MysqlIO.createSocketFactory(MysqlIO.java:3324)
... 80 more
Which was very strange since I had everything working previously.
Turns out that my wifi connection was on the wrong network and I had no connectivity. When I fixed my network connection, the DB connection worked again. Tried enabling and disabling wifi to be sure. Yep, very confusing error for the actual problem.
Hope this helps out someone with the same issue.
Related
I am trying to implement the REst Client example from the Quarkus website (code 1:1): https://quarkus.io/guides/rest-client
When I launch http://localhost:8080/country/name/greece I get:
Error handling ce3120e3-1a55-418e-a5a1-a17a80d7e278-1, org.jboss.resteasy.spi.UnhandledException: javax.ws.rs.ProcessingException: RESTEASY003145: Unable to find a MessageBodyReader of content-type application/json;charset=utf-8 and type interface java.util.Set
After some reading on the internets I stumbled upon a hint, that it could be connected to a missing Jackson dependency.
So I added the below and reran (same error regardless of the version):
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy-jackson</artifactId>
<version>1.3.0.Alpha2</version>
</dependency>
Now I get the following issue:
Error handling 00077d3a-bbdb-48ee-b84b-653bf98baefc-2, org.jboss.resteasy.spi.UnhandledException:
javax.ws.rs.ProcessingException: com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException:
Unrecognized field "topLevelDomain" (class org.acme.Country),
not marked as ignorable (4 known properties: "capital", "alpha2Code", "name", "currencies"])
My stack is Quarkus 1.2.1, JDK 12.0.2 and Windows 10.
Any ideas what I might be doing wrong?
I had the same error at my project, it stopped happening when I added this dependency:
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy-jsonb</artifactId>
</dependency>
I'm trying to config Hawkbit following this guide: https://www.eclipse.org/hawkbit/guides/runhawkbit/
In pom.xml:
<dependency>
<groupId>org.mariadb.jdbc</groupId>
<artifactId>mariadb-java-client</artifactId>
<scope>compile</scope>
</dependency>
In application.properties:
spring.jpa.database=MYSQL
spring.datasource.url=jdbc:mysql://localhost:3306/{SCHEMA_NAME}
spring.datasource.username={USER_NAME}
spring.datasource.password={PWD}
spring.datasource.driverClassName=org.mariadb.jdbc.Driver
But I got this error: https://paste.ubuntu.com/p/YDtFKxF4Vv/
How to resolve this?
Might be a bit late, but basically the Hawkbit server has database migration scripts (Flyway). Within the HawkBit database, there is a table reserved for tracking these migrations for backwards compatibility. This is the schema_version table.
The problem that you see here is that Flyway is trying to migrate the state of the database, but fails because it detects a previous migration that failed.
Caused by: org.flywaydb.core.api.FlywayException: Validate failed: Detected failed migration to version 1.0.1 (init )
at org.flywaydb.core.Flyway.doValidate(Flyway.java:1482)
at org.flywaydb.core.Flyway.access$100(Flyway.java:85)
at org.flywaydb.core.Flyway$1.execute(Flyway.java:1364)
at org.flywaydb.core.Flyway$1.execute(Flyway.java:1356)
at org.flywaydb.core.Flyway.execute(Flyway.java:1711)
at org.flywaydb.core.Flyway.migrate(Flyway.java:1356)
at org.springframework.boot.autoconfigure.flyway.FlywayMigrationInitializer.afterPropertiesSet(FlywayMigrationInitializer.java:66)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1837)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1774)
... 98 common frames omitted
Easiest solution would be to start with a fresh database. But in the case that you have important data in the database, you could also truncate the schema_version table and rerun the Hawkbit server.
Hi I am facing this issue while launching the driver.
Starting ChromeDriver 2.35.528161 (5b82f2d2aae0ca24b877009200ced9065a772e73) on port 4097
Only local connections are allowed.
Exception in thread "main" java.lang.NoSuchMethodError: com.google.gson.GsonBuilder.setLenient()Lcom/google/gson/GsonBuilder;
at org.openqa.selenium.json.Json.<clinit>(Json.java:47)
at org.openqa.selenium.logging.profiler.HttpProfilerLogEntry.constructMessage(HttpProfilerLogEntry.java:37)
at org.openqa.selenium.logging.profiler.HttpProfilerLogEntry.<init>(HttpProfilerLogEntry.java:29)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:141)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:83)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:601)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:219)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:142)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:181)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:168)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:123)
at isf.Login.main(Login.java:21)
Can anybody tell what i am missing ..because same libs i am using for another project and its working fine there.
I was facing the same issue and got resolved using below approach:
If you check JSON class at line 47, setLenient() is missing.
This issue is possibly due to conflicts in Gson versions.
Go to your repository:
C:\Users\User_name\.m2\repository\com\google\code\gson
Delete all the existing folders.
Now, add below maven dependency in your pom file:
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.5</version>
<scope>provided</scope>
</dependency>
Re-build your pom.xml file and execute the script.
In case you are using maven, you should add the following dependency:
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.5</version>
</dependency>
That should solve it. Gson package version should be correlated with latest Selenium version.
Before anyone downvotes me for a duplicate question.... I have read all the other StackOverflow answers related to this topic and nothing has answered my question.
So I am using JMockit 1.19, below is my pom.xml dependencies for Jmockit and Junit
<dependency>
<groupId>org.jmockit</groupId>
<artifactId>jmockit</artifactId>
<version>1.19</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.7</version>
</dependency>
I am using EclEmma 2.3.2 plugin as installed via Eclipse Marketplace.
However I am getting several different issues at once when I try to view my code coverage.
For one I get the following exception log:
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at sun.instrument.InstrumentationImpl.loadClassAndStartAgent(InstrumentationImpl.java:386)
at sun.instrument.InstrumentationImpl.loadClassAndCallPremain(InstrumentationImpl.java:401)
Caused by: java.lang.RuntimeException: Class java/util/UUID could not be instrumented.
at org.jacoco.agent.rt.internal_9dd1198.core.runtime.ModifiedSystemClassRuntime.createFor(ModifiedSystemClassRuntime.java:138)
at org.jacoco.agent.rt.internal_9dd1198.core.runtime.ModifiedSystemClassRuntime.createFor(ModifiedSystemClassRuntime.java:99)
at org.jacoco.agent.rt.internal_9dd1198.PreMain.createRuntime(PreMain.java:55)
at org.jacoco.agent.rt.internal_9dd1198.PreMain.premain(PreMain.java:47)
... 6 more
Caused by: java.lang.NoSuchFieldException: $jacocoAccess
at java.lang.Class.getField(Class.java:1695)
at org.jacoco.agent.rt.internal_9dd1198.core.runtime.ModifiedSystemClassRuntime.createFor(ModifiedSystemClassRuntime.java:136)
... 9 more
FATAL ERROR in native method: processing of -javaagent failed
Exception in thread "main"
I also get two pop-ups that say....
popup 1) - "No coverage data has been collected during this coverage session. Please do not terminate the Java process manually from Eclipse."
pupup 2) - "Error while dumping coverage data (code 5013). com.mountainminds.eclemma.internal.core.launching.AgentServer"
In order to get JMockit to run successfully I am providing the JVM argument
-javaagent:C:/Users/vn90614/.m2/repository/org/jmockit/jmockit/1.19/jmockit-1.19.jar
I think this argument is realted to the issue
Ok, so I FINALLY solved this issue after almost a week of working on this and asking everyone in the office. I had linked another project on my build path and that's what caused this issue. Not only did it affect this but this caused a ton of issues with JMockit, Mockito, and PowerMock functions. Linking projects on your build path WILL cause issues for testing frameworks and code coverage.
spring-data-couchbase 2.0.0.RELEASE
4.0.0-4047 Community Edition (build-4047)
At times I face connection timeout exception being thrown
Caused by: com.couchbase.client.deps.io.netty.channel.ConnectTimeoutException: connection timed out
I am using following environment configuration
#Override
protected CouchbaseEnvironment getEnvironment() {
return DefaultCouchbaseEnvironment.builder()
.connectTimeout(TimeUnit.SECONDS.toMillis(100))
.computationPoolSize(6).autoreleaseAfter(9000).build();
}
my databuckets are auto wired in my services and I in one particular use case, I update a few documents across two data bucket. In case of connection being a bit iffy I get this exception and I am left with corrupt data of not all docs getting updated. Is there any connection retry mechanism which I can use if in case of connection failure?
As a temporary attempt to fix, can you try forcing the Couchbase Java SDK to bump to version 2.2.4?
Add this to your pom.xml's <dependencies> section:
<dependency>
<groupId>com.couchbase.client</groupId>
<artifactId>java-client</artifactId>
<version>2.2.4</version>
</dependency>