Hibernate Project + maven 3 + Jetty 9.3 Web Server – My study Notes

  1. Create Simple Project – using eclipse IDE.
  2. At Command Prompt , run the maven script to create example Dynamic Web Project:
  • mvn archetype:generate -DgroupId=com.fndong -DartifactId=JettyHibernate -DarchetypeArtifactId=maven-archetype-webapp -DinteractiveMode=false

hibertnate.png

3. Then, import project to your Eclipse IDE , using “Existing Maven Projects” .Setting up and fix if its have an errors.

4. add the jetty Maven Plugin add inside pom.xml , so i can use jetty web server for running my simple application.

<!– https://mvnrepository.com/artifact/org.eclipse.jetty/jetty-maven-plugin –>
<dependency>
    <groupId>org.eclipse.jetty</groupId>
    <artifactId>jetty-maven-plugin</artifactId>
    <version>9.3.10.v20160621</version>
</dependency>

4.2. And also servlet

<!– Servlet Library –>
<dependency>
   <groupId>javax.servlet</groupId>
   <artifactId>javax.servlet-api</artifactId>
   <version>3.1.0</version>
   <scope>provided</scope>
</dependency>

5. pom.xml

<project xmlns=”http://maven.apache.org/POM/4.0.0&#8243; xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance&#8221;
  xsi:schemaLocation=”http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd”&gt;
  <modelVersion>4.0.0</modelVersion>
 <groupId>com.fndong</groupId>
  <artifactId>JettyHibernate</artifactId>
  <packaging>war</packaging>
  <version>1.0-SNAPSHOT</version>
  <name>HibernateJetty Maven Webapp</name>
  <url>http://maven.apache.org</url&gt;
  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
    <!– https://mvnrepository.com/artifact/org.eclipse.jetty/jetty-maven-plugin –>
<dependency>
    <groupId>org.eclipse.jetty</groupId>
    <artifactId>jetty-maven-plugin</artifactId>
    <version>9.3.10.v20160621</version>
</dependency>
  </dependencies>
   <build>
        <finalName>JettyHibernate</finalName>
        <plugins>
             
            <!– http://mvnrepository.com/artifact/org.eclipse.jetty/jetty-maven-plugin –>
            <plugin>
                <groupId>org.eclipse.jetty</groupId>
                <artifactId>jetty-maven-plugin</artifactId>
                <version>9.3.10.v20160621</version>
                 
                <configuration>
                    <scanIntervalSeconds>10</scanIntervalSeconds>
                    <webApp>
                        <contextPath>/JettyHibernate</contextPath>
                    </webApp>
                </configuration>
                 
            </plugin>
        </plugins>
    </build>
</project>

6. Run Configurations… at eclipse IDE.

 

7. Add New Maven Build for Jetty running program.

mavenbuild

  • Apply and Run

jettyrun.jpg

8. Errors after running the command:

Exception in thread “main” java.util.ServiceConfigurationError: org.apache.juli.logging.Log: Provider org.eclipse.jetty.apache.jsp.JuliLog not a subtype
    at java.util.ServiceLoader.fail(ServiceLoader.java:239)

9. If you guys read that error, can you guys help me to solve it. why jetty command in run configuration Eclipse IDE does not run.

10. I’ll continue using command prompt to run it.

  • Run command jetty : mvn package jetty:run

serverstarted.jpg

 11. Output my web in browser – http://localhost:8080/JettyHibernate/:

successhelloworld.jpg

12. Maybe my eclipse setting have problem, my command prompt work fine.

13. I’ll Ignore with jetty run on eclipse , I just using directly run on command prompt – mvn package jetty:run.

14. Continue integrate with Facade Design Pattern + Hibernate ORM + mysql