Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mvn building compilation error

I've imported a maven project to intellij IDEA. Dependencies were successfully resolved. But when running the

    sudo mvn install

from terminal it gives this error.

  [ERROR] BUILD FAILURE
  [INFO] ------------------------------------------------------------------------
  [INFO] Compilation failure

/media/Academic/Work/Project/InputAdapter/IDEAInputEventAdapter/testIn/org.wso2.event.adaptor.testIn/src/main/java/org/wso2/event/adaptor/testIn/TestInEventAdaptorFactory.java:[24,5] error: annotations are not supported in -source 1.3

(use -source 5 or higher to enable annotations)
/media/Academic/Work/Project/InputAdapter/IDEAInputEventAdapter/testIn/org.wso2.event.adaptor.testIn/src/main/java/org/wso2/event/adaptor/testIn/TestInEventAdaptorType.java:[40,5] error: annotations are not supported in -source 1.3

(use -source 5 or higher to enable annotations)
/media/Academic/Work/Project/InputAdapter/IDEAInputEventAdapter/testIn/org.wso2.event.adaptor.testIn/src/main/java/org/wso2/event/adaptor/testIn/TestInEventAdaptorType.java:[46,18] error: generics are not supported in -source 1.3

Earlier I've imported this project into eclipse also. Then running mvn install from eclipse it gave a diffrent type of error.

[ERROR] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Compilation failure

error: error reading /home/asiri/.m2/repository/com/hazelcast/hazelcast/3.0.1/hazelcast-3.0.1.jar; invalid LOC header (bad signature)
error: error reading /home/asiri/.m2/repository/org/eclipse/equinox/org.eclipse.equinox.http.helper/1.1.0.wso2v1/org.eclipse.equinox.http.helper-1.1.0.wso2v1.jar; zip file is empty
error: error reading /home/asiri/.m2/repository/org/apache/ws/commons/axiom/axiom-api/1.2.11/axiom-api-1.2.11.jar; invalid CEN header (bad signature)
error: error reading /home/asiri/.m2/repository/commons-io/commons-io/2.0/commons-io-2.0.jar; invalid LOC header (bad signature)
error: error reading /home/asiri/.m2/repository/org/wso2/carbon/org.wso2.carbon.user.core/4.2.0/org.wso2.carbon.user.core-4.2.0.jar; error in opening zip file
error: error reading /home/asiri/.m2/repository/org/apache/poi/poi-scratchpad/3.9/poi-scratchpad-3.9.jar; invalid LOC header (bad signature)
error: error reading /home/asiri/.m2/repository/org/apache/poi/poi/3.9/poi-3.9.jar; invalid LOC header (bad signature)
error: error reading /home/asiri/.m2/repository/commons-pool/commons-pool/1.5/commons-pool-1.5.jar; invalid LOC header (bad signature)
error: error reading /home/asiri/.m2/repository/org/apache/tomcat/tomcat-tribes/7.0.34/tomcat-tribes-7.0.34.jar; invalid LOC header (bad signature)
error: error reading /home/asiri/.m2/repository/org/apache/tomcat/tomcat-catalina/7.0.34/tomcat-catalina-7.0.34.jar; invalid CEN header (bad signature)
error: error reading /home/asiri/.m2/repository/org/wso2/carbon/org.wso2.carbon.authenticator.stub/4.2.0/org.wso2.carbon.authenticator.stub-4.2.0.jar; error in opening zip file
error: error reading /home/asiri/.m2/repository/com/google/code/gson/gson/2.1/gson-2.1.jar; invalid LOC header (bad signature)
error: error reading /home/asiri/.m2/repository/org/apache/httpcomponents/wso2/httpclient/4.1.1-wso2v1/httpclient-4.1.1-wso2v1.jar; error in opening zip file
error: error reading /home/asiri/.m2/repository/com/google/guava/guava/12.0/guava-12.0.jar; invalid CEN header (bad signature)

right after that running the

 sudo mvn install 

from the terminal could get build successful. I don't understand the reason for this behavior. If there's a way to resolve the error getting in the first part of the question it would really help.

like image 654
Asiri Liyana Arachchi Avatar asked Jul 20 '26 04:07

Asiri Liyana Arachchi


2 Answers

Please see Maven Compiler Plugin Documentation. Set the correct source and target levels. That should fix it.

like image 143
RaviH Avatar answered Jul 23 '26 00:07

RaviH


Sound like Your compiler plugin configuration is not complete

Your Jdk level should be greater than 1.5

example pom.xml configuration

<plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.1</version>
        <configuration>
            <source>1.7</source>
            <target>1.7</target>
        </configuration>
    </plugin>
like image 25
Alex Mathew Avatar answered Jul 23 '26 00:07

Alex Mathew



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!