com.sun.el.parser.ParseException:在码头上运行selenium时遇到“(”)

时间:2013-06-28 15:16:01

标签: java-ee jsf-2 selenium jetty gradle

我正在尝试使用 gradle 码头上运行 selenium 测试,我的gradle配置如下:

的build.gradle:

apply plugin: 'java'
apply plugin: 'eclipse-wtp'
apply plugin: 'war'
apply plugin: 'findbugs'
apply from: 'emma.gradle'
apply plugin: 'jetty'

sourceCompatibility = 1.7
version = ''

sourceSets {
    selenium
}

buildscript {
    repositories {
        mavenCentral()
    }

    dependencies {
        classpath 'org.gradle.api.plugins:gradle-cargo-plugin:0.6'
    }
}

repositories {
    mavenCentral()
    mavenRepo url: 'http://repository.primefaces.org'
    mavenRepo url: 'http://repository.jboss.org/nexus/content/groups/public'
    mavenRepo url: 'http://repository.jboss.org/maven2'
    mavenRepo url: 'http://maven.springframework.org/release'
    mavenRepo url: 'http://repo1.maven.org/maven2'
    mavenRepo url: 'http://git.solutionstream.com/nexus/content/repositories/thirdparty'
}

dependencies {
    //JSF
    compile group: 'com.sun.faces', name: 'jsf-api', version: '2.1.22'
    compile group: 'com.sun.faces', name: 'jsf-impl', version: '2.1.22'
    compile 'org.ocpsoft.rewrite:rewrite-servlet:2.0.3.Final'
    compile 'org.ocpsoft.rewrite:rewrite-config-prettyfaces:2.0.3.Final'


    //Servlet
    compile group: 'javax.servlet', name: 'jstl', version: '1.2'
    providedCompile group: 'org.jboss.spec', name: 'jboss-javaee-6.0', version: '1.0.0.Final'
    compile 'taglibs:standard:1.1.2'
    compile group: 'org.springframework', name: 'spring-web', version: '3.2.2.RELEASE'

    //Omnifaces
    compile 'org.omnifaces:omnifaces:1.5'

    //Prime Faces
    compile group: 'org.primefaces', name: 'primefaces', version: '4.0-SNAPSHOT'
    compile 'org.primefaces.themes:bootstrap:1.0.10'

    // DB
    compile group: 'org.springframework.data', name: 'spring-data-jpa', version: '1.3.1.RELEASE'
    compile group: 'org.springframework', name: 'spring-aspects', version: '3.2.2.RELEASE'
    compile group: 'mysql', name: 'mysql-connector-java', version: '5.1.9'

    compile group: 'javax.inject', name: 'javax.inject', version: '1'
    compile group: 'javax.enterprise', name: 'cdi-api', version: '1.0-SP4'
    compile 'cglib:cglib-nodep:2.2.2'

    //Hibernate / JPA   
    compile 'org.hibernate:hibernate-core:4.1.0.Final'
    compile 'org.hibernate:hibernate-entitymanager:4.1.0.Final'
    compile 'org.hibernate.javax.persistence:hibernate-jpa-2.0-api:1.0.1.Final'
    //JSR-303
    compile 'org.hibernate:hibernate-validator:4.3.1.Final'

    // Spring Security
    compile 'org.springframework.security:spring-security-core:3.1.4.RELEASE'
    compile 'org.springframework.security:spring-security-web:3.1.4.RELEASE'
    compile 'org.springframework.security:spring-security-config:3.1.4.RELEASE'

    //Utility
    compile 'com.google.guava:guava:14.0.1'
    compile 'commons-lang:commons-lang:2.6'
    compile 'org.apache.commons:commons-email:1.3.1'
    compile 'com.typesafe:config:1.0.0'
    compile 'joda-time:joda-time:2.2'
    compile 'org.apache.geronimo.javamail:geronimo-javamail_1.4_mail:1.8.3'
    compile 'org.slf4j:slf4j-api:1.7.2'
    compile 'org.slf4j:jcl-over-slf4j:1.7.2'
    compile 'org.slf4j:slf4j-log4j12:1.7.2'


    //Mustache Templates
    compile 'com.github.jknack:handlebars:1.0.0'

    //Projects
    //compile project(":ExtraValidators")

    ////TESTING DEPENDENCIES
    testCompile 'com.googlecode.jmockit:jmockit:1.2'
    testCompile group: 'junit', name: 'junit', version: '4.11'
    testCompile 'com.h2database:h2:1.3.172'

    //Spring Testing
    testCompile 'org.springframework:spring-test:3.2.3.RELEASE'

    /* Selenium */
    seleniumCompile 'org.seleniumhq.selenium:selenium-java:2.33.0'
    seleniumCompile 'junit:junit:4.11'
}

