java.lang.NoSuchMethodError:带有jsp支持的嵌入式码头的javax.servlet.jsp.tagext.TagAttributeInfo [英] java.lang.NoSuchMethodError: javax.servlet.jsp.tagext.TagAttributeInfo with embedded jetty with jsp support

查看:434
本文介绍了java.lang.NoSuchMethodError:带有jsp支持的嵌入式码头的javax.servlet.jsp.tagext.TagAttributeInfo的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在此处

Per instructions found in here embedded jetty unable to parse web.xml when jsp jars present in classpath I put together the following startup code to launch jetty with jsp support in embedded mode but still having no luck. I'm gettign the following error, full stack provided farther below:

java.lang.NoSuchMethodError: javax.servlet.jsp.tagext.TagAttributeInfo.<init>(Ljava/lang/String;ZLjava/lang/String;ZZLjava/lang/String;ZZLjava/lang/String;Ljava/lang/String;)V

所讨论的类javax.servlet.jsp.tagext.TagAttributeInfo在org.mortbay.jasper.apache-jsp-8.0.9.M3.jar中定义.出于其他原因,也需要此jar来引入JasperInitializer类(JettyJasperInitializer的超类).

The class in question, javax.servlet.jsp.tagext.TagAttributeInfo, is defined in org.mortbay.jasper.apache-jsp-8.0.9.M3.jar. This jar is also required for other reason, to bring in the class JasperInitializer, superclass of JettyJasperInitializer.

我怀疑码头9.2.10.v20150310不建议使用org.mortbay.jasper.apache-jsp-8.0.9.M3.jar罐子.如果是这样,还有什么选择? 我应该获得org.apache.jasper.servlet.JasperInitializer和javax.servlet.jsp.tagext.TagAttributeInfo吗?

I'm suspecting that using the jar org.mortbay.jasper.apache-jsp-8.0.9.M3.jar is not recommended for jetty 9.2.10.v20150310. If so - what's the alternative? Wher should I get org.apache.jasper.servlet.JasperInitializer and javax.servlet.jsp.tagext.TagAttributeInfo?

java.lang.NoSuchMethodError: javax.servlet.jsp.tagext.TagAttributeInfo.<init>(Ljava/lang/String;ZLjava/lang/String;ZZLjava/lang/String;ZZLjava/lang/String;Ljava/lang/String;)V
at org.apache.tomcat.util.descriptor.tld.TldRuleSet$Attribute.toTagAttributeInfo(TldRuleSet.java:272)
at org.apache.tomcat.util.descriptor.tld.TldRuleSet$TagAttributeRule.end(TldRuleSet.java:150)
at org.apache.tomcat.util.digester.Digester.endElement(Digester.java:959)
at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown Source)
at org.apache.xerces.impl.dtd.XMLNSDTDValidator.endNamespaceScope(Unknown Source)
at org.apache.xerces.impl.dtd.XMLDTDValidator.handleEndElement(Unknown Source)
at org.apache.xerces.impl.dtd.XMLDTDValidator.endElement(Unknown Source)
at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanEndElement(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
at org.apache.tomcat.util.digester.Digester.parse(Digester.java:1457)
at org.apache.tomcat.util.descriptor.tld.TldParser.parse(TldParser.java:76)
at org.apache.jasper.servlet.TldScanner.parseTld(TldScanner.java:257)
at org.apache.jasper.servlet.TldPreScanned.scanJars(TldPreScanned.java:46)
at org.apache.jasper.servlet.TldScanner.scan(TldScanner.java:99)
at org.apache.jasper.servlet.JasperInitializer.onStartup(JasperInitializer.java:103)
at org.eclipse.jetty.plus.annotation.ContainerInitializer.callStartup(ContainerInitializer.java:140)
at org.eclipse.jetty.annotations.ServletContainerInitializersStarter.doStart(ServletContainerInitializersStarter.java:65)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:274)
at org.eclipse.jetty.webapp.WebAppContext.startWebapp(WebAppContext.java:1349)
at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1342)
at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:741)
at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:505)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:132)
at org.eclipse.jetty.server.Server.start(Server.java:387)
at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:114)
at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:61)
at org.eclipse.jetty.server.Server.doStart(Server.java:354)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
at webappdev.JettyWebAppTest.init(JettyWebAppTest.java:140)
at webappdev.JettyWebAppTest.main(JettyWebAppTest.java:148)

我的启动代码:

 public static void main(String[] args) throws Exception
 {
    JettyWebAppTest thiss = new JettyWebAppTest();
    thiss.init();
 }


