I've never seen someone configure Jetty manually instead of using the 
maven-jetty-plugin. My guess would be there's some disconnect there. Have you 
tried using that instead of your AppServer class and the exec-maven-plugin? The 
only other thing I can think of is to try setting the scope for the slf4j 
dependencies to compile, just to see if that helps them get picked up.
 
In case you'd like to try the maven-jetty-plugin, here's how ours is configured:
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.mortbay.jetty</groupId>
                        <artifactId>maven-jetty-plugin</artifactId>
                        <version>${jetty.version}</version>
                        <configuration>
                            <contextPath>/</contextPath>
                            <connectors>
                                <connector 
implementation="org.mortbay.jetty.nio.SelectChannelConnector">
                                    <port>8080</port>
                                    <maxIdleTime>60000</maxIdleTime>
                                </connector>
                            </connectors>
                            <requestLog 
implementation="org.mortbay.jetty.NCSARequestLog">
                                
<filename>./target/yyyy_mm_dd.request.log</filename>
                                <retainDays>90</retainDays>
                                <append>true</append>
                                <extended>false</extended>
                                <logTimeZone>GMT</logTimeZone>
                            </requestLog>
                        </configuration>
                    </plugin>
                </plugins>
            </build>

 This plugin would be configured in the same Maven module that builds your 
webapp's .war file. You can use its configuration to configure the 
SelectChannelConnector to be on 80 (we run ours on 8080 under development) and 
add the SslSelectChannelConnector. The runtime dependencies on slf4j-api and 
slf4j-simple would be in that module as well. You should then be able to run 
your webapp using mvn jetty:run, or mvn jetty:run-war or mvn jetty:run-exploded 
depending on how much packaging you want done.
 
Full documentation is here: 
http://docs.codehaus.org/display/JETTY/Maven+Jetty+Plugin. You can also 
download the Apache Shiro source, and there is a simple web sample which uses 
the maven-jetty-plugin to run.
 
Hope this helps,
Bryan Turner
Katasoft, Inc
> From: [email protected]
> To: [email protected]
> Subject: Re: Runtime error in web app
> Date: Sat, 9 Jul 2011 08:39:44 -0700
> 
> OK, I'll take a closer look at jetty.
> 
> ---James
> 
> ----- Original Message ----- 
> From: "Jared Bunting" <[email protected]>
> To: <[email protected]>
> Sent: Saturday, July 09, 2011 8:31 AM
> Subject: Re: Runtime error in web app
> 
> 
> > So you did.  Sorry, guess I didn't get down that far.  Well, while it
> > looks to me like you have the slf4j jars on your classpath, for some
> > reason they're not getting seen.  I don't know why that would be.  It
> > seems that the exec-maven-plugin should handle that properly, so I
> > imagine that it's something related to Jetty's classloader handling for
> > webapps.  Unfortunately, I'm not overly versed in that.  So, I'd say
> > that's where you should start looking.
> >
> > On 07/09/2011 09:55 AM, James Whetstone wrote:
> >> So I put the contents of my pom.xml file and my web.xml and my 
> >> application
> >> in this posting.  You just gotta scroll down (a lot).
> >>
> >> One thing I didn't post was the command I'm using to compile and run my 
> >> app
> >> which is the following:
> >>
> >> mvn clean compile exec:java
> >>
> >> ---James
> >>
> >>
> >> ----- Original Message -----
> >> From: "Jared Bunting" <[email protected]>
> >> To: <[email protected]>
> >> Sent: Saturday, July 09, 2011 4:13 AM
> >> Subject: Re: Runtime error in web app
> >>
> >>
> >>> 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
> >>>
> >>>
> >>>
> >
> > 
> 

                                          

Reply via email to