Jetty通过maven正确运行,但作为jar却错误地运行 [英] Jetty runs correctly via maven, but incorrectly as a jar

查看:152
本文介绍了Jetty通过maven正确运行,但作为jar却错误地运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

(如果我的标题有误导性/不正确,请提出一些更具描述性的内容,这是我能想到的最好的东西)

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

我已经使用spring roo创建了自己的网络应用,但尚未编辑任何代码.我正在使用Maven和Jetty构建和运行Web应用程序.当我执行以下命令时,一切正常.

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

但是,当我打包然后直接运行jar时,遇到了一些奇怪的问题.

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

(与"mvn码头:爆炸"相同)

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

主页将按预期加载,但是当我单击其中一个导航链接(以创建或列出我的模型)时,最终将这些错误打印到浏览器(http://localhost:8080/pages/main .jsf)

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:

请在此处查看pom.xml文件: http://pastebin.com/6aPpYP47

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

推荐答案

查看了您的 pom.xml 它很明显,您正在运行不同版本的Jetty.这可能是问题的根本原因,也可能不是问题的根本原因,但是由于不同的版本实现了Servlet容器规范的不同版本,因此您可能会发现Servlet 3.0功能与Jetty 8兼容,而与Jetty 7不兼容(这是Servlet 2.5 IIRC)

Having looked at your pom.xml it is clear that you are running different versions of Jetty. That may or may not be the root cause of your issue, but as the different versions implement different versions of the Servlet Container specification you may find that something which is a Servlet 3.0 feature works with Jetty 8 and doesn't work with Jetty 7 (which is 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将使用Jetty 8.1.4.v20120524,而在注入码头运行器

You will notice that jetty:run will be using Jetty 8.1.4.v20120524 whereas when you inject the jetty-runner

       <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运行您正在使用Jetty 7.4.5.v20110725

And run with java -jar jetty-runner.jar namename.war you are using Jetty 7.4.5.v20110725

正如其他人指出的那样,您正在使用EL 2.2,它实际上是Servlet 3.0的功能,因此也许您只需要升级到

As somebody else has pointed out you are using EL 2.2 which is really a Servlet 3.0 feature, so perhaps you just need to upgrade to a newer version of jetty runner

这篇关于Jetty通过maven正确运行,但作为jar却错误地运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