Why do I need PrimeFaces Maven Repository to use a theme? - maven

Why do I need PrimeFaces Maven Repository, when using all-themes dependency from PrimeFaces?
When I just use one dependency I got no errors and can work.
But when I use all-themes I get missing artifact org.primefaces.themes:all-themes.jar:1.0.10, but why?
<repositories>
<repository>
<id>prime-repo</id>
<name>PrimeFaces Maven Repository</name>
<url>http://repository.primefaces.org</url>
<layout>default</layout>
</repository>
</repositories>
<dependency>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
<version>5.0</version>
</dependency>
<dependency>
<groupId>org.primefaces.themes</groupId>
<artifactId>all-themes</artifactId>
<version>1.0.10</version>
</dependency>

Maven's default repository is "maven central". There are a lot of artifacts in there, but some vendors may not have put their artifacts there and primefaces is one of them. Maven will look for the jar in maven central and won't find it. If you don't specify that it should also look in the Primefaces Maven Repository (which does have the artifact), it can't find the artifact.

The PrimeFaces people have decided not to deliver their packages into Maven central so that's the reason why you need to define the prime faces repository separately.
For such purposes it's a good idea to start using a repository manager which can be configured in a central location for your company to use PrimeFaces repository as well. This will make life easier.

Question:
But when I use all-themes I get missing artifact org.primefaces.themes:all-themes.jar:1.0.10, but why?
Answer:
Because the version of PrimeFaces all-theme you are using it does not exist in Maven repo. Currently Maven has 1.0.8 version as latest.
<dependency>
<groupId>org.primefaces.extensions</groupId>
<artifactId>all-themes</artifactId>
<version>1.0.8</version>
</dependency>
Maven Repo

Alternatively, you can use single themes from Icefaces
<dependency>
<groupId>org.icefaces.ace-themes</groupId>
<artifactId>ace-sunny</artifactId>
<version>4.1.0</version>
</dependency>
In your XHTML page include the style:
<h:outputStylesheet name="theme.css" library="ace-sunny"/>

We can only guess why this solution was chosen back then. Currently there is no need to a custom repository for themes. They are simply built-in, or, in case of premium themes, you will need to add the resources to your project yourself.
See https://primefaces.github.io/primefaces/12_0_0/#/core/themes

Related

How can I use Maven locations in Eclipse Target files that come from custom repositories

I am trying to use a maven location in a Tycho build, that comes from a different repository than maven central. Below is the part of the definition that provides this on PDE. Tycho does not seem to honour the repository declaration and fails on resolution. Assuming I am observing this correctly, I have the following
Question: How can I hint Tycho to understand that these maven coordinates should be obtained from the associated repositories?
If this is not a current feature, but there is an issue, please comment as well, so this can be found and tracked.
<location includeDependencyScope="compile" includeSource="true" missingManifest="generate" type="Maven">
<dependencies>
<dependency>
<groupId>com.github.amlorg</groupId>
<artifactId>amf-api-contract_2.12</artifactId>
<version>5.0.2</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.raml</groupId>
<artifactId>webapi-parser</artifactId>
<version>0.5.0</version>
<type>jar</type>
</dependency>
</dependencies>
<repositories>
<repository>
<id>mulesoft.releases</id>
<url>https://repository-master.mulesoft.org/nexus/content/repositories/releases</url>
</repository>
<repository>
<id>mulesoft.public</id>
<url>https://repository.mulesoft.org/nexus/content/repositories/public/</url>
</repository>
</repositories>
</location>

mvn- look for wrong url in maven repositories

