vertx 3.5.1 missing classes - maven

I started to look into developing with VertX, and I stumbled into problems with some classes that couldnt be resolved. I am posting a simple example.
pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>demo.rabbit</groupId>
<artifactId>rabbitmq-client</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>io.vertx</groupId>
<artifactId>vertx-core</artifactId>
<version>3.5.1</version>
</dependency>
</dependencies>
</project>
java code
import io.vertx.core.AbstractVerticle;
import io.vertx.core.AsyncResult;
import io.vertx.core.json.JsonObject;
public class RabbitMQVerticle extends AbstractVerticle
{
#Override
public void start() throws Exception {
AsyncResult ar;
JsonObject jo;
}
}
If I leave it like this, the compiler cannot resolve the AsyncResult and JsonObject imports, and thus cannot resolve both types.
In the external libraries view, those classes appear as part of the io.vertx.core library but the icon next to them indicates that they are missing from the library.
If I replace the vertx.core version to 3.5.0 in the pom file everything works great, switch back to 3.5.1 and nothing works again.
It's also my first time using Maven, what am I missing?
Couldn't find any useful information anywhere on the web

The mentioned classes are parts of the core Vert.x library. Core blocks never get deleted in mature libraries.
Here down the AsyncResult class for example under both versions:
AsyncResult under 3.5.0 version
AsyncResult under 3.5.1 version
Indeed I think even when changing the library version, your project still compiles (using cmd line or using IntelliJ IDEA) but you are facing a UI highlight issue with you IDE.
You can try to:
Re-import all Maven modules using the Maven Projects Tool Window
Clean the system caches and restart the IDE

Related

Spring Boot 2: Unable to start tomcat

I am new to spring boot.. Getting started by referring to the link: https://docs.spring.io/spring-boot/docs/current/reference/html/getting-started-first-application.html
After running the project its not starting the tomcat server.. Getting the error as [ERROR] error reading /home/rahul/.m2/repository/org/apache/tomcat/embed/tomcat-embed-core/8.5.31/tomcat-embed-core-8.5.31.jar; invalid LOC header (bad signature)
Not able to address this issue.. Any help would be appreciated..
Thanks a lot in advance..
My code is like below,
pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.wocs</groupId>
<artifactId>REST</artifactId>
<version>0.0.1-SNAPSHOT</version>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.2.RELEASE</version>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
</project>
Example.java
import org.springframework.boot.*;
import org.springframework.boot.autoconfigure.*;
import org.springframework.web.bind.annotation.*;
#RestController
#EnableAutoConfiguration
public class Example {
#RequestMapping("/")
String home() {
return "Hello World!";
}
public static void main(String[] args) throws Exception {
SpringApplication.run(Example.class, args);
}
}
Seems like you have a corrupted file. Try clean your maven cache with rm -rf ~/.m2/repository and run again
Looks like you have a corrupted jar that is under your default MAVEN folder. You can delete the specific jar file that is causing this issue and trying the follow should help!
Take a Maven update by right clicking on your Project -> then select Maven and then click on 'Update Project'. You've got to wait until these dependencies are downloaded.
Run target Clean Maven (Project -> Run as -> Clean Maven)
Then finally Install Maven (Project -> Run as -> Install Maven)
These steps should resolve your invalid LOC header error.
Here is what worked for me on Windows 10:
Deleted this jar file from the shell command line
mvn spring-boot:run
After that, the jar was downloaded with no error and all is running fine.
and all is running fine

Intellij - Add project as dependency to another project

I am trying to make my project work on intellij (it works with eclipse). I have a project with this in my pom:
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.fitnetapplication</groupId>
<artifactId>fitnet-common</artifactId>
<version>6.0.2-Final</version>
<packaging>war</packaging>
<name>FitnetCommon</name>
<description>Socle Commun FitnetManager / SyrhaLogic</description>
Now i have another project which needs to be linked to this one, so I had:
com.fitnetapplication
fitnet-common
6.0.2-Final
runtime
war
<dependency>
<groupId>com.fitnetapplication</groupId>
<artifactId>fitnet-common</artifactId>
<version>6.0.2-Final</version>
<type>jar</type>
<scope>provided</scope>
<classifier>classes</classifier>
</dependency>
The problem is that on Intellij, the version is not accepted for some reason, I don't know why, it tells me that the version 6.0.2-Final is not found for the artifact fitnet-common
To confirm - you are actually running mvn clean install (or similar) on the first project before trying to resolve the dependency in the second project?
If you are, it sounds like you're installing the project using one Maven repo location, and then in the other project it is looking in a completely different location. Are your .m2 location settings identical for both projects?
Edit:
Is it because you're specifying the first project as a war packaging, but in the dependency declaration you are looking for a jar? They would essentially be two different artefacts:
.war - com.fitnetapplication:fitnet-common:6.0.2-Final:war
.jar - com.fitnetapplication:fitnet-common:6.0.2-Final:jar
Check in your .m2/com/fitnetapplication/fitnet-common/6.0.2-Final to see what you have there, likely it is just the war file.

OpenCV-2.4.4 POM entry Tag

