<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>6.0.6</version>
</dependency>
<dependency>
<groupId>net.sourceforge.jtds</groupId>
<artifactId>jtds</artifactId>
<version>1.3.1</version>
</dependency>
I have the code above, but only whichever on top seemed to work when I run my program as I'm getting an error "no driver found".
if (isMySQL) {
url = "jdbc:mysql://localhost:3306/sportsdb?useSSL=false";
} else {
url = "jdbc:jtds:sqlserver://localhost:1433;DatabaseName=sportsdb";
}
Related
I am trying to migrate my code from older version of opensaml to version 4.0.1
AuthnContextClassRef authnCtxClassRef = null;
final AuthnContext authnCtx = existing20authnStatement.getAuthnContext();
if (authnCtx != null) {
authnCtxClassRef = authnCtx.getAuthnContextClassRef();
if (authnCtxClassRef != null) {
authnCtxClassRefName = authnCtxClassRef.getAuthnContextClassRef();
if (authnCtxClassRefName != null) {
authNStmt.setAuthenticationInstant(now);
authNStmt.setAuthenticationMethod(translateAuthN20to11(authnCtxClassRefName));
authNStmt.setSubject(makeSubject(subjectName, nameId));
assertion.getAuthenticationStatements().add(authNStmt);
}
}
}
I can see, from the source code that the class is defined at org.opensaml.saml.saml2.core.AuthnContextClassRef But when I try to import it, it says
AuthnContextClassRef cannot be resolved to a type
Same goes for the class ConfirmationMethod where the code written is as follows:
final ConfirmationMethod confirmationMethod = buildObj(ConfirmationMethodBuilder.class,ConfirmationMethod.DEFAULT_ELEMENT_NAME);
confirmationMethod.setConfirmationMethod(SAML10_CM_SENDER_VOUCHES);
I would guess you have some dependency missing in your POM. I have a working PoC for OpenSAML 4 here. Im using the following dependecies and AuthnContextClassRef works fine.
<dependency>
<groupId>org.opensaml</groupId>
<artifactId>opensaml-core</artifactId>
<version>4.1.1</version>
</dependency>
<dependency>
<groupId>org.opensaml</groupId>
<artifactId>opensaml-saml-api</artifactId>
<version>4.1.1</version>
</dependency>
<dependency>
<groupId>org.opensaml</groupId>
<artifactId>opensaml-saml-impl</artifactId>
<version>4.1.1</version>
</dependency>
<dependency>
<groupId>org.opensaml</groupId>
<artifactId>opensaml-messaging-api</artifactId>
<version>4.1.1</version>
</dependency>
<dependency>
<groupId>org.opensaml</groupId>
<artifactId>opensaml-messaging-impl</artifactId>
<version>4.1.1</version>
</dependency>
<dependency>
<groupId>org.opensaml</groupId>
<artifactId>opensaml-soap-api</artifactId>
<version>4.1.1</version>
</dependency>
<dependency>
<groupId>org.opensaml</groupId>
<artifactId>opensaml-soap-impl</artifactId>
<version>4.1.1</version>
</dependency>
I tried with 4.0.1 and it also works
I am working on a Java Google App Engine app, and when I deploy my app and open it on my browser I get the above error. iworks_db is the name of my database, and for some reason my app fails to connect to it. I'm using the guide found here: https://cloud.google.com/sql/docs/mysql/connect-app-engine.
My createConnectionPool method:
private DataSource createConnectionPool() {
HikariConfig config = new HikariConfig();
config.setJdbcUrl(String.format("jdbc:mysql:///%s", DB_NAME));
config.setUsername(DB_USER);
config.setPassword(DB_PASS);
config.setDriverClassName("org.hsqldb.jdbc.JDBCDriver");// This line does NOT exist on the guide
// I added it because I was getting "failed
// to get driver instance" error
config.addDataSourceProperty("socketFactory", "com.google.cloud.sql.mysql.SocketFactory");
config.addDataSourceProperty("cloudSqlInstance", CLOUD_SQL_CONNECTION_NAME);
config.addDataSourceProperty("useSSL", "false");
config.setMaximumPoolSize(5);
config.setMinimumIdle(5);
config.setConnectionTimeout(10000); // 10 seconds
config.setIdleTimeout(600000); // 10 minutes
config.setMaxLifetime(1800000); // 30 minutes
DataSource pool = new HikariDataSource(config);
return pool;
}
The dependencies in my pom.xml file:
<!-- Compile/runtime dependencies -->
<dependency>
<groupId>com.google.appengine</groupId>
<artifactId>appengine-api-1.0-sdk</artifactId>
<version>1.9.59</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
<type>jar</type>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>jstl</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>com.zaxxer</groupId>
<artifactId>HikariCP</artifactId>
<version>3.3.1</version>
</dependency>
<dependency>
<groupId>org.hsqldb</groupId>
<artifactId>hsqldb</artifactId>
<version>2.3.2</version>
</dependency>
Any help would be much appreciated!
Your URL is a mysql url while your driver is HyperSQL DataBase (hsqldb). That is the reason you get the exception regarding not acceptable jdbcUrl.
Your DB is Google Cloud mysql, which I believe is the case as the rest of your code use mysql factory (com.google.cloud.sql.mysql.SocketFactory), then change the driver class name to following:
config.setDriverClassName("com.mysql.jdbc.GoogleDriver");
Also replace the hsldb maven dependency with
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.18</version>
</dependency>
<dependency>
<groupId>com.google.cloud.sql</groupId>
<artifactId>mysql-socket-factory-connector-j-8</artifactId>
<version>1.0.14</version>
</dependency>
The com.google.cloud.sql.mysql.SocketFactory is provided in the mysql-socket-factory-connector-j-8 maven artifact.
Update:
You could also try not to use the DriverClassName at all.
Try adding the above two dependencies and remove the setDriverClassName line.
Getting exception whilst using Google Pubsub to list topics, my web application is running on tomcat.
public static List<String> listTopics(GcpCredentials gcCredentials, String project) throws GCPException, IOException
{
List<String> topics = new ArrayList<>();
TopicAdminClient client = getTopicClient(gcCredentials);
ProjectName projectName = ProjectName.create(project);
ListTopicsPagedResponse response = client.listTopics(projectName);
for (Topic topic :response.iterateAll())
{
topics.add(topic.getNameAsTopicName().getTopic());
}
return topics;
}`
Exception:
java.lang.IllegalArgumentException: Jetty ALPN/NPN has not been properly configured.
at io.grpc.netty.GrpcSslContexts.selectApplicationProtocolConfig(GrpcSslContexts.java:174)
at io.grpc.netty.GrpcSslContexts.configure(GrpcSslContexts.java:151)
at io.grpc.netty.GrpcSslContexts.configure(GrpcSslContexts.java:139)
at io.grpc.netty.GrpcSslContexts.forClient(GrpcSslContexts.java:109)
at io.grpc.netty.NettyChannelBuilder.createProtocolNegotiatorByType(NettyChannelBuilder.java:335)
at io.grpc.netty.NettyChannelBuilder.createProtocolNegotiator(NettyChannelBuilder.java:308)
at io.grpc.netty.NettyChannelBuilder$NettyTransportFactory$DynamicNettyTransportParams.getProtocolNegotiator(NettyChannelBuilder.java:499)
at io.grpc.netty.NettyChannelBuilder$NettyTransportFactory.newClientTransport(NettyChannelBuilder.java:448)
at io.grpc.internal.CallCredentialsApplyingTransportFactory.newClientTransport(CallCredentialsApplyingTransportFactory.java:61)
at io.grpc.internal.InternalSubchannel.startNewTransport(InternalSubchannel.java:209)
at io.grpc.internal.InternalSubchannel.obtainActiveTransport(InternalSubchannel.java:186)
at io.grpc.internal.ManagedChannelImpl$SubchannelImplImpl.obtainActiveTransport(ManagedChannelImpl.java:806)
at io.grpc.internal.GrpcUtil.getTransportFromPickResult(GrpcUtil.java:568)
at io.grpc.internal.DelayedClientTransport.reprocess(DelayedClientTransport.java:296)
at io.grpc.internal.ManagedChannelImpl$LbHelperImpl$5.run(ManagedChannelImpl.java:724)
at io.grpc.internal.ChannelExecutor.drain(ChannelExecutor.java:87)
at io.grpc.internal.ManagedChannelImpl$LbHelperImpl.runSerialized(ManagedChannelImpl.java:715)
at io.grpc.internal.ManagedChannelImpl$NameResolverListenerImpl.onUpdate(ManagedChannelImpl.java:752)
at io.grpc.internal.DnsNameResolver$1.run(DnsNameResolver.java:174)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
I have observed this problem with Netty version 4.1.15.Final but not with 4.1.13.Final. Check your transitive dependencies. I.e Spring Boot references Netty.
What I added to POM to make it work with Spanner API version 0.22.0-beta:
<properties>
<v.netty>4.1.13.Final</v.netty>
</properties>
...
<dependencyManagement>
<dependencies>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-codec</artifactId>
<version>${v.netty}</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-codec-http</artifactId>
<version>${v.netty}</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-codec-http2</artifactId>
<version>${v.netty}</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-handler</artifactId>
<version>${v.netty}</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-common</artifactId>
<version>${v.netty}</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-handler-proxy</artifactId>
<version>${v.netty}</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-transport</artifactId>
<version>${v.netty}</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-resolver</artifactId>
<version>${v.netty}</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-codec-socks</artifactId>
<version>${v.netty}</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-buffer</artifactId>
<version>${v.netty}</version>
</dependency>
</dependencies>
</dependencyManagement>
If the problem persists, or if it is not an option, plase run your JVM with appropriate bootclasspath entry, like:
java -Xbootclasspath/p:/tmp/alpn-boot-8.1.11.v20170118.jar -cp ...
Make sure to replace /tmp/alpn-boot-8.1.11.v20170118.jar with location of alpn jar that matches your JVM version as listed on this page: https://www.eclipse.org/jetty/documentation/9.4.x/alpn-chapter.html
There is a possible solution on github: "Exception when configuring SSL: "Jetty ALPN/NPN has not been properly configured."
The recommended steps, quoting from the above document:
1) Edit catalina.sh
/usr/local/Cellar/tomcat/8.5.3/libexec/bin/catalina.sh
2) At line 103, add the following
CATALINA_OPTS="-javaagent:/Library/Tomcat/lib/jetty-alpn-agent-2.0.6.jar"
3) Restart tomcat
../bin/shutdown.sh ../bin/startup.sh
I am trying to use gremlin to interact with my Neo4j community database. I am working in eclipse using maven.
Following the documentation in http://tinkerpop.apache.org/docs/3.1.0-incubating/#neo4j-gremlin i set up my dependencies to:
<dependencies>
<dependency>
<groupId>org.neo4j</groupId>
<artifactId>neo4j-cypher</artifactId>
<version>2.2.0</version>
</dependency>
<dependency>
<groupId>org.neo4j</groupId>
<artifactId>neo4j-ha</artifactId>
<version>2.2.0</version>
</dependency>
<dependency>
<groupId>org.apache.tinkerpop</groupId>
<artifactId>gremlin-core</artifactId>
<version>3.1.0-incubating</version>
</dependency>
<dependency>
<groupId>org.apache.tinkerpop</groupId>
<artifactId>neo4j-gremlin</artifactId>
<version>3.1.0-incubating</version>
</dependency>
<dependency>
<groupId>org.neo4j</groupId>
<artifactId>neo4j-tinkerpop-api-impl</artifactId>
<version>0.1-2.2</version>
</dependency>
<dependency>
<groupId>org.neo4j</groupId>
<artifactId>neo4j-tinkerpop-api</artifactId>
<version>0.1</version>
</dependency>
</dependencies>
After executing:
package test.gremlin.maven;
import org.apache.tinkerpop.gremlin.neo4j.structure.Neo4jGraph;
import org.apache.tinkerpop.gremlin.structure.Graph;
public class TestGremlin {
public static void main(String[] args) {
Graph graph = Neo4jGraph.open("/tmp/gremlintest");
}
}
i get the following error:
Exception in thread "main" java.lang.ClassCastException: org.neo4j.function.Functions$$Lambda$24/252651381 cannot be cast to org.neo4j.helpers.Function
at org.neo4j.helpers.Settings$DefaultSetting.apply(Settings.java:846)
at org.neo4j.kernel.configuration.ConfigurationValidator.validate(ConfigurationValidator.java:50)
at org.neo4j.kernel.configuration.Config.replaceSettings(Config.java:204)
at org.neo4j.kernel.configuration.Config.<init>(Config.java:92)
at org.neo4j.kernel.impl.factory.PlatformModule.<init>(PlatformModule.java:124)
at org.neo4j.kernel.impl.factory.GraphDatabaseFacadeFactory.createPlatform(GraphDatabaseFacadeFactory.java:177)
at org.neo4j.kernel.impl.factory.GraphDatabaseFacadeFactory.newFacade(GraphDatabaseFacadeFactory.java:124)
at org.neo4j.kernel.impl.factory.CommunityFacadeFactory.newFacade(CommunityFacadeFactory.java:40)
at org.neo4j.kernel.impl.factory.GraphDatabaseFacadeFactory.newFacade(GraphDatabaseFacadeFactory.java:108)
at org.neo4j.graphdb.factory.GraphDatabaseFactory.newDatabase(GraphDatabaseFactory.java:130)
at org.neo4j.graphdb.factory.GraphDatabaseFactory$1.newDatabase(GraphDatabaseFactory.java:118)
at org.neo4j.graphdb.factory.GraphDatabaseBuilder.newGraphDatabase(GraphDatabaseBuilder.java:185)
at org.neo4j.tinkerpop.api.impl.Neo4jFactoryImpl.newGraphDatabase(Neo4jFactoryImpl.java:44)
at org.neo4j.tinkerpop.api.Neo4jFactory$Builder.open(Neo4jFactory.java:32)
at org.apache.tinkerpop.gremlin.neo4j.structure.Neo4jGraph.<init>(Neo4jGraph.java:131)
at org.apache.tinkerpop.gremlin.neo4j.structure.Neo4jGraph.open(Neo4jGraph.java:145)
at org.apache.tinkerpop.gremlin.neo4j.structure.Neo4jGraph.open(Neo4jGraph.java:154)
at test.gremlin.maven.TestGremlin.main(TestGremlin.java:10)
Can you try to use the latest release: which is 0.3-2.3.3
see: https://github.com/neo4j-contrib/neo4j-tinkerpop-api-impl/tree/0.3-2.3.3
I tried to connect using orientdb database with java. like this
OrientGraph odb = new OrientGraph("plocal:C:/Users/USER/Desktop/orientdb/databases/testJ", "admin", "admin");
Its showing an error
HTTP Status 500 - Handler processing failed; nested exception is java.lang.NoClassDefFoundError: com/orientechnologies/orient/core/db/record/ODatabaseRecord
My dependencies..
<dependency>
<groupId>com.orientechnologies</groupId>
<artifactId>orientdb-core</artifactId>
<version>2.0.8</version>
</dependency>
<dependency>
<groupId>com.orientechnologies</groupId>
<artifactId>orientdb-jdbc</artifactId>
<version>1.7</version>
</dependency>
<dependency>
<groupId>com.tinkerpop</groupId>
<artifactId>pipes</artifactId>
<version>2.4.0</version>
</dependency>
<dependency>
<groupId>com.tinkerpop.blueprints</groupId>
<artifactId>blueprints-core</artifactId>
<version>2.4.0</version>
</dependency>
<dependency>
<groupId>com.tinkerpop.blueprints</groupId>
<artifactId>blueprints-orient-graph</artifactId>
<version>2.4.0</version>
</dependency>
help me to resolve the error..
thank you in advance
The ODatabaseRecord seems to be deprecated from new version. I made following changes to your code and it worked (remove all other dependencies).
pom
<dependency>
<groupId>com.orientechnologies</groupId>
<artifactId>orientdb-core</artifactId>
<version>2.0.8</version>
</dependency>
<dependency>
<groupId>com.orientechnologies</groupId>
<artifactId>orientdb-jdbc</artifactId>
<version>2.0.8</version>
</dependency>
Java Code
OrientGraphFactory ogf = new OrientGraphFactory(
"plocal:C:/Users/USER/Desktop/orientdb/databases/testJ", "admin", "admin");
OrientGraph og = ogf.getTx();
try {
System.out.println("Features = " + og.getFeatures());
} finally {
og.shutdown();
}
Note: I found clue here.