When I run mvn package to compile a maven project it downloads the jar file from
wrong URLs. It adds org/dnosproject/ to the URL which is wrong.
Downloading: https://mvnrepository.com/artifact/io.github.dnos-project/dnos-lib-all/org/dnosproject/onos-port-protobuf/1.1.5/onos-port-protobuf-1.1.5.jar
<repositories>
<repository>
<id>dnos-lib-all</id>
<name>dnos-lib</name>
<url>https://mvnrepository.com/artifact/io.github.dnos-project/dnos-lib-all</url>
<layout>default</layout>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>io.github.dnos-project</groupId>
<artifactId>dnos-lib-all</artifactId>
<version>1.1.5</version>
</dependency>
The website mvnrepository.com is a kind of search engine across multiple real Maven repositories. If you look at the link you mentioned in your <repository/> configuration, you'll notice they list that dependency as available in "Central", in fact here. "Central" is configured by default, so you don't need a <repository/> configuration for this dependency. Instead, you just need the correct <dependency/> entry:
<dependency>
<groupId>io.github.dnos-project</groupId>
<artifactId>dnos-lib-all</artifactId>
<version>1.1.5</version>
</dependency>
You already had this in the snippet you posted, so just removing the <repository/> configuration should do the trick.

spring use library version not in the mvn repository

I'm trying to use spring-session-jdbc:2.0.0.RC2 which is not listed in https://mvnrepository.com/artifact/org.springframework.session/spring-session-jdbc/1.3.1.RELEASE
spring session github has newer version than mvnrepository.
How can I add the dependency of the new version in the pom.xml file?
To obtain dependencies that aren't on the central mvn repository, you must communicate to your project that you need it to point to an additional repository. In your case, this snippet, added to your pom, should do:
<repositories>
<repository>
<id>spring-milestone-repository</id>
<name></name>
<url>http://repo.spring.io/milestone/</url>
</repository>
</repositories>
After declaring this, you just add this to your dependencies, and it will be downloaded:
<dependency>
<groupId>org.springframework.session</groupId>
<artifactId>spring-session-jdbc</artifactId>
<version>2.0.0.M2</version>
</dependency>

Dependency error in jasper-reports from itext

From yesterday I have problems compiling with maven because of iText jar.
My project has a dependency of jasperreports-2.0.1 that depends on itext-1.02b or higher.
<dependency>
<groupId>com.lowagie</groupId>
<artifactId>itext</artifactId>
<version>[1.02b,)</version>
<scope>compile</scope>
</dependency>
That is the log error in maven:
Failed to collect dependencies for [jasperreports:jasperreports:jar:2.0.1 (compile)]: Failed to read artifact descriptor for com.lowagie:itext:jar:4.2.2: Could not transfer artifact com.itextpdf:itextpdf:pom:4.2.2 from/to jaspersoft (http://www.jasperforge.org/maven2): Access denied to http://www.jasperforge.org/maven2/com/itextpdf/itextpdf/4.2.2/itextpdf-4.2.2.pom. Error code 403, Forbidden -> [Help 1]
I see here a comment from Amedee Van Gasse that says something about a 4.2.2 version with no jar.
Why does the 1.02b version attach to 4.2.2?
Edit:
Jasper-reports uses an open version range:
[1.02b,)
This range says to maven to take the library latest version.
With the update from iText adding new version Pom with no jar and editting the maven-metadata of maven-central to that no-jar version crashes the compilation to all jar depending form latest com.lowagie library.
Updating locally your maven-metadata-central.xml (and other metadata if your company has it's own nexus.public) from ...m2\repository\com\lowagie\itext
to that works. Temporally solucion until iText updates the metadata or ALL companies that has dependencies for it's latest version updates it's pom
<metadata modelVersion="1.1.0">
<groupId>com.lowagie</groupId>
<artifactId>itext</artifactId>
<versioning>
<latest>4.2.1</latest>
<release>4.2.1</release>
<versions>
<version>0.99</version>
<version>1.1.4</version>
<version>1.02b</version>
<version>1.2.3</version>
<version>1.3</version>
<version>1.3.1</version>
<version>1.4</version>
<version>1.4.8</version>
<version>2.0.1</version>
<version>2.0.6</version>
<version>2.0.7</version>
<version>2.0.8</version>
<version>2.1.0</version>
<version>2.1.2</version>
<version>2.1.3</version>
<version>2.1.4</version>
<version>2.1.5</version>
<version>2.1.7</version>
<version>4.2.0</version>
<version>4.2.1</version>
</versions>
<lastUpdated>20150709153501</lastUpdated>
</versioning>
</metadata>
A much simpler solution may be to upgrade to a newer version of jasperreports. Version 6.1.0 has this dependency on iText:
<dependency>
<groupId>com.lowagie</groupId>
<artifactId>itext</artifactId>
<version>2.1.7.js2</version>
<scope>compile</scope>
</dependency>
No more "floating" dependency on iText, and it's a version that's custom made for jasperreports!
See http://mvnrepository.com/artifact/net.sf.jasperreports/jasperreports/6.1.0 for the complete pom.xml.
I'm using gradle and for the current version 6.8.2 I got the following build error:
> Could not find com.lowagie:itext:2.1.7.js6
So I added http://jaspersoft.jfrog.io/jaspersoft/third-party-ce-artifacts/ as repository and now it works.
repositories {
mavenCentral()
maven { url "https://jaspersoft.jfrog.io/jaspersoft/third-party-ce-artifacts/" }
}
dependencies {
compile 'net.sf.jasperreports:jasperreports:6.8.0'
}
EDIT:
If you used this solution and suddenly get an error like
> Could not resolve com.lowagie:itext:2.1.7.js6.
> Could not parse POM http://jaspersoft.jfrog.io/jaspersoft/third-party-ce-artifacts/com/lowagie/itext/2.1.7.js6/itext-2.1.7.js6.pom
> The element type "hr" must be terminated by the matching end-tag "</hr>".
This is because the jfrog repository disabled http and only allows https now. For some reason this creates a broken pom with the following content
<html>
<head><title>308 Permanent Redirect</title></head>
<body>
<center><h1>308 Permanent Redirect</h1></center>
<hr><center>nginx</center>
</body>
</html>
Solution: Replace the http in the repository url with https.
The problem is indeed in the POM of jasper-reports:
<dependency>
<groupId>com.lowagie</groupId>
<artifactId>itext</artifactId>
<version>[1.02b,)</version>
<scope>compile</scope>
</dependency>
Jasper-reports distributes a (modified) build of iText 2.1.7 since at least November 2012 (if memory serves me well), so if your version of jasper-reports still has a dependency on 1.02b and up, it must be a very old version.
The jasper-reports dependency on iText should be changed to:
<dependency>
<groupId>com.lowagie</groupId>
<artifactId>itext</artifactId>
<version>[1.02b,2.1.7]</version>
<scope>compile</scope>
</dependency>
Or just:
<dependency>
<groupId>com.lowagie</groupId>
<artifactId>itext</artifactId>
<version>2.1.7</version>
<scope>compile</scope>
</dependency>
This relates to this question: How do I tell Maven to use the latest version of a dependency?
That page is riddled with cautions about always using the latest version for your dependencies. It reduces reproducibility of your builds.
2.1.7 was the last version of iText released by the company iText Group NV (or its legal predecessor), with the com.lowagie groupId. The next version of iText, released by the company iText Group NV, was version 5.0.0, with the com.itextpdf groupId, which means it's binary incompatible with your current code. There's also the matter of a license change to AGPL, but that is outside the scope of StackOverflow, I want to restrict my answer to the technical matters.
Any other versions of iText between 2.1.7 and 5.0.0, like 4.2.0 and 4.2.1, are forks by other companies. According to Apache's Guide to uploading artifacts to the Central Repository (https://maven.apache.org/guides/mini/guide-central-repository-upload.html), those companies should have used a different groupId, as the page clearly states in their FAQ:
I have a patched version of the foo project developed at foo.com, what
groupId should I use? When you patch / modify a third party project,
that patched version becomes your project and therefore should be
distributed under a groupId you control as any project you would have
developed, never under com.foo. See above considerations about
groupId.
TL;DR
If you don't want to change your code, tell your Maven to only get iText 2.1.7.
We decide to maintain same jasperreport version and made this changes in conflicteds pom:
<dependencies>
<dependency>
<groupId>jasperreports</groupId>
<artifactId>jasperreports</artifactId>
<version>2.0.1</version>
<exclusions>
<exclusion>
<groupId>com.lowagie</groupId>
<artifactId>itext</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.lowagie</groupId>
<artifactId>itext</artifactId>
<version>2.1.7</version>
</dependency>
...
</dependencies>
Edit: Change dependecy to 2.1.7 to be certain it will compile in future
I was making manteinance to some legacy code, and i faced the same problem. The solution that i found was to add the following to the pom.xml:
<repositories>
<repository>
<id>jasper-3rd-party</id>
<name>Jasper3rdParty</name>
<url>http://jaspersoft.jfrog.io/jaspersoft/third-party-ce-artifacts/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>net.sf.jasperreports</groupId>
<artifactId>jasperreports</artifactId>
<version>6.12.2</version>
</dependency>
<!-- More dependencies like: commons-collections4, org.apache.xmlgraphics, etc -->
<dependency>
<groupId>com.lowagie</groupId>
<artifactId>itext</artifactId>
<version>2.1.7.js4</version>
</dependency>
</dependencies>
The JasperReports version used to test this code was released on Mar/2020. Hope this helps!
I got the same problem,
Just realized that https://jaspersoft.jfrog.io/artifactory/third-party-ce-artifacts is not accessible by public, you need to change the artifactory to jaspersoft directory.
For maven you can use below repositories in pom.xml
<repositories>
<repository>
<id>jaspersoft-third-party</id>
<url>https://jaspersoft.jfrog.io/jaspersoft/third-party-ce-artifacts/</url>
</repository>
</repositories>
JasperReports patched the iText with some bug fixes. So you have to add the patched iText repo[1] in your pom/gradle file.
[1] http://jasperreports.sourceforge.net/maven2/
Below is the gradle snippet for your reference when using jasper report 6.1.1.
repositories {
mavenLocal()
mavenCentral()
maven { url "http://repo.spring.io/release" }
maven { url "https://jaspersoft.jfrog.io/artifactory/third-party-ce-artifacts/" }
maven { url "http://jasperreports.sourceforge.net/maven2/" }
}
This worked with the latest jasper-reports version 6.17.0 and maven 3.8.1, especially with the jasperreports-plugin from com.alexnederlof in version 2.8:
<project>
...
<repositories>
<!-- JasperSoft, they modified a standard library for their own special needs -->
<repository>
<id>jaspersoft-third-party</id>
<url>https://jaspersoft.jfrog.io/jaspersoft/third-party-ce-artifacts/</url>
</repository>
</repositories>
<pluginRepositories>
<!-- JasperSoft, they modified a standard library for their own special needs -->
<pluginRepository>
<id>jaspersoft-third-party</id>
<url>https://jaspersoft.jfrog.io/jaspersoft/third-party-ce-artifacts/</url>
</pluginRepository>
</pluginRepositories>
...
It's important to know that there is not only <repositories> but also <pluginRepositories> which you maybe have to supply (depending on your setup and transitive dependencies).
Answer for searchers in 2k19
Artifact:
<groupId>com.lowagie</groupId>
<artifactId>itext</artifactId>
is deprecated now.
Better to exclude it from jasperreports and add new itext dependency manually
<dependency>
<groupId>jasperreports</groupId>
<artifactId>jasperreports</artifactId>
<version>6.10.0</version> <!--(or higher)-->
<exclusions>
<exclusion>
<groupId>com.lowagie</groupId>
<artifactId>itext</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>itextpdf</artifactId>
<version>5.5.13</version> <!--(or higher)-->
</dependency>
"Fix" for me was to switch from jasperreports version 5.5.0 to 4.5.1 LOL. (which doesn't depend on itext)
Then it doesn't depend on a custom, seemingly unpublished dependency version of itext (2.1.7.js2 in my case).
You could download 2.1.7.js2.jar from the jasper people and publish it locally to your "own" custom maven repo, or even your local ~/.m2/repository (ugh). I've even seen people have a custom ivy command to "publish" a local copy of it to a local server (ivy or maven).
Or add the repo's in the other answers. Or just specify it manually as 2.1.7, which is in the main repo's, etc. (you'll miss some bug fixes though).
If you are using gradle Note That the url to the jaspersoft package below was changed from this one:
maven{ url "http://jaspersoft.artifactoryonline.com/jaspersoft/third-party-ce-artifacts" }
To this one here:
maven { url "https://jaspersoft.jfrog.io/artifactory/third-party-ce-artifacts" }
We have the same problem. To solve it, we have deleted the proxy parameters of the Maven config, and change the last version of the maven-metadata-central (in folder com\lowagie\itext of your repository).
A bad solution, but, temporaly, works :/
I have the same problem when using Maven 2.2.1, i re-built my project using Maven 3.2.3 and its works !
You have to use Maven 3 to resolve your problem, the bug seem to be resolved in this version.

Maven build issue with Hibernate for Windows

I'm getting build errors for for my Maven enabled project related to the Hibernate extension. - It's a very basic app, and I was able to solve this issue on my Linux box by manually installing some required artifacts:
mvn install:install-file -DgroupId=javassist -DartifactId=javassist
-Dversion=3.9.0 -Dpackaging=jar -Dfile=foo.jar
That worked out (Hibernate as a set of required deps).
But in case of Windows things are different. How do I add the dependencies manually to Maven on Windows?
1) org.hibernate:hibernate:jar:3.3.2
Try downloading the file manually from the project website.
Then, install it using the command:
mvn install:install-file -DgroupId=org.hibernate -DartifactId=hibernate -Dversion=3.3.2
-Dpackaging=jar -Dfile=/path/to/file
2) javassist:javassist:jar:3.9.0
Can I automate this cumbersome manual dependency installation for my coworkers on their Windows machines? Are there any helpful tools or GUI that can perform these tasks? The best way would be that Maven does it all automatically. I'm not too familiar with it jet.
Thanks for answers.
Firstly, you can manually install artifacts to your local Maven repository in Windows in exactly the same way you did on your Linux box.
Ideally, as you say, Maven will do the hard work for you. Usually you won't have to install jars manually: for most libraries Maven will know what dependencies each jar has. By default, Maven will check the central repository, and a couple of others. To access jars in other repositories, just add them to your POM, as follows:
<project>
...
<repositories>
<repository>
<id>jboss.maven2.repo</id>
<name>JBoss Maven Repo</name>
<url>http://repository.jboss.com/maven2</url>
</repository>
<!-- other repositories here -->
</repositories>
...
</project>
The JBoss repo mentioned above is a good one to add. It has a lot of common jars, including the jars for the hibernate version you mentioned above. Reference it in your pom.xml like this:
<dependencies>
<!-- ... -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>3.3.2.GA</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-annotations</artifactId>
<version>3.4.0.GA</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-commons-annotations</artifactId>
<version>3.3.0.ga</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>3.4.0.GA</version>
</dependency>
</dependencies>
Once you have added these dependencies, Maven will also download the libraries that these libraries depend on, and so on (including the Javassist library in your example).
Finally, as mentioned in another answer, if you have a lot of third party libraries to install for your project that don't exist in other repositories, you might want to install a repository manager like Nexus, Artifactory, or Archiva, which will allow you to perform the install commands you mentioned, through a web-based interface.
You can use mvn install:install-file on your Windows machine to install dependencies to the local repository as well
You might want to change your settings.xml to add additional repository mirrors, so you aren't relying on just central. Check out jboss, java.net, etc. You can also set up your own repository manager (like Nexus) to handle mirroring, storing your team's artifacts, etc.; and then just point each developers machine at your repository.
See Repository Management with Nexus and Reasons to use a Repository Manager for more.
I was able to solve this issue on my Linux box by manually installing some required artifacts (...)
Manually installing an artifact is a bad practice (it makes your build non portable as you're experiencing) and, actually, there is no reason to install the artifacts you're looking for manually, they're both available in the JBoss repository. So, add it to the list of "declared" repositories:
<project>
...
<repositories>
<repository>
<id>repository.jboss.org</id>
<name>Jboss Repository for Maven</name>
<url>http://repository.jboss.org/maven2</url>
</repository>
</repositories>
...
</project>
And then declare the following dependencies:
<dependencies>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>3.3.2.GA</version>
</dependency>
<dependency>
<groupId>javassist</groupId>
<artifactId>javassist</artifactId>
<version>3.9.0.GA</version>
</dependency>
</dependencies>
Note the dependency on hibernate-core (http://repository.jboss.org/maven2/org/hibernate/hibernate/3.3.2.GA/ contains only a pom).

Resources