使用 gradle build 运行 tomcat jasper 任务 (jspc)

发布于 2024-11-01 18:12:35 字数 6253 浏览 4 评论 0原文

我试图在 gradle 中使用 jspc 编译我们的 jsp 文件,但出现异常。

这是相关的 gradle 部分

//tomcatHome is defined in gradle.properties
ant.tomcatHome = "${tomcatHome}"
ant.webAppDir = "${webAppDir}"
ant.importBuild 'jspc.xml'
test.dependsOn jspc

和 jspc.xml ant 文件

<?xml version="1.0"?>

<project name="jspc" basedir="." default="jspc">
  <!-- Import tasks from Tomcat -->
  <import file="${tomcatHome}/bin/catalina-tasks.xml" />

  <target name="jspc">
    <jasper validateXml="false" uriroot="${webAppDir}" />
  </target>
</project>

存储库部分:

repositories {
  mavenRepo urls: 'http://repository.jboss.org/nexus/content/groups/public-jboss'
  mavenRepo urls: 'http://oss.sonatype.org/content/repositories/sourceforge-releases'
  mavenRepo urls: 'http://google-gson.googlecode.com/svn/mavenrepo'
  mavenCentral()
}

依赖项部分:

dependencies {

  springVersion = '3.0.4.RELEASE'
  securityVersion = '3.0.5.RELEASE'

  //Compile time local dependencies
  compile fileTree(dir: 'staticLib', include: '*.jar')

  //Compile time but not included dependencies
  providedCompile group: 'javax.servlet', name: 'servlet-api', version:'2.5'
  providedCompile group: 'javax.servlet', name: 'jstl', version: '1.1.2'
  providedCompile group: 'taglibs', name: 'standard', version: '1.1.2'

  //Compile time remote dependencies
  compile group: 'com.google.code.gson', name:'gson', version: '1.7.1'
  compile group: 'com.google.visualization', name: 'visualization-datasource', version: '1.0.2'
  compile group: 'com.ibm.icu', name:'icu4j', version: '4.6.1'
  compile group: 'commons-codec', name: 'commons-codec', version: '1.4'
  compile group: 'commons-collections', name: 'commons-collections', version: '3.2.1'
  compile group: 'commons-dbcp', name: 'commons-dbcp', version: '1.4'
  compile group: 'commons-io', name: 'commons-io', version: '1.4'
  compile group: 'commons-lang', name: 'commons-lang', version: '2.6'
  compile group: 'commons-logging', name: 'commons-logging', version: '1.1.1'
  compile group: 'commons-pool', name: 'commons-pool', version: '1.5.5'
  compile group: 'javax.inject', name: 'javax.inject', version: '1'
  compile group: 'javax.servlet', name: 'jstl', version: '1.2'
  compile group: 'joda-time', name: 'joda-time', version: '1.6.2'
  compile group: 'log4j', name: 'log4j', version: '1.2.15'
  compile group: 'mysql', name: 'mysql-connector-java', version: '5.1.15'
  compile group: 'net.sf.ehcache', name: 'ehcache-core', version: '2.4.0'
  compile group: 'net.sf.ofx4j', name: 'ofx4j', version: '1.4'
  compile group: 'org.codehaus.jackson', name: 'jackson-mapper-asl', version: '1.7.2'
  compile group: 'org.hibernate', name: 'hibernate-core', version: '3.6.2.Final'
  compile group: 'org.hibernate', name: 'hibernate-validator', version: '4.1.0.Final'
  compile group: 'org.ostermiller', name: 'utils', version: '1.07.00'
  compile group: 'org.springframework', name: 'spring-aop', version: springVersion
  compile group: 'org.springframework', name: 'spring-asm', version: springVersion
  compile group: 'org.springframework', name: 'spring-aspects', version: springVersion
  compile group: 'org.springframework', name: 'spring-beans', version: springVersion
  compile group: 'org.springframework', name: 'spring-context', version: springVersion
  compile group: 'org.springframework', name: 'spring-core', version: springVersion
  compile group: 'org.springframework', name: 'spring-expression', version: springVersion
  compile group: 'org.springframework', name: 'spring-instrument', version: springVersion
  compile group: 'org.springframework', name: 'spring-jdbc', version: springVersion
  compile group: 'org.springframework', name: 'spring-jms', version: springVersion
  compile group: 'org.springframework', name: 'spring-orm', version: springVersion
  compile group: 'org.springframework', name: 'spring-oxm', version: springVersion
  compile group: 'org.springframework', name: 'spring-tx', version: springVersion
  compile group: 'org.springframework', name: 'spring-web', version: springVersion
  compile group: 'org.springframework', name: 'spring-webmvc', version: springVersion
  compile group: 'org.springframework.security', name: 'spring-security-acl', version: securityVersion
  compile group: 'org.springframework.security', name: 'spring-security-aspects', version: securityVersion
  compile group: 'org.springframework.security', name: 'spring-security-cas-client', version: securityVersion
  compile group: 'org.springframework.security', name: 'spring-security-config', version: securityVersion
  compile group: 'org.springframework.security', name: 'spring-security-core', version: securityVersion
  compile group: 'org.springframework.security', name: 'spring-security-ldap', version: securityVersion
  compile group: 'org.springframework.security', name: 'spring-security-taglibs', version: securityVersion
  compile group: 'org.springframework.security', name: 'spring-security-web', version: securityVersion
  compile group: 'uk.com.robust-it', name: 'cloning', version: '1.7.4'

  //Runtime dependencies
  runtime group: 'commons-fileupload', name: 'commons-fileupload', version: '1.2.2'
  runtime group: 'javassist', name: 'javassist', version: '3.9.0.GA'
  runtime group: 'javax.mail', name: 'mail', version: '1.4'
  runtime group: 'org.codehaus.jackson', name: 'jackson-mapper-asl', version: '1.7.4'
  runtime group: 'org.codehaus.jackson', name: 'jackson-core-asl', version: '1.7.4'
  runtime group: 'org.slf4j', name: 'slf4j-api', version: '1.6.1'
  runtime group: 'org.slf4j', name: 'slf4j-log4j12', version: '1.6.1'

  //Test dependencies
  testCompile group: 'cglib', name: 'cglib-nodep', version: '2.2'
  testCompile group: 'junit', name: 'junit', version: '4.8.2'
  testCompile group: 'org.mockito', name: 'mockito-all', version: '1.8.5'
  testCompile group: 'org.springframework', name: 'spring-test', version: springVersion
}

