Discussion:
ERJavaMail problem
Ondřej Čada
2011-09-07 05:01:51 UTC
Permalink
Hello there,

I've bumped into another problem. Since I need a bit more for mail than WOMailDelivery can give, I've decided to use ERJavaMail.

I went by this quickstart recommendation:

http://homepage.mac.com/kelleherk/iblog/C183784902/E2093239404/index.html

First problem was that I've kept getting the "When setting 'er.javamail.centralize=true' (which means you just test sending mails), you must also give a valid 'er.javamail.adminEmail=***@bar.com' to which the mails are sent" error, although the Properties are set up all right.

Well I've downloaded the Wonder sources too, and quickly found the cause is that the quickstart self-evidently forgot to point out that one must first send the initializeFrameworkFromSystemProperties to the ERJavaMail shared instance. Never mind, I've added the intialization.

Nevertheless, from the method I kept getting null pointer exceptions. Digging deeper into the source and trying it step by step I've found the cause to be the ERJavaMail.isValidEmail method, which raises the exception.

Guess I could dive into its pattern stuff as well, but I've already spent too many hours on something which should "just work" :(

Any hints?

Thanks,
---
Ondra Čada
OCSoftware: ***@ocs.cz http://www.ocs.cz
private ***@ocs.cz http://www.ocs.cz/oc
David LeBer
2011-09-07 12:01:36 UTC
Permalink
Post by Ondřej Čada
Hello there,
I've bumped into another problem. Since I need a bit more for mail than WOMailDelivery can give, I've decided to use ERJavaMail.
http://homepage.mac.com/kelleherk/iblog/C183784902/E2093239404/index.html
Well I've downloaded the Wonder sources too, and quickly found the cause is that the quickstart self-evidently forgot to point out that one must first send the initializeFrameworkFromSystemProperties to the ERJavaMail shared instance. Never mind, I've added the intialization.
Nevertheless, from the method I kept getting null pointer exceptions. Digging deeper into the source and trying it step by step I've found the cause to be the ERJavaMail.isValidEmail method, which raises the exception.
Guess I could dive into its pattern stuff as well, but I've already spent too many hours on something which should "just work" :(
Any hints?
Does your application/session extend ERXApplication/ERXSession?

;david

--
David LeBer
Codeferous Software
'co-def-er-ous' adj. Literally 'code-bearing'
site: http://codeferous.com
blog: http://davidleber.net
profile: http://www.linkedin.com/in/davidleber
twitter: http://twitter.com/rebeld
--
Toronto Area Cocoa / WebObjects developers group:
http://tacow.org
Ondřej Čada
2011-09-07 13:09:36 UTC
Permalink
David,
Post by David LeBer
Post by Ondřej Čada
Hello there,
I've bumped into another problem. Since I need a bit more for mail than WOMailDelivery can give, I've decided to use ERJavaMail.
http://homepage.mac.com/kelleherk/iblog/C183784902/E2093239404/index.html
Well I've downloaded the Wonder sources too, and quickly found the cause is that the quickstart self-evidently forgot to point out that one must first send the initializeFrameworkFromSystemProperties to the ERJavaMail shared instance. Never mind, I've added the intialization.
Nevertheless, from the method I kept getting null pointer exceptions. Digging deeper into the source and trying it step by step I've found the cause to be the ERJavaMail.isValidEmail method, which raises the exception.
Guess I could dive into its pattern stuff as well, but I've already spent too many hours on something which should "just work" :(
Any hints?
Does your application/session extend ERXApplication/ERXSession?
I don't use either -- the only part of ER/Wonder I (am trying to) use is ERJavaMail. The rest is "pure WebObjects", so to speak. So, there's just -- as always -- Application extending WOApplication and Session extending WOSession.

I've inferred from the "quickstart" above that it should be possible? Is it not, i.e., can't ERJM work "alone"?

Thanks a lot and best,
---
Ondra Čada
OCSoftware: ***@ocs.cz http://www.ocs.cz
private ***@ocs.cz http://www.ocs.cz/oc
David LeBer
2011-09-07 13:18:48 UTC
Permalink
Post by Ondřej Čada
David,
Post by David LeBer
Post by Ondřej Čada
Hello there,
I've bumped into another problem. Since I need a bit more for mail than WOMailDelivery can give, I've decided to use ERJavaMail.
http://homepage.mac.com/kelleherk/iblog/C183784902/E2093239404/index.html
Hmm, yeah: "This article is OBSOLETE and the content has been removed!"
Post by Ondřej Čada
Post by David LeBer
Post by Ondřej Čada
Well I've downloaded the Wonder sources too, and quickly found the cause is that the quickstart self-evidently forgot to point out that one must first send the initializeFrameworkFromSystemProperties to the ERJavaMail shared instance. Never mind, I've added the intialization.
Nevertheless, from the method I kept getting null pointer exceptions. Digging deeper into the source and trying it step by step I've found the cause to be the ERJavaMail.isValidEmail method, which raises the exception.
Guess I could dive into its pattern stuff as well, but I've already spent too many hours on something which should "just work" :(
Any hints?
Does your application/session extend ERXApplication/ERXSession?
I don't use either -- the only part of ER/Wonder I (am trying to) use is ERJavaMail. The rest is "pure WebObjects", so to speak. So, there's just -- as always -- Application extending WOApplication and Session extending WOSession.
I've inferred from the "quickstart" above that it should be possible? Is it not, i.e., can't ERJM work "alone"?
Thanks a lot and best
ERXApplication is going to handle the properties setup and framework initialization for ERJavaMail for you. You'll need to handle that yourself if you don't extend it.

;david

--
David LeBer
Codeferous Software
'co-def-er-ous' adj. Literally 'code-bearing'
site: http://codeferous.com
blog: http://davidleber.net
profile: http://www.linkedin.com/in/davidleber
twitter: http://twitter.com/rebeld
--
Toronto Area Cocoa / WebObjects developers group:
http://tacow.org
Ondřej Čada
2011-09-07 13:51:22 UTC
Permalink
David,
Post by David LeBer
Post by Ondřej Čada
Post by Ondřej Čada
http://homepage.mac.com/kelleherk/iblog/C183784902/E2093239404/index.html
Hmm, yeah: "This article is OBSOLETE and the content has been removed!"
I'll be damned -- yesterday it did look quite normally :-O
Post by David LeBer
Post by Ondřej Čada
I don't use either -- the only part of ER/Wonder I (am trying to) use is ERJavaMail. The rest is "pure WebObjects", so to speak. So, there's just -- as always -- Application extending WOApplication and Session extending WOSession.
I've inferred from the "quickstart" above that it should be possible? Is it not, i.e., can't ERJM work "alone"?
Thanks a lot and best
ERXApplication is going to handle the properties setup and framework initialization for ERJavaMail for you. You'll need to handle that yourself if you don't extend it.
I'm willing to, but can you suggest how?

I'd be quite contended with sending the initializeFrameworkFromSystemProperties message to the shared ERJavaMail instance before using; the problem I so far was not able to solve is that it crashes (since the ERJavaMail.isValidEmail method inside raises the null exception).

Thanks a lot,
---
Ondra Čada
OCSoftware: ***@ocs.cz http://www.ocs.cz
private ***@ocs.cz http://www.ocs.cz/oc
David LeBer
2011-09-07 14:09:30 UTC
Permalink
Post by Ondřej Čada
David,
Post by David LeBer
Post by Ondřej Čada
Post by Ondřej Čada
http://homepage.mac.com/kelleherk/iblog/C183784902/E2093239404/index.html
Hmm, yeah: "This article is OBSOLETE and the content has been removed!"
I'll be damned -- yesterday it did look quite normally :-O
Post by David LeBer
Post by Ondřej Čada
I don't use either -- the only part of ER/Wonder I (am trying to) use is ERJavaMail. The rest is "pure WebObjects", so to speak. So, there's just -- as always -- Application extending WOApplication and Session extending WOSession.
I've inferred from the "quickstart" above that it should be possible? Is it not, i.e., can't ERJM work "alone"?
Thanks a lot and best
ERXApplication is going to handle the properties setup and framework initialization for ERJavaMail for you. You'll need to handle that yourself if you don't extend it.
I'm willing to, but can you suggest how?
I'd be quite contended with sending the initializeFrameworkFromSystemProperties message to the shared ERJavaMail instance before using; the problem I so far was not able to solve is that it crashes (since the ERJavaMail.isValidEmail method inside raises the null exception).
Sorry, ERJavaMail was the framework that got me using Wonder. I've not created a non-Wonder app since. Without reading through ERXApplication and the ERJavaMail principal I don't have the steps necessary. Maybe someone else on the list has done this recently. You may be able to get away with just initializing ERJavaMail and ERExtensions.

;david

--
David LeBer
Codeferous Software
'co-def-er-ous' adj. Literally 'code-bearing'
site: http://codeferous.com
blog: http://davidleber.net
profile: http://www.linkedin.com/in/davidleber
twitter: http://twitter.com/rebeld
--
Toronto Area Cocoa / WebObjects developers group:
http://tacow.org
Ondřej Čada
2011-09-07 14:16:14 UTC
Permalink
David,
just initializing ... ERExtensions
is what I did not try yet. Thanks for the idea, I'll do and see!

Best,
---
Ondra Čada
OCSoftware: ***@ocs.cz http://www.ocs.cz
private ***@ocs.cz http://www.ocs.cz/oc
Ondřej Čada
2011-09-07 15:18:49 UTC
Permalink
Kieran, David,
just initializing ... ERExtensions
Perhaps I am extraordinarily dense today, but can you please tell me how does one do that?

There's a finishInitialization method in ERExtensions which looks promising, but it's an instance method, not a class one; and althougth there is a sharedInstance inherited method there too, it needs some "principal class".

I understand that for someone who studied Wonder for years this all is self-evident, but I do not see what "principal class" should be; all I need is simply to send an e-mail :(

Thanks!

As for
My guess is that you will struggle and it will not "just work" until you have at least ERExtensions, ERJars and ERJavaMail in your classpath
That I do have, per the yesterday's document whose cached version is here:

http://webcache.googleusercontent.com/search?q=cache:BtMBAPwKZqEJ:homepage.mac.com/kelleherk/iblog/C183784902/E2093239404/index.html+ERJavaMail&cd=4&hl=en&ct=clnk&gl=cz&client=safari
and you extend ERXSession/ERXApplication.
Thanks. I was quite reluctant to do global changes in tested and reliable code (session/application) to support some local change (send an e-mail from a component), but I've tried anyway in hope it would solve the initialization problem outlined above, but indeed it does not work: I've replaced WOApplication/WOSession by their ERX variants in my code (simply "Application extends ERXApplication", "Session extends ERXSession" and appropriate import so as that builds), and then the application crashes immediately upon launch:

[2011-09-07 16:52:05 CEST] <main> java.lang.NullPointerException
at er.extensions.ERXApplication.<init>(ERXApplication.java:472)
at Application.<init>(Application.java:21)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:494)
at java.lang.Class.newInstance0(Class.java:350)
at java.lang.Class.newInstance(Class.java:303)
at com.webobjects.appserver.WOApplication.main(WOApplication.java:323)
at Application.main(Application.java:184)

Probably there are more complex changes which one must do in the project before ERXApp can be used.

Oh sigh. While I do trust Wonder is great for those who want to embrace it fully and study its details, does not seem one is able just to use its mail without completely re-doing all the rest :(

Best,
---
Ondra Čada
OCSoftware: ***@ocs.cz http://www.ocs.cz
private ***@ocs.cz http://www.ocs.cz/oc
Ondřej Čada
2011-09-07 15:32:31 UTC
Permalink
P.S.
Post by Ondřej Čada
There's a finishInitialization method in ERExtensions which looks promising, but it's an instance method, not a class one; and althougth there is a sharedInstance inherited method there too, it needs some "principal class".
I've tried

ERXExtensions.sharedInstance(ERXExtensions.class).finishInitialization();

which seemed logical, but that yielded

exception: java.lang.IllegalArgumentException: No key operator available to compute aggregate @sortAsc.key

when trying to send mail. Then, straw-catching, I've tried

ERXExtensions.sharedInstance(ERJavaMail.class).finishInitialization();

which seems completely illogical, *but* it seems to work (wow!), more or less. This time erjavamail does log the process which fails eventually, but the logs

MAIL FROM:<***@fpvs.cz>
250 2.1.0 Ok
RCPT TO:<***@ocs.cz>
554 5.7.1 <***@ocs.cz>: Relay access denied
DEBUG SMTP: Invalid Addresses
DEBUG SMTP: ***@ocs.cz
DEBUG SMTP: Sending failed because of invalid destination addresses
RSET
250 2.0.0 Ok
javax.mail.SendFailedException: Invalid Addresses;

suggest this time it might all right in the app, and that the remaining problem would be at the firewall/SMTP server, will have to check with the admin.

Triple-weird! Anyway thanks a lot for all the advices.
---
Ondra Čada
OCSoftware: ***@ocs.cz http://www.ocs.cz
private ***@ocs.cz http://www.ocs.cz/oc
Ondřej Čada
2011-09-07 15:39:42 UTC
Permalink
Kieran,
BTW, did you change your Application main to look like this?
No I did not -- thanks for reminding me! If my current solution fails/proves unstable (I'd prefer if it worked since then there'd be no global changes in my project), I'll fix this and try again.

(Darn. For shame, I've -- for about the zillionth time -- simply forgot the Java thing needs these contraptions where simple inheritance would suffice in a decent language :( )

Thanks and best,
---
Ondra Čada
OCSoftware: ***@ocs.cz http://www.ocs.cz
private ***@ocs.cz http://www.ocs.cz/oc

Loading...