I am starting OpenCV in Java and want to get started by creating a maven project.
For that I am using OpenCV-2.4.4 jar.
But was not able to find out the pom entry needed for that jar to be included in the dependency.
Tell me if I am missing something too trivial. Or where to find the POM entry for the same.
All I was able to find was the pom entry for the google version:
<dependency>
<groupId>com.googlecode.javacv</groupId>
<artifactId>javacv</artifactId>
<classifier>linux-x86_64</classifier>
<version>0.3</version>
</dependency>
But I need the pom tag for OpenCV-2.4.4.jar
as far as I can see from the http://code.google.com/p/javacv/#Quick_Start_for_OpenCV_and_FFmpeg you should:
point your pom.xml file to the Maven repository
http://maven2.javacv.googlecode.com/git/, and make sure that the
library files of OpenCV and FFmpeg (*.so, *.dylib, or *.dll) can be
found either in their default installation directories or in the
system library PATH, which under Windows includes the current working
directory.
To add new maven repo, you can follow:
http://www.mkyong.com/maven/how-to-add-remote-repository-in-maven-pom-xml/
afterwards, it seems you can go for the latest version of javacv (present in repo):
<dependency>
<groupId>com.googlecode.javacv</groupId>
<artifactId>javacv</artifactId>
<version>0.5</version>
</dependency>
or maybe, as you specified (with platform specific classifier):
<dependency>
<groupId>com.googlecode.javacv</groupId>
<artifactId>javacv</artifactId>
<classifier>linux-x86_64</classifier>
<version>0.5</version>
</dependency>
UPDATE:
Sorry, I seem to miss the point with my previous answer. If you're trying to go with the OpenCV java bindings rather than JavaCV (http://code.google.com/p/javacv), there seems to be no maven packaging provided yet.
As the official tutorial uses ant only (http://docs.opencv.org/2.4.4-beta/doc/tutorials/introduction/desktop_java/java_dev_intro.html)
Moreover there is an open bug for what you expect: http://code.opencv.org/issues/3097
So the only option seem to be wait for resolution of the bug and use another way in the meanwhile.
I know OpenCV developers are working to make a public maven repository for Java bindings, but I've made an example that shows how to do it, pretty much like Java OpenGL deals with it.
The full example can be retrieved from:
https://github.com/JavaOpenCVBook/code/tree/master/chapter1/maven-sample
Remember to add the github repository, as pointed by:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<repositories>
<repository>
<id>javaopencvbook</id>
<url>https://raw.github.com/JavaOpenCVBook/code/maven2/</url>
</repository> </repositories>
<modelVersion>4.0.0</modelVersion> … </project>
For now, there are only windows 64 and 32 native jars available, but it should be easy to add your Linux/MacOS version of it.
Best regards,
Daniel

Maven Systempath not working as expected

I have specified following dependencies(For example mentioned one here) in pom.xml which will look for saaj.jar under the specified sytempath and Maven used to pick it from same path and working fine.
<dependency>
<groupId>saaj</groupId>
<artifactId>saaj</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>${basedir}/src/main/webapp/WEB-INF/lib/saaj.jar</systemPath>
</dependency>
Now I have moved to windows 7 and Spring Tool suite 2.7.1 version(Previously Win XP and Spring older vesion). In this new setup am getting below error.
Missing artifact saaj:saaj:jar:1.0:system
Now, It is looking for saaj-1.0.jar instead of saaj.jar and under the folder ${basedir}/src/main/webapp/WEB-INF/lib/saaj/saaj/1.0/ instead of ${basedir}/src/main/webapp/WEB-INF/lib/.
Why is it so? Please provide the solution where my previous setup should work fine.
Avoid systemPath, you must create a local repository like :
this is you pom file :
<repositories>
<repository>
<id>local-repo</id>
<url>file://${basedir}/lib</url>
</repository>
</repositories>
<dependency>
<groupId>tiago.medici</groupId>
<artifactId>eureka</artifactId>
<version>0.0.1</version>
</dependency>
on project you create a lib folder to put your jar and maven pom file generated from
mvn install:install-file -Dfile=c:\tiago.medici-0.0.1.jar -DgroupId=tiago.medici -DartifactId=eureka -Dversion=0.0.1 -Dpackaging=jar
tiago.medici-0.0.1.pom
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>tiago.medici</groupId>
<artifactId>eureka</artifactId>
<version>0.0.1</version>
<description>POM was created from install:install-file</description>
</project>
Don't use system scope. It was meant for system provided libraries. Given the path you gave for it, you are obviously creating a web application.
Use a war project and specify your dependencies with provided scope if they're already available (e.g. because they are provided by your application server) or without a scope specification otherwise. Maven will take care of packaging your project dependency in a correct way, both for Eclipse development and for deployment in your application server.

Maven can't find httpcomponents-client in repository

I am trying to add the Apache httpcomponents-client library to my Maven project. I have added a dependency to pom.xml (as found on http://mvnrepository.com/artifact/org.apache.httpcomponents/httpcomponents-client/4.1.1), but when building my Eclipse project Maven is unable to find and download the library.
I have made a test project which does nothing but include this library to ensure that it's not any other settings that cause problems:
<?xml version="1.0"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>no.gundelsby.test</groupId>
<artifactId>NeedMyPackage</artifactId>
<version>0.1</version>
<dependencies>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcomponents-client</artifactId>
<version>4.1.1</version>
</dependency>
</dependencies>
</project>
Building this project results in the same error.
Other things I have tested:
Tried building with vanilla installs of both Maven 2.2.1 and 3.0.3
Had a friend build the test project on his computer to rule out local problems on my computer
Changed the version from 4.1.1 to 4.1
For what it's worth I had the same problem a few days ago with org.easytesting.fest-swing, see pom dependency entry below:
<dependency>
<groupId>org.easytesting</groupId>
<artifactId>fest-swing</artifactId>
<version>1.2.1</version>
</dependency>
You don't want httpcomponents-client as a dependency. That's just the parent pom for the client-related modules. I suspect you actually want <artifactId>httpclient</artifactId>.
Here a simple solution...
Its great for me...
You can downloar jar file from internet and add manually to project from netbeans or another IDE.
Here an example for you:
enter image description here
Search the downloaded jar in your computer
enter image description here

Resources