码头通过行家运行正确,但错误地作为一个罐子(Jetty runs correctly via mav

2019-06-27 17:33发布

(If my title is misleading/incorrect please suggest something more descriptive, that the best I could think of)

I've created my own web app using spring roo and have yet to edit any of the code. I am building and running the web app with maven and jetty. When I execute the following everything works fine.

mvn jetty:run

However when I package and then run the jar directly, I come across some strange problems.

mvn package
java -jar target/dependency/jetty-runner.jar target/*.war

(Same thing with "mvn jetty:run-exploded")

The main page loads as it should, but when I click one of the navigation links (to create or list my models) I end up with these errors printed to the browser (http://localhost:8080/pages/main.jsf)

HTTP ERROR 500

Problem accessing /pages/main.jsf. Reason:

/pages/nameMeaning.xhtml @25,80 value="#{applicationBean.getColumnName(column)}" Error Parsing: #{applicationBean.getColumnName(column)}
Caused by:

javax.faces.view.facelets.TagAttributeException: /pages/nameMeaning.xhtml @25,80 value="#{applicationBean.getColumnName(column)}" Error Parsing: #{applicationBean.getColumnName(column)}
at com.sun.faces.facelets.tag.TagAttributeImpl.getValueExpression(TagAttributeImpl.java:401)
at com.sun.faces.facelets.tag.TagAttributeImpl.getValueExpression(TagAttributeImpl.java:351)
at com.sun.faces.facelets.tag.jsf.ValueHolderRule$DynamicValueExpressionMetadata.applyMetadata(ValueHolderRule.java:129)
at com.sun.faces.facelets.tag.MetadataImpl.applyMetadata(MetadataImpl.java:81)
at javax.faces.view.facelets.MetaTagHandler.setAttributes(MetaTagHandler.java:129)
at javax.faces.view.facelets.DelegatingMetaTagHandler.setAttributes(DelegatingMetaTagHandler.java:102)
at com.sun.faces.facelets.tag.jsf.ComponentTagHandlerDelegateImpl.doNewComponentActions(ComponentTagHandlerDelegateImpl.java:398)
at com.sun.faces.facelets.tag.jsf.ComponentTagHandlerDelegateImpl.apply(ComponentTagHandlerDelegateImpl.java:159)
...
Caused by: javax.el.ELException: Error Parsing: #{applicationBean.getColumnName(column)}
at com.sun.el.lang.ExpressionBuilder.createNodeInternal(ExpressionBuilder.java:171)
at com.sun.el.lang.ExpressionBuilder.build(ExpressionBuilder.java:188)
at com.sun.el.lang.ExpressionBuilder.createValueExpression(ExpressionBuilder.java:232)
at com.sun.el.ExpressionFactoryImpl.createValueExpression(ExpressionFactoryImpl.java:92)
at com.sun.faces.facelets.tag.TagAttributeImpl.getValueExpression(TagAttributeImpl.java:385)
... 95 more
Caused by: com.sun.el.parser.ParseException: Encountered "(" at line 1, column 32.
Was expecting one of:

"}" ...
"." ...
"[" ...
">" ...
"gt" ...
"<" ...
"lt" ...
">=" ...
"ge" ...
"<=" ...
"le" ...
"==" ...
"eq" ...
"!=" ...
"ne" ...
"&&" ...
"and" ...
"||" ...
"or" ...
"*" ...
"+" ...
"-" ...
"?" ...
"/" ...
"div" ...
"%" ...
"mod" ...


at com.sun.el.parser.ELParser.generateParseException(ELParser.java:1664)
at com.sun.el.parser.ELParser.jj_consume_token(ELParser.java:1544)
at com.sun.el.parser.ELParser.DeferredExpression(ELParser.java:147)
at com.sun.el.parser.ELParser.CompositeExpression(ELParser.java:74)
at com.sun.el.lang.ExpressionBuilder.createNodeInternal(ExpressionBuilder.java:139)
... 99 more
Caused by:

Please see the pom.xml file here: http://pastebin.com/6aPpYP47

Answer 1:

说完看着你pom.xml很显然,你正在运行不同版本的码头的。 这可能是也可能不是你的问题的根本原因,但作为不同的版本实现不同版本的Servlet容器规范的您可能会发现一些东西,是一个Servlet 3.0功能的工作原理与码头8,不与码头7工作(也就是Servlet 2.5 IIRC)

如果你看看你的插件配置:

        <plugin>
            <groupId>org.mortbay.jetty</groupId>
            <artifactId>jetty-maven-plugin</artifactId>
            <version>8.1.4.v20120524</version>
            <configuration>
                <webAppConfig>
                    <contextPath>/${project.name}</contextPath>
                </webAppConfig>
            </configuration>
        </plugin>

你会发现, jetty:run将使用码头8.1.4.v20120524当你注入的码头,而亚军

       <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-dependency-plugin</artifactId>
          <version>2.3</version>
          <executions>
            <execution>
              <phase>package</phase>
              <goals><goal>copy</goal></goals>
              <configuration>
                <artifactItems>
                  <artifactItem>
                    <groupId>org.mortbay.jetty</groupId>
                    <artifactId>jetty-runner</artifactId>
                    <version>7.4.5.v20110725</version>
                    <destFileName>jetty-runner.jar</destFileName>
                  </artifactItem>
                </artifactItems>
              </configuration>
            </execution>
          </executions>
        </plugin>

并与运行java -jar jetty-runner.jar namename.war使用的是码头7.4.5.v20110725

正如别人指出你是使用EL 2.2这实在是一个Servlet 3.0功能,所以也许你只需要升级到一个码头亚军的新版本



Answer 2:

我已经得到了同样的错误,我解决。 你的问题是错误的。

这是由于表达式解析器。 已使用

#{applicationBean.getColumnName(column)}

在nameMeaning.xhtml。 它是无效的EL为解析器。 无论是u需要改变像

#{applicationBean.getColumnName} 

并通过PARAM像

 <f:param name="column" value="#{column}"/>

或者使用EL-API-2.2.jar解析器码头。



文章来源: Jetty runs correctly via maven, but incorrectly as a jar