2013-10-07 85 views
0

我在(Maven)項目中都有GWT 2.5.1,Spring 3.2和Tiles。只要我用mvn jetty:run-war之類的東西開始項目,一切正常。無法獲得JSP 2.1 ExpressionFactory:jsp EL

只要我嘗試用mvn gwt啓動項目:運行到DevMode。它引發以下錯誤消息:

2013-10-07 14:49:31,676 [main] WARN org.springframework.web.servlet.view.tiles3.TilesConfigurer - Could not obtain JSP 2.1 ExpressionFactory 

...這:

java.lang.NoSuchMethodError: javax.servlet.jsp.JspFactory.getJspApplicationContext(Ljavax/servlet/ServletContext;)Ljavax/servlet/jsp/JspApplicationContext; 
    at org.springframework.web.servlet.view.tiles3.TilesConfigurer$TilesElActivator.createEvaluator(TilesConfigurer.java:395) 
    at org.springframework.web.servlet.view.tiles3.TilesConfigurer$SpringTilesContainerFactory.createELEvaluator(TilesConfigurer.java:357) 
    at org.springframework.web.servlet.view.tiles3.TilesConfigurer$SpringTilesContainerFactory.createAttributeEvaluatorFactory(TilesConfigurer.java:352) 
    at org.apache.tiles.factory.BasicTilesContainerFactory.createContainer(BasicTilesContainerFactory.java:88) 
    at org.springframework.web.servlet.view.tiles3.TilesConfigurer$SpringTilesContainerFactory.createContainer(TilesConfigurer.java:277) 
    at org.apache.tiles.startup.AbstractTilesInitializer.createContainer(AbstractTilesInitializer.java:114) 
    at org.apache.tiles.startup.AbstractTilesInitializer.initialize(AbstractTilesInitializer.java:64) 
    at org.springframework.web.servlet.view.tiles3.TilesConfigurer.afterPropertiesSet(TilesConfigurer.java:252) 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1541) 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1479) 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:521) 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458) 
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295) 
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223) 
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292) 
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194) 
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:628) 
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:932) 
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:479) 
    at org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:651) 
    at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:599) 
    at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:665) 
    at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:518) 
    at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:459) 
    at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:136) 
    at javax.servlet.GenericServlet.init(GenericServlet.java:241) 
    at org.mortbay.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:433) 
    at org.mortbay.jetty.servlet.ServletHolder.doStart(ServletHolder.java:256) 
    at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:39) 
    at org.mortbay.jetty.servlet.ServletHandler.initialize(ServletHandler.java:616) 
    at org.mortbay.jetty.servlet.Context.startContext(Context.java:140) 
    at org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1220) 
    at org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:513) 
    at org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:448) 
    at com.google.gwt.dev.shell.jetty.JettyLauncher$WebAppContextWithReload.doStart(JettyLauncher.java:468) 
    at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:39) 
    at org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:130) 
    at org.mortbay.jetty.handler.RequestLogHandler.doStart(RequestLogHandler.java:115) 
    at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:39) 
    at org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:130) 
    at org.mortbay.jetty.Server.doStart(Server.java:222) 
    at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:39) 
    at com.google.gwt.dev.shell.jetty.JettyLauncher.start(JettyLauncher.java:672) 
    at com.google.gwt.dev.DevMode.doStartUpServer(DevMode.java:509) 
    at com.google.gwt.dev.DevModeBase.startUp(DevModeBase.java:1093) 
    at com.google.gwt.dev.DevModeBase.run(DevModeBase.java:836) 
    at com.google.gwt.dev.DevMode.main(DevMode.java:311) 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 
    at java.lang.reflect.Method.invoke(Method.java:597) 
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120) 

請在下面找到我的web.xml:

