I'm trying to import various Neo4j annotations in Eclipse with Maven
I have
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-neo4j</artifactId>
<version>4.0.0.RELEASE</version>
</dependency>
But I get:
The import org.springframework.data.neo4j.annotation.Fetch cannot be resolved
when I try to import #Fetch, #RelatedTo and #GraphId. Curiously eclipse shows that the annotations #Query, and #QueryResult are present on org.springframework.data.neo4j.annotation, but only those two and none of the other annotations. All the documentation I can find says the annotations should be there, but it just looks are if they're not.
I downloaded the spring-data-neo4j.jar, extracted it, and it appears the annotations are not there. I changed to the 3.4.1 release and everything's ok.
Update.
This problem was actually because the quick start example for using neo4j on the Spring website is actually using annotations that are no longer supported by Neo4j 4 whilst showing the dependency to use as Neo4j 4.
Neo4J 4 doesn't use these annotations anymore.
Related
Context: in a project composed of 5 different applications and a 20 some packages, i try to update spring-boot (to 2.7.4) and only spring-boot, the project uses an internal enterprise artifactory, if that may have some impact. when i indicated that i need 2.7.4 some packages begun to use mongo-driver 4.6.2. Before it was 3.11.0. I went a head and updated it as well, by indicating in those pom.xml (where it was explicitly said 3.11.0 to use 4.6.2 instead). But that caused many unwanted errors (as some syntaxes have changed between those versions) So i went back to 3.11.0 and i explicitly indicated in all pom.xml that i want to use 3.11.0
The issue is that spring-boot now calls things in my mongodb-driver that are not there yet.
So the question is: can i have spring-boot 2.7.4. with mongodb-driver 3.11.0 (and i am just missing how to tell it to use it correctly) OR that those versions are the strongly coupled with 4.6.2 so i have no choice but update that as well?
Also i did tried to find (for 2 days now), and i am sure it should exist for something so widely used as spring, but not found an explicit list that says "to upgrade from X->Y version of dependancy Z, here is the list of syntax changes that need to be made.", does it and how to find that?
Sorry for no concrete pom.xml exemples i am not on my work PC now.
You can use the <exclusions> tag for this:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot</artifactId>
<exclusions>
<exclusion>
<!-- dependency you want to exclude (with version) -->
</exclusion>
</exclusions>
</dependency>
<dependency>
<!-- The version you want as a dependency -->
</dependency>
After upgrading the couchbase java-client to 2.6.1, I get the following error on application startup:
exception is java.lang.NoClassDefFoundError: com/couchbase/client/encryption/CryptoManager
After a quick investigation it looks that a Support for Field-Level Encryption was added since 2.6.0.
The problem seems to be the following transitive dependency:
<dependency>
<groupId>com.couchbase.client</groupId>
<artifactId>encryption</artifactId>
<version>${encryptionextension.version}</version>
<optional>true</optional>
</dependency>
which is marked as optional, however, it is declared in DefaultCouchbaseEnvironment and therefore cannot be optional.
The quick fix for this problem is to add the "encryption" transitive dependency to the classpath explicitly. Nevertheless, it seems to be a bug which will force all the clients to encounter the same problem.
UPDATE
The easiest way to reproduce the issue is to invoke the following code:
DefaultCouchbaseEnvironment.class.getDeclaredMethods();
This code is invoked by spring when loading coucbase environment as a spring bean. I've managed to isolate the issue to the single line of code which causes the problem.
I am working on a simple project as a point of reference for new projects or to try new technologies. The project has Hibernate & Spring capabilities.
I tried to add some anotations for validate fields. Those are the validation which I am using
import javax.validation.constraints.Digits;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
The problem is that I need javax.validation dependecy and There are a lot of jars which includes those clases but none of Spring or Hibernate.
Which one is the standard?
Note: I check the dependency in the big project and I am using the validation-api
Try the library "Apache Geronimo JSR-303 Bean Validation Spec API", the jar is "geronimo-validation_1.0_spec-1.0-CR5.jar".
Look at this link :
http://www.findjar.com/jar/org/apache/geronimo/specs/geronimo-validation_1.0_spec/1.0-CR5/geronimo-validation_1.0_spec-1.0-CR5.jar.html
Here is maven part to add it :
http://mvnrepository.com/artifact/org.apache.geronimo.specs/geronimo-validation_1.0_spec/1.0-CR5
Use
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>1.1.0.Final</version>
</dependency>
or
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>1.0.0.GA</version>
</dependency>
depending on which version of the API you want to use. Note that the API is not enough, of course you also need an implementation (if you don't deploy your application in an Java EE application server). The implementation usually has a transitive dependency on the correct API jar.
We use ivy to manage a multi project java application, and recently this error started showing up when we do builds. What's causing this?
This was fixed by adding the following line to the end of the dependencies section in ivy.xml:
<dependencies>
<exclude module="log4j-over-slf4j" />
</dependencies>
Why was it an issue?
Looks like the log4j bridge for sjf4j has an incomplete implementation
This url explains it in more detail.
It looks like the log4j bridge does not implement the full interface for log4j . If you are still using direct log4j calls, you will need both the slf4j bridge jar and the log4j jar
In your case it looks like you excluded the bridge jar, so all slf4j calls go directly to log4j instead of the bridge.
If your code invokes log4j through the xml file , this will work. However if your code programatically invokes log4j initialization this bridge is not going to work
I know this is a very old question but I wanted to share what worked out fine for me. If you have different artifacts of slf4j-log4j* for two projects that are interdependent on each other, for example spring data jpa and spring MVC, this happens. Keep it consistent or even better have a parent pom. In my case I had slf4j-log4j12 on my spring data jpa project and slf4j-log4j13 on my spring MVC one.
Comment this dependency from the pom.xml
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j13</artifactId>
<version>
</dependency>
And add (or keep) the following one:
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.12</version>
</dependency>
Wherever you see a compile time error regarding Log4j, add the following import:
import org.apache.log4j.Logger;
I used to use neo4j-community-1.9.4 with my java maven project. I switched to version 2.0 and made completly new db in 2.0. When I run the same java code, I get error:
Exception in thread "main" org.neo4j.kernel.impl.storemigration.UpgradeNotAllowedByConfigurationException: Failed to start Neo4j with an older data store version. To enable automatic upgrade, please set configuration parameter "allow_store_upgrade=true"
at org.neo4j.kernel.impl.storemigration.ConfigMapUpgradeConfiguration.checkConfigurationAllowsAutomaticUpgrade(ConfigMapUpgradeConfiguration.java:39)
at org.neo4j.kernel.impl.storemigration.StoreUpgrader.attemptUpgrade(StoreUpgrader.java:64)
at org.neo4j.kernel.impl.nioneo.store.StoreFactory.tryToUpgradeStores(StoreFactory.java:104)
at org.neo4j.kernel.impl.nioneo.store.StoreFactory.newNeoStore(StoreFactory.java:86)
at org.neo4j.kernel.impl.nioneo.xa.NeoStoreXaDataSource.<init>(NeoStoreXaDataSource.java:232)
at org.neo4j.kernel.InternalAbstractGraphDatabase.create(InternalAbstractGraphDatabase.java:423)
at org.neo4j.kernel.InternalAbstractGraphDatabase.run(InternalAbstractGraphDatabase.java:226)
at org.neo4j.kernel.EmbeddedGraphDatabase.<init>(EmbeddedGraphDatabase.java:79)
at org.neo4j.graphdb.factory.GraphDatabaseFactory$1.newDatabase(GraphDatabaseFactory.java:70)
at org.neo4j.graphdb.factory.GraphDatabaseBuilder.newGraphDatabase(GraphDatabaseBuilder.java:205)
at org.neo4j.graphdb.factory.GraphDatabaseFactory.newEmbeddedDatabase(GraphDatabaseFactory.java:56)
at tools.Import.main(Import.java:32)
Any idea? Thank you.
Neo4j 2.0 requires an explicit store upgrade, because older versions will no longer be able to run on the upgraded store. The exception mentions this:
Failed to start Neo4j with an older data store version. To enable automatic upgrade, please set configuration parameter "allow_store_upgrade=true"
Simply add allow_store_upgrade=true to your neo4j.properties file, and start the database again. Then it should do the upgrade. You can read more about this here:
http://docs.neo4j.org/chunked/stable/deployment-upgrading.html#explicit-upgrade
Solved, I replaced dependency from spring:
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-neo4j</artifactId>
<version>2.3.3.RELEASE</version>
</dependency>
By this:
<dependency>
<groupId>org.neo4j</groupId>
<artifactId>neo4j</artifactId>
<version>2.0.0</version>
</dependency>
For community edition on windows,
click on Options, Database Configuration, Edit
look for allow_store_upgrade