Remove Unnecesary Maven Dependencies from Eclipse - eclipse

I am working with Spring-Boot 2.3.8 and Eclipse.
I am using these dependencies to work on some videos:
<!-- javacv -->
<dependency>
<groupId>org.bytedeco</groupId>
<artifactId>javacv</artifactId>
<version>1.5.4</version>
</dependency>
<!--opencv-platform -->
<dependency>
<groupId>org.bytedeco</groupId>
<artifactId>opencv-platform</artifactId>
<version>4.4.0-1.5.4</version>
</dependency>
<!-- ffmpeg-platform -->
<dependency>
<groupId>org.bytedeco</groupId>
<artifactId>ffmpeg-platform</artifactId>
<version>4.3.1-1.5.4</version>
</dependency>
Eclipse is adding all JARs of opencv, javaccp and ffmpeg, including JARs for Androind, MacOs, etc. I just need the ones for Windows and the problem is that these extra dependencies are creating problems for my teams when they try to load the project, build or test it (it is extreamly slow or just doesnt work).
These dependencies are not present in my final WAR when I build with maven form the command line and I use:
mvn -Djavacpp.platform=windows-x86_64 clean install
Is there a way to tell eclipse to do the same?
The WAR size goes from 800 MB to around 200 MB when building without and with and the platform flag, these extra 600 MB are what in my opinion is too much for eclipse.
Here is an image of all the JARs being added to the project.

Related

How do I update Itext7 to version 7.1.1

