Maven Install Cannot Find Packages - java

I'm trying to build an existing project using Maven on Eclipse. It uses a lot of jar files which I've downloaded years back.
Eclipse seem to recognize these jar files on build(no warnings/errors on editor) but when I do Run > Run As... > Clean Install, it shows a lot of compile errors(i.e. package org.apache.log4j does not exist, cannot find symbol)
It looks like Maven is not including may jar files on build. Any suggestion on how to include this in POM.XML? I tried playing with but does not seem to work.
Note: I've been doing this on ANT, I just include the jar folder in my build.xml and it gets picked up.
Failed Solution 1:
Tried downloading each of the missing jars via adding it on dependency(copy pasted from maven repo site). This seemed an impractical solution and also some of the jars are not on maven repo anymore.
Failed Solution 2:
Tried playing with localRepository but does not do anything.
Failed Solution 3:
Used Add Dependency interface on eclipse but nothing shows on the search reults.

Related

GWT maven build eclipse

I had a GWT app, and I wanted to automate its build and deploy system, since I do it manually. But I did not find a way how to build the app from command line, so it can than be automated. I had to click the Google button, then compile GWT project and then click Compile.
I found out that it is possible to create a GWT maven project and that it should then be possible to compile my project from commandline with mvn gwt:compile.
So I created a new project using this plugin. Copied my sources from the old project to this new one.
Now the structure is like this:
/src
---/main
------/java -> here are all my sources including my Project.gwt.xml file.
------/webapp
---/test
pom.xml
Now I have 2 problems.
1. I thought that I add dependencies to the pom.xml, and then when I build the app, it will create the jars and I can use those libraries in my GWT app. I guess 'mvn clean install' should do this, but so far I'm getting compile errors.
2. I did not get mvn clean install to work, so I added all the jars manually again... And then yes! I was able to build the app using the plugin GWT button! So I was thinking that now I can use 'mvn gwt:compile', but it fails with:
Unable to find: "com/company/project/Project.gwt.xml" on your classpath; could be a typo, or maybe you forgot to include a classpath entry for source?
EDIT:
So I fixed my <moduleName> element in pom.xml, so now it finds the Project.gwt.xml. I'm trying to run:
mvn clean install gwt:compile
But I am getting compile errors. I think, it tries to build my project without the actual dependecies because it tells few classes don't exist, but those classes are part of an external library. (specifically this one). But I have it in the dependencies, so I don't know what more to do.
<dependency>
<groupId>com.github.tdesjardins</groupId>
<artifactId>gwt-ol3</artifactId>
<version>3.0.0</version>
</dependency>
Also in eclipse I had to manually add the jars to my project, so that was why it worked there and not in the command line. So I would also like to ask how to tell eclipse to get those jars and include them to the project, because otherwise eclipse is missing those dependencies and displays many errors.
First I had a problem with <moduleName> in my pom.xml was missing com.company.project prefix before the actual module name.
Then I had errors in my Java files, which was caused by RELEASE version of GWT-OpenLayers 3 library missing some of the features that I previously used by building the JAR from the GitHub repository.

GWT maven project compiles and run from maven but don't compile and run in eclipse

I have multi module maven project, that is build with gwt as a main web framework. Here is github repo.
Everythink works as it should as I supose. I haven't got anything wrong.
Unfortunatelly the problems occur when I try to import this project into eclipse (as maven project). I can not compile this project (using RMB on project in Package Explorer -> Google -> GWT Compile).
I am getting an error:
Loading inherited module 'src.main.resources.pl.derp.parent'
Loading inherited module 'pl.derp.shared'
[ERROR] Unable to find 'pl/derp/shared.gwt.xml' on your classpath; could be a typo, or maybe you forgot to include a classpath entry for source?
When I tried to RMB on Project name in Package Explorer -> Run -> Run as Web application (GWT Super Dev Mode)
I've got:
Working directory does not exist: /home/danielo/eclipseGwt/gwt_2.7.0_maven_eclipse/web/src/main/webapp
I've added modules to build path.
I've followed this instruction
I think, that I've done everything to make it work, but still can make it work.
I think the problem is in packages name, and the way they are treated by maven and eclipse. They are treated in diferent ways.
Maven easily find every class (f.e.: package pl.derp.web;) needed and compile. The eclipse is trying to find them by f.e.: src.main.java.pl.derp.web but can't found it.
Really I don't know how to resolve this issue?
I am not sure witch package name patter is better (src.main.java.pl.derp.server or pl.derp.server)- for me the shorter is better.
To run this project in maven (it is well described here):
mvn clean install
mvn tomcat7:run-war-only
and in second shell:
mvn gwt:run -pl web
And in Eclipse I think I am running built in Jetty server
Please give me some help.
You apparently have a single Eclipse project, with server, shared, and web declared as source directories. When using M2Eclipse, you should have 3 projects, each with their src/{main,test}/{java,resources} declared as source directories. At a minimum, without M2Eclipse, the source directories must be the src/{main,test}/{java,resources}, whether you have 1 or 3 projects.
This is why Eclipse looks for src.main.java.pl.derp.server instead of pl.derp.server, and why GWT fails too (classpath is similarly wrong).

