connection type: IMAPS
When I call 'getDisposition' on an email such that the attachment bound to the mail is an EML file, javamail throws an 'Unable to load BODYSTRUCTURE' exception.
I'm unclear why this happens. Ideas, anybody?
Take a look at JAVAMAIL API FAQ.
It is a "bad" server issue.
try {
msg.getContentType(); // or getDisposition or similar
} catch (Exception e) {
errorMsg = new MimeMessage((MimeMessage)msg);
}
...
someProcessing(errorMsg);
Related
I have ADF web application developed using Jdeveloper 12.1.3 version, Glassfish server 3.1.2 version and Apache Shiro for security.
Login action and application security are working fine, but not logout action.
After logged out from application, it should be redirected to login page. But it throws
"javax.servlet.ServletException: java.lang.IllegalStateException:
org.apache.shiro.session.UnknownSessionException: There is no session
with id" error.
Logout action method code is
public String logout() throws IOException {
try {
ExternalContext externalContext = FacesContext.getCurrentInstance().getExternalContext();
externalContext.invalidateSession();
SecurityUtils.getSubject().logout();
} catch (Exception e) {
FacesMessage msg = new FacesMessage(FacesMessage.SEVERITY_ERROR, e.getMessage(), "");
FacesContext.getCurrentInstance().addMessage(null, msg);
e.printStackTrace(); // TODO: logger.
}
return "";
}
Do I miss anything ?
It looks like you invalidating the session and then calling logout. Have you tried logging out first? Or something like:
Subject subject = SecurityUtils.getSubject();
ExternalContext externalContext = FacesContext.getCurrentInstance().getExternalContext();
externalContext.invalidateSession();
subject.logout();
Otherwise, it looks like you are trying to get the current subject from an empty session.
I keep getting this error "Server at solr 8080 returned non ok status:500, message:Internal Server Error" when I am trying to index text files on solr server using solrj api.
My code is as follows:
public void IndexData(String filePath,String solrId)
{
try {
String urlString = "http://localhost:8080//solr";
HttpSolrServer server = new HttpSolrServer(urlString);
ContentStreamUpdateRequest up
= new ContentStreamUpdateRequest("/update/extract");
up.addFile(new File(filePath),"");
up.setParam("literal.id", solrId);
up.setParam("uprefix", "attr_");
up.setParam("fmap.content", "attr_content");
up.setAction(AbstractUpdateRequest.ACTION.COMMIT, true,true);
server.request(up);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SolrServerException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
}
I am able to query the solr server using same server but while indexing data, why I am getting this error?
log4j:WARN No appenders could be found for logger (org.apache.solr.client.solrj.impl.HttpClientUtil).
log4j:WARN Please initialize the log4j system properly.
org.apache.solr.client.solrj.impl.HttpSolrServer$RemoteSolrException: Server at `http://localhost:8080//solr` returned non ok status:500, message:Internal Server Error
at org.apache.solr.client.solrj.impl.HttpSolrServer.request(HttpSolrServer.java:372)
at org.apache.solr.client.solrj.impl.HttpSolrServer.request(HttpSolrServer.java:180)
at dataAnalysis.dataIndexer.DataIndexer.IndexData(DataIndexer.java:41)
at dataAnalysis.dataHome.DataHome.main(DataHome.java:13)
Hey great news I was able to solve the issue. Two changes required. First I edited solrconfig.xml to remove extra tab like to for every path and second change was to copy jars from /solr/contrib/extraction/lib to /tomcat/web-inf/lib folder. –
I created application that runs on GAE and connects to specific page, automatically logins to this page and AFTER login I want to receive html and process it.
here is the problematic (writer.write part and connection.connect()) part of code:
this.username = URLEncoder.encode(username, "UTF-8");
this.password = URLEncoder.encode(password, "UTF-8");
this.login = "login";
connection = (HttpURLConnection) url.openConnection();
connection.setDoOutput(true);
connection.setRequestMethod("POST");
OutputStreamWriter writer = new OutputStreamWriter(
connection.getOutputStream());
writer.write("str_login=" + login + "&str_user=" + username
+ "&str_pass=" + password);
writer.close();
connection.connect();
I am getting IOException (connection.connect()) while establishig connection. Problem is "application/x-www-form-urlencoded" data. When I pass wrong parameters to page (for example str_pasSSs, str_usernaAAme, or no parameters at all) I am not possible to login but I do get response with html of login page. So, it seems that Google App Engine does not support this kind of communication. Is it possible to login to this page in some other way that GAE supports?
In Wireshark, I saw that username and password are sent in plaintext as line-based text data (application/x-www-form-urlencoded). I know this is not safe, but it's the way it is.
The connection is already established implicitly when you call getOutputStream(). There is no need to call connection.connect() again.
Also, instead of closing the output writer, try flush() instead.
As a best practice, you should be closing in, out and conn in a finally block:
InputStream in = null;
OutputStream out = null;
HttpUrlConnection conn = null;
try {
...
} catch (IOException ioe) {
...
} finally {
if (in!=null) {try {in.close()} catch (IOException e) {}}
if (out!=null) {try {out.close()} catch (IOException e) {}}
if (conn!=null) {try {conn.close()} catch (IOException e) {}}
}
I have a Windows Phone 7 application built with silverlight. This application has been deployed. I've noticed in the log files that occasionally, my user's actions throw a "NotSupportedException". I have not been able to produce this. However, because of my logs, I know that it is happening in the Execute method shown here:
public void Execute()
{
try
{
// 1. Build the query
string serviceUrl = GetServiceUrl;
// 2. Asynchronously execute the query using HttpWebRequest
WebRequest request = HttpWebRequest.Create(serviceUrl);
request.BeginGetResponse(new AsyncCallback(ServiceRequest_Completed), request);
} catch (Exception ex)
{
LogException(ex, "1");
}
}
private void ServiceRequest_Completed(IAsyncResult result)
{
try
{
// 1. Get the response from the service call
WebRequest request = (WebRequest)(result.AsyncState);
WebResponse response = request.EndGetResponse(result);
// 2. Do stuff with response
}
catch (Exception ex)
{
LogException(ex, "2");
}
}
I know it is happening in the Execute method because the "1" is written in the log file instead of the "2" My question is, what would cause this? I looked at the MSDN documentation and it looks like I'm doing what I should be doing. Like I said, I can't reproduce it locally. But I do know that it is happening regularly by different users because of the log files.
There is a previous question with a very similar title - https://stackoverflow.com/questions/4053197/httpwebrequest-leads-me-to-system-notsupportedexception
The answer to that problem seems to have been using ServiceRequest_Completed instead of new AsyncCallback(ServiceRequest_Completed)
I'm using the MailService feature of Google App Engine in my
application. It works fine in one application without any issues.
But the same code doesn't work in another app. I'm not able to figure
it out. Please help. Following is the piece of code that I use to
send mail.
public static void sendHTMLEmail(String from, String fromName, String
to, String toName, String subject, String body) {
_logger.info("entering ...");
Properties props = new Properties();
Session session = Session.getDefaultInstance(props, null);
_logger.info("got mail session ...");
String htmlBody = body;
try {
Message msg = new MimeMessage(session);
_logger.info("created mimemessage ...");
msg.setFrom(new InternetAddress(from,
fromName));
_logger.info("from is set ...");
msg.addRecipient(Message.RecipientType.TO, new InternetAddress(
to, toName));
_logger.info("recipient is set ...");
msg.setSubject(subject);
_logger.info("subject is set ...");
Multipart mp = new MimeMultipart();
MimeBodyPart htmlPart = new MimeBodyPart();
htmlPart.setContent(htmlBody, "text/html");
mp.addBodyPart(htmlPart);
_logger.info("body part added ...");
msg.setContent(mp);
_logger.info("content is set ...");
Transport.send(msg);
_logger.info("email sent successfully.");
} catch (AddressException e) {
e.printStackTrace();
} catch (MessagingException e) {
e.printStackTrace();
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
System.err.println(e.getMessage());
}
}
When I look at the log (on the server admin console), it prints the
statement "content is set ..." and after that there is nothing in the
log. The mail is not sent. At times I get the following error after
the above statement is printed (and the mail is not sent).
com.google.appengine.repackaged.com.google.common.base.internal.Finalizer
getInheritableThreadLocalsField: Couldn't access
Thread.inheritableThreadLocals. Reference finalizer threads will
inherit thread local values.
But the mail quota usage keeps increasing.
Remember, this works fine in one application, but not in other. I'm
using the same set of email addresses in both the apps (for from and
to).
I'm really stuck with this. Appreciate any help.
Thank you.
Velu
Have you tried logging the exceptions? I bet one of them is being thrown - your printStackTrace will go nowhere.