This seems like it should be simple but I cannot find anything on how to upgrade to newer versions of itext7. I am using an Eclipse maven project with itext7 version 7.0.4 and would like to update to 7.1.1. However, I can find nothing that tells me how to do that. Neither the Eclipse update menu or the Maven menu has an option to update itext7. Can someone point me to the documentation on how to do an update? TIA.
After answer:
I am not getting the libraries but instead getting conflicts:
I can't seem to post my pom.xml using code tags (I guess the formatter has a problem with XML code because of the <>) but I will include it if someone tells me how. I've uploaded the pom file to DropBox:
pom.xml
(Turning #mkl's and #amedee's comments into an answer)
In your project there is a file pom.xml which contains the Maven project definition. In there is a dependencies section with entries for the iText artifacts (among others). The version is therein. Well, it could also be in a separate dependencies management section or in a parent pom.xml referenced in your file.
As soon as you update the POM file, you can update the Eclipse project configuration in your Eclipse Maven menu. That will, if necessary, automatically download the jar artifacts. If your Eclipse Maven integration is properly configured, that is, and if your computer has proper internet connectivity.
Old versions will remain in your local repository but won't be in the class path anymore.
Also check out our getting started guide. Which contains an example POM snippet.
https://developers.itextpdf.com/itext7/download-and-install-information/Java
If you put your iText version number in POM properties, then you only have to update the value once when you want to upgrade. Like this:
<properties>
<itext.version>7.1.1</itext.version>
</properties>
and then
<dependencies>
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>kernel</artifactId>
<version>${itext.version}</version>
</dependency>
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>io</artifactId>
<version>${itext.version}</version>
</dependency>
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>layout</artifactId>
<version>${itext.version}</version>
</dependency>
...
</dependencies>

selenium webdriver later than 2.29.1 not working in maven

Does anyone knows why later version of selenium not working in maven project in eclipse? I have the below code in pom.xml of my maven project and it works fine
<dependencies>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.29.1</version>
</dependency>
</dependencies>
but if I change the version e.g. 2.29.1 to 2.53 or 3.something , my project doesn't run and gives the ff.error
Try this :
Right click on the project, go to Maven > Enable Work Space Resolution.
this should start downloading the dependencies and build the project.

eclipse maven external jars unable to compile

Maven compilation failes even after adding the external jars to eclipse. My Eclipse codes are okay with external jars, however when I compile Maven complains package blah blah not found, and I have almost 50 external packages.
I will use the mvn dependency to add the jars later.
However It should work, but not luck.
Any troubleshooting/suggestion please.
I think you can not get away with Maven Project without having <dependencies> tag in your pom.xml (Whether you run it from eclipse or from command-line) . That too for the project which is dependent on classes that are coming from 50 external jars.
If you don't want maven to look for these jars, you have to add below entry in pom.xml with system scope:
<dependencies>
<dependency>
<groupId>selenium-server-standalone</groupId>
<artifactId>selenium-server-standalone</artifactId>
<version>2.46.0</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/selenium-server-standalone-2.46.0.jar</systemPath>
</dependency>
</dependencies>
With this, groupID & artifactID are meaningless. You can write such 50 <dependency> tags for referring your 50 external jars.

Missing artifact "sun.jdk:jconsole:jar:jdk"

When adding Arquillian to a Maven build I get the above exception in Eclipse:
Missing artifact sun.jdk:jconsole:jar:jdk
<dependency>
<groupId>org.jboss.arquillian.junit</groupId>
<artifactId>arquillian-junit-container</artifactId>
<version>1.1.7.Final</version>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.extension</groupId>
<artifactId>arquillian-persistence-dbunit</artifactId>
<version>1.0.0.Alpha7</version>
</dependency>
(The message is not the problem, but that Eclipse refuses to compile the project because of it. Maven works, though.)
Naturally the first thing I did was trying to exclude it from the Maven dependencies (wildfly-arquillian-container-managed is where the dependency tree states the dependency comes from):
<dependency>
<groupId>org.wildfly</groupId>
<artifactId>wildfly-arquillian-container-managed</artifactId>
<exclusions>
<exclusion>
<artifactId>jconsole</artifactId>
<groupId>sun.jdk</groupId>
</exclusion>
</exclusions>
</dependency>
There was no change. I tried to start Eclipse with -vm C:\Program Files\Java\jdk1.8.0_60\bin. And tried to edit the JDK in "Preferences -> Installed JREs" to contain the JAR in the tools directory. But nothing works.
What can I do?
I put my dependencies like this and it works fine:
<dependency>
<groupId>org.jboss.arquillian.junit</groupId>
<artifactId>arquillian-junit-container</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.wildfly</groupId>
<artifactId>wildfly-arquillian-container-embedded</artifactId>
<version>8.1.0.CR1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.15</version>
<scope>test</scope>
</dependency>
<!-- Arquillian -->
<dependency>
<groupId>org.wildfly</groupId>
<artifactId>wildfly-embedded</artifactId>
<version>8.1.0.CR1</version>
<exclusions>
<exclusion>
<groupId>sun.jdk</groupId>
<artifactId>jconsole</artifactId>
</exclusion>
</exclusions>
<scope>test</scope>
</dependency>
See that the exclusion tag is in the "wildfly-embedded" dependency...
Don't forget to command "mvn install" and click right button at project and "Maven Update", if it doesn't work try delete folder "~/.m2/repository" and download all the dependencies again.
Alastair, thanks for solving the problem. The cause lies in the the pom of the transient dependency org.wildfly:wildfly-cli (8.2.0.Final). There you can find the following dependency declaration:
<dependency>
<groupId>sun.jdk</groupId>
<artifactId>jconsole</artifactId>
<version>jdk</version>
<scope>system</scope>
<systemPath>${java.home}/../lib/jconsole.jar</systemPath>
</dependency>
Actually, the jar is located in ${java.home}/lib/jconsole.jar.
P.S.: The version is also insufficient. So, I deleted this version from my local maven repository.
I faced this while working in a Windows machine. The project itself worked perfectly fine in my Ubuntu machine. However the project's build failed with exactly that message, induced by a transient org.wildfly:wildfly-ejb dependency.
Missing artifact sun.jdk:jconsole:jar:jdk
I didn't feel the project configuration needed to be changed as it's supposed to just work fine across all environments and thus the Windows environment itself must have been wrong. My first thought was that Eclipse itself is in some way using JRE instead of JDK.
So I checked java -version in CMD and it appears to point to a JRE installed somewhere in /Program Files folder while I've always been manually installing JDKs in /Java folder. Then I inspected the %PATH% environment variable in Windows settings. It appears to include a /ProgramData/Oracle/Java/javapath. That folder contained a few symlinks to the JRE in /Program Files folder. That was thus actually being used to start Eclipse and run all its tasks. When I removed it (there was already a JDK/bin further down in %PATH% setting) and restarted Eclipse and re-executed Maven build, the error went away.
No changes needed to pom.xml or Eclipse configuration. Just watch out with what's Windows all installing and updating for you in the background and check your %PATH% if it still has JDK in top.
The reason of the problem is that the jconsole.jar is part of the jdk, thus it is not distributed as an ordinary maven package.
Typically, project pom.xmls insert this jconsole.jar as a system package, i.e. it doesn't even try to download them from the central maven repo. Although it would be possible to distribute it also on this way.
The simplest solution of the problem is to use a jdk which contains this jconsole.jar.
Alternatively, you can download this jar from anywhere, only you have to make it reachable in the compilation classpath.
Or, you can also modify the pom.xml, or install the package manually into your local maven repo, as the other answers state.
I spent the best part of a day fighting this problem. Simple solution is to manually install the missing jar from your jdk using maven, something like:
c:\workspace\prism>mvn install:install-file -Dfile=C:\java\jdk\lib\jconsole.jar -DgroupId=sun.jdk -DartifactId=jconsole -Dversion=1.8 -Dpackaging=war.
Who knows why eclipse cannot do this ...
Maybe is more of a workaround than a proper solution, anyway I solved this issue by removing the profile "activebydefault" in the pom. This way, Eclipse won't complain for the "Missing artifact sun.jdk:jconsole:jar:jdk" but the JUnit test won't run in Eclipse - as I use testing only from maven test, and not the Eclipse embedded JUnit runner, it just need to specify which profile ID you want to run against.
I was facing the same issue, but none of this was a perfect solution for me. Steps to solve :
Check if you are pointing to the JDK location correctly :
echo $JAVA_HOME
Open pom.xml from IDE (mine is eclipse), select Dependency Hierarchy, and search for jconsole. If you see jconsole, it is because sometimes jconsole would be given as an interdependency and the path given could not be recognized. Excluding that jar will solve the issue.
Dependency Hierarchy
Interdependent jconsole
Exclusing jconsole
i was searched jdk full name.
(cos i was used when startethe 1.8.0_191 but after change laptop. its also changed to 1.8.0_282)
so i was searched at STS.
there is a string(java path) at the .factorypath.
so i change that.
its fixed now.
guys try this way~

ClassNotFoundException when I try to deploy to Tomcat / tc Server in Eclipse / STS

I'm new to Eclipse/STS, and I am having deploying to Tomcat / tcServer. My project builds just fine and deploys to Tomcat fine both in Netbeans and directly to Tomcat, but it will not deploy to Tomcat or tc Server in Eclipse. I get a ClassNotFoundException for org.hibernate.HibernateException, which I know is on the included in the pom.
Here's my log output if it helps.
Also in the markers view, I see the following build path problem:
Archive for required library: '~/.m2/repository/org/hibernate/hibernate-core/4.1.1.Final/hibernate-core-4.1.1.Final.pom' in project 'flamespass-web-dev' cannot be read or is not a valid ZIP file
I found a work around:
I noticed that I had hibernate-core:4.1.1.Final in my Dependency Hierarchy twice, so I tried a few things, and specifying the newest version of hibernate-core in my dependencyManagement node fixed my problem.
I am not sure why. I can only assume that the two copies of hibernate-core:4.1.1 were creating some sort of ambiguity that m2eclipse or WTP couldn't understand even though my external Maven/Tomcat could. I would really appreciate any explanation or better fixes anyone may have. Thanks.
...
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>4.1.9.Final</version>
</dependency>
</dependencies>
</dependencyManagement>