简体   繁体   中英

Jakarta EE with Apache Shiro

I am using Wildfly webserver, and trying to implement Apache Shiro within Jakarta EE application, unfortunately I am getting this error:

16:49:36,189 ERROR [org.jboss.as.controller.management-operation] (management-handler-thread - 1) WFLYCTL0013: Operation ("deploy") failed - address: ([("deployment" => "testjee8-1.0-SNAPSHOT")]) - failure description: {"WFLYCTL0080: Failed services" => {"jboss.deployment.unit.\"testjee8-1.0-SNAPSHOT.war\".undertow-deployment.UndertowDeploymentInfoService" => "Failed to start service
    Caused by: java.lang.NoClassDefFoundError: Failed to link org/apache/shiro/web/servlet/ShiroFilter (Module \"deployment.testjee8-1.0-SNAPSHOT.war\" from Service Module Loader): Failed to link org/apache/shiro/web/servlet/AbstractShiroFilter (Module \"deployment.testjee8-1.0-SNAPSHOT.war\" from Service Module Loader): Failed to link org/apache/shiro/web/servlet/OncePerRequestFilter (Module \"deployment.testjee8-1.0-SNAPSHOT.war\" from Service Module Loader): Failed to link org/apache/shiro/web/servlet/NameableFilter (Module \"deployment.testjee8-1.0-SNAPSHOT.war\" from Service Module Loader): Failed to link org/apache/shiro/web/servlet/AbstractFilter (Module \"deployment.testjee8-1.0-SNAPSHOT.war\" from Service Module Loader): javax/servlet/Filter"}}
16:49:36,190 ERROR [org.jboss.as.controller.management-operation] (management-handler-thread - 1) WFLYCTL0013: Operation ("deploy") failed - address: ([("deployment" => "testjee8-1.0-SNAPSHOT")]) - failure description: {"WFLYCTL0080: Failed services" => {"jboss.deployment.unit.\"testjee8-1.0-SNAPSHOT.war\".undertow-deployment.UndertowDeploymentInfoService" => "Failed to start service
    Caused by: java.lang.NoClassDefFoundError: Failed to link org/apache/shiro/web/servlet/ShiroFilter (Module \"deployment.testjee8-1.0-SNAPSHOT.war\" from Service Module Loader): Failed to link org/apache/shiro/web/servlet/AbstractShiroFilter (Module \"deployment.testjee8-1.0-SNAPSHOT.war\" from Service Module Loader): Failed to link org/apache/shiro/web/servlet/OncePerRequestFilter (Module \"deployment.testjee8-1.0-SNAPSHOT.war\" from Service Module Loader): Failed to link org/apache/shiro/web/servlet/NameableFilter (Module \"deployment.testjee8-1.0-SNAPSHOT.war\" from Service Module Loader): Failed to link org/apache/shiro/web/servlet/AbstractFilter (Module \"deployment.testjee8-1.0-SNAPSHOT.war\" from Service Module Loader): javax/servlet/Filter"}}
16:49:36,190 ERROR [org.jboss.as.server] (management-handler-thread - 1) WFLYSRV0021: Deploy of deployment "testjee8-1.0-SNAPSHOT.war" was rolled back with the following failure message: 
{"WFLYCTL0080: Failed services" => {"jboss.deployment.unit.\"testjee8-1.0-SNAPSHOT.war\".undertow-deployment.UndertowDeploymentInfoService" => "Failed to start service
    Caused by: java.lang.NoClassDefFoundError: Failed to link org/apache/shiro/web/servlet/ShiroFilter (Module \"deployment.testjee8-1.0-SNAPSHOT.war\" from Service Module Loader): Failed to link org/apache/shiro/web/servlet/AbstractShiroFilter (Module \"deployment.testjee8-1.0-SNAPSHOT.war\" from Service Module Loader): Failed to link org/apache/shiro/web/servlet/OncePerRequestFilter (Module \"deployment.testjee8-1.0-SNAPSHOT.war\" from Service Module Loader): Failed to link org/apache/shiro/web/servlet/NameableFilter (Module \"deployment.testjee8-1.0-SNAPSHOT.war\" from Service Module Loader): Failed to link org/apache/shiro/web/servlet/AbstractFilter (Module \"deployment.testjee8-1.0-SNAPSHOT.war\" from Service Module Loader): javax/servlet/Filter"}}
16:49:36,214 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-3) WFLYSRV0028: Stopped deployment testjee8-1.0-SNAPSHOT (runtime-name: testjee8-1.0-SNAPSHOT.war) in 23ms
[2023-01-02 04:49:36,249] Artifact testjee8:war exploded: Error during artifact deployment. See server log for details.
[2023-01-02 04:49:36,250] Artifact testjee8:war exploded: java.lang.Exception: {"WFLYCTL0080: Failed services" => {"jboss.deployment.unit.\"testjee8-1.0-SNAPSHOT.war\".undertow-deployment.UndertowDeploymentInfoService" => "Failed to start service
    Caused by: java.lang.NoClassDefFoundError: Failed to link org/apache/shiro/web/servlet/ShiroFilter (Module \"deployment.testjee8-1.0-SNAPSHOT.war\" from Service Module Loader): Failed to link org/apache/shiro/web/servlet/AbstractShiroFilter (Module \"deployment.testjee8-1.0-SNAPSHOT.war\" from Service Module Loader): Failed to link org/apache/shiro/web/servlet/OncePerRequestFilter (Module \"deployment.testjee8-1.0-SNAPSHOT.war\" from Service Module Loader): Failed to link org/apache/shiro/web/servlet/NameableFilter (Module \"deployment.testjee8-1.0-SNAPSHOT.war\" from Service Module Loader): Failed to link org/apache/shiro/web/servlet/AbstractFilter (Module \"deployment.testjee8-1.0-SNAPSHOT.war\" from Service Module Loader): javax/servlet/Filter"}}

looks like the class is not found...

The following web.xml and shiro.ini (placed in WEB-INF) as follows:

web.xml:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="https://jakarta.ee/xml/ns/jakartaee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee https://jakarta.ee/xml/ns/jakartaee/web-app_5_0.xsd"
         version="5.0">
    <context-param>
        <param-name>shiroConfigLocations</param-name>
        <param-value>/WEB-INF/shiro.ini</param-value>
    </context-param>

    <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>
</web-app>

Shiro.ini:

[main]


[urls]
/** = noSessionCreation,authcJWT[permissive]

Forgot to add the pom.xml:

...
<dependency>
    <groupId>org.apache.shiro</groupId>
    <artifactId>shiro-web</artifactId>
    <version>1.10.0</version>
 </dependency>
...

Please help me how to address this issue!

Unfortunately, Apache Shiro is not compatible with Jarkarta namespace yet. According to Apache Shiro's [publication]: https://shiro.apache.org/blog/2022/06/30/jakarta-work.html , version 1.10.0 of Shiro was supposed to be shipped with jakarta but unfortunately as of this writing their latest version, being 1.10.1, does not come with the jakarta namespace yet.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM