cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Piratenvisier <hansheinrichbr...@yahoo.de>
Subject Re: [jira] [Closed] (COCOON3-129) Create an example to send a mail via cocoon
Date Mon, 22 Jul 2013 10:17:52 GMT
I have some problem getting the Restexample running:
In the pom I have :

<dependency>
   <groupId>org.apache.cocoon.pipeline</groupId>
   <artifactId>cocoon-pipeline</artifactId>
   <version>${cocoon.version}</version>
</dependency>

<dependency>
<groupId>org.apache.cocoon.databases</groupId>
   <artifactId>cocoon-databases</artifactId>
<version>${cocoon.version}</version>
</dependency>

<dependency>
    <groupId>org.apache.cocoon.sax</groupId>
    <artifactId>cocoon-sax</artifactId>
    <version>${cocoon.version}</version>
</dependency>

  <dependency>
       <groupId>org.apache.cocoon.rest</groupId>
       <artifactId>cocoon-rest</artifactId>
   <version>${cocoon.version}</version>
     </dependency>

     <dependency>
<groupId>org.apache.cocoon.stringtemplate</groupId>
       <artifactId>cocoon-stringtemplate</artifactId>
   <version>${cocoon.version}</version>
     </dependency>

<dependency>
   <groupId>org.apache.cocoon.wicket</groupId>
   <artifactId>cocoon-wicket</artifactId>
   <version>${cocoon.version}</version>
</dependency>

   <dependency>
       <groupId>org.apache.cocoon.optional</groupId>
       <artifactId>cocoon-optional</artifactId>
       <version>${cocoon.version}</version>
     </dependency>

  <dependency>
       <groupId>org.apache.xmlgraphics</groupId>
       <artifactId>fop</artifactId>
       <version>1.0</version>
     </dependency>

  <dependency>
    <groupId>org.apache.cocoon</groupId>
<artifactId>cocoon-serializers-charsets</artifactId>
<version>${cocoon.serializers.charset.version}</version>
     </dependency>
     </dependencies>

my sitemap includes :

  <map:pipeline>

       <map:match pattern="controller/{id}/{name}">
         <controller:call controller="rest-controller" 
select="org.apache.cocoon.sample.controller.DemoRESTController">
           <map:parameter name="id" value="{map:id}" />
           <map:parameter name="name" value="{map:name}" />
         </controller:call>
       </map:match>
     </map:pipeline>
     <map:pipeline type="noncaching">
       <map:match pattern="controller/screen">
         <map:generate src="controller/demo.html" 
type="controller-aware-string-template" />
         <map:serialize type="xml" status-code="202" />
       </map:match>
     </map:pipeline>

I included cocoon-sample-controller.xml :

<beans xmlns="http://www.springframework.org/schema/beans" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xmlns:p="http://www.springframework.org/schema/p" 
xmlns:aop="http://www.springframework.org/schema/aop"
   xmlns:context="http://www.springframework.org/schema/context"
   xsi:schemaLocation="
     http://www.springframework.org/schema/beans 
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
     http://www.springframework.org/schema/aop 
http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
     http://www.springframework.org/schema/context 
http://www.springframework.org/schema/context/spring-context-2.5.xsd
   ">

   <!-- Scan for all REST controllers and make them as beans available -->
   <context:component-scan 
base-package="org.apache.cocoon.sample.controller" 
use-default-filters="false"
name-generator="org.apache.cocoon.rest.controller.ControllerBeanNameGenerator"
scope-resolver="org.apache.cocoon.rest.controller.ControllerBeanScopeResolver">
     <context:include-filter type="annotation" 
expression="org.apache.cocoon.rest.controller.annotation.RESTController" />
   </context:component-scan>

   <context:annotation-config />

   <bean id="org.apache.cocoon.sample.controller.aspect1" 
class="org.apache.cocoon.sample.controller.DemoRESTControllerAspect1" />
   <bean id="org.apache.cocoon.sample.controller.aspect2" 
class="org.apache.cocoon.sample.controller.DemoRESTControllerAspect2" />
</beans>

and cocoon-sample-servlet-service.xml:

<beans xmlns="http://www.springframework.org/schema/beans"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns:servlet="http://cocoon.apache.org/schema/servlet"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
                            http://cocoon.apache.org/schema/servlet
http://cocoon.apache.org/schema/servlet/cocoon-servlet-1.0.xsd">

   <!-- A Cocoon-Sitemap based servlet-service. -->

   <bean id="org.apache.cocoon.sample.servlet" 
