Neo4j No query engine installed - java

I tried running the Neo4j sample program JavaQuery.java. I used the neo4j maven script provided to get all the dependencies. However when I run it I get the following error:
Exception in thread "main" java.lang.UnsupportedOperationException: No query engine installed.
at org.neo4j.kernel.impl.query.NoQueryEngine.noQueryEngine(NoQueryEngine.java:56)
at org.neo4j.kernel.impl.query.NoQueryEngine.executeQuery(NoQueryEngine.java:33)
at org.neo4j.kernel.InternalAbstractGraphDatabase.execute(InternalAbstractGraphDatabase.java:953)
at org.neo4j.kernel.InternalAbstractGraphDatabase.execute(InternalAbstractGraphDatabase.java:944)
at JavaQuery.JavaQuery.run(JavaQuery.java:60)
at JavaQuery.JavaQuery.main(JavaQuery.java:44)
I haven't found any documentation about how to get the query engine installed.
the simple low level java interface seems to work, but I haven't been able to get Cypher queries to work.
How do I get past this issue?

You need neo4j cypher dependency.
<dependency>
<groupId>org.neo4j</groupId>
<artifactId>neo4j-cypher</artifactId>
<version>2.2.0</version>
</dependency>

The neo4j-cypher dependency that #shazin mentioned, should come along when you depend on:
<dependency>
<groupId>org.neo4j</groupId>
<artifactId>neo4j</artifactId>
<version>2.2.0</version>
</dependency>

I had a similar issue and I had the dependency org.neo4j:neo4j:* configured. Here are some ideas.
Cause #1 : Dependency shadowing
It could be one of your dependencies conflicting with transitive dependency from neo4j. Putting neo4j higher in your SBT could solve this issue.
(This was what worked for me)
Cause #2 : Maximum command line reach (Windows only)
Neo4j has tons of jars. It could be the java command that is too long for windows' maximum number of characters. See: How to set a long Java classpath in Windows?

Related

Spring, Maven: Correct the classpath of your application

I am trying to create a maven version of the gradle-based treehouse 'unit-testing-a-spring-application' project used in this course. See course code here.
After not being able to build initially, I ended up adding dependency versions specified in the original gradle build file. Maven will build fine, but running the app gives this:
The following method did not exist:
org.springframework.data.repository.config.RepositoryConfigurationSource.getAttribute(Ljava/lang/String;)
Ljava/lang/String;
The method's class, org.springframework.data.repository.config.RepositoryConfigurationSource, is
available from the following locations:
jar:file:/C:/Users/home/.m2/repository/org/springframework/data/spring-data-
commons/2.1.6.RELEASE/spring-data-commons-2.1.6.RELEASE.jar!/org/springframework/data/repository/config/RepositoryConfigurationSource.class
It was loaded from the following location:
file:/C:/Users/home/.m2/repository/org/springframework/data/spring-data-commons/2.1.6.RELEASE/spring-
data-commons-2.1.6.RELEASE.jar
Action
Correct the classpath of your application so that it contains a single, compatible version of
org.springframework.data.repository.config.RepositoryConfigurationSource.
Several similar problems are solved here on S.O. by changing the version of some related dependency. I have tried various versions of the following to no avail (I stick normally with spring-boot-starter-parent v2.1.4 cause it works all the time with my projects):
spring-data-commons
spring-boot-starter-parent
I see the needed class below listed in my project Dependencies directory, but what dependency versions will work in this case? How can I solve this otherwise?
org/springframework/data/repository/config/RepositoryConfigurationSource.class
I looked at your code and found some mistakes. Since your project is a spring-boot one, you mustn't add direct spring dependencies in your pom file. Instead try to use spring-boot based dependencies. For instance, instead of having such this dependency:
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-jpa</artifactId>
<version>1.9.2.RELEASE</version>
</dependency>
You must have the following one in your pom file.
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>

SoapUI maven plugin: Error: TestAssertionRegistry Missing assertion for type JsonPath Count

