cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From 朱 亮 <hotz...@hotmail.com>
Subject use CocoonBean Generate Static HTML
Date Tue, 12 Dec 2006 08:04:43 GMT
Hi,everybody.I try to use CocoonBean Generate Static HTML in my servlet.but 
always question.
somebody can help me?



    public void init(ServletConfig config) throws ServletException 
    {
        super.init(config);
        configPath = getServletContext().getRealPath("/");
    }  	
	
	/* (non-Java-doc)
	 * @see javax.servlet.http.HttpServlet#doGet(HttpServletRequest request, 
HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse 
response) throws ServletException, IOException 
	{
		try
		{
			doSomething(configPath);
		}
		catch(Exception e)
		{
			e.printStackTrace();
		}			
	}  	
	
	public void doSomething(String cocoonWebappDir)
	{
		CocoonBeanController controller = new 
CocoonBeanControllerImpl();//CocoonBeanFactory.createCocoonBeanController(cocoonWebappDir);

			
	    BeanConfiguration config = new BeanConfiguration();
	    
	    //config.setLogKit(cocoonWebappDir+"WEB-INF/logkit.xconf");
	    
	    config.setContextDir(cocoonWebappDir);
	     
	    controller.initialize(config);      

	    //the uri to process
	    ProcessURI uri = new ProcessURI();
	    uri.setType("append");
	    uri.setSrcPrefix("");
	    uri.setUri("hello/hello.html");
	    uri.setDest("dest/");
	    
	    Task task = new Task();
	    task.addProcessURI(uri);          

	    //let the cocoon do the job
	    controller.processTask(task);
	}

FATAL_E 2006-12-12 15:46:00.250 [        ] (): Exception caught
org.apache.avalon.framework.configuration.ConfigurationException: Cannot 
find ServletContext object in application context
	at 
org.apache.avalon.excalibur.logger.factory.ServletTargetFactory.createTarget(ServletTargetFactory.java:85)

	at 
org.apache.avalon.excalibur.logger.DefaultLogTargetManager.configure(DefaultLogTargetManager.java:92)

	at 
org.apache.avalon.framework.container.ContainerUtil.configure(ContainerUtil.java:201)

	at 
org.apache.avalon.excalibur.logger.LogKitLoggerManager.setupTargetManager(LogKitLoggerManager.java:457)

	at 
org.apache.avalon.excalibur.logger.LogKitLoggerManager.configure(LogKitLoggerManager.java:403)

	at org.apache.cocoon.bean.CocoonWrapper.initialize(CocoonWrapper.java:143)
	at 
de.miethxml.hawron.cocoon.impl.ReuseableCocoonBean.initialize(ReuseableCocoonBean.java:104)

	at 
de.miethxml.hawron.cocoon.impl.ReuseableCocoonBean.process(ReuseableCocoonBean.java:719)

	at 
de.miethxml.hawron.cocoon.impl.CocoonBeanControllerImpl.processTask(CocoonBeanControllerImpl.java:383)

	at 
smcc.cms.ant.GenerateHTMLServlet.doSomething(GenerateHTMLServlet.java:76)
	at smcc.cms.ant.GenerateHTMLServlet.doGet(GenerateHTMLServlet.java:45)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
	at 
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)

	at 
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)

	at 
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)

	at 
org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)

	at 
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
	at 
org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:198)

	at 
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:152)

	at 
org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)

	at 
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
	at 
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)

	at 
org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)

	at 
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:118)

	at 
org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)

	at 
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
	at 
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)

	at 
org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)

	at 
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
	at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)
	at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
	at 
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
	at 
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)

	at 
org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
	at 
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)

	at java.lang.Thread.run(Unknown Source)
Caused by: org.apache.avalon.framework.context.ContextException: Unable to 
resolve context key: servlet-context
	at 
org.apache.avalon.framework.context.DefaultContext.get(DefaultContext.java:118)

	at 
org.apache.avalon.framework.context.DefaultContext.get(DefaultContext.java:121)

	at 
org.apache.avalon.excalibur.logger.factory.ServletTargetFactory.createTarget(ServletTargetFactory.java:81)

	... 36 more
org.apache.avalon.framework.configuration.ConfigurationException: Cannot 
find ServletContext object in application context
	at 
org.apache.avalon.excalibur.logger.factory.ServletTargetFactory.createTarget(ServletTargetFactory.java:85)

	at 
org.apache.avalon.excalibur.logger.DefaultLogTargetManager.configure(DefaultLogTargetManager.java:92)

	at 
org.apache.avalon.framework.container.ContainerUtil.configure(ContainerUtil.java:201)

	at 
org.apache.avalon.excalibur.logger.LogKitLoggerManager.setupTargetManager(LogKitLoggerManager.java:457)

	at 
org.apache.avalon.excalibur.logger.LogKitLoggerManager.configure(LogKitLoggerManager.java:403)

	at org.apache.cocoon.bean.CocoonWrapper.initialize(CocoonWrapper.java:143)
	at 
de.miethxml.hawron.cocoon.impl.ReuseableCocoonBean.initialize(ReuseableCocoonBean.java:104)

	at 
de.miethxml.hawron.cocoon.impl.ReuseableCocoonBean.process(ReuseableCocoonBean.java:719)

	at 
de.miethxml.hawron.cocoon.impl.CocoonBeanControllerImpl.processTask(CocoonBeanControllerImpl.java:383)

	at 
smcc.cms.ant.GenerateHTMLServlet.doSomething(GenerateHTMLServlet.java:76)
	at smcc.cms.ant.GenerateHTMLServlet.doGet(GenerateHTMLServlet.java:45)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
	at 
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)

	at 
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)

	at 
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)

	at 
org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)

	at 
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
	at 
org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:198)

	at 
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:152)

	at 
org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)

	at 
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
	at 
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)

	at 
org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)

	at 
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:118)

	at 
org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)

	at 
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
	at 
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)

	at 
org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)

	at 
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
	at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)
	at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
	at 
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
	at 
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)

	at 
org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
	at 
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)

	at java.lang.Thread.run(Unknown Source)
Caused by: org.apache.avalon.framework.context.ContextException: Unable to 
resolve context key: servlet-context
	at 
org.apache.avalon.framework.context.DefaultContext.get(DefaultContext.java:118)

	at 
org.apache.avalon.framework.context.DefaultContext.get(DefaultContext.java:121)

	at 
org.apache.avalon.excalibur.logger.factory.ServletTargetFactory.createTarget(ServletTargetFactory.java:81)

	... 36 more

_________________________________________________________________
与联机的朋友进行交流,请使用 MSN Messenger:  http://messenger.msn.com/cn  


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Mime
View raw message