class="org.apache.cocoon.servlet.XMLSitemapServlet">
here I am not sure if I did this the right way:
     <servlet:context mount-path="" 
context-path="jar:classpath:/WEB-INF/lib/cocoon-servlet-3.0.0-beta-1-SNAPSHOT!/webapp/"/>


   </bean>

   <!-- A servlet-service that exposes JAX-RS REST endpoints. -->
<!--  <bean id="org.apache.cocoon.sample.rest.servlet" 
class="org.apache.cocoon.rest.jaxrs.container.CocoonJAXRSServlet">
     <servlet:context mount-path="/jax-rs" 
context-path="jar:classpath:lib/${project.build.finalName}.jar!/COB-INF/">
       <servlet:connections>
         <entry key="sample" value-ref="org.apache.cocoon.sample.servlet" />
       </servlet:connections>
     </servlet:context>

     <property name="restResourcesList">
       <list>
         <ref bean="org.apache.cocoon.sample.rest.resource.one" />
         <ref bean="org.apache.cocoon.sample.rest.resource.two" />
       </list>
     </property>
   </bean>-->
</beans>

in web.xml the only part of importance is :

  <context-param>
         <param-name>contextConfigLocation</param-name>
         <param-value>
             classpath:/applicationContext-resources.xml
             classpath:/applicationContext-dao.xml
             classpath:/applicationContext-service.xml
             /WEB-INF/applicationContext*.xml
     /WEB-INF/cocoon-sample-*.xml
         </param-value>
     </context-param>

I get the error:

java.net.MalformedURLException: unknown protocol: servlet at 
java.net.URL.<init>(URL.java:592) at java.net.URL.<init>(URL.java:482) 
at java.net.URL.<init>(URL.java:431) at 
org.apache.cocoon.rest.controller.response.URLResponse.<init>(URLResponse.java:49) 
at 
org.apache.cocoon.sample.controller.DemoRESTController.doGet(DemoRESTController.java:54) 
at java.lang.reflect.Method.invoke(Method.java:606) at 
org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:319)

at 
org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)

at 
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)

at 
org.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint.proceed(MethodInvocationProceedingJoinPoint.java:80)

at 
org.apache.cocoon.sample.controller.DemoRESTControllerAspect2.someTestAdvice(DemoRESTControllerAspect2.java:40)

at java.lang.reflect.Method.invoke(Method.java:606) at 
org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:621)

at 
org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:610)

at 
org.springframework.aop.aspectj.AspectJAroundAdvice.invoke(AspectJAroundAdvice.java:65) 
at 
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)

at 
org.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint.proceed(MethodInvocationProceedingJoinPoint.java:80)

at 
org.apache.cocoon.sample.controller.DemoRESTControllerAspect1.someTestAdvice(DemoRESTControllerAspect1.java:40)

at java.lang.reflect.Method.invoke(Method.java:606) at 
org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:621)

at 
org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:610)

at 
org.springframework.aop.aspectj.AspectJAroundAdvice.invoke(AspectJAroundAdvice.java:65) 
at 
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)

at 
org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:90)

at 
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)

at 
org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202) 
at com.sun.proxy.$Proxy83.doGet(Unknown Source) at 
org.apache.cocoon.rest.controller.MethodDelegator$GetDelegate.execute(MethodDelegator.java:128)

at 
org.apache.cocoon.rest.controller.MethodDelegator.delegate(MethodDelegator.java:63) 
at 
org.apache.cocoon.rest.controller.SpringRESTController.setup(SpringRESTController.java:119)

at 
org.apache.cocoon.controller.SpringControllerComponent.setup(SpringControllerComponent.java:110)

at 
org.apache.cocoon.pipeline.AbstractPipeline.setupComponents(AbstractPipeline.java:181) 
at 
org.apache.cocoon.pipeline.AbstractPipeline.setup(AbstractPipeline.java:132) 
at 
org.apache.cocoon.pipeline.CachingPipeline.setup(CachingPipeline.java:183) 
at java.lang.reflect.Method.invoke(Method.java:606) at 
org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:319)

at 
org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)

at 
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)

at 
org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:90)

at 
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)

