Once a user has submitted a registration form, the system must verify that the supplied email address is valid. This will be done by submitting an email to the user with link which includes a nonce token that once clicked will activate the user account.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
User submits a registration form (User registration is a different task)
User details are stored on a database table together with a nonce token.
Email is sent to the user with a link containing that token.
User clicks on the link to activate the account.
User gets successfully registered in the application.
We need a mail server. I suggest you take a look at http://james.apache.org but you are free to use whatever email server you wish.
Question/Exception - java.lang.ClassCastException: javax.mail.Session cannot be cast to javax.mail.Session
I am getting this exception, can anyone please help?
Here is where I am at so far:
I setup james mail server on my local, added users and tested.
Added register.jsp and register.xhtml to webapp directory
Copied helloWorld.xhtml contents into register.xhtml, copied index.jsp contents into register.jsp and changed response.sendRedirect parameter to register.jsf
Added registerBacking.java to web dir. and copied helloWorldBacking.java contents into registerBacking.java
I then run mvn jetty:run and server starts with several points of interest(see console output below)
I then fill out user/email fields in form, click register button, and I get this exception:
java.lang.ClassCastException: javax.mail.Session cannot be cast to javax.mail.Session
In console output you can see from the System.out I added, that lookup is returning a javax.mail.Session class, so I am confused by this exception.
Complete console output:
C:\home\work\workspace\mpango\trunk>mvn jetty:run
[INFO] Scanning for projects...
[WARNING]
[WARNING] Some problems were encountered while building the effective model for net.sourceforge.mpango:mpango:war:0.0.1-SNAPSHOT
[WARNING] 'build.plugins.plugin.version' for org.mortbay.jetty:maven-jetty-plugin is missing. @ line 156, column 12
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-compiler-plugin is missing. @ line 164, column 12
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING]
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building mPango 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] >>> maven-jetty-plugin:6.1.16:run (default-cli) @ mpango >>>
[INFO]
[INFO] --- maven-resources-plugin:2.4.3:resources (default-resources) @ mpango ---
[WARNING] File encoding has not been set, using platform encoding Cp1252, i.e. build is platform dependent!
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 6 resources
[INFO] Copying 3 resources
[INFO]
[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ mpango ---
[WARNING] File encoding has not been set, using platform encoding Cp1252, i.e. build is platform dependent!
[INFO] Compiling 1 source file to C:\home\work\workspace\mpango\trunk\target\classes
[INFO]
[INFO] --- maven-resources-plugin:2.4.3:testResources (default-testResources) @ mpango ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:2.3.2:testCompile (default-testCompile) @ mpango ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] <<< maven-jetty-plugin:6.1.16:run (default-cli) @ mpango <<<
[INFO]
[INFO] --- maven-jetty-plugin:6.1.16:run (default-cli) @ mpango ---
[INFO] Configuring Jetty for project: mPango
[INFO] Webapp source directory = C:\home\work\workspace\mpango\trunk\src\main\webapp
[INFO] Reload Mechanic: automatic
[INFO] web.xml file = C:\home\work\workspace\mpango\trunk\src\main\webapp\WEB-INF\web.xml
[INFO] Classes = C:\home\work\workspace\mpango\trunk\target\classes
2011-05-23 16:09:12.680::INFO: Logging to STDERR via org.mortbay.log.StdErrLog
[INFO] Context path = /mpango
[INFO] Tmp directory = determined at runtime
[INFO] Web defaults = org/mortbay/jetty/webapp/webdefault.xml
[INFO] Web overrides = none
[INFO] Webapp directory = C:\home\work\workspace\mpango\trunk\src\main\webapp
[INFO] Starting jetty 6.1.16 ...
2011-05-23 16:09:12.753::INFO: jetty-6.1.16
2011-05-23 16:09:12.965::INFO: No Transaction manager found - if your webapp requires one, please configure one.
2011-05-23 16:09:13.814:/mpango:INFO: Initializing Spring root WebApplicationContext
DEBUG: JavaMail version 1.4ea
DEBUG: java.io.FileNotFoundException: c:\home\apps\jdk1.6.0_18\jre\lib\javamail.providers (The system cannot find the file specified)
DEBUG: !anyLoaded
DEBUG: not loading resource: /META-INF/javamail.providers
DEBUG: successfully loaded resource: /META-INF/javamail.default.providers
DEBUG: Tables of loaded providers
DEBUG: Providers Listed By Class Name: {com.sun.mail.smtp.SMTPSSLTransport=javax.mail.Provider[TRANSPORT,smtps,com.sun.mail.smtp.SMTPSSLTransport,Sun Microsystems, Inc], com.sun.mail.smtp.SMTPTranspor
t=javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc], com.sun.mail.imap.IMAPSSLStore=javax.mail.Provider[STORE,imaps,com.sun.mail.imap.IMAPSSLStore,Sun Microsyst
ems, Inc], com.sun.mail.pop3.POP3SSLStore=javax.mail.Provider[STORE,pop3s,com.sun.mail.pop3.POP3SSLStore,Sun Microsystems, Inc], com.sun.mail.imap.IMAPStore=javax.mail.Provider[STORE,imap,com.sun.mail
.imap.IMAPStore,Sun Microsystems, Inc], com.sun.mail.pop3.POP3Store=javax.mail.Provider[STORE,pop3,com.sun.mail.pop3.POP3Store,Sun Microsystems, Inc]}
DEBUG: Providers Listed By Protocol: {imaps=javax.mail.Provider[STORE,imaps,com.sun.mail.imap.IMAPSSLStore,Sun Microsystems, Inc], imap=javax.mail.Provider[STORE,imap,com.sun.mail.imap.IMAPStore,Sun M
icrosystems, Inc], smtps=javax.mail.Provider[TRANSPORT,smtps,com.sun.mail.smtp.SMTPSSLTransport,Sun Microsystems, Inc], pop3=javax.mail.Provider[STORE,pop3,com.sun.mail.pop3.POP3Store,Sun Microsystems
, Inc], pop3s=javax.mail.Provider[STORE,pop3s,com.sun.mail.pop3.POP3SSLStore,Sun Microsystems, Inc], smtp=javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc]}
DEBUG: successfully loaded resource: /META-INF/javamail.default.address.map
DEBUG: !anyLoaded
DEBUG: not loading resource: /META-INF/javamail.address.map
DEBUG: java.io.FileNotFoundException: c:\home\apps\jdk1.6.0_18\jre\lib\javamail.address.map (The system cannot find the file specified)
2011-05-23 16:09:17.426::INFO: Started SelectChannelConnector@0.0.0.0:8080
[INFO] Started Jetty Server
May 23, 2011 4:09:19 PM com.sun.facelets.compiler.TagLibraryConfig loadImplicit
INFO: Added Library from: jar:file:/C:/Users/steve.hoeksema/.m2/repository/org/apache/myfaces/trinidad/trinidad-impl/1.2.14/trinidad-impl-1.2.14.jar!/META-INF/tr.taglib.xml
May 23, 2011 4:09:19 PM com.sun.facelets.compiler.TagLibraryConfig loadImplicit
INFO: Added Library from: jar:file:/C:/Users/steve.hoeksema/.m2/repository/com/sun/facelets/jsf-facelets/1.1.11/jsf-facelets-1.1.11.jar!/META-INF/jstl-fn.taglib.xml
May 23, 2011 4:09:19 PM com.sun.facelets.compiler.TagLibraryConfig loadImplicit
INFO: Added Library from: jar:file:/C:/Users/steve.hoeksema/.m2/repository/com/sun/facelets/jsf-facelets/1.1.11/jsf-facelets-1.1.11.jar!/META-INF/jstl-core.taglib.xml
May 23, 2011 4:09:19 PM com.sun.facelets.compiler.TagLibraryConfig loadImplicit
INFO: Added Library from: jar:file:/C:/Users/steve.hoeksema/.m2/repository/com/sun/facelets/jsf-facelets/1.1.11/jsf-facelets-1.1.11.jar!/META-INF/jsf-ui.taglib.xml
May 23, 2011 4:09:19 PM com.sun.facelets.compiler.TagLibraryConfig loadImplicit
INFO: Added Library from: jar:file:/C:/Users/steve.hoeksema/.m2/repository/org/apache/myfaces/trinidad/trinidad-impl/1.2.14/trinidad-impl-1.2.14.jar!/META-INF/trh.taglib.xml
May 23, 2011 4:09:19 PM com.sun.facelets.compiler.TagLibraryConfig loadImplicit
INFO: Added Library from: jar:file:/C:/Users/steve.hoeksema/.m2/repository/com/sun/facelets/jsf-facelets/1.1.11/jsf-facelets-1.1.11.jar!/META-INF/jsf-core.taglib.xml
May 23, 2011 4:09:19 PM com.sun.facelets.compiler.TagLibraryConfig loadImplicit
INFO: Added Library from: jar:file:/C:/Users/steve.hoeksema/.m2/repository/com/sun/facelets/jsf-facelets/1.1.11/jsf-facelets-1.1.11.jar!/META-INF/jsf-html.taglib.xml
Creating instance of Steve class net.sourceforge.mpango.web.RegisterBacking
Creating instance of Steve class net.sourceforge.mpango.web.RegisterBacking
DEBUG: JavaMail version 1.4ea
DEBUG: java.io.FileNotFoundException: c:\home\apps\jdk1.6.0_18\jre\lib\javamail.providers (The system cannot find the file specified)
DEBUG: !anyLoaded
DEBUG: not loading resource: /META-INF/javamail.providers
DEBUG: successfully loaded resource: /META-INF/javamail.default.providers
DEBUG: Tables of loaded providers
DEBUG: Providers Listed By Class Name: {com.sun.mail.smtp.SMTPSSLTransport=javax.mail.Provider[TRANSPORT,smtps,com.sun.mail.smtp.SMTPSSLTransport,Sun Microsystems, Inc], com.sun.mail.smtp.SMTPTranspor
t=javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc], com.sun.mail.imap.IMAPSSLStore=javax.mail.Provider[STORE,imaps,com.sun.mail.imap.IMAPSSLStore,Sun Microsyst
ems, Inc], com.sun.mail.pop3.POP3SSLStore=javax.mail.Provider[STORE,pop3s,com.sun.mail.pop3.POP3SSLStore,Sun Microsystems, Inc], com.sun.mail.imap.IMAPStore=javax.mail.Provider[STORE,imap,com.sun.mail
.imap.IMAPStore,Sun Microsystems, Inc], com.sun.mail.pop3.POP3Store=javax.mail.Provider[STORE,pop3,com.sun.mail.pop3.POP3Store,Sun Microsystems, Inc]}
DEBUG: Providers Listed By Protocol: {imaps=javax.mail.Provider[STORE,imaps,com.sun.mail.imap.IMAPSSLStore,Sun Microsystems, Inc], imap=javax.mail.Provider[STORE,imap,com.sun.mail.imap.IMAPStore,Sun M
icrosystems, Inc], smtps=javax.mail.Provider[TRANSPORT,smtps,com.sun.mail.smtp.SMTPSSLTransport,Sun Microsystems, Inc], pop3=javax.mail.Provider[STORE,pop3,com.sun.mail.pop3.POP3Store,Sun Microsystems
, Inc], pop3s=javax.mail.Provider[STORE,pop3s,com.sun.mail.pop3.POP3SSLStore,Sun Microsystems, Inc], smtp=javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc]}
DEBUG: successfully loaded resource: /META-INF/javamail.default.address.map
DEBUG: !anyLoaded
DEBUG: not loading resource: /META-INF/javamail.address.map
DEBUG: java.io.FileNotFoundException: c:\home\apps\jdk1.6.0_18\jre\lib\javamail.address.map (The system cannot find the file specified)
******** initial.lookup(java:/comp/env/mail/Session) = class javax.mail.Session ***********
DEBUG: JavaMail version 1.4ea
DEBUG: java.io.FileNotFoundException: c:\home\apps\jdk1.6.0_18\jre\lib\javamail.providers (The system cannot find the file specified)
DEBUG: !anyLoaded
DEBUG: not loading resource: /META-INF/javamail.providers
DEBUG: successfully loaded resource: /META-INF/javamail.default.providers
DEBUG: Tables of loaded providers
DEBUG: Providers Listed By Class Name: {com.sun.mail.smtp.SMTPSSLTransport=javax.mail.Provider[TRANSPORT,smtps,com.sun.mail.smtp.SMTPSSLTransport,Sun Microsystems, Inc], com.sun.mail.smtp.SMTPTranspor
t=javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc], com.sun.mail.imap.IMAPSSLStore=javax.mail.Provider[STORE,imaps,com.sun.mail.imap.IMAPSSLStore,Sun Microsyst
ems, Inc], com.sun.mail.pop3.POP3SSLStore=javax.mail.Provider[STORE,pop3s,com.sun.mail.pop3.POP3SSLStore,Sun Microsystems, Inc], com.sun.mail.imap.IMAPStore=javax.mail.Provider[STORE,imap,com.sun.mail
.imap.IMAPStore,Sun Microsystems, Inc], com.sun.mail.pop3.POP3Store=javax.mail.Provider[STORE,pop3,com.sun.mail.pop3.POP3Store,Sun Microsystems, Inc]}
DEBUG: Providers Listed By Protocol: {imaps=javax.mail.Provider[STORE,imaps,com.sun.mail.imap.IMAPSSLStore,Sun Microsystems, Inc], imap=javax.mail.Provider[STORE,imap,com.sun.mail.imap.IMAPStore,Sun M
icrosystems, Inc], smtps=javax.mail.Provider[TRANSPORT,smtps,com.sun.mail.smtp.SMTPSSLTransport,Sun Microsystems, Inc], pop3=javax.mail.Provider[STORE,pop3,com.sun.mail.pop3.POP3Store,Sun Microsystems
, Inc], pop3s=javax.mail.Provider[STORE,pop3s,com.sun.mail.pop3.POP3SSLStore,Sun Microsystems, Inc], smtp=javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc]}
DEBUG: successfully loaded resource: /META-INF/javamail.default.address.map
DEBUG: !anyLoaded
DEBUG: not loading resource: /META-INF/javamail.address.map
DEBUG: java.io.FileNotFoundException: c:\home\apps\jdk1.6.0_18\jre\lib\javamail.address.map (The system cannot find the file specified)
java.lang.ClassCastException: javax.mail.Session cannot be cast to javax.mail.Session
at net.sourceforge.mpango.web.RegisterBacking.send(RegisterBacking.java:73)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.sun.el.parser.AstValue.invoke(AstValue.java:187)
at com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:297)
at com.sun.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:68)
at javax.faces.component._MethodExpressionToMethodBinding.invoke(_MethodExpressionToMethodBinding.java:75)
at org.apache.myfaces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:54)
at javax.faces.component.UICommand.broadcast(UICommand.java:121)
at javax.faces.component.UIViewRoot._broadcastForPhase(UIViewRoot.java:292)
at javax.faces.component.UIViewRoot.process(UIViewRoot.java:209)
at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:117)
at org.apache.myfaces.lifecycle.InvokeApplicationExecutor.execute(InvokeApplicationExecutor.java:32)
at org.apache.myfaces.lifecycle.LifecycleImpl.executePhase(LifecycleImpl.java:103)
at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:76)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:148)
at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:502)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:147)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1148)
at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:387)
at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:417)
at org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:230)
at org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.Server.handle(Server.java:324)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:535)
at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:880)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:747)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:218)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:409)
at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:520)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I think it is my fault that I miss guided you pointing you to a Jetty Mail JNDI resource on one of the links I posted here. According to what I read on the Spring documentation you can work your way around it and not use JNDI but connect directly to the SMTP server from Spring making it easier for you to implement your solution.
Besides this problem, I don't understand why you have created register.jsp and register.xhtml as I believe you should be able to reuse the same screens that Jay has delivered as we should send an email to users that register using the userRegistration.xhtml.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Please document the installation of the James server (or post a URL on which it's documented) so that we can follow a step by step instructions in order to execute the feature you are developing.
Thanks!
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Once a user has submitted a registration form, the system must verify that the supplied email address is valid. This will be done by submitting an email to the user with link which includes a nonce token that once clicked will activate the user account.
Steve, I have temptavely assigned to you this task.
I would like to discuss the implementation details with you if you don't mind. What is your preferred way? gtalk? irc? forum? email?
We can try forum/email for now, if that becomes tedious, we can look into IRC. Cool?
Looking forward to hearing your thoughts.
Use Case:
User submits a registration form (User registration is a different task)
User details are stored on a database table together with a nonce token.
Email is sent to the user with a link containing that token.
User clicks on the link to activate the account.
User gets successfully registered in the application.
We need a mail server. I suggest you take a look at http://james.apache.org but you are free to use whatever email server you wish.
We need the mail server configured on the web application level. I suggest you take a look at the following web sites:
http://blog.valotas.com/2010/05/mail-session-on-tomcat-and-jetty-via.html (jetty configuration)
http://static.springsource.org/spring/docs/2.0.3/reference/mail.html (spring configuration)
Create a spring service that uses the mailSender and mailTemplate explained on the spring example and sends an email to the user upon registration.
If doubts/questions dont hesitate to contact the team.
Thanks for use case.
I am setup, and have site running locally.
James is perfect because I have used it before.
Looks like I will have a couple hours to work on this today and will post questions if they arise.
Thanks!
Steve
Can you help me understand below calls?
1. I Hit "http://localhost:8080/mpango/" in browser
2. index.jsp is called and re-directs to "http://localhost:8080/mpango/helloWorld.jsf"
3. Spring then serves up http://localhost:8080/mpango/helloWorld.xhtml in browser
I am confused by the magic that is happening between steps 2 and 3.
I have been looking in pom.xml and web.xml, but cannot immediately determine what is happeneing here?
Thanks,
Steve
Take a look at the following article explaining "the magic":
http://www.javabeat.net/articles/39-integrating-spring-and-jsf-1.html
Thanks for link, that helped.
If I am understanding correctly...
1. /mpango is defined in pom.xml here: <artifactId>mpango</artifactId>
2. /mpango is then mapped to here in web.xml:
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
3. index.jsp calls/redirects to hellowWorld.jsf and is mapped in web.xml here:
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping>
4. FacesServlet then takes over, looks in webapp directory for a file that matches "helloWorld," and then displays that file in browser
So the lesson here for me is that the details of how FacesServlet serves up that page is not necessary, and treat FacesServlet as a blackbox...?
Thanks,
Steve
Question/Exception - java.lang.ClassCastException: javax.mail.Session cannot be cast to javax.mail.Session
I am getting this exception, can anyone please help?
Here is where I am at so far:
I setup james mail server on my local, added users and tested.
Added register.jsp and register.xhtml to webapp directory
Copied helloWorld.xhtml contents into register.xhtml, copied index.jsp contents into register.jsp and changed response.sendRedirect parameter to register.jsf
Added registerBacking.java to web dir. and copied helloWorldBacking.java contents into registerBacking.java
All is well up to this point, then...
I added:
To jetty-env.xml:
<New id="mailsessionid" class="org.mortbay.jetty.plus.naming.Resource">
<Arg>mail/Session</Arg>
<Arg >
<New class="org.mortbay.naming.factories.MailSessionReference">
<Set name="user">root</Set>
<Set name="password">root</Set>
<Set name="properties">
<New class="java.util.Properties">
<Put name="mail.host">localhost</Put>
<Put name="mail.debug">true</Put>
<Put name="mail.smtp.auth">true</Put>
</New>
</Set>
</New>
</Arg>
</New>
To pom.xml:
<dependency>
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
<version>1.4.1</version>
</dependency>
To context.xml:
<ResourceLink name="mail/Session"
global="mail/Session"
type="javax.mail.Session"/>
To web.xml:
<resource-ref>
<description>Session</description>
<res-ref-name>mail/Session</res-ref-name>
<res-type>javax.mail.Session</res-type>
<res-auth>Container</res-auth>
</resource-ref>
To registerBacking.java:
public String send() throws NamingException {
InitialContext initial = new InitialContext();
System.out.println("******** initial.lookup(java:/comp/env/mail/Session) = "+initial.lookup("java:/comp/env/mail/Session").getClass()+" ***********");
Session session = (Session) initial.lookup("java:comp/env/mail/Session");
return "success";
}
I then run mvn jetty:run and server starts with several points of interest(see console output below)
I then fill out user/email fields in form, click register button, and I get this exception:
java.lang.ClassCastException: javax.mail.Session cannot be cast to javax.mail.Session
In console output you can see from the System.out I added, that lookup is returning a javax.mail.Session class, so I am confused by this exception.
Complete console output:
C:\home\work\workspace\mpango\trunk>mvn jetty:run
[INFO] Scanning for projects...
[WARNING]
[WARNING] Some problems were encountered while building the effective model for net.sourceforge.mpango:mpango:war:0.0.1-SNAPSHOT
[WARNING] 'build.plugins.plugin.version' for org.mortbay.jetty:maven-jetty-plugin is missing. @ line 156, column 12
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-compiler-plugin is missing. @ line 164, column 12
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING]
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building mPango 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] >>> maven-jetty-plugin:6.1.16:run (default-cli) @ mpango >>>
[INFO]
[INFO] --- maven-resources-plugin:2.4.3:resources (default-resources) @ mpango ---
[WARNING] File encoding has not been set, using platform encoding Cp1252, i.e. build is platform dependent!
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 6 resources
[INFO] Copying 3 resources
[INFO]
[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ mpango ---
[WARNING] File encoding has not been set, using platform encoding Cp1252, i.e. build is platform dependent!
[INFO] Compiling 1 source file to C:\home\work\workspace\mpango\trunk\target\classes
[INFO]
[INFO] --- maven-resources-plugin:2.4.3:testResources (default-testResources) @ mpango ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:2.3.2:testCompile (default-testCompile) @ mpango ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] <<< maven-jetty-plugin:6.1.16:run (default-cli) @ mpango <<<
[INFO]
[INFO] --- maven-jetty-plugin:6.1.16:run (default-cli) @ mpango ---
[INFO] Configuring Jetty for project: mPango
[INFO] Webapp source directory = C:\home\work\workspace\mpango\trunk\src\main\webapp
[INFO] Reload Mechanic: automatic
[INFO] web.xml file = C:\home\work\workspace\mpango\trunk\src\main\webapp\WEB-INF\web.xml
[INFO] Classes = C:\home\work\workspace\mpango\trunk\target\classes
2011-05-23 16:09:12.680::INFO: Logging to STDERR via org.mortbay.log.StdErrLog
[INFO] Context path = /mpango
[INFO] Tmp directory = determined at runtime
[INFO] Web defaults = org/mortbay/jetty/webapp/webdefault.xml
[INFO] Web overrides = none
[INFO] Webapp directory = C:\home\work\workspace\mpango\trunk\src\main\webapp
[INFO] Starting jetty 6.1.16 ...
2011-05-23 16:09:12.753::INFO: jetty-6.1.16
2011-05-23 16:09:12.965::INFO: No Transaction manager found - if your webapp requires one, please configure one.
2011-05-23 16:09:13.814:/mpango:INFO: Initializing Spring root WebApplicationContext
DEBUG: JavaMail version 1.4ea
DEBUG: java.io.FileNotFoundException: c:\home\apps\jdk1.6.0_18\jre\lib\javamail.providers (The system cannot find the file specified)
DEBUG: !anyLoaded
DEBUG: not loading resource: /META-INF/javamail.providers
DEBUG: successfully loaded resource: /META-INF/javamail.default.providers
DEBUG: Tables of loaded providers
DEBUG: Providers Listed By Class Name: {com.sun.mail.smtp.SMTPSSLTransport=javax.mail.Provider[TRANSPORT,smtps,com.sun.mail.smtp.SMTPSSLTransport,Sun Microsystems, Inc], com.sun.mail.smtp.SMTPTranspor
t=javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc], com.sun.mail.imap.IMAPSSLStore=javax.mail.Provider[STORE,imaps,com.sun.mail.imap.IMAPSSLStore,Sun Microsyst
ems, Inc], com.sun.mail.pop3.POP3SSLStore=javax.mail.Provider[STORE,pop3s,com.sun.mail.pop3.POP3SSLStore,Sun Microsystems, Inc], com.sun.mail.imap.IMAPStore=javax.mail.Provider[STORE,imap,com.sun.mail
.imap.IMAPStore,Sun Microsystems, Inc], com.sun.mail.pop3.POP3Store=javax.mail.Provider[STORE,pop3,com.sun.mail.pop3.POP3Store,Sun Microsystems, Inc]}
DEBUG: Providers Listed By Protocol: {imaps=javax.mail.Provider[STORE,imaps,com.sun.mail.imap.IMAPSSLStore,Sun Microsystems, Inc], imap=javax.mail.Provider[STORE,imap,com.sun.mail.imap.IMAPStore,Sun M
icrosystems, Inc], smtps=javax.mail.Provider[TRANSPORT,smtps,com.sun.mail.smtp.SMTPSSLTransport,Sun Microsystems, Inc], pop3=javax.mail.Provider[STORE,pop3,com.sun.mail.pop3.POP3Store,Sun Microsystems
, Inc], pop3s=javax.mail.Provider[STORE,pop3s,com.sun.mail.pop3.POP3SSLStore,Sun Microsystems, Inc], smtp=javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc]}
DEBUG: successfully loaded resource: /META-INF/javamail.default.address.map
DEBUG: !anyLoaded
DEBUG: not loading resource: /META-INF/javamail.address.map
DEBUG: java.io.FileNotFoundException: c:\home\apps\jdk1.6.0_18\jre\lib\javamail.address.map (The system cannot find the file specified)
2011-05-23 16:09:17.426::INFO: Started SelectChannelConnector@0.0.0.0:8080
[INFO] Started Jetty Server
May 23, 2011 4:09:19 PM com.sun.facelets.compiler.TagLibraryConfig loadImplicit
INFO: Added Library from: jar:file:/C:/Users/steve.hoeksema/.m2/repository/org/apache/myfaces/trinidad/trinidad-impl/1.2.14/trinidad-impl-1.2.14.jar!/META-INF/tr.taglib.xml
May 23, 2011 4:09:19 PM com.sun.facelets.compiler.TagLibraryConfig loadImplicit
INFO: Added Library from: jar:file:/C:/Users/steve.hoeksema/.m2/repository/com/sun/facelets/jsf-facelets/1.1.11/jsf-facelets-1.1.11.jar!/META-INF/jstl-fn.taglib.xml
May 23, 2011 4:09:19 PM com.sun.facelets.compiler.TagLibraryConfig loadImplicit
INFO: Added Library from: jar:file:/C:/Users/steve.hoeksema/.m2/repository/com/sun/facelets/jsf-facelets/1.1.11/jsf-facelets-1.1.11.jar!/META-INF/jstl-core.taglib.xml
May 23, 2011 4:09:19 PM com.sun.facelets.compiler.TagLibraryConfig loadImplicit
INFO: Added Library from: jar:file:/C:/Users/steve.hoeksema/.m2/repository/com/sun/facelets/jsf-facelets/1.1.11/jsf-facelets-1.1.11.jar!/META-INF/jsf-ui.taglib.xml
May 23, 2011 4:09:19 PM com.sun.facelets.compiler.TagLibraryConfig loadImplicit
INFO: Added Library from: jar:file:/C:/Users/steve.hoeksema/.m2/repository/org/apache/myfaces/trinidad/trinidad-impl/1.2.14/trinidad-impl-1.2.14.jar!/META-INF/trh.taglib.xml
May 23, 2011 4:09:19 PM com.sun.facelets.compiler.TagLibraryConfig loadImplicit
INFO: Added Library from: jar:file:/C:/Users/steve.hoeksema/.m2/repository/com/sun/facelets/jsf-facelets/1.1.11/jsf-facelets-1.1.11.jar!/META-INF/jsf-core.taglib.xml
May 23, 2011 4:09:19 PM com.sun.facelets.compiler.TagLibraryConfig loadImplicit
INFO: Added Library from: jar:file:/C:/Users/steve.hoeksema/.m2/repository/com/sun/facelets/jsf-facelets/1.1.11/jsf-facelets-1.1.11.jar!/META-INF/jsf-html.taglib.xml
Creating instance of Steve class net.sourceforge.mpango.web.RegisterBacking
Creating instance of Steve class net.sourceforge.mpango.web.RegisterBacking
DEBUG: JavaMail version 1.4ea
DEBUG: java.io.FileNotFoundException: c:\home\apps\jdk1.6.0_18\jre\lib\javamail.providers (The system cannot find the file specified)
DEBUG: !anyLoaded
DEBUG: not loading resource: /META-INF/javamail.providers
DEBUG: successfully loaded resource: /META-INF/javamail.default.providers
DEBUG: Tables of loaded providers
DEBUG: Providers Listed By Class Name: {com.sun.mail.smtp.SMTPSSLTransport=javax.mail.Provider[TRANSPORT,smtps,com.sun.mail.smtp.SMTPSSLTransport,Sun Microsystems, Inc], com.sun.mail.smtp.SMTPTranspor
t=javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc], com.sun.mail.imap.IMAPSSLStore=javax.mail.Provider[STORE,imaps,com.sun.mail.imap.IMAPSSLStore,Sun Microsyst
ems, Inc], com.sun.mail.pop3.POP3SSLStore=javax.mail.Provider[STORE,pop3s,com.sun.mail.pop3.POP3SSLStore,Sun Microsystems, Inc], com.sun.mail.imap.IMAPStore=javax.mail.Provider[STORE,imap,com.sun.mail
.imap.IMAPStore,Sun Microsystems, Inc], com.sun.mail.pop3.POP3Store=javax.mail.Provider[STORE,pop3,com.sun.mail.pop3.POP3Store,Sun Microsystems, Inc]}
DEBUG: Providers Listed By Protocol: {imaps=javax.mail.Provider[STORE,imaps,com.sun.mail.imap.IMAPSSLStore,Sun Microsystems, Inc], imap=javax.mail.Provider[STORE,imap,com.sun.mail.imap.IMAPStore,Sun M
icrosystems, Inc], smtps=javax.mail.Provider[TRANSPORT,smtps,com.sun.mail.smtp.SMTPSSLTransport,Sun Microsystems, Inc], pop3=javax.mail.Provider[STORE,pop3,com.sun.mail.pop3.POP3Store,Sun Microsystems
, Inc], pop3s=javax.mail.Provider[STORE,pop3s,com.sun.mail.pop3.POP3SSLStore,Sun Microsystems, Inc], smtp=javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc]}
DEBUG: successfully loaded resource: /META-INF/javamail.default.address.map
DEBUG: !anyLoaded
DEBUG: not loading resource: /META-INF/javamail.address.map
DEBUG: java.io.FileNotFoundException: c:\home\apps\jdk1.6.0_18\jre\lib\javamail.address.map (The system cannot find the file specified)
******** initial.lookup(java:/comp/env/mail/Session) = class javax.mail.Session ***********
DEBUG: JavaMail version 1.4ea
DEBUG: java.io.FileNotFoundException: c:\home\apps\jdk1.6.0_18\jre\lib\javamail.providers (The system cannot find the file specified)
DEBUG: !anyLoaded
DEBUG: not loading resource: /META-INF/javamail.providers
DEBUG: successfully loaded resource: /META-INF/javamail.default.providers
DEBUG: Tables of loaded providers
DEBUG: Providers Listed By Class Name: {com.sun.mail.smtp.SMTPSSLTransport=javax.mail.Provider[TRANSPORT,smtps,com.sun.mail.smtp.SMTPSSLTransport,Sun Microsystems, Inc], com.sun.mail.smtp.SMTPTranspor
t=javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc], com.sun.mail.imap.IMAPSSLStore=javax.mail.Provider[STORE,imaps,com.sun.mail.imap.IMAPSSLStore,Sun Microsyst
ems, Inc], com.sun.mail.pop3.POP3SSLStore=javax.mail.Provider[STORE,pop3s,com.sun.mail.pop3.POP3SSLStore,Sun Microsystems, Inc], com.sun.mail.imap.IMAPStore=javax.mail.Provider[STORE,imap,com.sun.mail
.imap.IMAPStore,Sun Microsystems, Inc], com.sun.mail.pop3.POP3Store=javax.mail.Provider[STORE,pop3,com.sun.mail.pop3.POP3Store,Sun Microsystems, Inc]}
DEBUG: Providers Listed By Protocol: {imaps=javax.mail.Provider[STORE,imaps,com.sun.mail.imap.IMAPSSLStore,Sun Microsystems, Inc], imap=javax.mail.Provider[STORE,imap,com.sun.mail.imap.IMAPStore,Sun M
icrosystems, Inc], smtps=javax.mail.Provider[TRANSPORT,smtps,com.sun.mail.smtp.SMTPSSLTransport,Sun Microsystems, Inc], pop3=javax.mail.Provider[STORE,pop3,com.sun.mail.pop3.POP3Store,Sun Microsystems
, Inc], pop3s=javax.mail.Provider[STORE,pop3s,com.sun.mail.pop3.POP3SSLStore,Sun Microsystems, Inc], smtp=javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc]}
DEBUG: successfully loaded resource: /META-INF/javamail.default.address.map
DEBUG: !anyLoaded
DEBUG: not loading resource: /META-INF/javamail.address.map
DEBUG: java.io.FileNotFoundException: c:\home\apps\jdk1.6.0_18\jre\lib\javamail.address.map (The system cannot find the file specified)
java.lang.ClassCastException: javax.mail.Session cannot be cast to javax.mail.Session
at net.sourceforge.mpango.web.RegisterBacking.send(RegisterBacking.java:73)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.sun.el.parser.AstValue.invoke(AstValue.java:187)
at com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:297)
at com.sun.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:68)
at javax.faces.component._MethodExpressionToMethodBinding.invoke(_MethodExpressionToMethodBinding.java:75)
at org.apache.myfaces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:54)
at javax.faces.component.UICommand.broadcast(UICommand.java:121)
at javax.faces.component.UIViewRoot._broadcastForPhase(UIViewRoot.java:292)
at javax.faces.component.UIViewRoot.process(UIViewRoot.java:209)
at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:117)
at org.apache.myfaces.lifecycle.InvokeApplicationExecutor.execute(InvokeApplicationExecutor.java:32)
at org.apache.myfaces.lifecycle.LifecycleImpl.executePhase(LifecycleImpl.java:103)
at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:76)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:148)
at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:502)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:147)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1148)
at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:387)
at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:417)
at org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:230)
at org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.Server.handle(Server.java:324)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:535)
at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:880)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:747)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:218)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:409)
at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:520)
Hi Steve,
I think it is my fault that I miss guided you pointing you to a Jetty Mail JNDI resource on one of the links I posted here. According to what I read on the Spring documentation you can work your way around it and not use JNDI but connect directly to the SMTP server from Spring making it easier for you to implement your solution.
I think you can by pass your problem if you follow the instructions found on the next link:
http://static.springsource.org/spring/docs/3.0.x/reference/mail.html
Take a look at it and see if it helps!
Besides this problem, I don't understand why you have created register.jsp and register.xhtml as I believe you should be able to reuse the same screens that Jay has delivered as we should send an email to users that register using the userRegistration.xhtml.
Hi,
I will implement using link you provided, thanks.
Regarding your question about files I created...I had old code base, did svn update, and I now see Jay changes.
I will use userRegistration.xhtml moving forward.
Thanks for quick response!
Steve
Steve,
Please document the installation of the James server (or post a URL on which it's documented) so that we can follow a step by step instructions in order to execute the feature you are developing.
Thanks!
Please provide resources that will help me implement this with JMS.
I am also searching on my own.