Compilation error/issues while executing maven install - java

I have a maven project and try to do a maven install.While performing the maven install, Im getting the below error.
[INFO] Compiling 403 source files to D:\\iTT_Backend\itt\target\classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /D:/iTT_Backend/itt/src/main/java/com/iowe/bean/Project.java:[5,27]
package com.cx.util does not exist
[ERROR]
/D:/iTT_Backend/itt/src/main/java/com/itt/controller/ScanController.java:
[21,39] package com.cx.business.to.scan does not exist
Above is the error Im getting while trying to do a clean install.The specified package in the above error message package com.cx.util is available as part of the itt.jar. That jar has been added as a dependency to this project. I dont see any errors in eclipse. Only while trying to do install, Im getting the above compilation error.
Analysis Done
Below are the analysis done
Checked for the dependency and the jar is available as part of dependency in pom.xml file.
The application does not show any dependency error in eclipse. Its able to navigate to the corresponding method in the jar file.The issue occurs while executing mvn install command.
Tried executing mvn install via command prompt. Still getting the same error as above.
Have renamed the .m2 repository folder to old repository and re executed the mvn install command. same issue exists.
Need help in getting the above issue resolved.
Any help on this is much appreciated. Thanks in Advance.

Remove from .m2 local repository and execute command mvn clean install
Try to remove and add again dependency in Pom.xml

Related

Goal not executed during clean lifecycle

I developed a maven plugin to install the missing jars that cannot be found in central repository but can be found in local file system,i attach the goal to pre-clean phase and when i execute command "mvn clean compile", the plugin is not executed, instead i got the following error:
i suppose the missing jar in the error is installed firstly and then compile phase is executed. However, the error indicates dependency should be resolved firstly.
PS:
here is the config of my plugin in pom.xml:

What does "[ERROR] file doesn't exist" means when doing maven install?

When I execute maven install in my gitlab build, I get the following error message:
12338 [INFO] Installing com.mycompany:myartifact:1.0.0-SNAPSHOT at end
12338 [INFO] 12338 [INFO] --- maven-bundle-plugin:3.3.0:install
(default-install) # myartifact --- 12411 [ERROR] file doesn't exist:
file:/root/.m2/repository/com/mycompany/myartifact/1.0.0-SNAPSHOT/myartifact-1.0.0-SNAPSHOT.jar
I don't understand what does it mean. The file obviously doesn't exist because it was never installed in that environment, so it's strange that maven would complain about it.
I suppose this error hides some other error, like no write rights? But I see not other error in log. The build seems to be successful.
Try to make a clean install, maybe it's just a local repository issue
mvn clean install
When you do maven install, It usually looks into your .m2 folder and searches for the existence of the dependencies(mentioned in pom.xml). If it doesn't exist, maven will automatically download it. So the build will be successful.

Jenkins build cannot find resources but maven does

I am trying to setup Jenkins to automate project builds and I ran to the following problem. mvn clean install works perfectly from cmd but project build from jenkins fails when maven-antrun-plugin is being used.
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-antrun-plugin:1.7:run
(clientgen) on project Sample:
An Ant BuildException has occured: Compile failed; see the compiler error output for
details.
[ERROR] around Ant part ...<javac fork="yes" memoryInitialSize="512m"
destdir="E:\Jenkins\workspace\Trunk Builds\Sample\target/generated-sources"
memoryMaximumSize="1024m" srcdir="E:\Jenkins\workspace\Trunk Builds\Sample\target/build"
source="1.4" classpathref="maven.plugin.classpath" executable="C:\j2sdk1.4.2_19/bin/javac"
target="1.4"/>... # 46:428 in
E:\Jenkins\workspace\Trunk Builds\Sample\target\antrun\build-main.xml
Jenkins is actually unable to check for the packages imported when I use maven-antrun-plugin.
[javac] E:/Jenkins/workspace/Trunk Builds/Sample/target/build/ClassSample.java:20:
package org.sample.package does not exist
Whenever I do not use maven-antrun-plugin Jenkin build succeeds. Any ideas why even though it works through cmd jenkins fail to build the project?
Actually I found the real problem and found a workaround. The problem is that Jenkins did not access .m2/repository for some reason so I configured Jenkins to use local to workspace repository. Now it builds normally.

maven project run successfully but cann't build

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.

Cannot get the branch information from the scm repository

I am getting following error in building the maven project. Any idea in solving this?
[ERROR] Failed to execute goal org.codehaus.mojo:buildnumber-maven-plugin:1.4:create (default) on project pwc-em: Cannot get the branch information from the scm repository :
[ERROR] Exception while executing SCM command. Error while executing command. Error while executing process. Cannot run program "git" (in directory "C:\Users\vmasama\Documents\workspace-sts-3.7.2.RELEASE\pwc-em"): CreateProcess error=2, The system cannot find the file specified
[ERROR] ->
I solved the same issue by updating my git version. But downgrading the version of the maven plugin to 1.13 will also solve this issue.
buildnumber-maven-plugin v1.4 works with git v2.9.2 but not with v1.9.*
buildnumber-maven-plugin v1.3 works with git v1.9.*

Categories