Previous: Setup Up: Prerequisites Next: Tutorial

Our application uses JPA as data-access-layer. We configure this in the web.xml (in src/main/webapp/WEB-INF/) by changing the following lines

    
      <param-value>/WEB-INF/applicationContext-jdbc.xml</param-value>
      <!--
      <param-value>/WEB-INF/applicationContext-hibernate.xml</param-value>
      <param-value>/WEB-INF/applicationContext-jpa.xml</param-value>
      -->
    
  

into

    
      <!--
      <param-value>/WEB-INF/applicationContext-jdbc.xml</param-value>
      <param-value>/WEB-INF/applicationContext-hibernate.xml</param-value>
      -->
      <param-value>/WEB-INF/applicationContext-jpa.xml</param-value>
    
  

We now have to delete the packages org.springframework.samples.petclinic.aspects, org.springframework.samples.petclinic.jdbc, org.springframework.samples.petclinic.hibernate and org.springframework.samples.petclinic.toplink as we want to use OpenJPA as persistence provider and don't have the other dependencies in our pom.

We don't need any load-time-weaving so we disable AspectJ in the file applicationContext-jpa.xml (in the folder src/main/webapp/WEB-INF/) by commenting out the following two lines (that are spread over the file):

    
    <context:load-time-weaver/>
    
  
    
    <bean class="org.springframework.samples.petclinic.aspects.UsageLogAspect" p:historySize="300"/>
    
  

like this

    
    <!--
    <context:load-time-weaver/>
    -->
    
  
    
    <!--
    <bean class="org.springframework.samples.petclinic.aspects.UsageLogAspect" p:historySize="300"/>
    -->
    
  

Additionally we have to configure Springs annotation support not to use aspectj by changing the following line

    
    <tx:annotation-driven mode="aspectj"/>
    
  

into

    
    <tx:annotation-driven/>
    
  

As mentioned above, we want to use OpenJPA as persistence provider. We enable it by changing the following lines in applicationContext-jpa.xml (in the folder src/main/webapp/WEB-INF/)

    
            <bean class="org.springframework.orm.jpa.vendor.TopLinkJpaVendorAdapter"
                  p:databasePlatform="${jpa.databasePlatform}" p:showSql="${jpa.showSql}"/>
            <!--
            <bean class="org.springframework.orm.jpa.vendor.OpenJpaVendorAdapter"
                  p:database="${jpa.database}" p:showSql="${jpa.showSql}"/>
            -->
    
  

into

    
            <!--
            <bean class="org.springframework.orm.jpa.vendor.TopLinkJpaVendorAdapter"
                  p:databasePlatform="${jpa.databasePlatform}" p:showSql="${jpa.showSql}"/>
            -->
            <bean class="org.springframework.orm.jpa.vendor.OpenJpaVendorAdapter"
                  p:database="${jpa.database}" p:showSql="${jpa.showSql}"/>
    
  

The last step to do is to configure our database connection. This can be done in the file jdbc.properties (in the folder src/main/resources). Please change the following line

    
jdbc.url=jdbc:hsqldb:hsql://localhost:9001
    
  

into

    
jdbc.url=jdbc:hsqldb:file:petclinic;shutdown=true
    
  

If we have done all this configuration we should be able to start an embedded jetty-server with maven running the petclinic-application:

mvn jetty:run
  

If everything works all right, jetty started successfully and you can visit the spring-petclinic sample-application here.


Previous: Setup Up: Prerequisites Next: Tutorial