This week's book giveaway is in the Functional programming forum.
We're giving away four copies of A Functional Approach to Java: Augmenting Object-Oriented Java Code with Functional Principles and have Ben Weidig on-line!
See this thread for details.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Junilu Lacar
  • Tim Cooke
Saloon Keepers:
  • Carey Brown
  • Stephan van Hulst
  • Tim Holloway
  • Peter Rooke
  • Himai Minh
Bartenders:
  • Piet Souris
  • Mikalai Zaikin

maven cannot find symbol class EJBClientResult

 
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My codes has these compile errors:

when running



The missing EJBClientResult class is in the mypack.common-2021.03.jar file.

Another similar project which use the same jar file compile successfully.
 
so the same jar file is present in my maven local repository and maven is setup properly.

To debug, run


proj1-parent output:
 

proj2-parent output:



Both projects have the same dependency in the pom.xml:



How to fix this compile error?
Please help.
Thanks.
 
Saloon Keeper
Posts: 26891
192
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Did you do a "mvn install"?

The compile goal only compiles classes into the project's target directory. If you want to build and use a library JAR (including an EJB JAR) as a Maven dependency in another POM, you need to use the "install" goal to build the JAR and publish it to your local Maven repository.
 
A Kao
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tim Holloway wrote:Did you do a "mvn install"?

The compile goal only compiles classes into the project's target directory. If you want to build and use a library JAR (including an EJB JAR) as a Maven dependency in another POM, you need to use the "install" goal to build the JAR and publish it to your local Maven repository.



Yes, I did a "mvn install" for both projects.
Both projects used the same jar to compile, one project found it in my maven local repository but the other project did not find it.
 
Tim Holloway
Saloon Keeper
Posts: 26891
192
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In that case, I'd look at the POM for the failing project. Likely you either mis-spelled the dependency or you're referencing a version that you have not installed. Remember, Maven doesn't simply save a single instance of a JAR - it caches a separate instance for each version you install to the repository and you use that version number to ensure you got the right version for the project that depends on it.
 
A Kao
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tim Holloway wrote:In that case, I'd look at the POM for the failing project. Likely you either mis-spelled the dependency or you're referencing a version that you have not installed. Remember, Maven doesn't simply save a single instance of a JAR - it caches a separate instance for each version you install to the repository and you use that version number to ensure you got the right version for the project that depends on it.


I looked at the POM for the failing project several times.
I used Beyond Compare to compare the POM for the failing project and successful project.
They are the same.
The compile output of the failing project did not have
[DEBUG] Adding URL [file:/C:/Users/ak/.m2/repository/com/mypack/mypack.common/2021.03/mypack.common-2021.03.jar]
Is that an issue?
 
Tim Holloway
Saloon Keeper
Posts: 26891
192
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Maven does not normally list the dependencies pulled in when it compiles. In fact, I don't even know how to get it to do so.

However, the "dependency:list" goal should be able to show you what Maven should be looking for (there are IDE viewers that can also do this).
reply
    Bookmark Topic Watch Topic
  • New Topic