Can you share your pom, the command you use to run, and any shiro integration code? My first guess would be that you need slf4j libs on your classpath.
Thanks, Jared James Whetstone <[email protected]> wrote: I've built an example web app using maven that is dying during initialization and I can't figure out how to address the error. I'm using jetty 7.4.2 and Shiro 1.1.0. My example app is using jetty embedded. My project compiles but when I try to run it, I get some errors: 2011-07-09 00:38:26.390:INFO::jetty-7.4.2.v20110526 2011-07-09 00:38:26.577:INFO::NO JSP Support for /, did not find org.apache.jasper.servlet.JspServlet 2011-07-09 00:38:26.624:INFO::started o.e.j.w.WebAppContext{/,file:/C:/JettyMavenHelloWarApp/src/main/webapp/} 2011-07-09 00:38:26.640:WARN::FAILED ShiroFilter: java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory 2011-07-09 00:38:26.640:WARN::FAILED o.e.j.w.WebAppContext{/,file:/C:/JettyMavenHelloWarApp/src/main/webapp/}: java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory 2011-07-09 00:38:26.640:WARN::FAILED org.eclipse.jetty.server.handler.HandlerList@1b70f9e: java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory 2011-07-09 00:38:26.765:INFO::Started [email protected]:80 STARTING 2011-07-09 00:38:27.140:INFO::Started [email protected]:443 STARTING 2011-07-09 00:38:27.155:WARN::FAILED org.eclipse.jetty.server.Server@739aa3: java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 3.422s [INFO] Finished at: Sat Jul 09 00:38:27 PDT 2011 [INFO] Final Memory: 7M/17M [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.1:java (default-cli) on project hello-world: An exception occured while executing the Java class. null: InvocationTargetException: org/slf4j/ LoggerFactory: org.slf4j.LoggerFactory -> [Help 1] Here is the contents of my pom.xml file: <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>org.example</groupId> <artifactId>hello-world</artifactId> <version>0.1-SNAPSHOT</version> <packaging>jar</packaging> <name>Jetty HelloWorld</name> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <jettyVersion>7.4.2.v20110526</jettyVersion> <slf4j.version>1.6.1</slf4j.version> </properties> <dependencies> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId> <version>${slf4j.version}</version> <scope>runtime</scope> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-simple</artifactId> <version>${slf4j.version}</version> <scope>runtime</scope> </dependency> <dependency> <groupId>org.apache.shiro</groupId> <artifactId>shiro-core</artifactId> <version>1.1.0</version> </dependency> <dependency> <groupId>org.apache.shiro</groupId> <artifactId>shiro-web</artifactId> <version>1.1.0</version> </dependency> <dependency> <groupId>org.eclipse.jetty</groupId> <artifactId>jetty-server</artifactId> <version>${jettyVersion}</version> </dependency> <dependency> <groupId>org.eclipse.jetty</groupId> <artifactId>jetty-webapp</artifactId> <version>${jettyVersion}</version> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>exec-maven-plugin</artifactId> <version>1.1</version> <executions> <execution><goals><goal>java</goal></goals></execution> </executions> <configuration> <mainClass>org.example.AppServer</mainClass> </configuration> </plugin> </plugins> </build> </project> and here is my web.xml file: <?xml version="1.0" encoding="ISO-8859-1"?> <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_2_5.xsd" version="2.5"> <servlet> <servlet-name>Hello</servlet-name> <servlet-class>org.example.HelloServlet</servlet-class> </servlet> <servlet> <servlet-name>Login</servlet-name> <servlet-class>org.example.LoginServlet</servlet-class> </servlet> <servlet> <servlet-name>Recovery</servlet-name> <servlet-class>org.example.RecoveryServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>Hello</servlet-name> <url-pattern>/hello/*</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>Login</servlet-name> <url-pattern>/login</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>Recovery</servlet-name> <url-pattern>/recovery</url-pattern> </servlet-mapping> <filter> <filter-name>ShiroFilter</filter-name> <filter-class>org.apache.shiro.web.servlet.IniShiroFilter</filter-class> <init-param> <param-name>config</param-name> <param-value> # The IniShiroFilter configuration is very powerful and flexible, while still remaining succinct. # Please read the org.apache.shiro.web.servlet.IniShiroFilter JavaDoc for information. # Quick Tip: Instead of having this configuration here in web.xml, you can instead # move all of this to a 'shiro.ini' file at the root of the classpath and remove # the 'config' init-param. Or you can specify the 'configPath' init-param and specify the # path to a resource at any location (url, file or classpath). This may be desired if the # config gets long and you want to keep web.xml clean. [users] # format: username = password, role1, role2, ..., roleN root = secret,admin guest = guest,guest presidentskroob = 12345,president darkhelmet = ludicrousspeed,darklord,schwartz lonestarr = vespa,goodguy,schwartz [roles] # format; roleName = permission1, permission2, ..., permissionN admin = * schwartz = lightsaber:* goodguy = winnebago:drive:eagle5 [filters] shiro.loginUrl = /index.html [urls] # The /login is not restricted to authenticated users (otherwise no one could log in!), but # the 'authc' filter must still be specified for it so it can process that url's # login submissions. It is 'smart' enough to allow those requests through as specified by the # shiro.loginUrl above. /index.html = authc /account/** = authc /remoting/** = authc, roles[b2bClient], perms["remote:invoke:lan,wan"] </param-value> </init-param> </filter> <filter-mapping> <filter-name>ShiroFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> </web-app> Lastly, here is my main java file "AppServer.java": package org.example; import org.eclipse.jetty.http.ssl.SslContextFactory; import org.eclipse.jetty.server.Connector; import org.eclipse.jetty.server.Handler; import org.eclipse.jetty.server.Server; import org.eclipse.jetty.server.handler.DefaultHandler; import org.eclipse.jetty.server.handler.HandlerList; import org.eclipse.jetty.server.handler.ResourceHandler; import org.eclipse.jetty.server.nio.SelectChannelConnector; import org.eclipse.jetty.server.ssl.SslSelectChannelConnector; import org.eclipse.jetty.webapp.WebAppContext; public class AppServer { public static void main(String[] args) throws Exception { Server server = new Server(); SelectChannelConnector connector0 = new SelectChannelConnector(); connector0.setPort(80); connector0.setMaxIdleTime(30000); connector0.setRequestHeaderSize(8192); SslSelectChannelConnector ssl_connector = new SslSelectChannelConnector(); String jetty_home = System.getProperty("jetty.home","C:/jetty-hightide-7.4.2.v20110526"); System.setProperty("jetty.home",jetty_home); ssl_connector.setPort(443); SslContextFactory cf = ssl_connector.getSslContextFactory(); cf.setKeyStore(jetty_home + "/etc/keystore"); cf.setKeyStorePassword("OBF:1vny1zlo1x8e1vnw1vn61x8g1zlu1vn4"); cf.setKeyManagerPassword("OBF:1u2u1wml1z7s1z7a1wnl1u2g"); server.setConnectors(new Connector[]{ connector0, ssl_connector }); WebAppContext context = new WebAppContext(); context.setDescriptor("/WEB-INF/web.xml"); context.setResourceBase("../JettyMavenHelloWarApp/src/main/webapp"); context.setContextPath("/"); context.setParentLoaderPriority(true); context.setInitParameter("cacheControl","max-age=0,public"); ResourceHandler resource_handler = new ResourceHandler(); resource_handler.setDirectoriesListed(true); resource_handler.setWelcomeFiles(new String[]{ "index.html" }); resource_handler.setResourceBase("."); resource_handler.setCacheControl("max-age=0,public"); HandlerList handlers = new HandlerList(); handlers.setHandlers(new Handler[] { context, resource_handler, new DefaultHandler()}); server.setHandler(handlers); server.start(); server.join(); } } I've tried just about everything I can think of to fix this issue, but nothing has worked so far. ---James
