I am looking for suggestion in putting image file maven web project. One of classes under src/main/java need to use an image file. My problem is, if i put image file under src/main/webapp/images as well as under src/main/resources/Images then application server cannot find that path on runtime(where myeclipse can ) because war archive do not have specified path "src/main/webapp/images".

My question is where should i put the image file that my project can find it without prompting any error or exception.

I am using

  • Java Web Application with Mavenized falvour
  • MyEclipse 10
  • Application Server: JBoss 6

Currently i do have following dir structure

Project Directory Structure

-src/main/java
      -- classes
  -src/main/resources
     -- applicationContext.xml
  -src/main/resources/Images
      -- myImage.png (target image)
  -src/test/java
      -- test classes
  -src/test/resources
       (nothing)

  -src
    -- main
        --- webapp
              --WEB-INF
                 ---faces-config.xml
                 ---web.xml
              --Images
                 --OtherImages
                 --myImage.png( second place for image)
              --Css
              --Meta-INF
              --login.jspx
              --jsfPageType1
                 --page1.jspx
              --jsfPageType2
                 --page2.jspx
  -target
  -pom.xml

And pom.xml's build snippet is as follows

<build>
    <sourceDirectory>${basedir}/src/main/java</sourceDirectory>
    <outputDirectory>${basedir}/target/${project.artifactId}/classes</outputDirectory>
    <resources>
      <resource>
        <directory>${basedir}/src/main/resources</directory>
        <excludes>
          <exclude>**/*.java</exclude>
        </excludes>
      </resource>
    </resources>
    &
Edit
Report