title: Spring Web App with Maven dependency - class not found during deploy
body: <p>I'm having project named car-rental which contains business logic (built with maven). I use this project as dependency in other project named car-rental. It's declared as :</p>
  
  <pre><code>    &lt;dependency&gt;
          &lt;groupId&gt;com.car.rental&lt;/groupId&gt;
          &lt;artifactId&gt;car-rental-model&lt;/artifactId&gt;
          &lt;version&gt;1.0&lt;/version&gt;
      &lt;/dependency&gt;
  </code></pre>
  
  <p>During compilation in IDE Eclipse car-rental see all classes from dependency. But after deploy to Java EE container (for example GlassFish) classes aren't seen. Deployed project in server doesn't contain dependency classes.</p>
  
  <p>car-rental project doesn't contains any specific build definitions:</p>
  
  <pre><code>&lt;build&gt;
      &lt;plugins&gt;
          &lt;plugin&gt;
              &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
              &lt;artifactId&gt;maven-war-plugin&lt;/artifactId&gt;
              &lt;version&gt;2.2&lt;/version&gt;
              &lt;configuration&gt;
                  &lt;archive&gt;
                      &lt;manifest&gt;
                          &lt;addClasspath&gt;true&lt;/addClasspath&gt;
                      &lt;/manifest&gt;
                  &lt;/archive&gt;
              &lt;/configuration&gt;
          &lt;/plugin&gt;
          &lt;plugin&gt;
              &lt;artifactId&gt;maven-assembly-plugin&lt;/artifactId&gt;
              &lt;version&gt;2.2.2&lt;/version&gt;
              &lt;configuration&gt;
                  &lt;descriptorRefs&gt;
                      &lt;descriptorRef&gt;jar-with-dependencies&lt;/descriptorRef&gt;
                  &lt;/descriptorRefs&gt;
              &lt;/configuration&gt;
          &lt;/plugin&gt;
      &lt;/plugins&gt;
  &lt;/build&gt;
  </code></pre>
  
  <p>After maven packaging, car-rental-1.0 in target directory, contains required classes from business dependency.</p>
  
  <p>Here's my car-rental project structure:</p>
  
  <p><img src="https://i.stack.imgur.com/gzrkx.png" alt="enter image description here"></p>
  
  <p>Probably I should somehow link business dependency in pom.xml file, but I have no idea how... Or maybe I thining wrong?</p>
  
  <hr>
  
  <p>UPDATE</p>
  
  <p>car-rental-model is packaged as *.jar file</p>
  
  <pre><code>&lt;groupId&gt;com.car.rental&lt;/groupId&gt;
  &lt;artifactId&gt;car-rental-model&lt;/artifactId&gt;
  &lt;version&gt;1.0&lt;/version&gt;
  &lt;packaging&gt;jar&lt;/packaging&gt;
  &lt;name&gt;car-rental-model&lt;/name&gt;
  </code></pre>
  
  <p>car-rental is packaged as *.war file</p>
  
  <pre><code>&lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
  &lt;groupId&gt;com.car.rental&lt;/groupId&gt;
  &lt;artifactId&gt;car-rental&lt;/artifactId&gt;
  &lt;version&gt;1.0&lt;/version&gt;
  &lt;packaging&gt;war&lt;/packaging&gt;
  </code></pre>
  
  <hr>
  
  <p>UPDATE 2</p>
  
  <p>To give more info about project I put configuration files:</p>
  
  <p>web.xml:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
    &lt;web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
        xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
        id="CarRental" version="2.5"&gt;
        &lt;display-name&gt;CarRental&lt;/display-name&gt;
        &lt;context-param&gt;
            &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;
            &lt;param-value&gt;/WEB-INF/dispatcher-servlet.xml&lt;/param-value&gt;
        &lt;/context-param&gt;
        &lt;context-param&gt;
            &lt;param-name&gt;log4jConfigLocation&lt;/param-name&gt;
            &lt;param-value&gt;/WEB-INF/configs/log4j.properties&lt;/param-value&gt;
        &lt;/context-param&gt;
        &lt;context-param&gt;
            &lt;param-name&gt;log4jRefreshInterval&lt;/param-name&gt;
            &lt;param-value&gt;1000&lt;/param-value&gt;
        &lt;/context-param&gt;
        &lt;listener&gt;
            &lt;listener-class&gt;org.springframework.web.context.ContextLoaderListener&lt;/listener-class&gt;
        &lt;/listener&gt;
        &lt;listener&gt;
            &lt;listener-class&gt;org.springframework.web.util.Log4jConfigListener&lt;/listener-class&gt;
        &lt;/listener&gt;
        &lt;filter&gt;
            &lt;filter-name&gt;encodingFilter&lt;/filter-name&gt;
            &lt;filter-class&gt;org.springframework.web.filter.CharacterEncodingFilter&lt;/filter-class&gt;
            &lt;init-param&gt;
                &lt;param-name&gt;encoding&lt;/param-name&gt;
                &lt;param-value&gt;UTF-8&lt;/param-value&gt;
            &lt;/init-param&gt;
            &lt;init-param&gt;
                &lt;param-name&gt;forceEncoding&lt;/param-name&gt;
                &lt;param-value&gt;true&lt;/param-value&gt;
            &lt;/init-param&gt;
        &lt;/filter&gt;
        &lt;filter-mapping&gt;
            &lt;filter-name&gt;encodingFilter&lt;/filter-name&gt;
            &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
        &lt;/filter-mapping&gt;
        &lt;servlet&gt;
            &lt;servlet-name&gt;dispatcher&lt;/servlet-name&gt;
            &lt;servlet-class&gt;org.springframework.web.servlet.DispatcherServlet&lt;/servlet-class&gt;
            &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
        &lt;/servlet&gt;
        &lt;servlet-mapping&gt;
            &lt;servlet-name&gt;dispatcher&lt;/servlet-name&gt;
            &lt;url-pattern&gt;*.htm&lt;/url-pattern&gt;
        &lt;/servlet-mapping&gt;
        &lt;welcome-file-list&gt;
            &lt;welcome-file&gt;redirect.jsp&lt;/welcome-file&gt;
        &lt;/welcome-file-list&gt;
    &lt;/web-app&gt;
  </code></pre>
  
  <p>dispatcher-servlet.xml contains only references to other configuration files, which stores only configurations to Tiles, controllers or DAO implementations - it's rather not important to place here... maybe except Hibernate mapping:</p>
  
  <pre><code>&lt;bean id="sessionFactory"
      class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"&gt;
      &lt;property name="dataSource" ref="dataSource" /&gt;
      &lt;property name="hibernateProperties"&gt;
          &lt;value&gt;
              hibernate.dialect=org.hibernate.dialect.H2Dialect
              hibernate.hbm2ddl.auto=create
              hibernate.ejb.naming_strategy=org.hibernate.cfg.ImprovedNamingStrategy
              hibernate.connection.charSet=UTF-8
              hibernate.bytecode.provider=javassist
              hibernate.show_sql=true
              hibernate.format_sql=true
          &lt;/value&gt;
      &lt;/property&gt;
      &lt;property name="annotatedClasses"&gt;
          &lt;list&gt;
              &lt;value&gt;com.car.rental.model.Car&lt;/value&gt;
              &lt;value&gt;com.car.rental.model.User&lt;/value&gt;
          &lt;/list&gt;
      &lt;/property&gt;
  &lt;/bean&gt;
  </code></pre>