Reputation: 765
I have a application Java EE I have in class testmail this code
public Testmail() throws MessagingException, IOException, SQLException
{
Properties props = System.getProperties();
Session session = Session.getDefaultInstance(props, null);
Store store = session.getStore("imaps");
store.connect("imap.gmail.com", "[email protected]", "passsword");
//System.out.println(store);
Folder inbox = store.getFolder("Personnel");
inbox.open(Folder.READ_WRITE);
FlagTerm ft = new FlagTerm(new Flags(Flags.Flag.SEEN), false);
Message messages[] = inbox.search(ft);
for(Message message:messages)
{
//mycode
}
public static void main(String[] args) throws MessagingException, IOException, SQLException
{
new Testmail();
}
this code is working in console.
In my servlet a have this code
//sum code
S.setAttribute("user", user);
try
{
Testmail m=new Testmail();
}
catch (MessagingException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
catch (SQLException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
response.sendRedirect("listeemails.jsp");
but I have this problem
sept. 12, 2013 11:58:55 PM org.apache.catalina.core.ApplicationContext log
INFO: La servlet Login est marqué comme indisponible
sept. 12, 2013 11:58:55 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Exception lors de l'allocation pour la servlet Login
java.lang.ClassNotFoundException: javax.mail.MessagingException
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1387)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1233)
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Unknown Source)
at java.lang.Class.getConstructor0(Unknown Source)
at java.lang.Class.newInstance0(Unknown Source)
at java.lang.Class.newInstance(Unknown Source)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1116)
at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:809)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:129)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:849)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:454)
at java.lang.Thread.run(Unknown Source)
Upvotes: 1
Views: 209
Reputation: 455
you must copy file javax.mail.jar on directory webcontent/web-inf/ lib and its worked
Upvotes: 3
Reputation: 2027
Is javamail.jar in the webapp's classpath? Put another way, is javamail.jar bundled up in your project's WAR/EAR/etc., or in the lib directory of your app server? If it's on your build path in your IDE but isn't getting deployed with your webapp and isn't already on the app server, it'll be on the build path at compile time but not at deploy time.
Upvotes: 2