Mvn compile throwns an error related to ZipAndSendMail | Selenium Forum
M
Mahanthi Kanakamedala Posted on 28/01/2021

When we run "mvn compile" after setting up email configuration in the project, following error is observed. Unable to run the tests using mvn.

<projectr path>/hybrid/mail/ZipAndSendMail.java:[28,71] method references are not supported in -source 1.7(use -source 8 or higher to enable method references)

**However emails are successfully sent when ZipAndSendMail is run from eclipse

Please let me know, how to resolve this.

 


A
Ashish Thakur Replied on 30/01/2021

Please use jdk 8 and mention in maven that use source java 8

 

In maven compiler plugin-

<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>


M
Mahanthi Kanakamedala Replied on 31/01/2021

Thank You, Ashish! for the response. I have updated POM with above mentioned configuration.
mvn clean compile test  is working now. But when I run the command for emailing following issue is observed : mvn exec:java -Djava.version=1.8 -D"exec.mainClass"=" com.hoolva.hybrid.mail.ZipAndSendMail"


[INFO] Scanning for projects...
[INFO]
[INFO] -----------------< com.hoolva.hybrid:Automate_Hoolva >------------------
[INFO] Building Automate_Hoolva 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[WARNING] The artifact org.apache.commons:commons-io:jar:1.3.2 has been relocated to commons-io:commons-io:jar:1.3.2
[INFO]
[INFO] --- exec-maven-plugin:3.0.0:java (default-cli) @ Automate_Hoolva ---
[WARNING]
java.lang.ClassNotFoundException: com.hoolva.hybrid.mail.ZipAndSendMail
at java.net.URLClassLoader.findClass (URLClassLoader.java:382)
at java.lang.ClassLoader.loadClass (ClassLoader.java:418)
at java.lang.ClassLoader.loadClass (ClassLoader.java:351)
at org.codehaus.mojo.exec.ExecJavaMojo$1.run (ExecJavaMojo.java:246)
at java.lang.Thread.run (Thread.java:748)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.895 s
[INFO] Finished at: 2021-01-31T11:42:16+01:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:3.0.0:java (default-cli) on project Automate_Hoolva: An exception occured while executing the Java class. com.hoolva.hybrid.mail.ZipAndSendMail -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException


A
Ashish Thakur Replied on 02/02/2021

java.lang.ClassNotFoundException: com.hoolva.hybrid.mail.ZipAndSendMail

 

Its not able to find the ZipAndSendMail class at the given path.


M
Mahanthi Kanakamedala Replied on 10/02/2021

Thank you, the issue is resolved now. There was an extra space in the file path.


Related Posts