By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,913 Members | 1,379 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,913 IT Pros & Developers. It's quick & easy.

maven-scala-spring-jetty servlet not initialized

P: 1
I want to create a maven scala spring hibernate project **using ECLIPSE**. Im following this tutorial :
http://grahamhackingscala.blogspot.f...ebapp-how.html

Now I'm stuck in the 4th step : Start the Webapp with Maven using the Jetty Plugin. This is what the browser is displaying :

Expand|Select|Wrap|Line Numbers
  1.     HTTP ERROR 404
  2.  
  3.     Problem accessing /hello.html. Reason:
  4.  
  5.         Servlet Not Initialized
  6.  
  7.     Caused by:
  8.  
  9.     javax.servlet.UnavailableException: Servlet Not Initialized
  10.         at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:529)
  11.         at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:488)
  12.         at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:119)
  13.         at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:520)
  14.         at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:233)
  15.         at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:973)
  16.         at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:417)
  17.         at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:192)
  18.         at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:907)
  19.         at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:117)
  20.         at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:250)
  21.         at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:149)
  22.         at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:110)
  23.         at org.eclipse.jetty.server.Server.handle(Server.java:346)
  24.         at org.eclipse.jetty.server.HttpConnection.handleRequest(HttpConnection.java:442)
  25.         at org.eclipse.jetty.server.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:924)
  26.         at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:582)
  27.         at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:218)
  28.         at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:51)
  29.         at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:586)
  30.         at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:44)
  31.         at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:598)
  32.         at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:533)
  33.         at java.lang.Thread.run(Thread.java:722)
  34.  
  35. And this is the log im having during the initialisation :
  36.  
  37.     java.lang.ClassNotFoundException: org.springframework.web.servlet.DispatcherServlet
  38.         at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
  39.         at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
  40.         at java.security.AccessController.doPrivileged(Native Method)
  41.         at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
  42.         at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
  43.         at org.codehaus.classworlds.RealmClassLoader.loadClassDirect(RealmClassLoader.java:195)
  44.         at org.codehaus.classworlds.DefaultClassRealm.loadClass(DefaultClassRealm.java:255)
  45.         at org.codehaus.classworlds.DefaultClassRealm.loadClass(DefaultClassRealm.java:274)
  46.         at org.codehaus.classworlds.RealmClassLoader.loadClass(RealmClassLoader.java:214)
  47.         at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
  48.         at org.eclipse.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:424)
  49.         at org.eclipse.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:377)
  50.         at org.eclipse.jetty.util.Loader.loadClass(Loader.java:92)
  51.         at org.eclipse.jetty.util.Loader.loadClass(Loader.java:71)
  52.         at org.eclipse.jetty.servlet.Holder.doStart(Holder.java:92)
  53.         at org.eclipse.jetty.servlet.ServletHolder.doStart(ServletHolder.java:255)
  54.         at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:59)
  55.         at org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:779)
  56.         at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:255)
  57.         at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1212)
  58.         at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:610)
  59.         at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:453)
  60.         at org.mortbay.jetty.plugin.JettyWebAppContext.doStart(JettyWebAppContext.java:256)
  61.         at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:59)
  62.         at org.eclipse.jetty.server.handler.HandlerCollection.doStart(HandlerCollection.java:224)
  63.         at org.eclipse.jetty.server.handler.ContextHandlerCollection.doStart(ContextHandlerCollection.java:167)
  64.         at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:59)
  65.         at org.eclipse.jetty.server.handler.HandlerCollection.doStart(HandlerCollection.java:224)
  66.         at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:59)
  67.         at org.eclipse.jetty.server.handler.HandlerWrapper.doStart(HandlerWrapper.java:89)
  68.         at org.eclipse.jetty.server.Server.doStart(Server.java:262)
  69.         at org.mortbay.jetty.plugin.JettyServer.doStart(JettyServer.java:65)
  70.         at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:59)
  71.         at org.mortbay.jetty.plugin.AbstractJettyMojo.startJetty(AbstractJettyMojo.java:511)
  72.         at org.mortbay.jetty.plugin.AbstractJettyMojo.execute(AbstractJettyMojo.java:364)
  73.         at org.mortbay.jetty.plugin.JettyRunMojo.execute(JettyRunMojo.java:514)
  74.         at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:490)
  75.         at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:694)
  76.         at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeStandaloneGoal(DefaultLifecycleExecutor.java:569)
  77.         at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:539)
  78.         at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:387)
  79.         at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:348)
  80.         at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:180)
  81.         at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:328)
  82.         at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138)
  83.         at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
  84.         at org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:60)
  85.         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  86.         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
  87.         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  88.         at java.lang.reflect.Method.invoke(Method.java:601)
  89.         at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
  90.         at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
  91.         at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
  92.         at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
  93.  
  94.  
  95. first here s pom.xml:
  96.  
  97. <!-- language: xml -->
  98.  
  99.     <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  100.       xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  101.       <modelVersion>4.0.0</modelVersion>
  102.       <groupId>com.mycompany</groupId>
  103.       <artifactId>scala-spring-hibernate</artifactId>
  104.       <version>1.0-SNAPSHOT</version>
  105.       <inceptionYear>2008</inceptionYear>
  106.       <packaging>war</packaging>
  107.       <properties>
  108.         <scala.version>2.10.1</scala.version>
  109.         <org.springframework.version>3.0.0.RELEASE</org.springframework.version>
  110.       </properties>
  111.  
  112.       <repositories>
  113.  
  114.         <repository>
  115.           <id>scala-tools.org</id>
  116.           <name>Scala-Tools Maven2 Repository</name>
  117.           <url>http://scala-tools.org/repo-releases</url>
  118.         </repository>
  119.  
  120.         <repository>
  121.              <id>com.springsource.repository.bundles.release</id>
  122.              <name>EBR Spring Release Repository</name>
  123.              <url>http://repository.springsource.com/maven/bundles/release</url>
  124.         </repository>
  125.  
  126.         <repository>
  127.              <id>com.springsource.repository.bundles.external</id>
  128.              <name>EBR External Release Repository</name>
  129.              <url>http://repository.springsource.com/maven/bundles/external</url>
  130.         </repository>
  131.  
  132.       </repositories>
  133.  
  134.       <pluginRepositories>
  135.         <pluginRepository>
  136.           <id>scala-tools.org</id>
  137.           <name>Scala-Tools Maven2 Repository</name>
  138.           <url>http://scala-tools.org/repo-releases</url>
  139.         </pluginRepository>
  140.       </pluginRepositories>
  141.  
  142.       <dependencies>
  143.  
  144.         <dependency>
  145.           <groupId>org.scala-lang</groupId>
  146.           <artifactId>scala-library</artifactId>
  147.           <version>${scala.version}</version>
  148.         </dependency>
  149.  
  150.         <dependency>
  151.           <groupId>junit</groupId>
  152.           <artifactId>junit</artifactId>
  153.           <version>3.8.1</version>
  154.           <scope>test</scope>
  155.         </dependency>
  156.  
  157.         <dependency>
  158.             <groupId>org.springframework</groupId>
  159.             <artifactId>org.springframework.context</artifactId>
  160.             <version>${org.springframework.version}</version>
  161.         </dependency>
  162.  
  163.         <dependency>
  164.             <groupId>org.springframework</groupId>
  165.             <artifactId>org.springframework.transaction</artifactId>
  166.             <version>${org.springframework.version}</version>
  167.         </dependency>
  168.  
  169.         <dependency>
  170.             <groupId>org.springframework</groupId>
  171.             <artifactId>org.springframework.orm</artifactId>
  172.             <version>${org.springframework.version}</version>
  173.         </dependency>
  174.  
  175.         <dependency>
  176.             <groupId>org.springframework</groupId>
  177.             <artifactId>org.springframework.web</artifactId>
  178.             <version>${org.springframework.version}</version>
  179.         </dependency>
  180.  
  181.         <dependency>
  182.             <groupId>org.springframework</groupId>
  183.             <artifactId>org.springframework.web.servlet</artifactId>
  184.             <version>${org.springframework.version}</version>
  185.         </dependency>
  186.  
  187.         <dependency>
  188.              <groupId>javax.servlet</groupId>
  189.              <artifactId>servlet-api</artifactId>
  190.              <version>2.5</version>
  191.              <scope>provided</scope>
  192.         </dependency>
  193.  
  194.         <dependency>
  195.              <groupId>commons-logging</groupId>
  196.              <artifactId>commons-logging</artifactId>
  197.              <version>1.1.1</version>
  198.         </dependency>
  199.  
  200.       </dependencies>
  201.  
  202.       <build>
  203.         <sourceDirectory>src/main/scala</sourceDirectory>
  204.         <testSourceDirectory>src/test/scala</testSourceDirectory>
  205.         <plugins>
  206.  
  207.         <plugin>
  208.             <groupId>org.mortbay.jetty</groupId>
  209.             <artifactId>jetty-maven-plugin</artifactId>
  210.             <version>8.0.4.v20111024</version>
  211.         </plugin>    
  212.  
  213.           <plugin>
  214.             <groupId>org.scala-tools</groupId>
  215.             <artifactId>maven-scala-plugin</artifactId>
  216.             <executions>
  217.               <execution>
  218.                 <goals>
  219.                   <goal>compile</goal>
  220.                   <goal>testCompile</goal>
  221.                 </goals>
  222.               </execution>
  223.             </executions>
  224.             <configuration>
  225.               <scalaVersion>${scala.version}</scalaVersion>
  226.             </configuration>
  227.           </plugin>
  228.           <plugin>
  229.             <groupId>org.apache.maven.plugins</groupId>
  230.             <artifactId>maven-eclipse-plugin</artifactId>
  231.             <configuration>
  232.               <downloadSources>true</downloadSources>
  233.               <buildcommands>
  234.                 <buildcommand>ch.epfl.lamp.sdt.core.scalabuilder</buildcommand>
  235.               </buildcommands>
  236.               <additionalProjectnatures>
  237.                 <projectnature>ch.epfl.lamp.sdt.core.scalanature</projectnature>
  238.               </additionalProjectnatures>
  239.               <classpathContainers>
  240.                 <classpathContainer>org.eclipse.jdt.launching.JRE_CONTAINER</classpathContainer>
  241.                 <classpathContainer>ch.epfl.lamp.sdt.launching.SCALA_CONTAINER</classpathContainer>
  242.               </classpathContainers>
  243.             </configuration>
  244.           </plugin>
  245.         </plugins>
  246.       </build>
  247.       <reporting>
  248.         <plugins>
  249.           <plugin>
  250.             <groupId>org.scala-tools</groupId>
  251.             <artifactId>maven-scala-plugin</artifactId>
  252.             <configuration>
  253.               <scalaVersion>${scala.version}</scalaVersion>
  254.             </configuration>
  255.           </plugin>
  256.         </plugins>
  257.       </reporting>
  258.     </project>
  259.  
  260.  
  261. Here is my web.xml : 
  262.  
  263. <!-- language: xml -->
  264.  
  265.     <?xml version="1.0" encoding="UTF-8"?>
  266.     <web-app xmlns="http://java.sun.com/xml/ns/javaee"
  267.           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  268.           xsi:schemaLocation="
  269.             http://java.sun.com/xml/ns/javaee
  270.             http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
  271.           id="scala-spring-hibernate"
  272.           version="2.5">
  273.  
  274.      <servlet>
  275.          <servlet-name>dispatcher</servlet-name>
  276.          <servlet-class>
  277.              org.springframework.web.servlet.DispatcherServlet
  278.          </servlet-class>
  279.          <init-param>
  280.              <param-name>contextConfigLocation</param-name>
  281.              <param-value>/WEB-INF/web-context.xml</param-value>
  282.          </init-param>
  283.          <load-on-startup>1</load-on-startup>
  284.      </servlet>
  285.  
  286.      <servlet-mapping>
  287.          <servlet-name>dispatcher</servlet-name>
  288.          <url-pattern>*.html</url-pattern>
  289.      </servlet-mapping>
  290.  
  291. This the web-context.xml :
  292.  
  293. <!-- language: xml -->
  294.  
  295.     <?xml version="1.0" encoding="UTF-8"?>
  296.     <beans xmlns="http://www.springframework.org/schema/beans"
  297.         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  298.         xmlns:context="http://www.springframework.org/schema/context"
  299.         xsi:schemaLocation="
  300.          http://www.springframework.org/schema/beans
  301.          http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
  302.          http://www.springframework.org/schema/context
  303.          http://www.springframework.org/schema/context/spring-context-3.0.xsd">
  304.  
  305.      <context:component-scan
  306.          base-package="com.mycompany.spring.web"/>
  307.  
  308.      <bean id="viewResolver"
  309.            class="org.springframework.web.servlet.view.UrlBasedViewResolver">
  310.          <property name="viewClass"
  311.              value="org.springframework.web.servlet.view.JstlView"/>
  312.          <property name="prefix" value="/WEB-INF/jsp/"/>
  313.          <property name="suffix" value=".jsp"/>
  314.      </bean>
  315.  
  316.     </beans>
  317.  
  318. My JSP is containing the following code : 
  319.  
  320. <!-- language: xml -->
  321.  
  322.     <%@page contentType="text/html;"%>
  323.     <html>
  324.     <body>
  325.         <h1>Hello from ${pageContext.request.serverName}</h1>
  326.     </body>
  327.     </html>
  328.  
  329. My scala class :
  330.  
  331. <!-- language: java -->
  332.  
  333.     import org.springframework.stereotype.Controller
  334.     import org.springframework.web.bind.annotation.RequestMapping
  335.  
  336.     @Controller
  337.     class HelloWorldController {
  338.     @RequestMapping(Array("/hello.html"))
  339.     def showHello = "helloPage"
  340.     }


Can you help me please ?
Apr 30 '13 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.