0

I am developing a Web Service, built on Java 8. I am trying to determine how to overcome a common Maven error, but with a slight twist. Running the mvn install goal works perfectly, without any errors. My web service successfully builds and runs. It is only when trying to perform the site:deploy goal that I run into issues.

I have narrowed down the issue to the JMS 2.0 simplified API. Or more accurately, there is an issue where the streams-aq dependency I am using is not aware of the newer simplified API that was released with JMS 2.0 back in 2013. At least that is what appears to be happening. There is also a potential issue with the version of Spring being used. Regardless, the Spring / JMS dependencies that are imported are not aware of the JMS Context object.

When I try to create a Context object in code there isn't a problem running it. Yet when Maven's site-deploy attempts to compile the underlying dependencies (to build all of the JavaDocs used in the site documentation), I get the following error message:

[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /C:/{path}/src/main/java/org/name/config/JmsConfigurationComp.java:[75,46] cannot find symbol
  symbol:   method createContext()
  location: interface javax.jms.ConnectionFactory
[INFO] 1 error
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 40.037 s
[INFO] Finished at: 2019-09-16T19:31:17-06:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-site-plugin:3.7.1:site (default-site) on project testProject: failed to get report for org.apache.maven.plugins:maven-javadoc-plugin: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project testProject: Compilation failure
[ERROR] /C:/{path}/src/main/java/org/name/config/JmsConfigurationComp.java:[75,46] cannot find symbol
[ERROR]   symbol:   method createContext()
[ERROR]   location: interface javax.jms.ConnectionFactory
[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

QUESTION: There should be a way to exclude just the javax.jms.ConnectionFactory class, so that Maven does not try to compile it. I do not need the ConnectionFactory in my JavaDocs. I really don't need any of the JMS API docs in my documentation.

Since the code runs flawlessly, it seems ridiculous to be blocked simply by Maven's inability to build JavaDocs for an external class for which it cannot resolve! Especially when it is a valid method that the Java compiler has no trouble finding! ;-)

I have tried a number of exclude commands in my POM file, but none of them seem to have worked. I don't want to risk swaying any of you fine engineers from offering a solution that you think I have already tried, so I won't waste space here with a list of POM code blocks. If you have ran into an issue similar to this, please take a moment and give any suggestions or examples that worked for you.

Michael M
  • 1,303
  • 1
  • 12
  • 12
  • You seemed to be misunderstanding the error message cause the class `JmsConfigurationComp.java` can't be compiled you are missing a dependency ...Furthermore I have my doubts that code which can't be compiled runs in any way... – khmarbaise Sep 18 '19 at 18:39
  • @khmarbaise : You are absolutely correct. I was trying to exclude the class that Maven could not find, instead of determining why it couldn't find it in the first place. And until I did that, it would not compile. I was trying to attack the symptom instead of resolving the underlying problem. Thank you for that insight. – Michael M Sep 18 '19 at 20:23

1 Answers1

0

I resolved the issue. After reading through this excellent article that identifies an extensive list of causes that would result in the ("Cannot find symbol" compilation error) thrown by Maven, I realized that my attempts to exclude the unlocatable class was not the solution. @khmarbaise communicated a similar sentiment.

I resolved the compilation issue by explicitly defining version 2.0 of the JMS API as a Maven dependency in my project POM file. Previously only JMS 1.1 was resolving.

I erroneously stated that it was there already, but because version 1.1 was being inherited from an internal project that included streams-aq (and subsequently JMS), only version 1.1 of the JMS API was available.

Once JMS version 2.0 was properly defined, Maven was able to find the missing JMS 2.0 methods, and successfully compile the sources into the JavaDocs for the service. It had also been misleading because the Java code had no problem locating the methods in question.

Michael M
  • 1,303
  • 1
  • 12
  • 12