Results 1 to 2 of 2

Thread: Jetty's Deployers not loaded

  1. #1
    Join Date
    Mar 2009
    Posts
    2

    Default Jetty's Deployers not loaded

    I am trying to get the default Jetty configuration running under Spring. Via trace statements in the Jetty ContextDeployer and WebAppDeployer classes, I can see that they are not created by Spring when the Jetty Server and other classes are created and the Server started; they are the only ones wired in part using MethodInvokingFactoryBean. The Spring example on the jetty site does not include these classes, which are normally part of the default Jetty setup, so I wonder if others have blocked on this.

    It seems like a good problem to learn from, in that no error is reported but the expected behavior does not occur.

    The initial Spring context file came from here [sorry, can't post a url on my 1st post here]:

    cf. stehno blog entry 145

    Here is my current incarnation, which also starts Jetty without instantiating the deployers] (I think it may be a little easier to read, in that there are no forward references). First the Server bean is created, then the deployers are created with reference to the server's ContextHandlerCollection and are stitched in using MethodInvokingFactoryBean to call Server.addLifeCycle():

    [will add xml on followup, I keep getting this error no matter what I do to it: 1. You are only allowed to post URLs to other sites after you have made 1 post or more.]

    The actual program looks like this:

    public static void main(String[] args)
    throws Exception
    {
    Resource config=Resource.newResource(args.length==1?args[0]:"spring/etc/jetty-spring.xml");
    XmlBeanFactory bf = new XmlBeanFactory(new UrlResource(config.getURL()));
    /*
    ---this gets a deployer created, but it doesn't get it working to deploy my .war:---
    WebAppDeployer wad = (WebAppDeployer)
    bf.getBean("server.WebAppDeployer");
    */
    Server server = (Server) bf.getBean(args.length==2?args[1]:"Server");
    server.start();
    server.join();
    }

  2. #2
    Join Date
    Mar 2009
    Posts
    2

    Default Spring context file added

    Here is my xml:

    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">

    <bean id="Server" class="org.mortbay.jetty.Server" destroy-method="stop">
    <property name="threadPool">
    <bean class="org.mortbay.thread.QueuedThreadPool">
    <property name="maxThreads" value="100" />
    </bean>
    </property>
    <property name="connectors">
    <list>
    <bean class="org.mortbay.jetty.nio.SelectChannelConnecto r">
    <property name="port" value="8081" />
    <property name="maxIdleTime" value="30000" />
    </bean>
    </list>
    </property>
    <property name="handler">
    <bean class="org.mortbay.jetty.handler.HandlerCollection ">
    <property name="handlers">
    <list>
    <bean id="server.Contexts" class="org.mortbay.jetty.handler.ContextHandlerCol lection" />
    <bean class="org.mortbay.jetty.handler.DefaultHandler" />
    <bean class="org.mortbay.jetty.handler.RequestLogHandler ">
    <property name="requestLog">
    <bean class="org.mortbay.jetty.NCSARequestLog">
    <constructor-arg value="cfg/logs/jetty-yyyy_mm_dd.log" />
    <property name="extended" value="false"/>
    </bean>
    </property>
    </bean>
    </list>
    </property>
    </bean>
    </property>

    <property name="userRealms">
    <list>
    <bean class="org.mortbay.jetty.security.HashUserRealm">
    <property name="name" value="Test Realm" />
    <property name="config" value="cfg/etc/realm.properties" />
    </bean>
    </list>
    </property>

    <property name="stopAtShutdown" value="true" />
    <property name="sendServerVersion" value="true"/>
    </bean>


    <bean id="server.ContextDeployer" class="org.mortbay.jetty.deployer.ContextDeployer" >
    <property name="contexts" ref="server.Contexts" />
    <property name="configurationDir">
    <bean class="org.mortbay.resource.FileResource">
    <constructor-arg value="file://./cfg/contexts" />
    </bean>
    </property>
    <property name="scanInterval" value="1" />
    </bean>
    <!-- call Server.addLifeCycle() to add to server bean -->
    <bean class="org.springframework.beans.factory.config.Me thodInvokingFactoryBean">
    <property name="targetObject" ref="Server" />
    <property name="targetMethod" value="addLifeCycle" />
    <property name="arguments">
    <list><ref local="server.ContextDeployer" /></list>
    </property>
    </bean>


    <bean id="server.WebAppDeployer" class="org.mortbay.jetty.deployer.WebAppDeployer">
    <property name="contexts" ref="server.Contexts" />
    <property name="webAppDir" value="cfg/webapps" />
    <property name="parentLoaderPriority" value="false" />
    <property name="extract" value="true" />
    <property name="allowDuplicates" value="false" />
    <property name="defaultsDescriptor" value="cfg/etc/webdefault.xml" />
    </bean>
    <!-- call Server.addLifeCycle() to add to server bean -->
    <bean class="org.springframework.beans.factory.config.Me thodInvokingFactoryBean">
    <property name="targetObject" ref="Server" />
    <property name="targetMethod" value="addLifeCycle" />
    <property name="arguments">
    <list><ref local="server.WebAppDeployer" /></list>
    </property>
    </bean>

    </beans>

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •