Fortify Sourceanalyzer - Missing java class when analyzing XWiki - maven-2

The missing class is com.xpn.xwiki.test.AbstractXWikiComponentTestCase. This is the only class that cannot be resolved. I have run:
mvn package
Then I have tried to build with sourceanalyzer and this is the only class that cannot be found. I do not understand why mvn package would not have gotten this for me.

If you're getting missed dependencies when building with the Fortify SCA Maven2 plugin, you should try the "install" goal instead of the "package" goal.
"install" puts the dependencies into your repository. The Fortify SCA Maven2 Plugin looks in the repository for dependencies.
I hope this helps! Please let us know.

Looks like you're missing a jar. did you see any lines earlier in the build attempting to download dependencies?
The XWiki jars aren't hosted on central, but you can add the XWiki repository to your pom using configuration like this:
<repositories>
<repository>
<id>xwiki-releases</id>
<name>XWiki Maven2 Remote Repository for Releases</name>
<url>http://maven.xwiki.org/releases</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
Once that configuration is added, Maven should download all the required dependencies. If it still doesn't, you can explicitly add the missing dependency to your POM:
<dependencies>
...
<dependency>
<groupId>org.xwiki.platform</groupId>
<artifactId>xwiki-core-shared-tests</artifactId>
<version>??</version>
<scope>test<!--assume this is just for tests, if not omit the scope declaration--></scope>
</dependency>
</dependencies>

Related

IntelliJ JavaFX project cannot user bintray repo

I am trying to use the bintray repo in my JavaFX project using the IntelliJ ide.
I've tried to go Settings -> Maven -> Repositories and adding this 2:
https://jcenter.bintray.com/
https://bintray.com/bintray/jcenter
None of them work and I can't find any pom.xml or settings.xml or any maven settings.
What I can do ? Importing the JAR is not a solution. These .jar need other 3-4 libraries like Apache library and others and I don't want to import them manually.
If you use maven, then you can just add this repo to your pom.xml or settings.xml manually:
<repositories>
<repository>
<id>jcenter</id>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
<url>https://jcenter.bintray.com/</url>
</repository>
</repositories>
Note: in settings.xml you need to put this into profile.
Update: probably the easiest way to start using maven for building your project, is to create empty maven project using mvn archetype:generate command, and then copy your sources to created project src/main/java folder.

maven setup another repository for certain dependency

I have Maven2 project. All dependencies except one are downloaded from public repository http://repo.maven.apache.org/maven2/.
But I have 1 dependency which I need to download from internal company's repository (we use Sonatype Nexus to store this dependency).
Also, I don't want to create full copy of public repo on my internal repo.
At this moment I have in pom.xml:
<url>http://maven.apache.org</url>
and
<repositories>
<repository>
<id>thirdparty</id>
<url>http://<my_nexus_server_ip>:8081/nexus/content/repositories/thirdparty</url>
</repository>
</repositories>
So, during build I see a lot of trash messages (in this case first line is a trash):
Downloading: http://<my_nexus_server_ip>:8081/nexus/content/repositories/thirdparty/ant/ant/1.6.5/ant-1.6.5.pom
Downloading: http://repo.maven.apache.org/maven2/ant/ant/1.6.5/ant-1.6.5.pom
Downloaded: http://repo.maven.apache.org/maven2/ant/ant/1.6.5/ant-1.6.5.pom (861 B at 3.2 KB/sec)
I want to clearly point Maven for which dependency it have to use internal repository and ignore it for others dependencies (and point that for others dependencies Maven2 have to use public repository).
Could you please help to implement such behavior in Maven?
Thanks In Advance!
According to this answer, it is not possible to set a specific repository for for some of the declared dependencies.
You need to configure the public repository group in Nexus to be used the only one in your Maven builds like the following:
<settings>
<mirrors>
<mirror>
<!--This sends everything else to /public -->
<id>nexus</id>
<mirrorOf>*</mirrorOf>
<url>http://localhost:8081/nexus/content/groups/public</url>
</mirror>
</mirrors>
<profiles>
<profile>
<id>nexus</id>
<!--Enable snapshots for the built in central repo to direct -->
<!--all requests to nexus via the mirror -->
<repositories>
<repository>
<id>central</id>
<url>http://central</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<url>http://central</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
<activeProfiles>
<!--make the profile active all the time -->
<activeProfile>nexus</activeProfile>
</activeProfiles>
</settings>
You have to setup a separate repository in nexus like you described a repo called ThirdParty and add this repository into the configuration of the public repository group. Furthermore you need to upload the one dependency into that particular repository. Apart from that you should have to use the release and SNAPSHOT repository which means you need to configuration your distributionManagement accordingly in your company master pom file.

I did a mvn install to kundera. I want to add the installed jar to another maven project

Prefix: I'm very new to maven so I am open to "your doing it wrong" answers.
I want to build a kundera project with MongoDB as the backend. I tried these directions but ended up with a kundera without the Document class. I was trying this tutorial that I got from this answer, and came to the conclusion that the version of kundera in that jar did not have mongo support. So I built kundera from svn and did a mvn install. I want to know what mvn command or what edits to the pom.xml file I must make to add the kendera jar I just installed to my local maven repository as a dependency to another maven project.
Please add this into your pom under the <repositories> section.
<repository>
<id>kundera-missing</id>
<name>Kundera Public Missing Resources Repository</name>
<url>http://kundera.googlecode.com/svn/maven2/maven-missing-resources</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
And add a depedency like:
<dependency>
<groupId>com.impetus.kundera</groupId>
<artifactId>kundera</artifactId>
<version>1.1.1-SNAPSHOT</version>
</dependency>
into your pom.xml
That should solve yuour problem.
You can join this forum for discussions related to Kundera:
https://groups.google.com/forum/#!forum/kundera-discuss
Regards,
Amresh
I doubt if there is any such plugin available with maven. Unfortunately you need to do it manually.

Maven build error - The following artifacts could not be resolved

I want to build a spring mvc project by maven, I got the following error:
The following artifacts could not be resolved: org.aopalliance:com.springsource.org.aopalliance:jar:1.0.0, org.hibernate:hibernate-validator:jar:4.2.0.Beta1: Could not find artifact org.aopalliance:com.springsource.org.aopalliance:jar:1.0.0 in central (http://repo1.maven.org/maven2)
I use eclipse and m2eclipse plugin. I don't know how to add local repository. And I found for different versions of eclipse,the result is different. Some can pass, some fail. I am confused.
By the way where can I find the version of maven used in m2eclipse?
Update:Now I can handle hibernate-validator,but even I deleted all spring mvc dependencies,I found there are many other library are dependent on com.springsource.org.aopalliance,
Check your %.m2\repository\org\aopalliance\com.springsource.org.aopalliance\1.0.0\.
If there isn't a com.springsource.org.aopalliance-1.0.0.jar in there, just download it by yourself and copy it to this folder.
Since you are working with spring artifacts, you can refer to this doc. If you are working on released versions of spring, you can add the following repository in your settings.xml
<repository>
<id>com.springsource.repository.maven.release</id>
<url>http://maven.springframework.org/release/</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
[Edit 1: based on the comment]
The groupId/projectId of aopalliance seems to indicate it is in spring enterprise bundle repository. The contents of this accessible from the following repository url.
<url>http://repository.springsource.com/maven/bundles/release/</url>
As for hibernate-validator, being a beta release, it is possibly not available in the normal repos. It is available from
<url>http://repository.jboss.org/nexus/content/groups/public-jboss/</url>
The version of maven used in m2eclipse can be found in Window->Preferences->Maven->Installations
It looks like the artifact cann't be found in any repository you have defined in your settings.xml or pom file. Try adding sonatype repositories, they have artifacts you're looking for
In your pom.xml , add :
<project>
...
<repositories>
<repository>
<id>sonatype repo</id>
<url>https://repository.sonatype.org/content/repositories/central</url>
</repository>
</repositories>
...
</project>
However it's good practice to have its own repository manager (nexus, archiva, ...)
You should add the "external" repository to your pom.xml:
<repository>
<id>com.springsource.repository.bundles.external</id>
<url>http://repository.springsource.com/maven/bundles/external</url>
</repository>
My complete repositories tag in pom.xml is as follows:
<repositories>
<repository>
<id>com.springsource.repository.maven.release</id>
<url>http://repo.springsource.org/release/</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>com.springsource.repository.bundles.release</id>
<url>http://repository.springsource.com/maven/bundles/release</url>
</repository>
<repository>
<id>com.springsource.repository.bundles.external</id>
<url>http://repository.springsource.com/maven/bundles/external</url>
</repository>
</repositories>

java.net maven repo - JMS artifact missing

I just created a new Maven project using the default archetype and added the following dependency to my POM file.
<dependencies>
<dependency>
<groupId>javax.jms</groupId>
<artifactId>jms</artifactId>
<version>1.1</version>
<scope>compile</scope>
</dependency>
</dependencies>
Realizing that the Sun's JARs are not on Maven central due to licensing issues, I added
the following Maven repo to my POM (I know this is bad practice though and that it needs to be added to a settings.xml)
<repositories>
<repository>
<id>Repo ID</id>
<layout>default</layout>
<name>Java.net Maven repo</name>
<releases>
<enabled>true</enabled>
</releases>
<url>http://download.java.net/maven/2/</url>
</repository>
</repositories>
I still see this error in my POM file.
"Missing artifact javax.jms:jms:jar:1.1:compile"
Does anyone here know what else needs to be done in addition to the config I already have?
Realizing that the Sun's JARs are not on Maven central due to licensing issues, I added
the following Maven repo to my POM
Yeah, but http://download.java.net/maven/2/javax/ doesn't have the jms artifact...
The good news is that the JBoss Nexus repository does have it:
<repository>
<id>repository.jboss.org-public</id>
<name>JBoss repository</name>
<url>https://repository.jboss.org/nexus/content/groups/public</url>
</repository>
If you just want the jms artifact and don't want to add the whole repo, you can do the following:
wget https://repository.jboss.org/nexus/content/groups/public/javax/jms/jms/1.1/jms-1.1.jar
mvn -e install:install-file -Dfile=./jms-1.1.jar -DartifactId=jms -DgroupId=javax.jms -Dversion=1.1 -Dpackaging=jar
In fact the real solution for this issue is to use the jms-api-1.1-rev-1.jar artifact available on Maven Central : http://search.maven.org/#artifactdetails%7Cjavax.jms%7Cjms-api%7C1.1-rev-1%7Cjar