You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by marco bellacosa <ma...@sif.it> on 2007/10/10 12:03:09 UTC
error while calling component MailSender
Hi All,
I'm a new non-expert cocoon user and I'm trying to set up a simple contact
form:
--------------------------------------------------------------
function doContact(){
var path = cocoon.parameters.path;
var lang = cocoon.parameters.lang;
var form = new Form("forms/contact.def.xml");
form.showForm("templates/contact.jx",{path:path,lang:lang});
var MailSender =
cocoon.getComponent(Packages.org.apache.cocoon.mail.MailSender.ROLE);
var global =
cocoon.getComponent(Packages.org.apache.cocoon.components.modules.input.InputModule.ROLE+"Selector").select("global");
try{
MailSender.setSmtpHost(global.getAttribute("smtp",null,null));
MailSender.setFrom(global.getAttribute("smtpfrom",null,null));
MailSender.setSubject("subject");
var body = new java.lang.StringBuffer();
var model = form.getModel();
body.append("name").append(model.nametext).append("\n");
body.append("e-mail: ").append(model.mailtext).append("\n");
body.append("message: ").append(model.messagetext);
MailSender.setBody(body.toString());
MailSender.setTo(global.getAttribute("mail",null,null));
MailSender.send();
cocoon.log.debug("sending mail ok");
form.showForm("templates/contact.jx",{path:path,lang:lang,message:'ok'});
}catch(error){
cocoon.log.debug("sending mail failed");
cocoon.log.debug("sending mail error: "+error);
form.showForm("templates/contact.jx",{path:path,lang:lang,message:'error'});
}finally{
cocoon.releaseComponent(MailSender);
MailSender = null;
}
}
-----------------------------------------------------------
I have also put the Sun mail.jar and activation.jar in my WEB-INF/lib, but I
get the error:
------------------------------------------------------------
org.apache.avalon.framework.component.ComponentException: Could not find
component (key [[JavaPackage org.apache.cocoon.mail.MailSender.ROLE]])
Error calling continuation
context://..../resources/flow/forms.js - 76:-1
context://..../resources/resources.xmap - 227:66
context://..../sitemap.xmap - 165:91
---------------------------------------------------------------------
where forms.js - 76:-1 is
var MailSender =
cocoon.getComponent(Packages.org.apache.cocoon.mail.MailSender.ROLE);
and resources.xmap - 227:66 is
<map:when test="POST">
<map:call continuation="{request-param:continuation}"/>
</map:when>
and context://..../sitemap.xmap - 165:91 is simply
<map:match pattern="resources/**">
<map:mount uri-prefix="resources/" check-reload="yes"
src="resources/resources.xmap"/>
</map:match>
I really cannot understand what I'm doing wrong, I don't know if the code is
wrong or if some java package is missed.
Can anyone help? Thank you bery much.
marco
--
View this message in context: http://www.nabble.com/error-while-calling-component-MailSender-tf4599839.html#a13132925
Sent from the Cocoon - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: error while calling component MailSender
Posted by so...@apache.org.
On 10/25/07, marco bellacosa <ma...@sif.it> wrote:
> Joerg Heinicke wrote:
> > On 10.10.2007 6:03 Uhr, marco bellacosa wrote:
> >> I have also put the Sun mail.jar and activation.jar in my WEB-INF/lib,
> >> but I
> >> get the error:
> >> ------------------------------------------------------------
> >> org.apache.avalon.framework.component.ComponentException: Could not find
> >> component (key [[JavaPackage org.apache.cocoon.mail.MailSender.ROLE]])
> >
> > Hmm, this looks suspicious. The ComponentManager should never get this
> > string but only the actual constant ROLE, which is
> > MailSender.class.getName(), so "org.apache.cocoon.mail.MailSender". Also
> > the Cocoon sample at http://localhost:8888/samples/blocks/mail/sendmail/
> > works for me out of the box (without placing the "real" jars into the
> > lib dir only the actual sending failed).
> >
> > But I could reproduce your behavior by modifying the flowscript used for
> > this example (note the wrong class name):
> >
> > Could not find component (key [[JavaPackage
> > org.apache.cocoon.mail.Mailender.ROLE]])
> >
> > So obviously you seem to lack the MailSender class. Did you build your
> > Cocoon with the mail block included?
> > Joerg
> Hi Joerg,
>
> sorry for the late answer, I had worst problems on my system (raid crash and
> data lost) so I forgot to reply (not lucky weeks).
> Yes, Cocoon was built with the mail block. I simply put again by hand the
> files mail.jar and activation.jar into WEB-INF/lib as I got the error above.
> Anyway, the error persists.
>
> Thank you,
> marco
I tested the offensive line with two Cocoon-2.1.10 instances. The
code works if the "mail" and "asciiart" are included. This error
appears when those blocks are excluded:
org.apache.avalon.framework.component.ComponentException: Could not
find component (key [[JavaPackage
org.apache.cocoon.mail.MailSender.ROLE]])
Does that look familiar?
If you really cannot rebuild Cocoon with those blocks, JS Flow code to
email by accessing the Sun mail classes directly is at:
http://solprovider.com/lenya/flowemail
solprovider
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: error while calling component MailSender
Posted by marco bellacosa <ma...@sif.it>.
Joerg Heinicke wrote:
>
> On 10.10.2007 6:03 Uhr, marco bellacosa wrote:
>
>> I have also put the Sun mail.jar and activation.jar in my WEB-INF/lib,
>> but I
>> get the error:
>> ------------------------------------------------------------
>> org.apache.avalon.framework.component.ComponentException: Could not find
>> component (key [[JavaPackage org.apache.cocoon.mail.MailSender.ROLE]])
>
> Hmm, this looks suspicious. The ComponentManager should never get this
> string but only the actual constant ROLE, which is
> MailSender.class.getName(), so "org.apache.cocoon.mail.MailSender". Also
> the Cocoon sample at http://localhost:8888/samples/blocks/mail/sendmail/
> works for me out of the box (without placing the "real" jars into the
> lib dir only the actual sending failed).
>
> But I could reproduce your behavior by modifying the flowscript used for
> this example (note the wrong class name):
>
> Could not find component (key [[JavaPackage
> org.apache.cocoon.mail.Mailender.ROLE]])
>
> So obviously you seem to lack the MailSender class. Did you build your
> Cocoon with the mail block included?
>
> Joerg
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>
>
>
Hi Joerg,
sorry for the late answer, I had worst problems on my system (raid crash and
data lost) so I forgot to reply (not lucky weeks).
Yes, Cocoon was built with the mail block. I simply put again by hand the
files mail.jar and activation.jar into WEB-INF/lib as I got the error above.
Anyway, the error persists.
Thank you,
marco
--
View this message in context: http://www.nabble.com/error-while-calling-component-MailSender-tf4599839.html#a13406021
Sent from the Cocoon - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: error while calling component MailSender
Posted by Joerg Heinicke <jo...@gmx.de>.
On 10.10.2007 6:03 Uhr, marco bellacosa wrote:
> I have also put the Sun mail.jar and activation.jar in my WEB-INF/lib, but I
> get the error:
> ------------------------------------------------------------
> org.apache.avalon.framework.component.ComponentException: Could not find
> component (key [[JavaPackage org.apache.cocoon.mail.MailSender.ROLE]])
Hmm, this looks suspicious. The ComponentManager should never get this
string but only the actual constant ROLE, which is
MailSender.class.getName(), so "org.apache.cocoon.mail.MailSender". Also
the Cocoon sample at http://localhost:8888/samples/blocks/mail/sendmail/
works for me out of the box (without placing the "real" jars into the
lib dir only the actual sending failed).
But I could reproduce your behavior by modifying the flowscript used for
this example (note the wrong class name):
Could not find component (key [[JavaPackage
org.apache.cocoon.mail.Mailender.ROLE]])
So obviously you seem to lack the MailSender class. Did you build your
Cocoon with the mail block included?
Joerg
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org