Hassan Shaitou
Hassan Shaitou

Reputation: 55

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!

Upvotes: 1

Views: 1905

Answers (3)

Gyula K.
Gyula K.

Reputation: 81

Shiro supports jakarta since version 1.10.0

You have to define the dependecies with the jakarta classifier.

For instance this is what I used to make it work with gradle and spring boot 3.x.

implementation("org.apache.shiro:shiro-spring-boot-starter:${versions.shiro}:jakarta") {
    // has to be excluded to get replaced by the jars with 'jakarta' classifier
    exclude group: 'org.apache.shiro', module: 'shiro-spring' 
}
implementation("org.apache.shiro:shiro-spring:${versions.shiro}:jakarta")
implementation("org.apache.shiro:shiro-web:${versions.shiro}:jakarta")

The pom.xml version should look something like this:

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

Upvotes: 1

Lenny Primak
Lenny Primak

Reputation: 1

Jakarta EE module has been released as part of Shiro 2.0.0-alpha-1 This includes Jakarta namespace and JPMS. See https://shiro.apache.org/jakarta-ee.html Shiro 1.11.x (latest) also has Jakarta artifacts (with jakarta classifiers) that makes it compatible with jakarta namespace

Upvotes: 0

Tejumola Mann
Tejumola Mann

Reputation: 36

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.

Upvotes: 1

Related Questions