dependency not resolved: DocumentBuilderFactory class need dependency of javax.xml.parsers in openJDK 11 - ivy

Story:
I was using JDK8 and IVY as dependency manager with ANT Builder. everything was fine. My DocumentBuilderFactory class able to find javax.xml.parsers dependency.
Issue:
Now I am shifted to Open JDK11, Now DocumentBuilderFactory not able to find javax.xml.parsers dependency.
Eclipse gives me suggestions to import, but when i Import nothing happens, and already import says the import javax.xml.parsers.DocumentBuilder cannot be resolved
like this:
What I Need as Solution:
I need IVY dependency for Open JDK 11 to support javax.xml.parsers for DocumentBuilderFactory

I was facing this issue too,
It was because of DocumentBuilderFactory is available in other packages too.
Reason
Sometimes dependencies take transitive dependencies along with it self
For example
Class XYZ is available in jarA, JarB and JarC too. This issue was not visible untill Java8 but after Java9 release, Java9 release with Java Platform Module System.
This module system restrict to have multiple classes in different jars with same name, I am not saying that we can not have same name in different classes, for this you have to write module-info.java and have to convert your application into Module System.
If you are not planning to move your application into Module System then you can do one this, remove the dependencies which are not required for your applications and have same named classes.
Like for your problem what you can do
Open project in eclipse
Press ctrl + shit + T >
Dialog opens> write your class name which is creating problem, >
Dialog will show the packages which contains the same class, Now
find out the package which is not required or transitive property
because of other dependency >
Right click on package name and click show in Package Explorer>
Now you will have the jar name, remove or exclude that jar
from your dependency manager, Like Gradle or Maven Or Ivy
I know lengthy process, but its your application your love you have to maintain this.

I am using Eclipse Scout v9.0, and i facing same problem when i migrated from Java 1.8 to 11. I spent hours to solve it and i finally figure it out. Using the information provided by "catalystOne Dupinder", i found out that Java 11 has its own src.jar containing the following class:
DocumentBuilder.java
DocumentBuilderFactory.java
FactoryConfigurrationErro.java
etc.
same class as "xml-apis" thus. So what i did are the following:
exclude the "xml-apis" from maven dependency,
configured the build path of the module and under the "Order and Export" tab click "JRE System Library [JavaSE-11]"
What i just did is, i just exported the jar library from Java 11 to maven dependencies.
Hope this will help you guys..

javax.xml are extracted as separate module in Java 9.
In your project's Java build path option, go to Libraries tab and change JDK from Classpath to ModulePath and this should fix this problem.
Let me know if it helped.

I have resolved the same issue using the below-mentioned steps :
I have executed the mvn dependency:tree in my terminal
output:
[INFO] +- org.seleniumhq.selenium:selenium-server:jar:3.8.1:compile
[INFO] | +- com.beust:jcommander:jar:1.48:compile
[INFO] | +- org.apache.commons:commons-text:jar:1.1:compile
[INFO] | +- commons-io:commons-io:jar:2.6:compile
[INFO] | +- commons-net:commons-net:jar:3.6:compile
[INFO] | +- org.w3c.css:sac:jar:1.3:compile
[INFO] | +- net.sourceforge.cssparser:cssparser:jar:0.9.24:compile
[INFO] | +- net.sourceforge.htmlunit:htmlunit:jar:2.28:compile
[INFO] | +- net.sourceforge.htmlunit:htmlunit-core-js:jar:2.28:compile
[INFO] | +- net.sourceforge.htmlunit:neko-htmlunit:jar:2.28:compile
[INFO] | +- net.jcip:jcip-annotations:jar:1.0:compile
[INFO] | +- org.seleniumhq.selenium:jetty-repacked:jar:9.4.7.v20170914:compile
[INFO] | +- org.eclipse.jetty:jetty-client:jar:9.4.7.v20170914:compile
[INFO] | +- org.eclipse.jetty:jetty-http:jar:9.4.7.v20170914:compile
[INFO] | +- org.eclipse.jetty:jetty-io:jar:9.4.7.v20170914:compile
[INFO] | +- org.eclipse.jetty:jetty-util:jar:9.4.7.v20170914:compile
[INFO] | +- org.eclipse.jetty:jetty-xml:jar:9.4.7.v20170914:compile
[INFO] | +- org.seleniumhq.selenium:htmlunit-driver:jar:2.28:compile
[INFO] | +- javax.servlet:javax.servlet-api:jar:3.1.0:compile
[INFO] | +- org.eclipse.jetty.websocket:websocket-api:jar:9.4.7.v20170914:compile
[INFO] | +- org.eclipse.jetty.websocket:websocket-client:jar:9.4.7.v20170914:compile
[INFO] | +- org.eclipse.jetty.websocket:websocket-common:jar:9.4.7.v20170914:compile
[INFO] | +- xalan:serializer:jar:2.7.2:compile
[INFO] | +- xalan:xalan:jar:2.7.2:compile
[INFO] | +- xerces:xercesImpl:jar:2.11.0:compile
[INFO] | +- xml-apis:xml-apis:jar:1.4.01:compile
[INFO] | \- org.yaml:snakeyaml:jar:1.15:compile
I have exclude the xml-apis dependency from org.seleniumhq.selenium:selenium-server:jar:3.8.1:compile
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-server</artifactId>
<version>3.8.1</version>
<exclusions>
<exclusion>
<groupId>xml-apis</groupId>
<artifactId>xml-apis</artifactId>
</exclusion>
</exclusions>
</dependency>
3.I update the maven project (Project > maven > update project)
After updating the maven project I have solved my issue.

Related

Maven child modules not being built

I have a relativey simple multi module maven buid with a parent pom. This includes the 2 child modules as follows:
<modules>
<module>WebApp</module>
<module>WebService</module>
</modules>
When I run mvn clean install on the top level pom it cleans & installs each child module as expected. However I am now trying to add a plugin (codehaus weblogic) goal to deploy the WebApp .war to Weblogic 10.3.4 e.g. mvn clean install weblogic:deploy. For some reason this does not run the clean and install phases but does the deploy. If I run the command from within the WebApp directory it does do the clean and install before doing the deploy.
Is there some gotcha I'm missing that will not run the child life cycle phases if running a goal at the top level. Here's the command line output:
[INFO] Scanning for projects...
[INFO] Reactor build order:
[INFO] SupportClient
[INFO] SupportClient-WebServices
[INFO] SupportClient-WebApp
[INFO] Searching repository for plugin with prefix: 'weblogic'.
[INFO] org.apache.maven.plugins: checking for updates from central
[INFO] org.codehaus.mojo: checking for updates from central
[INFO] ------------------------------------------------------------------------
[INFO] Building SupportClient
[INFO] task-segment: [clean, install, weblogic:deploy]
[INFO] ------------------------------------------------------------------------
[INFO] [clean:clean]
[INFO] [site:attach-descriptor]
[INFO] [install:install]
[INFO] Installing C:\Development\Destin8SupportClient\pom.xml to C:\Users\finchaj.HPH\.m2 \repository\com\mcpplc\supportClient\supportClient\1.0\supportClient-1.0.pom
[INFO] [weblogic:deploy]
[INFO] Weblogic Deployment beginning with parameters DeployMojoBase[adminServerHostName = localhost, adminServerProtocol = t3, adminServerPort = 8001, userId = xx, password = ****, artifactPath = C:\Development\Destin8SupportClient/WebApp/target/WebApp.war, projectPackaging = war, name = support-client-webapp, targetNames = AdminServer, remote = false]
[INFO] Weblogic Deployment parameters [-adminurl, t3://localhost:8001, -username, xx, -password, xx, -name, support-client-webapp, -targets, AdminServer, -source, C:\Development\Destin8SupportClient/WebApp/target/WebApp.war, -deploy]
weblogic.Deployer invoked with options: -adminurl t3://localhost:8001 -username xx-name support-client-webapp -targets AdminServer -source C:\Development\Destin8SupportClient/WebApp/target/WebApp.war -deploy
The file, 'C:\Development\Destin8SupportClient/WebApp/target/WebApp.war', does not exist.
It is running the weblogic:deploy goal on the top-level (pom!) module. This goal can only be run on a war or ear module.
You need to bind that goal in the WebApp sub-module to run in the install phase.
It is currently running on the top-level (pom!) module.
e.g. try adding the following to your weblogic configuration in the Webapp sub-module.
<executions>
<execution>
<phase>install</phase>
<goals>
<goal>deploy</goal>
</goals>
</execution>
</executions>
See also Example C-1 in this documentation
If you wish to have this run at the end of your build, once all other modules have been built, you will need to either:
re-order your sub-modules, so WebApp is last, then do as above
or, add another sub-module that will execute last, which depends on your WebApp submodule. Then, tell the weblogic plugin to use that .war file by specifying the following property maven.weblogic.war . You may want to use the dependency:copy goal first, to get the into the target dir of that last sub-module.
If you want to run the install phase first for all projects and after that deploy your projects to your webserver, you have to split the maven calls.
mvn clean install
mvn weblogic:deploy
By default, maven execute all tasks per project and to separate maven tasks the only solution to run them separately.
maven runs all the specified goals first on the parent project and then on the chldren.
From the logs it is evident that maven ran the clean and install goals of the parent and then tried to run the weblogic:deploy goal. Now, weblogic:deploy evidently is not a goal which is relevant to the parent, since it is meant to deploy a child webapp. maven does not know that and thus the failure.
Perhaps you should reconsider npellow's solution since it should work for your requirement.

Maven Plugin - mvn release:prepare

Hi i'm checking via new created plugin (mpc) some parts of the pom (scm area)...but now i faced that during the mvn release:prepare of a different modules which uses the created plugin (mpc) I got the following messages:
[INFO] [INFO] Scanning the projects...
[INFO] [INFO] ...
[INFO] [INFO] not a working copy....
The output "not a working copy" ...is because I'm checking the svn info output...
The question is can I recogdnize this state during the mvn release:prepare somehow ? for example via roperties or checking an attribute of the current project ? Which means in other words that I know inside my maven plugin (mpc) that currently the release:prepare cycle is running?
I found a solution. I simply check if the current build is building an SNAPSHOT version or not (ArtifactUtil.isSnapshot() very helpfull).

maven dependency range does not work as expected

Maven 2.2.1 claims to support version ranges (see e.g. http://www.sonatype.com/books/mvnref-book/reference/pom-relationships-sect-project-dependencies.html#pom-relationships-sect-version-ranges)
I tried from a brandnew maven installation the following pom:
<project>
<modelVersion>4.0.0</modelVersion>
<artifactId>rangetest</artifactId>
<groupId>my.group</groupId>
<version>1.0</version>
<packaging>jar</packaging>
<description>test project containing one dependency, only</description>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
The dependency should resolve to junit 4.8.2, right?
But instead, the version 4.8 is resolved:
C:\Users>mvn dependency:tree
[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'dependency'.
[INFO] ------------------------------------------------------------------------
[INFO] Building Unnamed - my.group:rangetest:jar:1.0
[INFO] task-segment: [dependency:tree]
[INFO] ------------------------------------------------------------------------
[INFO] [dependency:tree {execution: default-cli}]
[INFO] my.group:rangetest:jar:1.0
[INFO] \- junit:junit:jar:4.8:test
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2 seconds
[INFO] Finished at: Thu Oct 07 14:30:40 CEST 2010
[INFO] Final Memory: 9M/23M
[INFO] ------------------------------------------------------------------------
You might think it's an issue with Junit, as 4.8 is an existing version, but it's not. In my projects, I have versions deployed from 1.0.0 to 1.0.15 (no version 1.0!), but mvn dependency:tree complains about missing artifact of version 1.0.
That only works if you actually specify a version range or if you have more than one POM. You use 4.8 which is a single version number, so Maven tries to resolve it directly. A version range must start with [ or ( (inclusive and exclusive, respectively).
In your case, try: [4.8,4.9)
That should give you the highest version with the same API (i.e. all bug fixes but no breaking changes).
This document shows how Maven interprets versions: https://maven.apache.org/enforcer/enforcer-rules/versionRanges.html
The first line seems to support your position (4.8 means "at least 4.8") but there is a catch: Maven will only select a higher version if anyone specifically asks for it. So unless you have more POMs in your build and one of those asks for 4.8.2, 4.8 is "good enough" for Maven.
Think of it as a hint for conflict resolution. If POM A asks for 4.8 and B asks for 4.8.2 and B depends on A, then Maven has to make a decision. Should it fail? Should it use 4.8? Or 4.8.2?
The rules resolve this conflict by picking 4.8.2 without giving a warning or an error.
If A asks for [4.8], you'd get an error instead since Maven can't silently "upgrade" the dependency to 4.8.2 and it certainly can't downgrade 4.8.2 to 4.8.
If you want to use version ranges, specify a version range as others pointed out. Currently, you're not.
But my real advice would be to not use version ranges at all, version ranges are a bad idea for build reproducibility and the last thing you want is a build that suddenly starts to fail because of an unknown reason. Just don't, they are a bad practice (which is probably why version ranges aren't documented anymore).
There doesn't seem to be a range qualifier in your version tag. Maybe you meant to use the following to require version 4.8 or later:
<version>[4.8,)</version>
In my case, everything was working but out of the sudden I got this error
No versions are present in the repository for the artifact with a range [x,y)
I went to the library location inside .m2/repository folder and deleted the whole folder,
if you removed folder of a specific version of the lib it won't work, should remove folders of all versions of that lib
one more thing, if the lib is transitive you might need to remove all libraries in the dependency path
hope this helps you

How do I stop Maven 2.x from trying to retrieve non-existent pom.xml files for dependencies every build?

In my project, there are a number of dependencies that are transitively included from other dependencies that do not have pom.xml files available in any of our corporate repositories. These are internal jar-only libraries supported by various teams which have been uploaded into repositories for convenience from non-Maven teams, however these repositories are unfortunately not mine to play with.
For these dependencies, Maven insists on trying to retrieve the poms from each of my repository list every time I run a build, or mvn dependency:list. This means maven tries to retrieve 8x pom files from 7 different repository locations, and given this is over the global corporate WAN; it's really slow.
e.g. for one particular dependency
C:\Working\dev\workspace\project>mvn dependency:list
[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'dependency'.
[INFO] ------------------------------------------------------------------------
[INFO] Building project
[INFO] task-segment: [dependency:list]
[INFO] ------------------------------------------------------------------------
[WARNING] Unable to get resource 'aGroupId:anArtifactId:pom:4.0.14i' from repository inhouse (http://someRepo1/proximity/repository/inhouse): While configuring wagon for 'inhouse': Unable to apply wagon configuration.
Downloading: http://someRepo1/proximity/repository/extFree/aGroupId/anArtifactId/4.0.14i/anArtifactId-4.0.14i.pom
[INFO] Unable to find resource 'aGroupId:anArtifactId:pom:4.0.14i' in repository extFree (http://someRepo1/proximity/repository/extFree)
Downloading: http://someRepo1/proximity/repository/externalNonFree/aGroupId/anArtifactId/4.0.14i/anArtifactId-4.0.14i.pom
[INFO] Unable to find resource 'aGroupId:anArtifactId:pom:4.0.14i' in repository extNonFree (http://someRepo1/proximity/repository/externalNonFree)
Downloading: http://someRepo2/efs/dist/maven/maven2-repository/incr/common/lib/aGroupId/anArtifactId/4.0.14i/anArtifactId-4.0.14i.pom
[INFO] Unable to find resource 'aGroupId:anArtifactId:pom:4.0.14i' in repository efsRepo (http://someRepo2/efs/dist/maven/maven2-repository/incr/common/lib)
Downloading: http://someRepo2/efs/dist/btijava/maven2-repository/incr/common/lib/aGroupId/anArtifactId/4.0.14i/anArtifactId-4.0.14i.pom
[INFO] Unable to find resource 'aGroupId:anArtifactId:pom:4.0.14i' in repository efsBTI (http://someRepo2/efs/dist/btijava/maven2-repository/incr/common/lib)
Downloading: http://someRepo3/maven/aGroupId/anArtifactId/4.0.14i/anArtifactId-4.0.14i.pom
[INFO] Unable to find resource 'aGroupId:anArtifactId:pom:4.0.14i' in repository internal.repo (http://someRepo3/maven)
Downloading: http://repo1.maven.org/maven2/aGroupId/anArtifactId/4.0.14i/anArtifactId-4.0.14i.pom
[INFO] Unable to find resource 'aGroupId:anArtifactId:pom:4.0.14i' in repository central (http://repo1.maven.org/maven2)`
...
etc
...
[INFO] [dependency:list {execution: default-cli}]
[INFO]
[INFO] The following files have been resolved:
... etc
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 20 seconds
[INFO] Finished at: Tue Jan 26 15:01:48 CST 2010
[INFO] Final Memory: 31M/74M
[INFO] ------------------------------------------------------------------------
On the other hand, for POMs which are just invalid (older modelVersion, or corrupt/invalid XML, for example) it just checks my local repo, complains it's invalid and then continues. Which is fine; at least that doesn't try again over the WAN.
Is there a way (setting, override, repository config change) I can prevent Maven's dependency plugin/artifact resolver from repeatedly trying to locate missing POMs, if it already has the jar file in the local repo?
Specs:
Maven 2.2.1 (default superPOM plugin definitions)
JDK 1.6.0_18
Pascal's answer is correct for two local build workarounds. However, your best option is to request the owners of these projects to create POMs for the artifacts. They don't need to be complex, the simple alternative that Maven is using internally will work:
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>aGroupId</groupId>
<artifactId>aArtifactId</artifactId>
<version>4.0.14i</version>
</project>
Downloading a POM is really a central concept in Maven to support transitive dependencies (actually, a dependency isn't just a JAR, see 3.5.5. Maven's Dependency Management for nice details on that) so I don't know if you can prevent it.
Of course, the right thing to do would be to fix the root cause of the problem. But if you can't, maybe you can run your build in offline mode (using the -o option). Or maybe you could just "install" the artifacts in your local repository using install:install-file and instruct the plugin to generate a pom for them using the generatePom optional parameter (but this obviously doesn't "scale" really well).
Set up a Nexus Repository (or similar) and upload the artifacts there. Nexus will automatically create basic poms for artifacts you upload.
download to local repo
setup nexus and upload
work offline
maybe the best idea is to get rid of maven all the way, it is horror !

How do I set up a test project for a Eclipse plugin project

I'm working on a eclipse plug-in and I've tried to create another test project seperate from the plug-in. The reason I do this is to not let the plug-in depend on jUnit when it is exported. However, I can't access the Eclipse Plug-in API when I do the testing. Whenever I try to add Plug-in dependencies the import list to that is empty.
Does anyone know how to import Eclipse plug-in API to an existing project? The workspace layout looks like this at the moment:
+- com.foo.myplugin
| |
| +- JRE System Library
| |
| +- Plug-in Dependencies
| |
| +- src
| |
| +- icons, META-INF, plugin.xml, etc...
|
+- com.foo.myplugin.test
|
+- JRE System Library
|
+- JUnit 4
|
+- src
The recomended way of ding this seems to be with Plug-in fragments:
http://rcpquickstart.com/2007/06/20/unit-testing-plug-ins-with-fragments/
The fragment gets a high-degree of access to your plugin's code and separates the testing logic / dependencies from the plugin itsself.
Now if only I could find a way to test them in an automated system... (see: Automating unit tests (junit) for Eclipse Plugin development )
You can export the plug-in dependency from the plug-in project. Easiest way is like this:
Go to your com.foo.plugin project properties
Go to Java Build Path > Order and Export
Check the Plug-in Dependencies entry
The test project should now be able to use plug-in API without the need to use all plugin configuration required for a plug-in project.
You could try to add the plugin nature to your new myplugin.test project.
In your .project file:
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
[...]
</natures>
Then in the .classpath, add:
<classpath>
[...]
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
[...]
</classpath>
Delete your myplugin.test from the workspace, re-import that project and see if that does the trick...