private void init() throws Exception {

    System.setProperty("java.io.tmpdir", "/tmp/bolek");
    System.setProperty("org.apache.jasper.compiler.disablejsr199", "false");
    Server server = new Server(8080);

    WebAppContext context = new WebAppContext();

    context.setResourceBase(<myresourcebase>);
    context.setDescriptor("/WEB-INF/web.xml");

    context.setContextPath("/");
    context.setParentLoaderPriority(false);
    context.setAttribute(
     "org.eclipse.jetty.server.webapp.ContainerIncludeJarPattern",
       ".*/[^/]*servlet-api-[^/]*\\.jar$|.*/javax.servlet.jsp.jstl-.*\\.jar$|.*/.*taglibs.*\\.jar$");


    context.setAttribute("javax.servlet.context.tempdir", 
            System.getProperty("java.io.tmpdir"));

    context.setAttribute("org.eclipse.jetty.containerInitializers",
         this.jspInitializers());
    context.setAttribute(InstanceManager.class.getName(),
            new SimpleInstanceManager());
    context.addBean(new ServletContainerInitializersStarter(context),
          true);

    context.setClassLoader(this.getUrlClassLoader());

    context.addServlet(this.jspServletHolder(), "*.jsp");


    server.setHandler(context);

    server.start();
    server.join();      
 }


 private ServletHolder defaultServletHolder(URI baseUri)
{
    ServletHolder holderDefault = new ServletHolder("default",
          DefaultServlet.class);

    holderDefault.setInitParameter("resourceBase", 
        baseUri.toASCIIString());
    holderDefault.setInitParameter("dirAllowed", "true");
    return holderDefault;
}


 private List<ContainerInitializer> jspInitializers()
 {
    JettyJasperInitializer sci = new JettyJasperInitializer();
    ServletContainerInitializer scii;
    scii = (ServletContainerInitializer)sci;

    ContainerInitializer initializer = new ContainerInitializer(scii, null);
    List<ContainerInitializer> initializers = new ArrayList<ContainerInitializer>();
    initializers.add(initializer);
    return initializers;
 }


 private ClassLoader getUrlClassLoader()
 {
    ClassLoader jspClassLoader = new URLClassLoader(new URL[0], this.getClass().getClassLoader());
    return jspClassLoader;
 }




private ServletHolder jspServletHolder()
{
    ServletHolder holderJsp = new ServletHolder("jsp", JettyJspServlet.class);
    holderJsp.setInitOrder(0);
    holderJsp.setInitParameter("logVerbosityLevel", "DEBUG");
    holderJsp.setInitParameter("fork", "false");
    holderJsp.setInitParameter("xpoweredBy", "false");
    holderJsp.setInitParameter("compilerTargetVM", "1.7");
    holderJsp.setInitParameter("compilerSourceVM", "1.7");
    holderJsp.setInitParameter("keepgenerated", "true");
    return holderJsp;
}

web.xml:

<?xml version="1.0" encoding="UTF-8"?>
<web-app 
xmlns="http://java.sun.com/xml/ns/javaee" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">
 <welcome-file-list>
  <welcome-file>index.jsp</welcome-file>
 </welcome-file-list>
</web-app>

推荐答案

您的jar冲突.

发行版lib/jsp中的文件用于JSP的Glassfish实现.

The files in the distro's lib/jsp are for the Glassfish Implementation of JSP.

Glassfish实施现在已被弃用(由于大量的错误且缺乏实施者的更新),并且在即将发布的Jetty 9.3版本中已将其完全删除.

The Glassfish Implementation is now deprecated (due to amount of bugs and lack up updates from the implementors), and has been fully removed in the upcoming Jetty 9.3 release.

不要在您的项目中包含这些Glassfish实施罐.

Do not include these Glassfish Implementation jars with your project.

仅使用发行版的lib/apache-jsp/目录中的4个jar,这是Apache Jasper JSP实现.

Only use the 4 jars in the distro's lib/apache-jsp/ directory, this is the Apache Jasper JSP implementation.

Apache Jasper JSP实施得到完全支持,稳定,最新,并拥有活跃而健康的社区和开发人员基础.

The Apache Jasper JSP implementation is fully supported, stable, up to date, and has an active and healthy community and developer base.

这篇关于java.lang.NoSuchMethodError:带有jsp支持的嵌入式码头的javax.servlet.jsp.tagext.TagAttributeInfo的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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