错误的Apache编译JSP的Tomcat 8.0.12 [英] Error compiling JSPs in Apache Tomcat 8.0.12

查看:278
本文介绍了错误的Apache编译JSP的Tomcat 8.0.12的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近从Apache Tomcat上6.X升级到7.x升级到8.0.12。我目前能够编译并在Tomcat中运行8我的应用程序;但是,我的pre-编译JSP ant任务不再工作。奇怪的是,如果我切换到Tomcat 7的不进行​​任何其他变动,JSPC通话将工作!

I recently upgraded from Apache Tomcat 6.X to 7.X to 8.0.12. I am currently able to compile and run my application in tomcat 8; however, my ant task for pre-compiling jsps is no longer working. The strange thing is that if I switch back to tomcat 7 without making any other changes the JspC call will work!

下面是Ant任务输出的错误:

Here is the error output from the ant task:


Sep 17, 2014 4:01:23 PM org.apache.jasper.servlet.TldScanner scanJars
    INFO: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
    java.lang.NullPointerException
        at org.apache.jasper.compiler.TldCache.getTaglibXml(TldCache.java:97)
        at org.apache.jasper.compiler.TagLibraryInfoImpl.(TagLibraryInfoImpl.java:179)
        at org.apache.jasper.compiler.Parser.parseTaglibDirective(Parser.java:411)
        at org.apache.jasper.compiler.Parser.parseDirective(Parser.java:469)
        at org.apache.jasper.compiler.Parser.parseElements(Parser.java:1428)
        at org.apache.jasper.compiler.Parser.parse(Parser.java:139)
        at org.apache.jasper.compiler.ParserController.doParse(ParserController.java:227)
        at org.apache.jasper.compiler.ParserController.parse(ParserController.java:100)
        at org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:199)
        at org.apache.jasper.compiler.Compiler.compile(Compiler.java:356)
        at org.apache.jasper.JspC.processFile(JspC.java:1217)
        at org.apache.jasper.JspC.execute(JspC.java:1368)
        at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
        at sun.reflect.GeneratedMethodAccessor7.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:483)
        at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
        at org.apache.tools.ant.Task.perform(Task.java:348)
        at org.apache.tools.ant.Target.execute(Target.java:435)
        at org.apache.tools.ant.Target.performTasks(Target.java:456)
        at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1393)
        at org.apache.tools.ant.Project.executeTarget(Project.java:1364)
        at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
        at org.eclipse.ant.internal.launching.remote.EclipseDefaultExecutor.executeTargets(EclipseDefaultExecutor.java:36)
        at org.apache.tools.ant.Project.executeTargets(Project.java:1248)
        at org.eclipse.ant.internal.launching.remote.InternalAntRunner.run(InternalAntRunner.java:452)
        at org.eclipse.ant.internal.launching.remote.InternalAntRunner.main(InternalAntRunner.java:139)

下面是Ant任务:

<target name="jspc-tomcat" depends="compile" description="compile jsps using tomcat jspc">
    <copy overwrite="false" file="${webxml.dir}/web.xml" tofile="web/WEB-INF/web.xml" />

    <jasper
        uriroot="web"
        outputDir="${build.dir}/JSP/src" />

    <delete file="web/WEB-INF/web.xml"/>
</target>
<target name="compile-jsps" depends="jspc-tomcat" description="compile jsps using apache tomcat">
    <mkdir dir="${build.dir}/JSP/classes"/>
    <mkdir dir="${build.dir}/JSP/lib"/>
    <javac memoryInitialSize="128m" memoryMaximumSize="512m" destdir="${build.dir}/JSP/classes"
        optimize="off" fork="true"
        debug="on" failonerror="false" source="1.8" target="1.8"
        srcdir="${build.dir}/JSP/src" includeantruntime="false"
        excludes="**/*.smap">
        <classpath>
            <fileset dir="${local.ctx1.home}/lib">
                <include name="*.jar"/>
            </fileset>
            <fileset dir="${local.ctx1.home}/bin">
                <include name="*.jar"/>
            </fileset>
            <pathelement path="${rade2.class.dir}" />
            <path refid="compile_classpath" />
        </classpath>
        <include name="**" />
        <exclude name="tags/**" />
    </javac>
</target>

我试着标签库玩,并确保它们都正确声明。到目前为止,我可以告诉大家,他们是。我无法跨preT从TldCache.java来的NullPointerException异常的原因。有没有其他可能的解决办法经历过这样或有什么想法?

I've tried playing with the taglibs and making sure they are all declared correctly. So far as I can tell, they are. I'm unable to interpret the cause of the NullPointerException coming from TldCache.java. Has anyone else experienced this or have any ideas on possible solutions?

推荐答案

我发现,我在我的WEB-INF / tags目录,这是明确排除在Ant目标定义的.TLD文件。除去Ant目标排除没有工作,让我感动的.TLD定义/ WEB-INF / JSP的。我也不得不恢复我的碧玉的taskdef,我已经改变必须从卡塔利娜-ant.xml 每页的 Apache的文档

I found that I had a .tld file defined in my WEB-INF/tags directory, which is explicitly excluded in the ant target. Removing the exclusion from the ant target did not work, so I moved the .tld definition to /WEB-INF/jsps. I also had to restore my definition of the jasper taskdef, which I had changed to be imported from catalina-ant.xml per Apache's documentation.

综上所述,从.TLD 移动WEB-INF /标签 WEB-INF / JSP的,并添加了碧玉的taskdef在蚂蚁。

In summary, moved .tld from WEB-INF/tags to WEB-INF/jsps and added a jasper taskdef in ant.

最后的Ant任务如下:

The final ant task is as follows:

<target name="jspc-tomcat" depends="compile"
 description="compile jsps using tomcat jspc">
    <copy overwrite="false" file="${webxml.dir}/web.xml"
        tofile="web/WEB-INF/web.xml" />
    <taskdef classname="org.apache.jasper.JspC" name="jasper">
        <classpath id="jspc.classpath">
            <pathelement location="${java.home}/../lib/tools.jar"/>
            <fileset dir="${local.ctx1.home}/bin">
                <include name="*.jar"/>
            </fileset>
            <fileset dir="${local.ctx1.home}/lib">
                <include name="*.jar"/>
            </fileset>
            <pathelement path="${rade2.class.dir}" />
            <path refid="compile_classpath" />
        </classpath>
    </taskdef>

    <jasper
        uriroot="web"
        outputDir="${build.dir}/JSP/src" />

    <delete file="web/WEB-INF/web.xml"/>
</target>
<target name="compile-jsps" depends="jspc-tomcat" description="compile jsps using apache tomcat">
    <mkdir dir="${build.dir}/JSP/classes"/>
    <mkdir dir="${build.dir}/JSP/lib"/>
    <javac memoryInitialSize="128m" memoryMaximumSize="512m" destdir="${build.dir}/JSP/classes"
        optimize="off" fork="true"
        debug="on" failonerror="false" source="1.8" target="1.8"
        srcdir="${build.dir}/JSP/src" includeantruntime="false"
        excludes="**/*.smap">
        <classpath>
            <fileset dir="${local.ctx1.home}/lib">
                <include name="*.jar"/>
            </fileset>
            <fileset dir="${local.ctx1.home}/bin">
                <include name="*.jar"/>
            </fileset>
            <pathelement path="${rade2.class.dir}" />
            <path refid="compile_classpath" />
        </classpath>
        <include name="**" />
        <exclude name="tags/**" />
    </javac>
</target>

这篇关于错误的Apache编译JSP的Tomcat 8.0.12的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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