at 
org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202) 
at com.sun.proxy.$Proxy80.setup(Unknown Source) at 
org.apache.cocoon.sitemap.InvocationImpl.execute(InvocationImpl.java:145) at 
org.apache.cocoon.sitemap.node.PipelineNode.invoke(PipelineNode.java:69) 
at 
org.apache.cocoon.sitemap.node.AbstractSitemapNode.invoke(AbstractSitemapNode.java:100) 
at 
org.apache.cocoon.sitemap.node.PipelinesNode.invoke(PipelinesNode.java:50) 
at 
org.apache.cocoon.sitemap.node.AbstractSitemapNode.invoke(AbstractSitemapNode.java:100) 
at org.apache.cocoon.sitemap.node.Sitemap.invoke(Sitemap.java:43) at 
org.apache.cocoon.servlet.RequestProcessor.invoke(RequestProcessor.java:245) 
at 
org.apache.cocoon.servlet.RequestProcessor.sendSitemapResponse(RequestProcessor.java:313)

at 
org.apache.cocoon.servlet.RequestProcessor.service(RequestProcessor.java:100) 
at 
org.apache.cocoon.wicket.request.CocoonSitemapRequestHandler.respond(CocoonSitemapRequestHandler.java:80)

at 
org.apache.wicket.request.cycle.RequestCycle$HandlerExecutor.respond(RequestCycle.java:861)

at 
org.apache.wicket.request.RequestHandlerStack.execute(RequestHandlerStack.java:64) 
at 
org.apache.wicket.request.cycle.RequestCycle.execute(RequestCycle.java:261) 
at 
org.apache.wicket.request.cycle.RequestCycle.processRequest(RequestCycle.java:218) 
at 
org.apache.wicket.request.cycle.RequestCycle.processRequestAndDetach(RequestCycle.java:289)

at 
org.apache.wicket.protocol.http.WicketFilter.processRequestCycle(WicketFilter.java:259) 
at 
org.apache.wicket.protocol.http.WicketFilter.processRequest(WicketFilter.java:201) 
at 
org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:282) 
at 
org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1338) 
at 
org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:484) 
at 
org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:119) 
at 
org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:524) 
at 
org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:233) 
at 
org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1065) 
at 
org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:413) at 
org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:192) 
at 
org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:999) 
at 
org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:117) 
at 
org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:250)

at 
org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:149) 
at 
org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:111) 
at org.eclipse.jetty.server.Server.handle(Server.java:350) at 
org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:454)

at 
org.eclipse.jetty.server.AbstractHttpConnection.headerComplete(AbstractHttpConnection.java:890)

at 
org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.headerComplete(AbstractHttpConnection.java:944)

at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:630) at 
org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:230) at 
org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:77) 
at 
org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:606) 
at 
org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:46) 
at 
org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:603) 
at 
org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:538) 
at java.lang.Thread.run(Thread.java:724)

Complete stack:

org.apache.cocoon.wicket.request.CocoonWicketRuntimeException: Error 
occurred while executing a Cocoon sitemap. at 
org.apache.cocoon.wicket.request.CocoonSitemapRequestHandler.respond(CocoonSitemapRequestHandler.java:87)

at 
org.apache.wicket.request.cycle.RequestCycle$HandlerExecutor.respond(RequestCycle.java:861)

at 
org.apache.wicket.request.RequestHandlerStack.execute(RequestHandlerStack.java:64) 
at 
org.apache.wicket.request.cycle.RequestCycle.execute(RequestCycle.java:261) 
at 
org.apache.wicket.request.cycle.RequestCycle.processRequest(RequestCycle.java:218) 
at 
org.apache.wicket.request.cycle.RequestCycle.processRequestAndDetach(RequestCycle.java:289)

at 
org.apache.wicket.protocol.http.WicketFilter.processRequestCycle(WicketFilter.java:259)

org.apache.cocoon.sitemap.InvocationException: 
java.net.MalformedURLException: unknown protocol: servlet at 
org.apache.cocoon.sitemap.util.ExceptionHandler.getInvocationException(ExceptionHandler.java:39)

at 
org.apache.cocoon.rest.controller.MethodDelegator$GetDelegate.execute(MethodDelegator.java:130)

at 
org.apache.cocoon.rest.controller.MethodDelegator.delegate(MethodDelegator.java:63) 
at 
org.apache.cocoon.rest.controller.SpringRESTController.setup(SpringRESTController.java:119)

at 
org.apache.cocoon.controller.SpringControllerComponent.setup(SpringControllerComponent.java:110)

at 
org.apache.cocoon.pipeline.AbstractPipeline.setupComponents(AbstractPipeline.java:181) 
at 
org.apache.cocoon.pipeline.AbstractPipeline.setup(AbstractPipeline.java:132) 
at 
org.apache.cocoon.pipeline.CachingPipeline.setup(CachingPipeline.java:183) 
at java.lang.reflect.Method.invoke(Method.java:606) at 
org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:319)