I am trying to execute SoapUI XML file using Java for Continuous Integration. My SoapUI project has JSONPath expressions as assertions. When I am executing using Java, it gives an error as follows.
17:37:26,465 ERROR [TestAssertionRegistry] Missing assertion for type [JsonPath RegEx Match]
17:37:26,482 ERROR [TestAssertionRegistry] Missing assertion for type [JsonPath Count]
I saw some people has commented on some threads that it works on SoapUI 5.2 on wards. In my pom.xml I am using the following dependency, but it don't work.
<dependency>
<groupId>com.smartbear.soapui</groupId>
<artifactId>soapui-maven-plugin</artifactId>
<version>5.2.0</version>
</dependency>
May be you want to try on latest version? i.e., SoapUI 5.3 and updated plugin?
So you need to update the maven-plugin version.
<dependency>
<groupId>com.smartbear.soapui</groupId>
<artifactId>soapui-maven-plugin</artifactId>
<version>5.3.0</version>
</dependency>
Note that haven't used for myself.
Anyway, the above should resolve the issue.
You can refer offical maven repo location here

com.microsoft.sqlserver.jdbc.SQLServerDriver class not found exception (NEW)

Now I am working with Microsoft SQLserver jdbc connectivity when I try to define class.forname
java.lang.ClassNotFoundException: com.microsoft.sqlserver.jdbc.SQLServerDriver
error occurs,
everything else is fine, but I dint have any idea about this error.
pom.xml:
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>sqljdbc4</artifactId>
<version>4-2.0</version>
<scope>system</scope>
<systemPath>D:\my current work(please backup this folder)\backup\12-15-2016\milma_jishnu/src/main/lib/sqljdbc4-2.0.jar</systemPath>
</dependency>
Quoting Maven documentation:
System Dependencies
Important note: This is marked deprecated.
Dependencies with the scope system are always available and are not looked up in repository. They are usually used to tell Maven about dependencies which are provided by the JDK or the VM. Thus, system dependencies are especially useful for resolving dependencies on artifacts which are now provided by the JDK, but where available as separate downloads earlier. Typical example are the JDBC standard extensions or the Java Authentication and Authorization Service (JAAS).
So, <scope>system</scope> tells Maven: This is already present, you don't need to do anything.
Ergo, it is not added to the classpath, and you wonder why it's not there?
Seems you misunderstood the purpose of <scope>system</scope>. Don't use it, because the MS SQL JDBC driver is not part of the JDK.

Cannot load driver class: com.mysql.jdbc.Driver Spring

