maven project run successfully but cann't build - java

I have a Maven projects and i want to build a project with Maven to create excutable JAR
I can run the project successfully but
when i run Maven build... in eclipse with the command clean package i get(this is just a sample of the log but the rest of the log just repeat the same type of errors)
[INFO] Compiling 6 source files to C:\StrockMarketAnalyzer\USB\master\integ\target\classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] C:\xxx\xxx\xxx\xxx-parent\xxx- integ\src\main\java\com/xxx/xxx/xxx\communicationInterface\IbfAdministrator.java:[22,48] error: package com.xxx/xxx/xxx.businessObject does not exist
[ERROR] C:\xxx\xxx\xxx-parent\xxx-integ\src\main\java\com\xxx\xxx\xxx\xxx\communicationInterface\IbfAdministrator.java:[23,48] error: package com.xxx.xxx.xxx.xxx.businessObject does not exist
and this is the pom.xml of the project i want to build.
<parent>
<groupId>com.xxx.xxx.xxx.xxx</groupId>
<artifactId>parent</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>integ</artifactId>
I am using packages from other projects that i created when i look to the JAR's in Maven dependency i can find the other projects with a folder icone and Inside them i can find there dependency but not there packages.
I hope there're enough information for you to know what's the problem

Try to run the parent project (with the same conf.)not the project it self.

Right klik project --> update project, wait for the Workbench to build then build using maven. This is a stopgap and not a permanent solution which i myself have not found yet.

You probably "run" the previous version of a program, without building it new.
You must write the dependencies and (their) repositories you use in pom.xml, the parent tag is strange to me.
Also, if you have dependency to another project you r working on clean and build it first.

Related

How can I use classes from other project with maven? (ClassNotFoundException and NoClassDefFoundError is thrown)

I have two Vaadin projects (I will name them A and B). Both are using Maven for resolving the dependencies and are in the same workspace. I'm working with Eclipse and I'm using the m2e-plugin. I want to use some classes of B in project A. In Eclipse I can instatiate them without errors/warnings but when I try to run A I get a ClassNotFoundException and a NoClassDefFoundError caused by instatiating a class of B.
The .class files of A are located in ...\workspace\A\target\classes and the for project B they are in ...\workspace\B\target\classes.
I've been trying to solve this problem but I didn't find a solution.
What I tried so far:
Configure build path -> Libaries -> add Class Folder -> B\target
Configure build path -> Libaries -> add External Class Folder -> B\target
Configure build path -> Projects -> add -> B
I think adding the project is necessary because when I remove it, Eclipse gives me error messages when I try to use the classes from B in A
I don't have any idea what else to do. Maybe I have to configure my pom.xml file but I don't know what I must do there.
Edit:
In pom.xml of project B:
<groupId>de.qufis</groupId>
<artifactId>CentwertApp</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>CentwertApp</name>
In pom.xml of project A:
<dependency>
<groupId>de.qufis</groupId>
<artifactId>CentwertApp</artifactId>
<version>0.0.1-SNAPSHOT</version>
<type>war</type>
<scope>import</scope>
</dependency>
I did clean compile for project B with maven build.
Then I tried to do the same with project A but then I get error message:
Could not find artifact de.qufis:CentwertApp:war:0.0.1-SNAPSHOT in vaadin-addons (http://maven.vaadin.com/vaadin-addons)
When I run the Application normally I still get the ClassNotFoundException and NoClassDefError.
Edit 2:
I have added
<scope>compile</scope>
When I run Maven build (clean compile), part of my building process looks like this:
[INFO] Building centwertAdmin 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[WARNING] The POM for de.qufis:CentwertApp:war:0.0.1-SNAPSHOT is missing, no dependency information available
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
Then there is the errormessage:
[ERROR] Failed to execute goal on project centwertAdmin: Could not resolve dependencies for project de.qufis:centwertAdmin:war:0.0.1-SNAPSHOT: Failure to find de.qufis:CentwertApp:war:0.0.1-SNAPSHOT in http://maven.vaadin.com/vaadin-addons was cached in the local repository, resolution will not be reattempted until the update interval of vaadin-addons has elapsed or updates are forced -> [Help 1]
can u try to remove <packaging>war</packaging> from B? Maven's default packaging is jar, and this is what you need for B.
Plus, add B to the dependencies of A.
Build B project. use mvn clean install, that would install B's
JAR+POM in your local repository (.m2).
Verify it is there... Then
Maven will be able to find it, so you will not get the error "Could
not find artifact de.qufis:CentwertApp"
Build A.
Usually, dependencies are of type JAR. If B must be a WAR, see this.

Jenkins: Maven project with modules that won't be build: no pom.xml found

I've got 3 maven projects.
Project A defines B and C as module in it's pom.xml
Now I want to use Jenkins.
I defined to checkout/build project A and I think I have to manually checkout/build B and C as well, right?
The project didn't find the pom.xml of the other projects.
I defined them with relative path.
It works fine on my local machine, but it crashes on Jenkins:
org.apache.maven.project.ProjectBuildingException: Some problems were encountered while processing the POMs:
[FATAL] Non-resolvable parent POM: Failure to find de.saenger:xyz:pom:1.0.0-SNAPSHOT
Now ... how to let the projects knowing each other?
Run mvn build on parent pom. It will build modules automatically.
You're running mvn build on module and mvn searches your local repository for parent pom to resolve dependencies but can't find the pom because you haven't built it yet.

Maven- Error building pom

While trying mvn clean install I got the following error:
[INFO] Error building POM (may not be this project's POM).
Project ID: org.codehaus.plexus:plexus-components:pom:1.1.15
Reason: Cannot find parent: org.codehaus.plexus:plexus for project: org.codehaus.plexus:plexus-components:pom:1.1.15 for project org.codehaus.plexus:plexus-components:pom:1.1.15
The same works when I user mvn clean install as root user. What may be the possible reason?
Follow these steps:-
Update maven to version 3.
Deleted the .m2/org/codehaus folder.
Build the project.
Issue fixed!

Creating a Maven Artifact from (Eclipse) Project, and Generating New Project from it

I have an Maven (eclipse) Project, which i want to convert to an Maven Artifact - so that others can generate new Project from it.
To create Artifact i did:
cd to my proj dir where pom.xml exists
mvn install
After this i can see that
.m2\repository has my project added.
But <user_home>\.m2\archetype-catalog.xml - did not have the archetype added.
So, i added manually as follows:
<archetype>
<groupId>com.whatever</groupId>
<artifactId>myapp</artifactId>
<version>1.0.0-BUILD-SNAPSHOT</version>
<repository></repository>
</archetype>
Now, i am not sure what to give in tag, as this is a local repository.
But, i am unable to generate a new project using:
mvn archetype:generate -DarchetypeCatalog=local
It asks me to choose the archetype, but after that i get error:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-archetype-plugin:2
.2:generate (default-cli) on project standalone-pom: The desired archetype does
not exist (com.whatever:myapp:1.0.0-BUILD-SNAPSHOT) -> [Help 1]
What step am i missing?
You need to run the archetype plugin from within your original project to generate an archetype descriptor.
Here is an example of how to do this.
The complete steps are listed here:
http://hello-its-crazy.blogspot.in/2012/08/steps-to-create-maven-archetype-from.html

Non-resolvable parent POM: Could not find artifact

I have recently looked into Gorilla Logic's open source testing tool and need to make some changes in order to be able to log something to the console. I have checked out the code out of source control for the "Android Agent" and now I am looking to build a new .jar agent file. I need to use the
mvn clean install to build the .jar file. When I try to build it the command line is giving this error
Non-resolvable parent POM: Could not find artifact com.gorillalogic.monkeytalk:monkeytalk:pom:1.0.12-SNAPSHOT and 'parent.relativePath' points at wrong local POM # line 6, column 10 -> [Help 2]
Can anyone help me with this or let me know what this means? Thanks. :)
I don't understand maven and just want to know what it means.
Here is the pom.xml file line 6-10
<parent>
<groupId>com.gorillalogic.monkeytalk</groupId>
<artifactId>monkeytalk</artifactId>
<version>1.0.12-SNAPSHOT</version>
<relativePath>/Users/henry/Desktop/monkeytalk-agent-android/parent/pom.xml</relativePath>
</parent>
This project seems to be module project under another maven project "moneytalk".
As this project can inherit properties, dependency management information, plugin information from the parent project, maven tries to read the parent pom.xml.
If the parent pom.xml is not available at the specified location, maven build will fail.
One option is to checkout all the projects including the parent project.
Other option is to place the pom.xml of the parent project at the required location (in your case /Users/henry/Desktop/monkeytalk-agent-android/parent/pom.xml
If there are lots of dependencies behind the project, they have to be pattered for first before building the main project.
Clean, compile and install such dependencies (from the "Maven" pane found on the right side of the IDE). First move such dependencies enclosed within their projects to the same main project directory.
Lastly, clean, compile and install the main project.

Categories