task wrapper(type: Wrapper){
    gradleVersion = '1.5'
}

eclipse {
    classpath {
       downloadSources=true
       plusConfigurations += configurations.seleniumCompile
    }
}


task jettyDaemon(type: org.gradle.api.plugins.jetty.JettyRun) {
    daemon = true
}

task selenium(type: Test, dependsOn: jettyDaemon) {
    testClassesDir = sourceSets.selenium.output.classesDir
    classpath = sourceSets.selenium.runtimeClasspath
}

测试类:

public class HomeTest {

    static WebDriver driver;

    @BeforeClass
    public static void before() {
        driver = new FirefoxDriver();
    }

    @AfterClass
    public static void after() {
        driver.close();
    }

    @Test
    public void testLoadHomePage() {
        driver.get("http://localhost:8080/MyApp/index.xhtml");
    }

}

CASE:当尝试使用命令gradle clean selenium运行selenium时,访问测试方法并加载网页,但后来我得到了异常:

com.sun.el.parser.ParseException: Encountered "(" at line 1, column 25.
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)
        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.el.ELText$ELTextVariable.apply(ELText.java:203)
        at com.sun.faces.facelets.el.ELText$ELTextComposite.apply(ELText.java:184)
        at com.sun.faces.facelets.compiler.CommentInstruction.apply(CommentInstruction.java:81)
        at com.sun.faces.facelets.compiler.UIInstructionHandler.apply(UIInstructionHandler.java:141)
        at javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:95)
        at javax.faces.view.facelets.DelegatingMetaTagHandler.applyNextHandler(DelegatingMetaTagHandler.java:137)
        at com.sun.faces.facelets.tag.jsf.ComponentTagHandlerDelegateImpl.apply(ComponentTagHandlerDelegateImpl.java:187)
        at javax.faces.view.facelets.DelegatingMetaTagHandler.apply(DelegatingMetaTagHandler.java:120)
        at javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:95)
        at com.sun.faces.facelets.tag.jsf.core.ViewHandler.apply(ViewHandler.java:188)
        at javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:95)
        at com.sun.faces.facelets.compiler.NamespaceHandler.apply(NamespaceHandler.java:93)
        at com.sun.faces.facelets.compiler.EncodingHandler.apply(EncodingHandler.java:87)
        at com.sun.faces.facelets.impl.DefaultFacelet.include(DefaultFacelet.java:320)
        at com.sun.faces.facelets.impl.DefaultFacelet.include(DefaultFacelet.java:379)
        at com.sun.faces.facelets.impl.DefaultFacelet.include(DefaultFacelet.java:358)
        at com.sun.faces.facelets.impl.DefaultFaceletContext.includeFacelet(DefaultFaceletContext.java:199)
        at com.sun.faces.facelets.tag.ui.CompositionHandler.apply(CompositionHandler.java:155)
        at com.sun.faces.facelets.compiler.NamespaceHandler.apply(NamespaceHandler.java:93)
        at com.sun.faces.facelets.compiler.EncodingHandler.apply(EncodingHandler.java:87)
        at com.sun.faces.facelets.impl.DefaultFacelet.apply(DefaultFacelet.java:164)
        at com.sun.faces.application.view.FaceletViewHandlingStrategy.buildView(FaceletViewHandlingStrategy.java:906)
        at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:99)
        at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
        at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
        at javax.faces.webapp.FacesServlet.service(FacesServlet.java:594)
        at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
        at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:390)
        at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
        at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
        at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
        at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:440)
        at org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:230)
        at org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114)
        at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
        at org.mortbay.jetty.Server.handle(Server.java:326)
        at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
        at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:926)
        at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:549)
        at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212)
        at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
        at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:410)
        at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)

BTW:当我在jboss上运行此页面时,我没有得到任何解析问题,因此它不是xhtml问题。

请告知,如何解决此异常。

2 个答案:

答案 0 :(得分:4)

解决方案如下:

1-将 com.sun.faces.expressionFactory 添加到web.xml中:

<context-param>
    <param-name>com.sun.faces.expressionFactory</param-name>
    <param-value>com.sun.el.ExpressionFactoryImpl</param-value>
</context-param>

2-将 el-api el-impl 添加到gradle.build:

compile 'javax.el:el-api:2.2'
runtime 'org.glassfish.web:el-impl:2.2'

答案 1 :(得分:0)

我还想补充一点,如果您的Web应用程序在Weblogic 10.3.x下运行,则需要配置 weblogic.xml (如果它是单个.war)或 weblogic-application.xml (如果是EAR),包含以下内容:

<prefer-application-packages>
    <package-name>com.sun.el.*</package-name>
    <package-name>javax.el.*</package-name>
</prefer-application-packages>