I am getting error at this line while triggering the gmail smtp email from my localhost "MimeMessage message = new MimeMessage(session)"
When i checked another similar thread it asked me to install a hidden module which I don't know how to install. Don't know the java commands and which interface i should install this module
HTTP Status 500 – Internal Server Error
Type Exception Report
Message An exception occurred processing [/resetPassword/reset_password.jsp] at line [105]
Description The server encountered an unexpected condition that prevented it from fulfilling the request.
Exception
org.apache.jasper.JasperException: An exception occurred processing [/resetPassword/reset_password.jsp] at line [105]
102: props.put("mail.smtp.starttls.required", "true");
103: Session mailSession = Session.getDefaultInstance(props);
104: mailSession.setDebug(sessionDebug);
105: MimeMessage msg = new MimeMessage(mailSession);
106: msg.setFrom(new InternetAddress(from, name));
107: InternetAddress[] address = {new InternetAddress(to)};
108: msg.setRecipients(Message.RecipientType.TO, address);
Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:610)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:489)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:380)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:328)
jakarta.servlet.http.HttpServlet.service(HttpServlet.java:777)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
Root Cause
jakarta.servlet.ServletException: java.lang.NoClassDefFoundError: javax/activation/DataSource
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:667)
org.apache.jsp.resetPassword.reset_005fpassword_jsp._jspService(reset_005fpassword_jsp.java:353)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
jakarta.servlet.http.HttpServlet.service(HttpServlet.java:777)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:466)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:380)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:328)
jakarta.servlet.http.HttpServlet.service(HttpServlet.java:777)
Related
I have the following code to send a email through EWS API,
ExchangeService service = new ExchangeService();
service.setUrl(new URI(**MyExchangeURL**));
ExchangeCredentials credentials = new WebCredentials(**UserName**, **Password**);
service.setCredentials(credentials);
EmailMessage message = new EmailMessage(service);
message.setSubject("EWS Test Mail");
message.setBody(MessageBody.getMessageBodyFromText("This is a test mail from EWS"));
message.getToRecipients().add("Test#gmail.com");
message.send();
With the above code, I facing a null pointer exception when message.send() is called.
Log:
Exception in thread "main" microsoft.exchange.webservices.data.core.exception.service.remote.ServiceRequestException: The request failed. null
at microsoft.exchange.webservices.data.core.request.SimpleServiceRequestBase.internalExecute(SimpleServiceRequestBase.java:74)
at microsoft.exchange.webservices.data.core.request.MultiResponseServiceRequest.execute(MultiResponseServiceRequest.java:158)
at microsoft.exchange.webservices.data.core.ExchangeService.internalCreateItems(ExchangeService.java:598)
at microsoft.exchange.webservices.data.core.ExchangeService.createItem(ExchangeService.java:657)
at microsoft.exchange.webservices.data.core.service.item.Item.internalCreate(Item.java:245)
at microsoft.exchange.webservices.data.core.service.item.EmailMessage.internalSend(EmailMessage.java:147)
at microsoft.exchange.webservices.data.core.service.item.EmailMessage.send(EmailMessage.java:258)
at EWS.main(EWS.java:28)
Caused by: java.lang.NullPointerException
at microsoft.exchange.webservices.data.core.request.ServiceRequestBase.readResponse(ServiceRequestBase.java:369)
at microsoft.exchange.webservices.data.core.request.SimpleServiceRequestBase.internalExecute(SimpleServiceRequestBase.java:63)
... 7 more
When debugged further there is a mismatch in the attribute name.
In request, the attribute is contentType is setted in request. But while reading the response, we are getting Null as code used have Content-type. There is a mismatch in the attribute name being set and read.
Is anyone else facing this issue or any workaround?
I have used the following example as a basis for my own code to publish to a MQTT server: https://github.com/spring-projects/spring-integration-samples/blob/master/basic/mqtt/src/main/java/org/springframework/integration/samples/mqtt/Application.java
I have a particular use case where the password is a token in particular a keycloak token which will expire. If for whatever reason the spring application loses connection with the MQTT server and tries to reconnect the token will have expired and an MqttSecurityException: Not authorized to connect exception will be thrown. I tried extending the method connectionLost in MqttPahoMessageHandler but as the MqttPahoClientFactory & IMqttAsyncClient are private final there is not much I can do. Wondering if there is any other approach I've not thought of or is the library just not meant to be used like this???
Thanks for any replies.
We get the MqttConnectOptions from the client factory each time we try to connect so you should be able to just update the password there.
If that doesn't work for some reason, open a new feature request.
EDIT
Regarding your comment, what's wrong with this?
#Bean
public MqttPahoClientFactory mqttClientFactory() {
DefaultMqttPahoClientFactory factory = new DefaultMqttPahoClientFactory();
MqttConnectOptions options = new MqttConnectOptions();
options.setServerURIs(new String[] { "tcp://localhost:1883" });
options.setUserName("guest");
options.setPassword("guest".toCharArray());
factory.setConnectionOptions(options);
return factory;
}
#Bean
public ApplicationRunner runner(MqttPahoClientFactory mqttClientFactory, MqttPahoMessageHandler handler) {
return args -> {
Thread.sleep(30_000);
System.out.println("Changing password");
mqttClientFactory.getConnectionOptions().setPassword("foo".toCharArray());
handler.stop();
handler.start();
};
}
foo
2020-03-10 17:42:33.560 INFO 95638 --- [iSampleConsumer] siSample
: foo sent to MQTT, received from MQTT
Changing password
foo
2020-03-10 17:43:08.705 ERROR 95638 --- [ask-scheduler-3] o.s.integration.handler.LoggingHandler
: org.springframework.messaging.MessageHandlingException: error occurred in message handler [bean 'mqttOutbound' for component 'mqttOutFlow.org.springframework.integration.config.ConsumerEndpointFactoryBean#1'; defined in: 'com.example.demo.So60610337Application'; from source: 'org.springframework.core.type.StandardMethodMetadata#79da8dc5']; nested exception is org.springframework.messaging.MessagingException: Failed to connect; nested exception is Bad user name or password (4), failedMessage=GenericMessage [payload=foo sent to MQTT, headers={id=4eab5b52-726f-7ea3-252d-77c4d0401cc8, timestamp=1583876588662}]
...
Caused by: Bad user name or password (4)
I am using spring integration in my project.
I have recently added the below method for my service activator PQMessageHandler:
#SuppressWarnings("unchecked")
public Message<?> getDatabaseProductName(Message<?> inMessage){
Message<?> outMessage = null;
String databaseProductName = null;
try {
//get the database name.
databaseProductName = DataSourceUtils.getConnection(rd).getMetaData().getDatabaseProductName();
} catch (SQLException e) {
throw new RuntimeException(e);
}
Document mainDom = XmlParserUtil.convertString2Document((String)inMessage.getPayload());
//include database name in the response xml
Element databaseName = mainDom.getRootElement().addElement("databaseName");
databaseName.setText(databaseProductName);
MessageHeaders inMsgHdrs = inMessage.getHeaders();
MessageBuilder<?> msgBuilder = MessageBuilder.withPayload(mainDom.asXML()).copyHeaders(inMsgHdrs);
outMessage= msgBuilder.build();
logger.debug("\n ************************** External System Request Message ********************* \n");
logger.debug(outMessage);
logger.debug("\n ******************************************************************************** \n");
return outMessage;
}
I have configured the code that calls the above service activator is as follows:
<int:channel id="PQPutUserBAInformation-Add-DatabaseProductName" />
<int:service-activator input-channel="PQPutUserBAInformation-Add-DatabaseProductName"
output-channel="PQPutUserBAInformation-Database-Router"
ref="msgHandler"
method="getDatabaseProductName" />
<int:router input-channel="PQPutUserBAInformation-Database-Router" default-output-channel="PQPutUserBAInformation-Default-InsertUserId-Channel" resolution-required="false" expression="#xpath(payload, '//databaseName').toLowerCase().contains('db2')">
<int:mapping value="true" channel="PQPutUserBAInformation-DB2-Request"/>
</int:router>
The above code works fine without any issues in the development environment. Weirdly when I deploy my application in client environment, I am getting the following error:
2017-04-10 10:41:50,525 INFO [org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler] (ServerService Thread Pool -- 65) Shutting down ExecutorService 'taskScheduler'
2017-04-10 10:41:50,526 ERROR [org.springframework.web.context.ContextLoader] (ServerService Thread Pool -- 65) Context initialization failed: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.integration.config.ConsumerEndpointFactoryBean#345': Cannot resolve reference to bean 'org.springframework.integration.config.ServiceActivatorFactoryBean#61' while setting bean property 'handler'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.integration.config.ServiceActivatorFactoryBean#61': FactoryBean threw exception on object creation; nested exception is java.lang.IllegalArgumentException: Target object of type [class com.dsths.cs.awd.jobs.PQMessageHandler] has no eligible methods for handling Messages.
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:329) [spring-beans-3.2.2.RELEASE.jar:3.2.2.RELEASE]
I am assuming that the recent changes are causing the issue. The log message is not clearly saying which service activator is causing the issue.
I googled about the error and confirmed that
1) There is no misspelled method attribute in the
configuration
2)The method is public
3)I haven't defined requires-reply="true" attribute in the configuration.
Any thoughts on troubleshooting the issue?
Figured out the root cause for the issue. The exception was due to EAR caching. Cleaning the EAR folder on Linux server and redeploying the war file freshly has worked out.
When ever I install the security Patch KB2742595 on my web server I'm start getting the " Exception type: InvalidProgramException
Exception message: Common Language Runtime detected an invalid program.
at System.ServiceModel.Dispatcher.ClientRuntime..ctor(String contractName, String contractNamespace)"
Stack trace: at System.ServiceModel.Dispatcher.ClientRuntime..ctor(String contractName, String contractNamespace)
at System.ServiceModel.Description.DispatcherBuilder.BuildProxyBehavior(ServiceEndpoint serviceEndpoint, BindingParameterCollection& parameters)
at System.ServiceModel.Channels.ServiceChannelFactory.BuildChannelFactory(ServiceEndpoint serviceEndpoint, Boolean useActiveAutoClose)
at System.ServiceModel.ChannelFactory.CreateFactory()
at System.ServiceModel.ChannelFactory.OnOpening()
at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
at System.ServiceModel.Channels.CommunicationObject.Open()
The configuration is W Server 2K8 SP1 and communicating the WCF service over nettcp.
Please help.
i'm trying to connect my app to Gmail to check emails. I must use SSL for POP3.
This is my code:
Properties props = new Properties();
props.put("mail.host", "pop.gmail.com");
props.put("mail.store.protocol", "pop3s");
props.put("mail.pop3s.auth", "true");
props.put("mail.pop3s.port", "993");
Session session = Session.getDefaultInstance(props, null);
Store store=session.getStore();
store.connect("myuser#gmail.com","mypass");
And I get this error:
Exception in thread "main" javax.mail.MessagingException: Connect failed;
nested exception is:
java.io.IOException: Unexpected response: * OK Gimap ready for requests from x.x.x.x.x z50if25691877wef.13
at com.sun.mail.pop3.POP3Store.protocolConnect(POP3Store.java:210)
at javax.mail.Service.connect(Service.java:295)
at javax.mail.Service.connect(Service.java:176)
at javax.mail.Service.connect(Service.java:196)
I think this has a good new: the gmail server answered, however... seems to answer in a bad way for javamail.
The port should be 995 for gmail: http://support.google.com/mail/bin/answer.py?hl=en&answer=13287
I think it will help you
Properties properties = new Properties();
properties.put("mail.pop3.host", pop3Host);
properties.put("mail.pop3.ssl.enable", true);
properties.put("mail.pop3.ssl.trust", "*");
properties.put("mail.pop3.port", 995);
Session emailSession = Session.getDefaultInstance(properties); `enter code here`