例外是:

原因: file:myfile.jsp(1,1) 绝对 uri: http://java.sun.com/jsp/jstl/core 无法在 web.xml 或jar 文件使用此应用程序部署

有什么想法吗?

I'm trying to compile our jsp files using jspc within gradle but am getting an exception.

Here is the pertinent gradle section

//tomcatHome is defined in gradle.properties
ant.tomcatHome = "${tomcatHome}"
ant.webAppDir = "${webAppDir}"
ant.importBuild 'jspc.xml'
test.dependsOn jspc

And the jspc.xml ant file

<?xml version="1.0"?>

<project name="jspc" basedir="." default="jspc">
  <!-- Import tasks from Tomcat -->
  <import file="${tomcatHome}/bin/catalina-tasks.xml" />

  <target name="jspc">
    <jasper validateXml="false" uriroot="${webAppDir}" />
  </target>
</project>

The repositories section:

repositories {
  mavenRepo urls: 'http://repository.jboss.org/nexus/content/groups/public-jboss'
  mavenRepo urls: 'http://oss.sonatype.org/content/repositories/sourceforge-releases'
  mavenRepo urls: 'http://google-gson.googlecode.com/svn/mavenrepo'
  mavenCentral()
}

The dependencies section:

dependencies {

  springVersion = '3.0.4.RELEASE'
  securityVersion = '3.0.5.RELEASE'

  //Compile time local dependencies
  compile fileTree(dir: 'staticLib', include: '*.jar')

  //Compile time but not included dependencies
  providedCompile group: 'javax.servlet', name: 'servlet-api', version:'2.5'
  providedCompile group: 'javax.servlet', name: 'jstl', version: '1.1.2'
  providedCompile group: 'taglibs', name: 'standard', version: '1.1.2'

  //Compile time remote dependencies
  compile group: 'com.google.code.gson', name:'gson', version: '1.7.1'
  compile group: 'com.google.visualization', name: 'visualization-datasource', version: '1.0.2'
  compile group: 'com.ibm.icu', name:'icu4j', version: '4.6.1'
  compile group: 'commons-codec', name: 'commons-codec', version: '1.4'
  compile group: 'commons-collections', name: 'commons-collections', version: '3.2.1'
  compile group: 'commons-dbcp', name: 'commons-dbcp', version: '1.4'
  compile group: 'commons-io', name: 'commons-io', version: '1.4'
  compile group: 'commons-lang', name: 'commons-lang', version: '2.6'
  compile group: 'commons-logging', name: 'commons-logging', version: '1.1.1'
  compile group: 'commons-pool', name: 'commons-pool', version: '1.5.5'
  compile group: 'javax.inject', name: 'javax.inject', version: '1'
  compile group: 'javax.servlet', name: 'jstl', version: '1.2'
  compile group: 'joda-time', name: 'joda-time', version: '1.6.2'
  compile group: 'log4j', name: 'log4j', version: '1.2.15'
  compile group: 'mysql', name: 'mysql-connector-java', version: '5.1.15'
  compile group: 'net.sf.ehcache', name: 'ehcache-core', version: '2.4.0'
  compile group: 'net.sf.ofx4j', name: 'ofx4j', version: '1.4'
  compile group: 'org.codehaus.jackson', name: 'jackson-mapper-asl', version: '1.7.2'
  compile group: 'org.hibernate', name: 'hibernate-core', version: '3.6.2.Final'
  compile group: 'org.hibernate', name: 'hibernate-validator', version: '4.1.0.Final'
  compile group: 'org.ostermiller', name: 'utils', version: '1.07.00'
  compile group: 'org.springframework', name: 'spring-aop', version: springVersion
  compile group: 'org.springframework', name: 'spring-asm', version: springVersion
  compile group: 'org.springframework', name: 'spring-aspects', version: springVersion
  compile group: 'org.springframework', name: 'spring-beans', version: springVersion
  compile group: 'org.springframework', name: 'spring-context', version: springVersion
  compile group: 'org.springframework', name: 'spring-core', version: springVersion
  compile group: 'org.springframework', name: 'spring-expression', version: springVersion
  compile group: 'org.springframework', name: 'spring-instrument', version: springVersion
  compile group: 'org.springframework', name: 'spring-jdbc', version: springVersion
  compile group: 'org.springframework', name: 'spring-jms', version: springVersion
  compile group: 'org.springframework', name: 'spring-orm', version: springVersion
  compile group: 'org.springframework', name: 'spring-oxm', version: springVersion
  compile group: 'org.springframework', name: 'spring-tx', version: springVersion
  compile group: 'org.springframework', name: 'spring-web', version: springVersion
  compile group: 'org.springframework', name: 'spring-webmvc', version: springVersion
  compile group: 'org.springframework.security', name: 'spring-security-acl', version: securityVersion
  compile group: 'org.springframework.security', name: 'spring-security-aspects', version: securityVersion
  compile group: 'org.springframework.security', name: 'spring-security-cas-client', version: securityVersion
  compile group: 'org.springframework.security', name: 'spring-security-config', version: securityVersion
  compile group: 'org.springframework.security', name: 'spring-security-core', version: securityVersion
  compile group: 'org.springframework.security', name: 'spring-security-ldap', version: securityVersion
  compile group: 'org.springframework.security', name: 'spring-security-taglibs', version: securityVersion
  compile group: 'org.springframework.security', name: 'spring-security-web', version: securityVersion
  compile group: 'uk.com.robust-it', name: 'cloning', version: '1.7.4'

  //Runtime dependencies
  runtime group: 'commons-fileupload', name: 'commons-fileupload', version: '1.2.2'
  runtime group: 'javassist', name: 'javassist', version: '3.9.0.GA'
  runtime group: 'javax.mail', name: 'mail', version: '1.4'
  runtime group: 'org.codehaus.jackson', name: 'jackson-mapper-asl', version: '1.7.4'
  runtime group: 'org.codehaus.jackson', name: 'jackson-core-asl', version: '1.7.4'
  runtime group: 'org.slf4j', name: 'slf4j-api', version: '1.6.1'
  runtime group: 'org.slf4j', name: 'slf4j-log4j12', version: '1.6.1'

  //Test dependencies
  testCompile group: 'cglib', name: 'cglib-nodep', version: '2.2'
  testCompile group: 'junit', name: 'junit', version: '4.8.2'
  testCompile group: 'org.mockito', name: 'mockito-all', version: '1.8.5'
  testCompile group: 'org.springframework', name: 'spring-test', version: springVersion
}

