2013-06-28 70 views
0

硒,當我試圖運行測試上碼頭gradle這個,和我的gradle這個配置如下:com.sun.el.parser.ParseException:遇到「(」在線運行在碼頭

的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的測試方法是訪問和網頁加載硒,但後來我得到異常:

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問題。

請指教,如何解決這個異常。

+0

似乎是與xhtml文件的東西。你可以將它粘貼到你的問題中嗎? – Magnilex

+0

@Magnilex,不,它不是xhtml問題,因爲當我在jboss上運行這個頁面時,它運行良好。 –

回答

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-APIEL-IMPL to gradle.build:

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

我也想廣告d如果您的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>