Maven missing classes

I created a basic maven project in eclipse and I'm getting errors in my pom.xml that classes are missing, I checked the folder that it was looking in and the file paths don't match what I have and the classes don't exist.. My path goes up to: C:\Users\user.m2\repository\org\apache\maven\shared and it is stating there is a /filtering/ folder which I don't have. I have the latest maven and m2eclipse installed.
Most probably a bad installations (incomplete download or missing jars). I suggest you delete the
C:\Users\user.m2\
folder completely and run mvn clean install again. Maven will fetch the jars for you. Also try to refresh the maven project from within eclipse. Right click on project -> maven -> update project. Sometimes eclipse has this issue.

Resolving dependencies in Eclipse for Fitnesse

My goal is to run unit tests in fitnesse.responders.run.slimResponder for testing my DataFlex SlimRunner implementation. So I downloaded the Fitnesse source code, and made it a new Java project in Eclipse. I was able to compile it by selecting Run As Ant Build (2) on the build.xml file. But in order to resolve include errors in the Problems view in Eclipse, I ended up manually adding dozens of external JARs by hand. I found that Maven/Ivy had apparently downloaded the jars as part of the Ant build. But somehow these were not added to the Java Build Path.
It seems reasonable to me to assume that there should be an easier way to set up the Java Build Path than to add the JAR files manually, since build.xml apparently contains all this information already. What am I missing?
The Fitnesse Readme.md mentions using Apache Ivy for dependency management. Download IvyDE from Eclipse Marketplace, and set it up (use the ivy.xml that is part of the Fitnesse source code).

JAR in project-specific local Maven repo, how to see library in Eclipse project?

I've been trying to add a custom .jar (ftp://ftp.ncbi.nlm.nih.gov/pub/eutils/soap/v2.0/java/axis2_1.5.2_jdk_6.0.12/eutils_axis2.jar) to a project that doesn't have a central corporate maven repository and that instead will have the custom JARs checked into SCM in the project directory tree. I was following this post to make it happen: Maven: add a dependency to a jar by relative path (awesome post btw).
What I did was:
Add local repository to pom.xml
install the file into the local repository
Add dependency to pom.xml
Based on what I see in m2eclipse, the library has been successfully recognized by Maven and added to the dependency list (or it'd be called ? : ? or something similar)
The problem is that Eclipse still doesn't see the referenced lib, so this still fails:
import gov.nih.nlm.ncbi.www.soap.eutils.*;
Pardon my maven newbiness, but what are changes / next steps I need to make to get to:
Have Eclipse see the library so that autocomplete works (and the import can be resolved)
Be able to compile the project
Be able to execute the jar produced by mvn package?
Thanks!
If you see the JAR under "Maven Dependencies" in your project, Eclipse should be able to see and use it. If it's not there, then m2eclipse wasn't able to resolve the dependency properly.
If it is missing, m2eclipse was unable to download the dependency from your local repository for some reason. Check the Maven 2 Console for errors and the Problem View.
Lastly, the JAR itself might be corrupt. Maven doesn't check for that, it simply adds the file to the classpath. If Eclipse can't open the JAR, you can also get the errors you mentioned.

Categories

Resources