<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="myclient_mdb" version="2.5"> 
    <display-name>MyClient Memberdatabase</display-name> 

    <!--Configuration--> 
    <context-param> 
     <param-name>contextConfigLocation</param-name> 
     <param-value>/WEB-INF/spring-security.xml, /WEB-INF/applicationContext.xml</param-value> 
    </context-param> 

    <filter> 
     <filter-name>hibernateFilter</filter-name> 
     <filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class> 
     <init-param> 
      <param-name>sessionFactoryBeanName</param-name> 
      <param-value>hibernateSessionFactory</param-value> 
     </init-param> 
    </filter> 

    <filter> 
     <filter-name>springSecurityFilterChain</filter-name> 
     <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class> 
    </filter> 

    <!--Spring Security Filter--> 
    <filter-mapping> 
     <filter-name>hibernateFilter</filter-name> 
     <url-pattern>/*</url-pattern> 
    </filter-mapping> 

    <filter-mapping> 
     <filter-name>springSecurityFilterChain</filter-name> 
     <url-pattern>/*</url-pattern> 
    </filter-mapping> 

    <!--Context Loader--> 
    <listener> 
     <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> 
    </listener> 

    <!-- Servlets --> 
    <servlet> 
     <servlet-name>springGwtRemoteServiceServlet</servlet-name> 
     <servlet-class>org.spring4gwt.server.SpringGwtRemoteServiceServlet</servlet-class> 
    </servlet> 

    <servlet> 
     <servlet-name>mvc-dispatcher</servlet-name> 
     <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> 
     <init-param> 
      <param-name>contextConfigLocation</param-name> 
      <param-value>/WEB-INF/applicationContext.xml</param-value> 
     </init-param> 
     <load-on-startup>1</load-on-startup> 
    </servlet> 


    <!-- Mapping --> 
    <servlet-mapping> 
     <servlet-name>mvc-dispatcher</servlet-name> 
     <url-pattern>/member/*</url-pattern> 
    </servlet-mapping> 

    <servlet-mapping> 
     <servlet-name>springGwtRemoteServiceServlet</servlet-name> 
     <url-pattern>/ui/springGwtServices/*</url-pattern> 
    </servlet-mapping> 

    <servlet-mapping> 
     <servlet-name>mvc-dispatcher</servlet-name> 
     <url-pattern>/account.html</url-pattern> 
    </servlet-mapping> 

    <servlet-mapping> 
     <servlet-name>mvc-dispatcher</servlet-name> 
     <url-pattern>/login.html</url-pattern> 
    </servlet-mapping> 

    <servlet-mapping> 
     <servlet-name>mvc-dispatcher</servlet-name> 
     <url-pattern>/logout.html</url-pattern> 
    </servlet-mapping> 

    <servlet-mapping> 
     <servlet-name>mvc-dispatcher</servlet-name> 
     <url-pattern>/loginfailed.html</url-pattern> 
    </servlet-mapping> 


    <!-- Default page to serve --> 
    <welcome-file-list> 
    <welcome-file>/login.html</welcome-file> 
    </welcome-file-list> 

</web-app> 

請在下面找到我的pom.xml:

<?xml version="1.0" encoding="UTF-8"?> 
<project 
     xmlns="http://maven.apache.org/POM/4.0.0" 
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> 

    <!-- POM file generated with GWT webAppCreator --> 
    <modelVersion>4.0.0</modelVersion> 
    <groupId>com.mycompany.myclient.mdb</groupId> 
    <artifactId>ui</artifactId> 
    <packaging>war</packaging> 
    <version>1.0-SNAPSHOT</version> 
    <name>Myclient MemberDatabase</name> 

    <properties> 
     <!-- Convenience property to set the GWT version --> 
     <gwtVersion>2.5.1</gwtVersion> 
     <!-- GWT needs at least java 1.5 --> 
     <webappDirectory>${project.build.directory}/${project.build.finalName}</webappDirectory> 
     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 
     <java.version>1.6</java.version> 
     <spring.version>3.2.4.RELEASE</spring.version> 
     <spring-security.version>3.2.0.M1</spring-security.version> 
     <cglib.version>2.2.2</cglib.version> 
     <contextPath>mdb</contextPath> 
    </properties> 

    <dependencies> 
     <!--Logging--> 
     <dependency> 
      <groupId>log4j</groupId> 
      <artifactId>log4j</artifactId> 
      <version>1.2.14</version> 
     </dependency> 

     <!--GWT--> 
     <dependency> 
      <groupId>com.google.gwt</groupId> 
      <artifactId>gwt-servlet</artifactId> 
      <version>${gwtVersion}</version> 
      <scope>runtime</scope> 
     </dependency> 
     <dependency> 
      <groupId>com.google.gwt</groupId> 
      <artifactId>gwt-user</artifactId> 
      <version>${gwtVersion}</version> 
      <scope>provided</scope> 
     </dependency> 

     <!--Testing--> 
     <dependency> 
      <groupId>junit</groupId> 
      <artifactId>junit</artifactId> 
      <version>4.7</version> 
      <scope>test</scope> 
     </dependency> 

     <!--Servlet--> 
     <dependency> 
      <groupId>javax.validation</groupId> 
      <artifactId>validation-api</artifactId> 
      <version>1.0.0.GA</version> 
      <!--<scope>test</scope>--> 
     </dependency> 
     <dependency> 
      <groupId>javax.validation</groupId> 
      <artifactId>validation-api</artifactId> 
      <version>1.0.0.GA</version> 
      <classifier>sources</classifier> 
      <!--<scope>test</scope>--> 
     </dependency> 
     <dependency> 
      <groupId>org.hibernate</groupId> 
      <artifactId>hibernate-validator</artifactId> 
      <version>4.3.1.Final</version> 
     </dependency> 

     <!-- Spring core & mvc --> 
     <dependency> 
      <groupId>org.springframework</groupId> 
      <artifactId>spring-context</artifactId> 
      <version>${spring.version}</version> 
     </dependency> 
     <dependency> 
      <groupId>org.springframework</groupId> 
      <artifactId>spring-web</artifactId> 
      <version>${spring.version}</version> 
     </dependency> 
     <dependency> 
      <groupId>org.springframework</groupId> 
      <artifactId>spring-webmvc</artifactId> 
      <version>${spring.version}</version> 
     </dependency> 
     <dependency> 
      <groupId>org.springframework</groupId> 
      <artifactId>spring-orm</artifactId> 
      <version>${spring.version}</version> 
      <type>jar</type> 
      <scope>compile</scope> 
     </dependency> 

     <dependency> 
      <groupId>org.springframework</groupId> 
      <artifactId>spring-test</artifactId> 
      <version>${spring.version}</version> 
      <type>jar</type> 
      <scope>test</scope> 
     </dependency> 

     <!-- Spring Security --> 
     <dependency> 
      <groupId>org.springframework.security</groupId> 
      <artifactId>spring-security-core</artifactId> 
      <version>${spring-security.version}</version> 
     </dependency> 

     <dependency> 
      <groupId>org.springframework.security</groupId> 
      <artifactId>spring-security-web</artifactId> 
      <version>${spring-security.version}</version> 
     </dependency> 

     <dependency> 
      <groupId>org.springframework.security</groupId> 
      <artifactId>spring-security-config</artifactId> 
      <version>${spring-security.version}</version> 
     </dependency> 

     <!-- CGLib for @Configuration --> 
     <dependency> 
      <groupId>cglib</groupId> 
      <artifactId>cglib-nodep</artifactId> 
      <version>${cglib.version}</version> 
      <scope>runtime</scope> 
     </dependency> 


     <!-- Servlet Spec --> 
     <dependency> 
      <groupId>javax.servlet</groupId> 
      <artifactId>servlet-api</artifactId> 
      <version>2.5</version> 
      <scope>provided</scope> 
     </dependency> 
     <dependency> 
      <groupId>javax.servlet.jsp</groupId> 
      <artifactId>jsp-api</artifactId> 
      <version>2.1</version> 
      <scope>compile</scope> 
     </dependency> 
     <dependency> 
      <groupId>javax.servlet</groupId> 
      <artifactId>jstl</artifactId> 
      <version>1.2</version> 
     </dependency> 

     <dependency> 
      <groupId>com.sun.el</groupId> 
      <artifactId>el-ri</artifactId> 
      <version>1.0</version> 
     </dependency> 

     <dependency> 
      <groupId>org</groupId> 
      <artifactId>spring4gwt</artifactId> 
      <version>0.0.1</version> 
     </dependency> 

     <dependency> 
      <groupId>commons-dbcp</groupId> 
      <artifactId>commons-dbcp</artifactId> 
      <version>1.4</version> 
     </dependency> 
     <dependency> 
      <groupId>org.hibernate</groupId> 
      <artifactId>hibernate-entitymanager</artifactId> 
      <version>3.3.2.GA</version> 
     </dependency> 
     <dependency> 
      <groupId>org.hsqldb</groupId> 
      <artifactId>hsqldb</artifactId> 
      <version>2.2.9</version> 
      <scope>test</scope> 
     </dependency> 
     <dependency> 
      <groupId>mysql</groupId> 
      <artifactId>mysql-connector-java</artifactId> 
      <!-- <version>5.0.8</version> --> 
      <version>5.1.10</version> 
     </dependency> 

     <dependency> 
      <groupId>commons-codec</groupId> 
      <artifactId>commons-codec</artifactId> 
      <version>1.6</version> 
     </dependency> 

     <!--Tiles--> 
     <dependency> 
      <groupId>org.apache.tiles</groupId> 
      <artifactId>tiles-extras</artifactId> 
      <version>3.0.1</version> 
     </dependency> 

     <dependency> 
      <groupId>org.slf4j</groupId> 
      <artifactId>slf4j-log4j12</artifactId> 
      <version>1.5.2</version> 
     </dependency> 


    </dependencies> 


    <build> 
     <finalName>mdb</finalName> 
     <!-- Generate compiled stuff in the folder used for developing mode --> 
     <outputDirectory>${webappDirectory}/WEB-INF/classes</outputDirectory> 

     <plugins> 

      <!-- GWT Maven Plugin --> 
      <plugin> 
       <groupId>org.codehaus.mojo</groupId> 
       <artifactId>gwt-maven-plugin</artifactId> 
       <version>2.5.1</version> 
       <executions> 
        <execution> 
         <goals> 
          <goal>compile</goal> 
          <goal>test</goal> 
          <goal>i18n</goal> 
          <goal>generateAsync</goal> 
         </goals> 
        </execution> 
       </executions> 
       <!-- Plugin configuration. There are many available options, see 
        gwt-maven-plugin documentation at codehaus.org --> 
       <configuration> 
        <runTarget>ui.html</runTarget> 
        <hostedWebapp>${webappDirectory}</hostedWebapp> 
        <i18nMessagesBundle>com.mycompany.myclient.mdb.ui.client.Messages</i18nMessagesBundle> 
       </configuration> 
      </plugin> 

      <!-- Copy static web files before executing gwt:run --> 
      <plugin> 
       <groupId>org.apache.maven.plugins</groupId> 
       <artifactId>maven-war-plugin</artifactId> 
       <version>2.3</version> 
       <executions> 
        <execution> 
         <phase>compile</phase> 
         <goals> 
          <goal>exploded</goal> 
         </goals> 
        </execution> 
       </executions> 
       <configuration> 
        <webappDirectory>${webappDirectory}</webappDirectory> 
       </configuration> 
      </plugin> 
      <plugin> 
       <groupId>org.apache.maven.plugins</groupId> 
       <artifactId>maven-compiler-plugin</artifactId> 
       <version>3.1</version> 
       <configuration> 
        <source>1.5</source> 
        <target>1.5</target> 
       </configuration> 
      </plugin> 

      <plugin> 
       <groupId>org.apache.tomcat.maven</groupId> 
       <artifactId>tomcat7-maven-plugin</artifactId> 
       <version>2.1</version> 
       <configuration> 
        <server>svr4-worker1</server> 
        <url>http://svr4.dmz.mycompany.com:8180/manager</url> 
        <update>true</update> 
        <path>${contextPath}</path> 
       </configuration> 
      </plugin> 
     </plugins> 



     <testResources> 
      <testResource> 
       <directory>src/main/webapp/WEB-INF</directory> 
      </testResource> 
      <testResource> 
       <directory>src/test/resources</directory> 
      </testResource> 
     </testResources> 
    </build> 
</project> 

我相信這有一些事情要做集成了GWT的Servlet容器。但是我不知道如何解決這個問題。有誰能給我一個提示嗎?

非常感謝!

+0

你搞砸了版本的。粘貼你的web.xml。 –

+0

@sᴜʀᴇsʜᴀᴛᴛᴀ我剛剛用我的web.xml更新了我的帖子。謝謝你看這個! – Randy

+0

你在JSP中使用表達式語言嗎?如果是的話,你是否加了'el-ri.jar'? –

回答

0

我經歷了這裏的問題是由在開發模式下默認使用GWT通過嵌入式和有些過時碼頭造成的。

我的主頁不僅僅是一個靜態html頁面,而是一個使用表達式語言的JSP(MVC視圖,Tiles 3)。由於我的配置需要一個比gwt附帶的servlet容器更近的servlet容器,因此我的項目無法使用嵌入式碼頭。

爲了解決這個問題,我不得不啓動一個像Jetty 7(Tomcat也可以)最近的servlet容器來運行項目的服務器端(和gwt)。

爲了能夠在開發模式下運行gwt並對其進行調試,有必要防止它啓動嵌入式服務器,併爲其提供信息在哪裏找到服務器。在我來說,我加入的IntelliJ的GWT運行/調試配置理念下開發模式參數以下行

-noserver -war localBuild -port 8080 com.myproject.modul 

你有你的模塊名稱替換模塊名稱科西嘉中。端口8080是我的Jetty 7正在偵聽客戶端連接的端口。選項-noserver阻止gwt啓動嵌入式服務器。

你也可以通過添加以下行Maven的GWT-插件配置與Maven達到相同的結果:

 <plugin> 
      <groupId>org.codehaus.mojo</groupId> 
      <artifactId>gwt-maven-plugin</artifactId> 
      <version>2.5.1</version> 
      ... 
      <configuration> 
       .. 
       <noServer>true</noServer> 
       <port>8080</port> 
      </configuration> 
     </plugin> 

要立即運行/調試你的GWT模塊,您只需啓動的服務器你選擇通過調用mvn clean jetty:run-war(也可以直接從IDE啓動),然後像以前那樣啓動gwt的Dev模式。

一個不錯的副作用是刷新現在快得多,因爲只要服務器端沒有任何變化,嵌入式服務器就不會始終開始刷新。

這就像幫助我找出這個解決方案:http://clojure-dev.blogspot.de/2011/12/debugging-gwt-client-side-code-with.html

1

最有可能的解決方案是包括el-ri.jar

<dependency> 
    <groupId>com.sun.el</groupId> 
    <artifactId>el-ri</artifactId> 
    <version>1.0</version> 
    </dependency> 
+0

我根據你以前的評論做了這個。不幸的是它沒有效果。 – Randy

+0

@Randy再次'無法獲得JSP 2.1 ExpressionFactory'問題? –

+0

不幸的是。我用mvn clean gwt運行它:run。與以前完全一樣的輸出。 – Randy