• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

maven assembly and classpath issue

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear all,

I'm having an issue with the classpath and the zip file that maven creates after running mvn assembly:assembly

The issue is this:
I'm having a problem reading an XML file that I read and use it as a template. My xml file is under /src/main/resouces/ and it is called slmData.xml
when I run the package and do the automatic tests my classes read the file and modify the xml this file is within the jar file.
However, when I create the zip file that contains all the jar dependencies my classes are not able to read this xml file.
Do you know if there's any issue with the class path when doing the assembly? my xml is still within the same jar as generated with the mvn package step.

What my cresources contains


My class:


What the jar (after mvn package) contains


What my zip file (after assembly contiains)


The stack trace:


do you see any issue why it doesn't find anything?

Regards
 
author
Posts: 5856
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Did you check that the JAR gathered by assembly:assembly contains hte XML file?

Does XmlHelper.loadDocumentFromFile() read the file from the classpath? If it doesn't, then your code is not going to work. I suspect that within Maven the XML file was read from target/classes, and not from the JAR. You will have to change your code to load the XML file as a resource.
 
Juan Luis Prieto
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Peter,

I'm sure that it is taking the xml file from the classpath as a resource file as I run it with a separate program for testing purposes.

thanks

 
reply
    Bookmark Topic Watch Topic
  • New Topic