at 
org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)

at 
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)

at 
org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:90)

at 
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)

at 
org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202) 
at com.sun.proxy.$Proxy80.setup(Unknown Source) at 
org.apache.cocoon.sitemap.InvocationImpl.execute(InvocationImpl.java:145) at 
org.apache.cocoon.sitemap.node.PipelineNode.invoke(PipelineNode.java:69) 
at 
org.apache.cocoon.sitemap.node.AbstractSitemapNode.invoke(AbstractSitemapNode.java:100) 
at 
org.apache.cocoon.sitemap.node.PipelinesNode.invoke(PipelinesNode.java:50) 
at 
org.apache.cocoon.sitemap.node.AbstractSitemapNode.invoke(AbstractSitemapNode.java:100) 
at org.apache.cocoon.sitemap.node.Sitemap.invoke(Sitemap.java:43) at 
org.apache.cocoon.servlet.RequestProcessor.invoke(RequestProcessor.java:245) 
at 
org.apache.cocoon.servlet.RequestProcessor.sendSitemapResponse(RequestProcessor.java:313)

at 
org.apache.cocoon.servlet.RequestProcessor.service(RequestProcessor.java:100) 
at 
org.apache.cocoon.wicket.request.CocoonSitemapRequestHandler.respond(CocoonSitemapRequestHandler.java:80)

at 
org.apache.wicket.request.cycle.RequestCycle$HandlerExecutor.respond(RequestCycle.java:861)

at 
org.apache.wicket.request.RequestHandlerStack.execute(RequestHandlerStack.java:64) 
at 
org.apache.wicket.request.cycle.RequestCycle.execute(RequestCycle.java:261) 
at 
org.apache.wicket.request.cycle.RequestCycle.processRequest(RequestCycle.java:218) 
at 
org.apache.wicket.request.cycle.RequestCycle.processRequestAndDetach(RequestCycle.java:289)

at 
org.apache.wicket.protocol.http.WicketFilter.processRequestCycle(WicketFilter.java:259)




Am 22.07.2013 10:05, schrieb Thorsten Scherler:
> On 07/22/2013 08:17 AM, Piratenvisier wrote:
>> Thank you Thorsten for sending the MailSender example.
>> I learnt one way to read out a bean could be a Controller based on a
>> StringTemplateGenerator
>> while a Restcontroller delivers the Bean.Do you know if there exists a
>> Generator like the former JXGenerator
>> Thanks for your help
> ATM the StringTemplateGenerator is the way, none has migrated the
> JXGenerator yet. Regarding the pipeline example it took me much longer
> then expected to extract the code since like I said it was based on a
> jms trigger and after 8 hours Saturday my kids requested to go swimming.
>
> I will have a look now to create a small pipe-example. Further for
> advanced mail operations you would need
> MimeMessageHelper message = new MimeMessageHelper(mimeMessage,
> true,"UTF-8");
> which allows to
> * message.addAttachment(...) ;
> * message.setText(text, htmlString); // alternative formats text and html
>
> salu2
>
>> Am 20.07.2013 18:26, schrieb Thorsten Scherler (JIRA):
>>>        [
>>> https://issues.apache.org/jira/browse/COCOON3-129?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
>>> ]
>>>
>>> Thorsten Scherler closed COCOON3-129.
>>> -------------------------------------
>>>
>>>       Resolution: Fixed
>>>
>>> Committed revision 1505158.
>>>
>>>                  
>>>> Create an example to send a mail via cocoon
>>>> -------------------------------------------
>>>>
>>>>                   Key: COCOON3-129
>>>>                   URL: https://issues.apache.org/jira/browse/COCOON3-129
>>>>               Project: Cocoon 3
>>>>            Issue Type: New Feature
>>>>            Components: cocoon-rest-optional
>>>>      Affects Versions: 3.0.0-beta-1
>>>>              Reporter: Thorsten Scherler
>>>>               Fix For: 3.0.0-beta-1
>>>>
>>>>
>>>> http://markmail.org/message/6ces6erwekf57qfo
>>>> as requested from hansheinrichbraun in above mail I extracted a
>>>> simple example to send a mail with cocoon based on work of
>>>> codebusters.es.
>>> -- 
>>> This message is automatically generated by JIRA.
>>> If you think it was sent incorrectly, please contact your JIRA
>>> administrators
>>> For more information on JIRA, see:
>>> http://www.atlassian.com/software/jira
>


Mime
View raw message