spring.freemarker.cache:false
spring.datasource.url=jdbc:mysql://localhost/mydb
spring.datasource.username=user
spring.datasource.password=pass
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
im getting this error even with the driver-class-name difined
java.lang.IllegalStateException: Cannot load driver class:
com.mysql.jdbc.Driver at
org.springframework.util.Assert.state(Assert.java:392)
~[spring-core-4.2.1.RELEASE.jar:4.2.1.RELEASE] at
org.springframework.boot.autoconfigure.jdbc.DataSourceProperties.getDriverClassName(DataSourceProperties.java:153)
~[spring-boot-autoconfigure-1.3.0.M5.jar:1.3.0.M5] at
org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration$NonEmbeddedConfiguration.dataSource(DataSourceAutoConfiguration.java:119)
~[spring-boot-autoconfigure-1.3.0.M5.jar:1.3.0.M5] at
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
~[na:1.8.0_60] at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
~[na:1.8.0_60] at ......
and it goes on
If you're using Maven, add this to your pom.xml:
(Recommended) For MySQL 5.6, 5.7, 8.x and Java >= 8 use;
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.30</version>
</dependency>
(Legacy) For MySQL <= 5.5 or Java <= 7 or JDBC < 4.2 use;
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.49</version>
</dependency>
More details on Connector/J versions
It might be that you are using the deprecated driver class name. I solved it by updating the property in application.properties file.
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
Just confirm the following things.
If you are under proxy make sure use VPN to connect to internal servers, iif you are accessing DEV/STG servers
Make sure you add the following dependency inside correct location, like this
<dependencies> <--- inside this section
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.15</version>
</dependency>
</dependencies>
and Not in
`<build> <--- Not this section
<dependencies>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.15</version>
</dependency>
`
3. And you don't need to use the following line
`spring.datasource.driver-class-name=com.mysql.jdbc.Driver.
The spring.datasource.url=jdbc:mysql://xxxxx` automatically know which driver to fetch.
If you are using IDEA and maven, you might forget reloading all maven projects, which causes the dependencies don't have the MySQL connector jar. And that's why when u run the application, there will be the error remind "com.mysql.cj.jdbc.Driver".
The crux of the problem is that you're missing MySQL driver dependency.
One of the ways, as outlined by other answers, is to specify it in your build tool's configuration. However, if you do not want to do it and are using IntelliJ IDEA (though I'm pretty sure Eclipse has something similar), you can also add the dependency via it. Steps:
Download desired jar from maven repository
Open your project in Intellij IDEA
File -> Project Structure -> Libraries
Click New Project Library (green plus sign on the left), or press Alt + Insert keys
Select Java
Select your jar
Press OK
Should look something like this:
Now you should be able to use the dependency you have just added.
Tested with IntelliJ IDEA 2017.3.4.
I will share more causes of this error:
I already seen this error many times using Intellij IDEA and running some integration test. The test fail with the message: Caused by: java.lang.IllegalStateException: Cannot load driver class: org.h2.Driver. After rebuild the project (Build > Rebuild Project) the error disappears.
Another cause of this error is a corrupted JAR. A college was receiving this error (also trying to run integration tests) and, after delete some related jars on .m2 directory, the error was gone.
build.gradle
runtimeOnly 'mysql:mysql-connector-java'
application.yml
spring:
application:
name: apevent
version: 1.0
datasource:
driverClassName: com.mysql.jdbc.Driver
url: jdbc:mysql://localhost:3306/applicaiton
Probably someone still needs an answer (as me before) I solved it by adding the following dependency
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
I encountered the same problem now and solved it after providing the required dependency,
<!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.15</version>
</dependency>
adding the following dependency solved my issue
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
I know this might be a little late but maybe anyone from the future might find this answer helpful.
This problem arises from potentially three reasons
Incorrect maven or Gradle configuration
Incorrect spring configuration in the application.properties file
Wrong class name on the application.properties file.
To troubleshoot if you are using maven. do not include the version name. This mostly is a recipe for problems, especially in huge applications. use maven autocompletes features to save you a little time.
configure the data source correctly. There are a lot of answers on it to this question. make sure it's correct. sometimes there is a cj that is missing or included where it's not supposed to be. Trial and error might help you discover the problem
if neither of the above options works. Remove spring.datasource.driver-class-name=com.mysql.jdbc.driver completely. I don't know if it magic but this last one worked for me.
GO NERDS!!!
My problem is solved just by refresh the project, perhap the dependency did not load by the time you run the application
I had the same issue. It happened because I forgot to declare the MySQL connector dependency in my pom file. I added the dependency, then boom! The error went away.
For People who uses Gradle 8.0 and beyond. I had to use
implementation 'mysql:mysql-connector-java:8.0.26'
instead of
implementation group: 'mysql', name: 'mysql-connector-java', version: '8.0.26' ,
my application.yml looks like:
spring:
datasource:
driverClassName: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/<Your DB name>?useSSL=false
remember to reload your gradle file

difference between com.sun.jna and net.java.dev.jna?

I'm looking through the central maven repository and seeing a net.java.dev.jna and a com.sun.jna groupId for JNA. The github for JNA, using the com.sun.jna path as the directories in their source code, indicates that 4.1 has been pushed into the repository as part of a comment, but I'm seeing net.java.dev.jna at 4.1 and com.sun.jna at 3.0.
Obviously, I want to use JNA, but am baffled. What's going on with this package?
The correct 4.1 version to use is net.java.dev.jna:
<dependency>
<groupId>net.java.dev.jna</groupId>
<artifactId>jna</artifactId>
<version>4.1.0</version>
</dependency>
The package name still seems to be com.sun.jna, but if you look in the POM file, the Maven coordinates have become net.java.dev.jna:jna.
They seem to have been that way for quite a long time, based on the MVN respository results.

Categories