I am trying to insert data into ElasticSearch (version 7.4.2) hosted on bonsai.io cloud. When I try to create an IndexRequest & IndexResponse in my client code in Java (Java High Level REST client), there is no import available for both IndexRequest & IndexResponse.
My pom.xml has the following dependencies:
<dependencies>
<dependency>
<groupId>org.elasticsearch.client</groupId>
<artifactId>elasticsearch-rest-high-level-client</artifactId>
<version>7.4.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-simple -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.25</version>
</dependency>
</dependencies>
I even tried adding the below dependency to my pom.xml
<dependency>
<groupId>org.elasticsearch</groupId>
<artifactId>elasticsearch</artifactId>
<version>7.4.2</version>
</dependency>
Can somebody help me solve this issue in 7.4.2 version?
Please check this GitHub repo which is using ES 7.3 with java high-level rest client. You can change the ES client version in pom.xml and ready to go, as these are just minor version change, there isn't really any change in IndexRequest and indexResponse APIs.
Please see this of com.indore.GalaxyApp#createIndex method, where IndexRequest is created.
You can change your elasticsearch details config.yml and read the README section on how to start the app.
Let me know if you need more information.
Error occurred as the maven build was unable to read the jar manifest for following 2 jar files.
1) .m2/repository/org/elasticsearch/elasticsearch/7.4.2/elasticsearch-7.4.2.jar
2) .m2/repository/org/elasticsearch/client/elasticsearch-rest-high-level-client/7.4.2/elasticsearch-rest-high-level-client-7.4.2.jar
Solved the error by deleting the .m2 directory locally. Running the pom.xml after this as a maven build fixed the error and the above 2 jars were installed correctly.
I want to use version 0.6.2 of drop wizard, but it seems to not exist on a maven repository anymore.
The original Maven include was:
<dependency>
<groupId>com.yammer.dropwizard</groupId>
<artifactId>dropwizard-core</artifactId>
<version>0.6.2</version>
</dependency>
but according to the website (http://mvnrepository.com/artifact/com.yammer.dropwizard/dropwizard-core/0.6.2), the group and artifact names have changed. On the new page (http://mvnrepository.com/artifact/io.dropwizard/dropwizard-core), the version 0.6.2 does not exist. When I try to do a include like so:
<dependency>
<groupId>io.dropwizard</groupId>
<artifactId>dropwizard-core</artifactId>
<version>0.6.2</version>
</dependency>
it doesn’t work. Is there any fix for this? I need to use Dropwizard that supports Java 6.
<dependency>
<groupId>com.yammer.dropwizard</groupId>
<artifactId>dropwizard-core</artifactId>
<version>0.6.2</version>
</dependency>
This still works, don't switch over to io.dropwizard unless you want to switch to 0.7.x. 0.6.2 is not available with groupId io.dropwizard. The message is just telling you that future releases will be in the new groupId.
I want to use Jetty as an embedded library in a Java project I'm working on in IntelliJ IDEA. However, there are many different packages for Jetty available from the Maven Central Repository. The JAR available for direct download from here is named as jetty-distribution-9.0.3.v20130506.tar.gz, so I assumed the best complete package available from the Maven Central Repo was org.eclipse.jetty:jetty-distribution:9.0.3.v20130506. But IntelliJ returns this error when attempting to use that coordinate to retrieve the library:
No files were downloaded for org.eclipse.jetty:jetty-distribution:9.0.3.v20130506
Why can't that package be found? And if it's not usable, which packages should I download?
Edit: I now realise that the coordinate I should have been using is org.eclipse.jetty.aggregate:jetty-all:9.0.3.v20130506. I can locate this at search.maven.org, but IntelliJ cannot find anything newer than version 7. Can anyone reproduce or explain this issue? Moved to new question.
Check the dependency type.
There are so called pom type of dependencies, which act as a list of other dependencies. To be able to fetch them, you have to mark them as pom dependencies in your pom.xml
If you only need the server component, try searching for this string
'org.eclipse.jetty:jetty-server:9.0.3.v20130506'
Maven dependencies have a type, which by default is jar. The jetty distribution package is not a jar, and as you can see in the central repository, you can download either a .zip or a .tar.gz, so you'll have to declare the dependency as:
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-distribution</artifactId>
<version>${jetty.version}</version>
<type>zip</type>
</dependency>
If you build now, it will download the zip and the build will probably succeed. But, a zip is different from a jar, so depending on what you're actually doing in that build, you will have to do more things to actually make use of that zip.
You probably don't want to use the distribution package unless you're also building a standalone distribution (.zip) for your project as well, in which case you should probably use the maven-assembly-plugin which can unzip the jetty distribution and rezip your whole project.
What you should do is decide what exactly you're going to need and build a custom jetty. Here's the starting point, enough to be able to deploy a simple servlet-based application:
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-server</artifactId>
<version>${jetty.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-util</artifactId>
<version>${jetty.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-xml</artifactId>
<version>${jetty.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-deploy</artifactId>
<version>${jetty.version}</version>
</dependency>
You're probably going to need this one as well, since this is how you can start Jetty:
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-start</artifactId>
<version>${jetty.version}</version>
</dependency>
Look at the list of modules to see what else you might need, for example jetty-ajp, jetty-websocket, or jetty-jsp.
I have downloaded some open source software written in Java and tried to compile it using Eclipse.
I got the error: "The hierarchy of the type 'Class name' is inconsistent" in some files.
What causes these errors and how do I fix them?
It means you are trying to implement a non-existing interface or you're extending an non-existing class.
Try to refresh your Eclipse.
If it doesn't work, it may mean that you have a reference to a JAR that is not in the build path.
Check your project's classpath and verify that the jar containing the interface or the class is in it.
Sometimes it happens when you add a jar that YOU need, but don't include the jars that IT needs. In my case adding all the jars in tomcat/lib helped me to solve this problem. I am working on a web-app.
Check your errors (tab "markers"). I had also the following error:
Archive for required library in project cannot be read...
and when that was fixed the "inconsistent-error" disappeared.
Actually I had added jars to the build path, but for some reason they could not be read with error
Archive for required library in project cannot be read or is not a valid ZIP file
So instead I added them as "External Jars". That helped and all compilation problems were no more!
I had this problem after I upgraded the JDK to a new version. I had to update the references to libraries in Project Properties/Java Build Path.
One more case I have had. Give the correct project path, and import it to eclipse.
Then go to Project--> Clean --> Clean all projects.
You should clean the project , or restart Eclipse.
You will see this error in case a some class in your library file you have in classpath has reference to non-existing classe(s) which could be in another jar file. Here, I received this error when I did not add org.springframework.beans-3.1.2.RELEASE.jar and had extended a class from org.springframework.jdbc.core.support.JdbcDaoSupport, which was in org.springframework.jdbc-3.1.2.RELEASE.jar of my classpath.
The problem may be that you have included incorrect jars. I had the same problem and the reason was that I had included incorrect default JRE library in the build path of the project. I had installed Java with another version and was including JRE files of Java with a different version. (I had installed JRE 1.6 in my system and was having JRE library 1.7 included in the build path due to previously installed Java) May be you can check if the JRE library that you have included in the build path is of correct version ie. of Java version that you have installed in your system.
I 've experienced this problem on Eclipse Juno, the root cause was that although some spring jars were being included by transient maven dependencies they were included in incorrect versions.
So you should check if using a modularized framework as spring that every module (or at least the most important: core, beans, context, aop, tx, etc.) are in the same version.
To solve the problem I 've used maven dependnecy exclusions to avoid incorrect version of transient dependencies.
Error : the hierarchy of the type "class name" is inconsistent error.
solution :
class OtherDepJar {} --> is inside "other.dep.jar" .
class DepJar extends OtherDepJar {} --> is inside "dep.jar".
class ProblematicClass extends DepJar {} --> is inside current project .
If dep.jar is in the project's classpath, but other.dep.jar isn't in the project's classpath, Eclipse will show the" The hierarchy of the type ... is inconsistent error"
To me, the issue was due to wrong imports. In fact, one need to update the imports after adding the v7 support library.
It can be fixed by doing as follows, for each class of your project:
Delete all the lines with import android.[*], in each class
Reorganize your imports: from the context menu select Source/Organize Imports or (CTRL+SHIFT+O)
When prompted, select the libraries android.support.[*] (and not android.[*]).
It was definitely because missing dependencies that were not in my maven pom.xml.
For example, I wanted to create integration tests for my implementation of the broadleaf ecommerce demo site.
I had included a broadleaf jar with integration tests from broadleaf commerce in order to reuse their configuration files and base testing classes. That project had other testing dependencies that I had not included and I received the "inconsistent hierarchy" error.
After copying the "test dependencies" from broadleaf/pom.xml and the associated properties variables that provided the versions for each dependency in broadleaf/pom.xml, the error went away.
The properties were:
<geb.version>0.9.3</geb.version>
<spock.version>0.7-groovy-2.0</spock.version>
<selenium.version>2.42.2</selenium.version>
<groovy.version>2.1.8</groovy.version>
The dependencies were:
<dependency>
<groupId>org.broadleafcommerce</groupId>
<artifactId>integration</artifactId>
<type>jar</type>
<classifier>tests</classifier>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.broadleafcommerce</groupId>
<artifactId>broadleaf-framework</artifactId>
<version>${blc.version}</version><!--$NO-MVN-MAN-VER$ -->
<classifier>tests</classifier>
</dependency>
<dependency>
<groupId>com.icegreen</groupId>
<artifactId>greenmail</artifactId>
<version>1.3</version>
<type>jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.easymock</groupId>
<artifactId>easymock</artifactId>
<version>2.5.1</version>
<type>jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.easymock</groupId>
<artifactId>easymockclassextension</artifactId>
<version>2.4</version>
<type>jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>5.9</version>
<type>jar</type>
<classifier>jdk15</classifier>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<version>${groovy.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.gebish</groupId>
<artifactId>geb-core</artifactId>
<version>${geb.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.gebish</groupId>
<artifactId>geb-spock</artifactId>
<version>${geb.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.spockframework</groupId>
<artifactId>spock-core</artifactId>
<version>${spock.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-support</artifactId>
<version>${selenium.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-firefox-driver</artifactId>
<version>${selenium.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-chrome-driver</artifactId>
<version>${selenium.version}</version>
<scope>test</scope>
</dependency>
<!-- Logging -->
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.12</version>
<type>jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.6.1</version>
<type>jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
<version>1.6.1</version>
<type>jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.6.1</version>
<type>jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hsqldb</groupId>
<artifactId>hsqldb</artifactId>
<version>2.3.1</version>
<type>jar</type>
<scope>test</scope>
</dependency>
If the extended class has the issue then the above error message will gets displayed.
Example
class Example extends Example1 {
}
fix the issues in Example1
I had the same exact problem marker and solved it by removing the #Override annotation from a method that was in fact the first implementation (the "super" one being an abstract method) and not an override.
In my case, the import references in many of the classes contained an extra word. I solved it by editing all the files to have the correct imports. I started doing the edits manually. But when I saw the pattern, I automated it with a find..replace in eclipse. This resolved the error.
For me it was changing the Android API level to one with Google APIs
I was having this problem too... I found out that the hierarchy of the class that was throwing this exception, cannot be traced all way back to its root class by eclipse... I Explain:
In my case, I have 3 java project: A, B and C... where A and B are maven projects and C a regular java eclipse project...
In the project A, i have the interface "interfaceA" ...
In the project B, i have the interface "interfaceB" that extends "interfaceA"
In the project C, i have the concrete class "classC" that implements "interfaceB"
The "project C" was including the "project B" in its build path but not "project A" (so that was the cause of the error).... After including "project A" inside the build path of "C", everything went back to normal...
I had a class that extends LabelProvider in a project with OSGi, there the error occured. The solution was: Adding org.eclipse.jface to the required plugins in the manifest.mf instead of importing the single packages like org.eclipse.jface.viewers
if you are importing the eclipse project just
1. Go to the java build path setting under the project properties.
2. In case the JRE System library has an error sign attach to it double click it to open the Edit library window
3. Change the execution environment to the correct java version of the system or choose edit the other settings by checking the radio buttons assign to them.
4. Click finish
When importing a GWT project in Eclipse without installing "Google Plugin for Eclipse", this will occur. After installing "Google Plugin for Eclipse", this error will disappear.
Right click on the project folder and select "Java Build Path". Under "Java Build Path" you should be able to see libraries. Eclipse will show errors in any of those libraries. Fixing those issue will help to resolve the issue.
I had this error after doing some git merge from a branch where my classes extended a new interface.
It was enough to Refresh (F5) the File-Tree in the Package Explorer frame of Eclipse.
It seems that Eclipse did not update everything properly and so the classes were extending a non-existing-yet interface. After refresh, all errors disappeared.
I had to switch from Eclipse Oxygen that I got from IBM and used IBM JDK 8 to Eclipse Photon and Oracle JDK 8. I'm working on Java customizations for maximo.
This error will also appear when one of the jars required by the existing dependencies is not available in current project path.
Ex:-> Current Proj depends on Lib1 depends on Lib2.
If we use one of the classes in Lib1 but Lib2 is not packaged in Lib1 or not available in current project path you'll see the issue.
How do I add the servlets API to my project's pom.xml
mvnrepository.com has lots of servlet api and similarly named projects, that I don't know which is the right one. Or are all of them ok?
I believe most web/app servers come bundled with a version of the servlet api, so you won't want to bundle the api in your .war file. You will need to find out which version is included with your server, then you can use
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>${servlet-api-version}</version>
<scope>provided</scope>
</dependency>
replacing servlet-api-version with your version. You will want to specify the "provided" scope so the api.jar isn't included in your war file.
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<scope>provided</scope>
</dependency>
For servlet-api 3.1.0, here is the declaration :
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
</dependency>
We use
<dependency>
<groupId>javax</groupId>
<artifactId>j2ee</artifactId>
<version>1.4</version>
<scope>provided</scope>
</dependency>
but if you only need the servlet api you might want to use
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>?</version>
<scope>provided</scope>
</dependency>
It depends on which version of the servlet API you are using.
The javax.servlet artifact will provide jars for all of the servlet API versions.
Scope provided can be used when you dont want to put jar file inside the WEB-INF/lib folder instead you are supplying it at runtime either by container or JDK.
Jakarta EE
In recent years, Oracle transferred the Java EE technologies to the Eclipse Foundation. There the technologies have been renamed to Jakarta EE. So Java Servlet is now known as Jakarta Servlet.
This name change was done to respect Oracle’s trademarks. Do a Web search to find many articles and videos discussing this transition.
This name change includes changing the package naming of the classes from javax.* to jakarta.*. This is a breaking change, though updating your project may be as simple as merely changing your import statements. But check that any libraries you depend on have versions available using the new naming as well.
Servlet 5
This transition has brought new versions of the Servlet specification. Version 5 of the spec is the same as Servlet 4 but with the new naming.
For the current version, edit your POM file to use the following Maven dependency. Check for updates in a Maven repository of your choice in the version numbering.
You can deploy web apps built with Servlet 5 to web containers such as Tomcat 10.0.x, Jetty 11.0.x, Glassfish 6, and several more.
<dependency>
<groupId>jakarta.servlet</groupId>
<artifactId>jakarta.servlet-api</artifactId>
<version>5.0.0</version>
<scope>provided</scope>
</dependency>
Servlet 6
Jakarta Servlet 6 specification is currently in development, and will contain significant changes. The spec will be finalized later this year 2022.
See the overview page, the product page, project links page, and repository coordinates page.
<dependency>
<groupId>jakarta.servlet</groupId>
<artifactId>jakarta.servlet-api</artifactId>
<version>6.0.0</version>
<scope>provided</scope>
</dependency>