NutzCN Logo
问答 加入Shiro listener,配置后启动失败
发布于 85天前 作者 nidegexing 96 次浏览 复制 上一个帖子 下一个帖子
标签:

根据教程加入shiro一章,引入了需要的jar包,增加web.xml中shiro的配置后,就无法启动了。
引入的jar包
commons-beanutils-1.9.3.jar
commons-logging-1.2.jar
druid-1.0.26.jar
log4j-1.2.17.jar
mysql-connector-java-5.1.40.jar
nutz-1.r.59.jar
nutz-integration-shiro-1.r.60.r2.jar
shiro-all-1.3.2.jar
slf4j-api-1.7.24.jar
slf4j-log4j12-1.7.24.jar
web.xml配置

<display-name>mybook</display-name>

    <!--加入Shiro-->
    <listener>
        <listener-class>org.apache.shiro.web.env.EnvironmentLoaderListener</listener-class>
    </listener>
    <filter>
        <filter-name>ShiroFilter</filter-name>
        <filter-class>org.apache.shiro.web.servlet.ShiroFilter</filter-class>
    </filter>
    <filter-mapping>
        <filter-name>ShiroFilter</filter-name>
        <url-pattern>/*</url-pattern>
        <dispatcher>REQUEST</dispatcher>
        <dispatcher>FORWARD</dispatcher>
        <dispatcher>INCLUDE</dispatcher>
        <dispatcher>ERROR</dispatcher>
    </filter-mapping>

    <filter>
        <filter-name>DruidWebStatFilter</filter-name>
        <filter-class>com.alibaba.druid.support.http.WebStatFilter</filter-class>
        <init-param>
            <param-name>exclusions</param-name>
            <param-value>*.js,*.gif,*.jpg,*.png,*.css,*.ico,/druid/*,/rs/*</param-value>
        </init-param>
    </filter>
    <filter-mapping>
        <filter-name>DruidWebStatFilter</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>

    <filter>
        <filter-name>nutz</filter-name>
        <filter-class>org.nutz.mvc.NutFilter</filter-class>
        <init-param>
            <param-name>modules</param-name>
            <param-value>net.wendal.nutzbook.MainModule</param-value>
        </init-param>
        <!--/druid或/rs下的路径,就无条件跳过NutFilter-->
        <init-param>
            <param-name>exclusions</param-name>
            <param-value>/rs/*,/druid/*</param-value>
        </init-param>
    </filter>
    <filter-mapping>
        <filter-name>nutz</filter-name>
        <url-pattern>/*</url-pattern>
        <!-- ForwardView需要下面的配置 @Ok("->:/xxx/yyy/zzz") -->
        <dispatcher>REQUEST</dispatcher>
        <dispatcher>FORWARD</dispatcher>
        <dispatcher>INCLUDE</dispatcher>
    </filter-mapping>

    <welcome-file-list>
        <welcome-file>index.html</welcome-file>
        <welcome-file>index.htm</welcome-file>
        <welcome-file>index.jsp</welcome-file>
        <welcome-file>default.html</welcome-file>
        <welcome-file>default.htm</welcome-file>
        <welcome-file>default.jsp</welcome-file>
    </welcome-file-list>

    <servlet>
        <servlet-name>DruidStatView</servlet-name>
        <servlet-class>com.alibaba.druid.support.http.StatViewServlet</servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>DruidStatView</servlet-name>
        <url-pattern>/druid/*</url-pattern>
    </servlet-mapping>

    <!--配置默认的错误页面-->
    <error-page>
        <error-code>500</error-code>
        <location>/WEB-INF/jsp/500.jsp</location>
    </error-page>

启动报错日志

28-Feb-2017 09:16:46.879 信息 [RMI TCP Connection(5)-127.0.0.1] org.apache.jasper.servlet.TldScanner.scanJars 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.
28-Feb-2017 09:16:46.926 严重 [RMI TCP Connection(5)-127.0.0.1] org.apache.catalina.core.StandardContext.startInternal One or more listeners failed to start. Full details will be found in the appropriate container log file
28-Feb-2017 09:16:46.926 严重 [RMI TCP Connection(5)-127.0.0.1] org.apache.catalina.core.StandardContext.startInternal Context [/nutzbook] startup failed due to previous errors
[2017-02-28 09:16:46,988] Artifact mybook:war exploded: Error during artifact deployment. See server log for details.
28-Feb-2017 09:16:53.320 信息 [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory D:\apache-tomcat-8.0.39\webapps\manager
28-Feb-2017 09:16:53.648 信息 [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory D:\apache-tomcat-8.0.39\webapps\manager has finished in 328 ms
28-Feb-2017 09:19:34.261 信息 [ContainerBackgroundProcessor[StandardEngine[Catalina]]] org.apache.catalina.startup.HostConfig.undeploy Undeploying context [/nutzbook]
28-Feb-2017 09:19:34.293 信息 [localhost-startStop-2] org.apache.catalina.startup.HostConfig.deployDescriptor Deploying configuration descriptor C:\Users\w_yusys2\.IntelliJIdea2016.2\system\tomcat\Unnamed_nutz\conf\Catalina\localhost\nutzbook.xml
28-Feb-2017 09:19:34.308 严重 [localhost-startStop-2] org.apache.catalina.core.ContainerBase.addChildInternal ContainerBase.addChild: start: 
 org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/nutzbook]]
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:162)
	at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:753)
	at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:729)
	at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:717)
	at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:587)
	at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1798)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at java.lang.Thread.run(Thread.java:745)
Caused by: org.apache.catalina.LifecycleException: Failed to start component [org.apache.catalina.webresources.StandardRoot@73d0d460]
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:162)
	at org.apache.catalina.core.StandardContext.resourcesStart(StandardContext.java:4969)
	at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5099)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
	... 10 more
Caused by: java.lang.IllegalArgumentException: The main resource set specified [C:\Programer\IDEAProjects\nutz\out\artifacts\mybook_war_exploded] is not valid
	at org.apache.catalina.webresources.StandardRoot.createMainResourceSet(StandardRoot.java:730)
	at org.apache.catalina.webresources.StandardRoot.startInternal(StandardRoot.java:688)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
	... 13 more
4 回复

http://stackoverflow.com/questions/25595104/java-lang-illegalargumentexception-the-main-resource-set-specified-is-not

I had this error when I was starting an application that was designed for Tomcat 8 using Tomcat 7.

tomcat版本问题???

我的tomcat是8.0.39。
slf4j的版本高了一点,应该不影响的吧。我找低版本试试

应该不是slf4j的问题吧, web.xml里面, 把shiro相关的去掉的, 能启动吗? clean 重新编译一次试试

idea,Artifacts中,依赖的lib报错了,修复后就可以了。多谢。

添加回复
请先登陆
回到顶部