The exception is:

Cause: file:myfile.jsp(1,1) The absolute uri: http://java.sun.com/jsp/jstl/core cannot be resolved in either web.xml or the jar files deployed with this application

Any ideas?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

彡翼 2024-11-08 18:12:35

您可以使用包含类 org.apache.jasper.JspC 的 Tomcat JAR 文件,而不是使用 Tomcat 的 bin 目录中的 catalina-tasks.xml > 相反。如果您的 JSP 编译缺少任何库,您可以轻松地将它们添加到配置 jasper 中。

configurations {
    jasper
}

repositories {
    mavenCentral()
}

dependencies {
    jasper 'org.apache.tomcat:jasper:6.0.33',
           'javax.servlet:jstl:1.1.2',
           'taglibs:standard:1.1.2'
}

test.doLast {
    ant.taskdef(classname: 'org.apache.jasper.JspC', name: 'jasper', classpath: configurations.jasper.asPath)
    ant.jasper(validateXml: false, uriRoot: webAppDir, outputDir: "$buildDir/jspc")
}

Instead of using catalina-tasks.xml from Tomcat's bin directory you can use the Tomcat JAR file that includes the class org.apache.jasper.JspC instead. If there are any libraries missing for your JSP compilation you can easily add them to the configuration jasper.

configurations {
    jasper
}

repositories {
    mavenCentral()
}

dependencies {
    jasper 'org.apache.tomcat:jasper:6.0.33',
           'javax.servlet:jstl:1.1.2',
           'taglibs:standard:1.1.2'
}

test.doLast {
    ant.taskdef(classname: 'org.apache.jasper.JspC', name: 'jasper', classpath: configurations.jasper.asPath)
    ant.jasper(validateXml: false, uriRoot: webAppDir, outputDir: "$buildDir/jspc")
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文