Wednesday, 4 January 2017

Textual Representation of logo

GC overhead limit exceeded Out Of Memory Error In JDBC

I have encountered this error when i was trying to insert a big list of object in to database , using jdbc . The list size was approximately 100k . One way to resolve this error to increase your memory size . I double checked my code and found that i have not closed the PreparedStatement Object in my DAO class .

java.lang.OutOfMemoryError: GC overhead limit exceeded
 at java.util.Calendar$Builder.build(Calendar.java:1482)
 at sun.util.locale.provider.CalendarProviderImpl.getInstance(CalendarProviderImpl.java:88)
 at java.util.Calendar.createCalendar(Calendar.java:1666)
 at java.util.Calendar.getInstance(Calendar.java:1655)
 at java.text.SimpleDateFormat.initializeCalendar(SimpleDateFormat.java:657)
 at java.text.SimpleDateFormat.(SimpleDateFormat.java:601)
 at com.mysql.jdbc.PreparedStatement.setTimestampInternal(PreparedStatement.java:4321)
 at com.mysql.jdbc.PreparedStatement.setTimestamp(PreparedStatement.java:4274)
 at org.apache.commons.dbcp.DelegatingPreparedStatement.setTimestamp(DelegatingPreparedStatement.java:147)
 at org.apache.commons.dbcp.DelegatingPreparedStatement.setTimestamp(DelegatingPreparedStatement.java:147)
 at ch.koala.dao.ProductDAO.insert(ProductDAO.java:42)
 at ch.koala.services.ProductSyncJob.execute(ProductSyncJob.java:64)
 at ch.koala.services.RestServices.productSyncJobExecute(RestServices.java:4020)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
 at java.lang.reflect.Method.invoke(Method.java:497)
 at com.sun.jersey.server.impl.model.method.dispatch.AbstractResourceMethodDispatchProvider$ResponseOutInvoker._dispatch(AbstractResourceMethodDispatchProvider.java:187)
 at com.sun.jersey.server.impl.model.method.dispatch.ResourceJavaMethodDispatcher.dispatch(ResourceJavaMethodDispatcher.java:71)
 at com.sun.jersey.server.impl.uri.rules.HttpMethodRule.accept(HttpMethodRule.java:280)
 at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147)
 at com.sun.jersey.server.impl.uri.rules.ResourceClassRule.accept(ResourceClassRule.java:108)
 at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147)
 at com.sun.jersey.server.impl.uri.rules.RootResourceClassesRule.accept(RootResourceClassesRule.java:84)
 at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1341)
 at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1273)
 at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1223)
 at org.mule.module.jersey.JerseyResourcesComponent.doInvoke(JerseyResourcesComponent.java:159)
 at org.mule.component.AbstractComponent.invokeInternal(AbstractComponent.java:122)
 at org.mule.component.AbstractComponent.access$000(AbstractComponent.java:57)
 at org.mule.component.AbstractComponent$1$1.process(AbstractComponent.java:238)
 at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:24)

So to solve this issue , if you encounter while using JDBC , just call close method on your PreparedStatement object , after you finished your work on that , and you might get rid of this error .


Please Post Comments and Suggestions !!!

Friday, 30 December 2016

Textual Representation of logo

Malformed Expression Error Mule ESB

I have got the following error when i tried to write java 8 stream in my expression component .
Message               : [Error: Malformed expression]
[Near : {... t.stream().map(a->a+"dd").collect(java.util.stream ....}]
                                   ^
[Line: 5, Column: 46] (org.mule.api.expression.InvalidExpressionException). Message payload is of type: NullPayload
Type                  : org.mule.api.MessagingException
Code                  : MULE_ERROR-29999
JavaDoc               : http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/MessagingException.html
Payload               : {NullPayload}
********************************************************************************
Exception stack is:
1. [Error: Malformed expression]
[Near : {... t.stream().map(a->a+"dd").collect(java.util.stream ....}]
                                   ^
[Line: 5, Column: 46] (org.mule.api.expression.InvalidExpressionException)
  org.mule.el.mvel.MVELExpressionLanguage:238 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/expression/InvalidExpressionException.html)
2. [Error: Malformed expression]
[Near : {... t.stream().map(a->a+"dd").collect(java.util.stream ....}]
                                   ^
[Line: 5, Column: 46] (org.mule.api.expression.InvalidExpressionException). Message payload is of type: NullPayload (org.mule.api.MessagingException)
  org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor:32 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/MessagingException.html)
********************************************************************************
Root Exception stack trace:
org.mule.api.expression.InvalidExpressionException: [Error: Malformed expression]
[Near : {... t.stream().map(a->a+"dd").collect(java.util.stream ....}]
                                   ^
[Line: 5, Column: 46]
 at org.mule.el.mvel.MVELExpressionLanguage.validate(MVELExpressionLanguage.java:238)
 at org.mule.el.mvel.MVELExpressionLanguage.evaluateInternal(MVELExpressionLanguage.java:189)
 at org.mule.el.mvel.MVELExpressionLanguage.evaluate(MVELExpressionLanguage.java:154)
 at org.mule.el.mvel.MVELExpressionLanguage.evaluate(MVELExpressionLanguage.java:133)
 at org.mule.el.ExpressionLanguageComponent.process(ExpressionLanguageComponent.java:51)
 at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:24)
 at org.mule.execution.MessageProcessorNotificationExecutionInterceptor.execute(MessageProcessorNotificationExecutionInterceptor.java:58)
 at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:44)
 at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:24)
 at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:44)
 at org.mule.processor.AsyncInterceptingMessageProcessor.process(AsyncInterceptingMessageProcessor.java:102)
 at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:24)
 at org.mule.execution.MessageProcessorNotificationExecutionInterceptor.execute(MessageProcessorNotificationExecutionInterceptor.java:58)
 at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:44)
 at org.mule.construct.DynamicPipelineMessageProcessor.process(DynamicPipelineMessageProcessor.java:54)
 at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:24)
 at org.mule.execution.MessageProcessorNotificationExecutionInterceptor.execute(MessageProcessorNotificationExecutionInterceptor.java:58)
 at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:44)
 at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:24)
 at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:44)
 at org.mule.interceptor.AbstractEnvelopeInterceptor.process(AbstractEnvelopeInterceptor.java:51)
 at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:24)
 at org.mule.execution.MessageProcessorNotificationExecutionInterceptor.execute(MessageProcessorNotificationExecutionInterceptor.java:58)
 at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:44)
 at org.mule.processor.AbstractFilteringMessageProcessor.process(AbstractFilteringMessageProcessor.java:40)
 at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:24)
 at org.mule.execution.MessageProcessorNotificationExecutionInterceptor.execute(MessageProcessorNotificationExecutionInterceptor.java:58)
 at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:44)
 at org.mule.construct.AbstractPipeline$1.process(AbstractPipeline.java:109)
 at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:24)
 at org.mule.execution.MessageProcessorNotificationExecutionInterceptor.execute(MessageProcessorNotificationExecutionInterceptor.java:58)
 at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:44)
 at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:24)
 at org.mule.execution.MessageProcessorNotificationExecutionInterceptor.execute(MessageProcessorNotificationExecutionInterceptor.java:58)
 at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:44)
 at org.mule.construct.AbstractPipeline$3.process(AbstractPipeline.java:207)
 at org.mule.module.http.internal.listener.HttpMessageProcessorTemplate.routeEvent(HttpMessageProcessorTemplate.java:72)
 at org.mule.execution.AsyncResponseFlowProcessingPhase$1.process(AsyncResponseFlowProcessingPhase.java:52)
 at org.mule.execution.AsyncResponseFlowProcessingPhase$1.process(AsyncResponseFlowProcessingPhase.java:47)
 at org.mule.execution.ExecuteCallbackInterceptor.execute(ExecuteCallbackInterceptor.java:16)
 at org.mule.execution.HandleExceptionInterceptor.execute(HandleExceptionInterceptor.java:30)
 at org.mule.execution.HandleExceptionIntercepto...
********************************************************************************
And here is my mule flow :
<http:listener path="/foreach/test" config-ref="myRequestConfig"
   allowedMethods="GET" doc:name="HTTP"/>
      <expression-component>
            java.util.ArrayList list = new java.util.ArrayList();
            list.add("abc");
            payload = list;
            payload = list.stream().map(a->a+"dd").collect(java.util.stream.Collectors.Collectors.toList());
         </expression-component>
        
        <logger message="paload : #[payload]" level="ERROR"/>
    </flow>

If anybody knows the answer please comment below .

Thursday, 15 December 2016

Textual Representation of logo

Mule Session And Flow Var Example

This is simple example in mule demonstrating use of SessionVar , FlowVar , SubFlow , Vm , ForEach ,Groovy and Expression Component .
<http:listener-config port="8081" host="0.0.0.0"
  name="myRequestConfig" doc:name="HTTP Listener Configuration">
  <http:worker-threading-profile
   maxThreadsActive="15" />
 </http:listener-config>

<flow name="foreachexample">
<http:listener path="/foreach/test" config-ref="myRequestConfig"
   allowedMethods="GET" doc:name="HTTP"/>
     <logger message="RUNNNING poller ra " level="ERROR"/>
      <expression-component>
            java.util.ArrayList list = new java.util.ArrayList();
            list.add("abc");
            payload = list;
         </expression-component>
        <set-session-variable value="true" variableName="changeMe" doc:name="Session Variable" />
        <set-variable value="true" variableName="myFlowVar" doc:name="Flow Variable" />
        <foreach >
         <logger message="fdsf" level="ERROR"/>
         <flow-ref name="subFlowTest" />
         <flow-ref name="flow2" />
         <vm:outbound-endpoint path="/opt"/>
        </foreach>
        <vm:outbound-endpoint path="/opt"/>
        <logger message="changeme : #[sessionVars.changeMe]" level="ERROR"/>
    </flow>
    
 <sub-flow name="subFlowTest">
  <logger message="changeme flow var in sub flow : #[flowVars.myFlowVar]" level="ERROR"/>
  <logger message="changeme session var in sub flow: #[sessionVars.changeMe]" level="ERROR"/>
  <scripting:component doc:name="sleep">
   <scripting:script engine="groovy">
                <scripting:text><![CDATA[
            java.lang.Thread.sleep(5000);]]></scripting:text>
   </scripting:script>

  </scripting:component>
 </sub-flow>
 <flow name="flow2">
  <vm:inbound-endpoint path="/opt"></vm:inbound-endpoint>
  <logger message="changeme session var in flow 2: #[sessionVars.changeMe]" level="ERROR"/>
  <logger message="changeme flow var in flow 2: #[flowVars.myFlowVar]" level="ERROR"/>
 </flow>

FlowVars do not get lost when you call another flow by using flow-ref , but if you call another flow by vm or any other transport , then the flow variable will be lost and you will not be able to find it in the other flow .

SessionVars will be present in each and every flow till the execution of the call .
This example also demonstrates how can we write java code in our mule file using groovy component and expression component . Make sure to import the packages of the class which you intend to use , otherwise use fully qualified class name in your code .


Friday, 2 December 2016

Textual Representation of logo

Multipart Jersey Request Does not work with mule 3.5.0

We can create file upload functionality in mule which is described in this blog post. But this solution does not work with mule version 3.5.0 and throws errors like this.
java.lang.StringIndexOutOfBoundsException: String index out of range: -1
 at java.lang.String.substring(String.java:1915)
 at org.mule.transport.http.multipart.MultiPartInputStream.parse(MultiPartInputStream.java:349)
 at org.mule.transport.http.multipart.MultiPartInputStream.getParts(MultiPartInputStream.java:304)
 at org.mule.transport.http.HttpMultipartMuleMessageFactory.extractPayloadFromHttpRequest(HttpMultipartMuleMessageFactory.java:35)
 at org.mule.transport.http.HttpMuleMessageFactory.extractPayload(HttpMuleMessageFactory.java:75)
 at org.mule.transport.AbstractMuleMessageFactory.doCreate(AbstractMuleMessageFactory.java:79)
 at org.mule.transport.AbstractMuleMessageFactory.create(AbstractMuleMessageFactory.java:63)
 at org.mule.transport.AbstractTransportMessageHandler.createMuleMessage(AbstractTransportMessageHandler.java:458)
 at org.mule.transport.AbstractTransportMessageProcessTemplate.createMessageFromSource(AbstractTransportMessageProcessTemplate.java:147)
 at org.mule.transport.http.HttpMessageProcessTemplate.createMessageFromSource(HttpMessageProcessTemplate.java:286)
 at org.mule.transport.AbstractTransportMessageProcessTemplate.getMuleEvent(AbstractTransportMessageProcessTemplate.java:48)
 at org.mule.execution.FlowProcessingPhase$1$1.process(FlowProcessingPhase.java:74)
 at org.mule.execution.FlowProcessingPhase$1$1.process(FlowProcessingPhase.java:63)
 at org.mule.execution.ExecuteCallbackInterceptor.execute(ExecuteCallbackInterceptor.java:16)
 at org.mule.execution.HandleExceptionInterceptor.execute(HandleExceptionInterceptor.java:30)
 at org.mule.execution.HandleExceptionInterceptor.execute(HandleExceptionInterceptor.java:14)
 at org.mule.execution.BeginAndResolveTransactionInterceptor.execute(BeginAndResolveTransactionInterceptor.java:54)
 at org.mule.execution.ResolvePreviousTransactionInterceptor.execute(ResolvePreviousTransactionInterceptor.java:44)
 at org.mule.execution.SuspendXaTransactionInterceptor.execute(SuspendXaTransactionInterceptor.java:50)
 at org.mule.execution.ValidateTransactionalStateInterceptor.execute(ValidateTransactionalStateInterceptor.java:40)
 at org.mule.execution.IsolateCurrentTransactionInterceptor.execute(IsolateCurrentTransactionInterceptor.java:41)
 at org.mule.execution.ExternalTransactionInterceptor.execute(ExternalTransactionInterceptor.java:48)
 at org.mule.execution.RethrowExceptionInterceptor.execute(RethrowExceptionInterceptor.java:28)
 at org.mule.execution.RethrowExceptionInterceptor.execute(RethrowExceptionInterceptor.java:13)
 at org.mule.execution.TransactionalErrorHandlingExecutionTemplate.execute(TransactionalErrorHandlingExecutionTemplate.java:109)
 at org.mule.execution.FlowProcessingPhase$1.run(FlowProcessingPhase.java:62)
 at org.mule.transport.TrackingWorkManager$TrackeableWork.run(TrackingWorkManager.java:267)
 at org.mule.work.WorkerContext.run(WorkerContext.java:286)
 at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
 at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
 at java.lang.Thread.run(Thread.java:745)


This is a known issue in mule and it is rectified in further version of mule , but not in 3.5.0 .
Now to resolve this , you need to remove mule-transport-http-3.5.0.jar file from mule_home/lib/mule folder and add mule-transport-http-3.3.1.jar and restart mule . It should work fine after that .

Wednesday, 30 November 2016

Textual Representation of logo

Access Denied Error When Sending Mail From Java

Sending Email from Java Class is very simple.Here is a simple java program to send emails .

import javax.mail.*;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
import java.util.Properties;

/**
 * Created by abhishek.somani on 30/11/16.
 */
public class MailSender {

    public static void main(String[] args) throws MessagingException {
        new MailSender().sendMail();
    }

    public void sendMail() throws MessagingException {
        System.setProperty("mail.smtp.localhost","localhost");
        Properties props = new Properties();
        props.put("mail.smtp.localhost","javaroots.com");
        props.put("mail.smtp.host","javaroots.host");
        props.put("mail.smtp.auth", "true");
        props.put("mail.smtp.port", 587);
        
        Session session = Session.getInstance(props,
                new javax.mail.Authenticator() {
                    protected PasswordAuthentication getPasswordAuthentication() {
                        return new PasswordAuthentication("test@test", "abcd");
                    }
                });
        session.setDebug(true);

        InternetAddress[] toAddress = new InternetAddress[1];
        toAddress = InternetAddress.parse("gmail@rajnikant.com",false);

        Transport t = session.getTransport("smtp");
        t.connect("host",
                587,"abcd","abcd");
        MimeMessage message = new MimeMessage(session);

        message.setFrom(new InternetAddress("gmail@amitabh.com"));
        message.setRecipients(Message.RecipientType.TO,
                toAddress);
        message.setSubject("Testing Subject");

        String body = "DSADSADAASDD";
        message.setText(body,"utf-8");
        t.send(message,message.getAllRecipients());
    }

}


Now this program gives you following error , even transport.isConnected() returns true . So it means that password and username and other details are correct , and it is able to make a connection to smtp server , but still it is not able to send mail .

javax.mail.SendFailedException: Invalid Addresses;
  nested exception is:
 com.sun.mail.smtp.SMTPAddressFailedException: 554 5.7.1 : Client host rejected: Access denied

 at com.sun.mail.smtp.SMTPTransport.rcptTo(SMTPTransport.java:1607)
 at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:887)
 at javax.mail.Transport.send0(Transport.java:191)
 at javax.mail.Transport.send(Transport.java:120)
 at com.services.RestServices.cancelManagerPicking(RestServices.java:2348)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
 at java.lang.reflect.Method.invoke(Method.java:497)
 at com.sun.jersey.server.impl.model.method.dispatch.AbstractResourceMethodDispatchProvider$ResponseOutInvoker._dispatch(AbstractResourceMethodDispatchProvider.java:187)
 at com.sun.jersey.server.impl.model.method.dispatch.ResourceJavaMethodDispatcher.dispatch(ResourceJavaMethodDispatcher.java:71)
 at com.sun.jersey.server.impl.uri.rules.HttpMethodRule.accept(HttpMethodRule.java:280)
 at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147)
 at com.sun.jersey.server.impl.uri.rules.ResourceClassRule.accept(ResourceClassRule.java:108)
 at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147)
 at com.sun.jersey.server.impl.uri.rules.RootResourceClassesRule.accept(RootResourceClassesRule.java:84)
 at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1341)
 at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1273)
 at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1223)
 at org.mule.module.jersey.JerseyResourcesComponent.doInvoke(JerseyResourcesComponent.java:159)
 at org.mule.component.AbstractComponent.invokeInternal(AbstractComponent.java:122)
 at org.mule.component.AbstractComponent.access$000(AbstractComponent.java:57)
 at org.mule.component.AbstractComponent$1$1.process(AbstractComponent.java:238)
 at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:24)
 at org.mule.execution.MessageProcessorNotificationExecutionInterceptor.execute(MessageProcessorNotificationExecutionInterceptor.java:58)
 at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:44)
 at org.mule.processor.AbstractInterceptingMessageProcessorBase.processNext(AbstractInterceptingMessageProcessorBase.java:102)
 at org.mule.interceptor.AbstractEnvelopeInterceptor.process(AbstractEnvelopeInterceptor.java:51)
 at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:24)
 at org.mule.execution.MessageProcessorNotificationExecutionInterceptor.execute(MessageProcessorNotificationExecutionInterceptor.java:58)
 at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:44)
 at org.mule.processor.chain.DefaultMessageProcessorChain.doProcess(DefaultMessageProcessorChain.java:94)
 at org.mule.processor.chain.AbstractMessageProcessorChain.process(AbstractMessageProcessorChain.java:67)
 at org.mule.processor.chain.InterceptingChainLifecycleWrapper.doProcess(InterceptingChainLifecycleWrapper.java:50)
 at org.mule.processor.chain.AbstractMessageProcessorChain.process(AbstractMessageProcessorChain.java:67)
 at org.mule.processor.chain.InterceptingChainLifecycleWrapper.access$001(InterceptingChainLifecycleWrapper.java:22)
 at org.mule.processor.chain.InterceptingChainLifecycleWrapper$1.process(InterceptingChainLifecycleWrapper.java:66)
 at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:24)
 at org.mule.execution.MessageProcessorNotificationExecutionInterceptor.execute(MessageProcessorNotificationExecutionInterceptor.java:58)
 at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:44)
 at org.mule.processor.chain.InterceptingChainLifecycleWrapper.process(InterceptingChainLifecycleWrapper.java:61)
 at org.mule.component.AbstractComponent.process(AbstractComponent.java:156)
 at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:24)
 at org.mule.execution.MessageProcessorNotificationExecutionInterceptor.execute(MessageProcessorNotificationExecutionInterceptor.java:58)
 at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:44)
 at org.mule.processor.chain.DefaultMessageProcessorChain.doProcess(DefaultMessageProcessorChain.java:94)
 at org.mule.processor.chain.AbstractMessageProcessorChain.process(AbstractMessageProcessorChain.java:67)
 at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:24)
 at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:44)
 at org.mule.processor.AbstractInterceptingMessageProcessorBase.processNext(AbstractInterceptingMessageProcessorBase.java:102)
 at org.mule.processor.AsyncInterceptingMessageProcessor.process(AsyncInterceptingMessageProcessor.java:97)
 at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:24)
 at org.mule.execution.MessageProcessorNotificationExecutionInterceptor.execute(MessageProcessorNotificationExecutionInterceptor.java:58)
 at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:44)
 at org.mule.processor.AbstractInterceptingMessageProcessorBase.processNext(AbstractInterceptingMessageProcessorBase.java:102)
 at org.mule.construct.DynamicPipelineMessageProcessor.process(DynamicPipelineMessageProcessor.java:54)
 at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:24)
 at org.mule.execution.MessageProcessorNotificationExecutionInterceptor.execute(MessageProcessorNotificationExecutionInterceptor.java:58)
 at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:44)
 at org.mule.processor.chain.DefaultMessageProcessorChain.doProcess(DefaultMessageProcessorChain.java:94)
 at org.mule.processor.chain.AbstractMessageProcessorChain.process(AbstractMessageProcessorChain.java:67)
 at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:24)
 at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:44)
 at org.mule.processor.AbstractInterceptingMessageProcessorBase.processNext(AbstractInterceptingMessageProcessorBase.java:102)
 at org.mule.interceptor.AbstractEnvelopeInterceptor.process(AbstractEnvelopeInterceptor.java:51)
 at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:24)
 at org.mule.execution.MessageProcessorNotificationExecutionInterceptor.execute(MessageProcessorNotificationExecutionInterceptor.java:58)
 at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:44)
 at org.mule.processor.AbstractInterceptingMessageProcessorBase.processNext(AbstractInterceptingMessageProcessorBase.java:102)
 at org.mule.processor.AbstractFilteringMessageProcessor.process(AbstractFilteringMessageProcessor.java:40)
 at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:24)
 at org.mule.execution.MessageProcessorNotificationExecutionInterceptor.execute(MessageProcessorNotificationExecutionInterceptor.java:58)
 at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:44)
 at org.mule.processor.AbstractInterceptingMessageProcessorBase.processNext(AbstractInterceptingMessageProcessorBase.java:102)
 at org.mule.construct.AbstractPipeline$1.process(AbstractPipeline.java:109)
 at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:24)
 at org.mule.execution.MessageProcessorNotificationExecutionInterceptor.execute(MessageProcessorNotificationExecutionInterceptor.java:58)
 at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:44)
 at org.mule.processor.chain.DefaultMessageProcessorChain.doProcess(DefaultMessageProcessorChain.java:94)
 at org.mule.processor.chain.AbstractMessageProcessorChain.process(AbstractMessageProcessorChain.java:67)
 at org.mule.processor.chain.InterceptingChainLifecycleWrapper.doProcess(InterceptingChainLifecycleWrapper.java:50)
 at org.mule.processor.chain.AbstractMessageProcessorChain.process(AbstractMessageProcessorChain.java:67)
 at org.mule.processor.chain.InterceptingChainLifecycleWrapper.access$001(InterceptingChainLifecycleWrapper.java:22)
 at org.mule.processor.chain.InterceptingChainLifecycleWrapper$1.process(InterceptingChainLifecycleWrapper.java:66)
 at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:24)
 at org.mule.execution.MessageProcessorNotificationExecutionInterceptor.execute(MessageProcessorNotificationExecutionInterceptor.java:58)
 at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:44)
 at org.mule.processor.chain.InterceptingChainLifecycleWrapper.process(InterceptingChainLifecycleWrapper.java:61)
 at org.mule.construct.AbstractPipeline$3.process(AbstractPipeline.java:207)
 at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:24)
 at org.mule.execution.MessageProcessorNotificationExecutionInterceptor.execute(MessageProcessorNotificationExecutionInterceptor.java:58)
 at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:44)
 at org.mule.processor.chain.SimpleMessageProcessorChain.doProcess(SimpleMessageProcessorChain.java:43)
 at org.mule.processor.chain.AbstractMessageProcessorChain.process(AbstractMessageProcessorChain.java:67)
 at org.mule.processor.chain.InterceptingChainLifecycleWrapper.doProcess(InterceptingChainLifecycleWrapper.java:50)
 at org.mule.processor.chain.AbstractMessageProcessorChain.process(AbstractMessageProcessorChain.java:67)
 at org.mule.processor.chain.InterceptingChainLifecycleWrapper.access$001(InterceptingChainLifecycleWrapper.java:22)
 at org.mule.processor.chain.InterceptingChainLifecycleWrapper$1.process(InterceptingChainLifecycleWrapper.java:66)
 at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:24)
 at org.mule.execution.MessageProcessorNotificationExecutionInterceptor.execute(MessageProcessorNotificationExecutionInterceptor.java:58)
 at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:44)
 at org.mule.processor.chain.InterceptingChainLifecycleWrapper.process(InterceptingChainLifecycleWrapper.java:61)
 at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:24)
 at org.mule.execution.MessageProcessorNotificationExecutionInterceptor.execute(MessageProcessorNotificationExecutionInterceptor.java:58)
 at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:44)
 at org.mule.processor.chain.SimpleMessageProcessorChain.doProcess(SimpleMessageProcessorChain.java:43)
 at org.mule.processor.chain.AbstractMessageProcessorChain.process(AbstractMessageProcessorChain.java:67)
 at org.mule.processor.chain.InterceptingChainLifecycleWrapper.doProcess(InterceptingChainLifecycleWrapper.java:50)
 at org.mule.processor.chain.AbstractMessageProcessorChain.process(AbstractMessageProcessorChain.java:67)
 at org.mule.processor.chain.InterceptingChainLifecycleWrapper.access$001(InterceptingChainLifecycleWrapper.java:22)
 at org.mule.processor.chain.InterceptingChainLifecycleWrapper$1.process(InterceptingChainLifecycleWrapper.java:66)
 at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:24)
 at org.mule.execution.MessageProcessorNotificationExecutionInterceptor.execute(MessageProcessorNotificationExecutionInterceptor.java:58)
 at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:44)
 at org.mule.processor.chain.InterceptingChainLifecycleWrapper.process(InterceptingChainLifecycleWrapper.java:61)
 at org.mule.transport.AbstractMessageReceiver.routeEvent(AbstractMessageReceiver.java:511)
 at org.mule.transport.AbstractMessageReceiver.routeMessage(AbstractMessageReceiver.java:226)
 at org.mule.transport.AbstractMessageReceiver.routeMessage(AbstractMessageReceiver.java:208)
 at org.mule.transport.AbstractMessageReceiver.routeMessage(AbstractMessageReceiver.java:200)
 at org.mule.transport.AbstractMessageReceiver.routeMessage(AbstractMessageReceiver.java:187)
 at org.mule.transport.http.HttpMessageReceiver$HttpWorker$1.process(HttpMessageReceiver.java:311)
 at org.mule.transport.http.HttpMessageReceiver$HttpWorker$1.process(HttpMessageReceiver.java:306)
 at org.mule.execution.ExecuteCallbackInterceptor.execute(ExecuteCallbackInterceptor.java:16)
 at org.mule.execution.HandleExceptionInterceptor.execute(HandleExceptionInterceptor.java:30)
 at org.mule.execution.HandleExceptionInterceptor.execute(HandleExceptionInterceptor.java:14)
 at org.mule.execution.BeginAndResolveTransactionInterceptor.execute(BeginAndResolveTransactionInterceptor.java:54)
 at org.mule.execution.ResolvePreviousTransactionInterceptor.execute(ResolvePreviousTransactionInterceptor.java:44)
 at org.mule.execution.SuspendXaTransactionInterceptor.execute(SuspendXaTransactionInterceptor.java:50)
 at org.mule.execution.ValidateTransactionalStateInterceptor.execute(ValidateTransactionalStateInterceptor.java:40)
 at org.mule.execution.IsolateCurrentTransactionInterceptor.execute(IsolateCurrentTransactionInterceptor.java:41)
 at org.mule.execution.ExternalTransactionInterceptor.execute(ExternalTransactionInterceptor.java:48)
 at org.mule.execution.RethrowExceptionInterceptor.execute(RethrowExceptionInterceptor.java:28)
 at org.mule.execution.RethrowExceptionInterceptor.execute(RethrowExceptionInterceptor.java:13)
 at org.mule.execution.TransactionalErrorHandlingExecutionTemplate.execute(TransactionalErrorHandlingExecutionTemplate.java:109)
 at org.mule.execution.TransactionalErrorHandlingExecutionTemplate.execute(TransactionalErrorHandlingExecutionTemplate.java:30)
 at org.mule.transport.http.HttpMessageReceiver$HttpWorker.doRequest(HttpMessageReceiver.java:305)
 at org.mule.transport.http.HttpMessageReceiver$HttpWorker.processRequest(HttpMessageReceiver.java:251)
 at org.mule.transport.http.HttpMessageReceiver$HttpWorker.run(HttpMessageReceiver.java:163)
 at org.mule.transport.TrackingWorkManager$TrackeableWork.run(TrackingWorkManager.java:267)
 at org.mule.work.WorkerContext.run(WorkerContext.java:286)
 at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
 at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
 at java.lang.Thread.run(Thread.java:745)
Caused by: com.sun.mail.smtp.SMTPAddressFailedException: 554 5.7.1 : Client host rejected: Access denied
The reason for this error was that you did not starttls in your program .Adding the following line fix the error .
props.put("mail.smtp.starttls.enable", "true");

Saturday, 10 September 2016

Textual description of firstImageUrl

How to Create Documentation of JAX-RS Web Services

In this post i will describe how to create a html document from you rest jersey class , which can be used by web sevices consumers easily .

First you need to install raml-for-jax-rs plugin in your eclipse or anypoint studio .

Once you start it properly , and go to your rest service JAX-RS class , and right click on it , you should be able to see "Generate raml for class" option . You click on it and provide name and location of your generated raml file .

Now you have your generated automatically by this awesome plugin , you need to convert it to html document . For that , you have to install raml to html plugin which is written in node.js . install this plugin and go to the location where you have generated the raml file .Now you have to just use following command :
raml2html RestServices.raml -o doc.html
Now your rest class is converted in good looking one page html document which you can expose on your web server .

Friday, 12 August 2016

Textual description of firstImageUrl

Download WebMaster Tool Data using Casper JS

This is a simple casper js script to automate your process of downloading webmaster tools reports .


Google Webmaster does not provide any api to download the data .

This simple casperjs script will allow you to download the data and automate the process .

please change the google account credentials and also the time period for which you want to download the report .
var page = require('webpage').create();
var xpath = require('casper').selectXPath;
var casper = require('casper').create({   
    verbose: true, 
    logLevel: 'debug',
    pageSettings: {
         loadImages:  false,         // The WebPage instance used by Casper will
         loadPlugins: false,         // use these settings
         userAgent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_5) AppleWebKit/537.4 (KHTML, like Gecko) Chrome/22.0.1229.94 Safari/537.4'
    }
});

// print out all the messages in the headless browser context
casper.on('remote.message', function(msg) {
    this.echo('remote message caught: ' + msg);
});

// print out all the messages in the headless browser context
casper.on("page.error", function(msg, trace) {
    this.echo("Page Error: " + msg, "ERROR");
});

var url = 'https://accounts.google.com/ServiceLogin';

casper.start(url, function() {
   // search for 'casperjs' from google form
   console.log("page loaded");
   this.fill('form#gaia_loginform', { 
        Email:'test', 
        Passwd:'test'
    }, true);
});

casper.thenEvaluate(function(){
   console.log("Page Title " + document.title);
});
var url = 'https://www.google.com/webmasters/tools/top-search-queries?hl=en&siteUrl=http://www.javaroots.com/&de=20150315&db=20150314&more=true&type=queries';
casper.thenOpen(url ,function (status) {
    /*var js = page.evaluate(function () {
        return document;
    });
    console.log(JSON.stringify(js)); */
 console.log(" trrsadsadsssssss");
});

casper.then(function() {
 console.log(" clickingggg first time ");
 this.click('#tsq-table-download > div:nth-child(1)');
 //this.click(xpath('//*[@class="goog-inline-block jfk-button jfk-button-standard"]'));
});


//casper.waitForSelector(xpath('/html/body/div[11]/div[3]/button[1]'), function() {
 casper.waitForSelector('.goog-buttonset-default', function() {

casper.then(function(){
  this.capture('abc.png', undefined, {
             format: 'png',
            quality: 100
     });
});
});

casper.then(function() {
 console.log(" clickingggg");
 //this.click(xpath('/html/body/div[11]/div[3]'));
 this.click('.goog-buttonset-default');
});

casper.on('resource.received', function(resource) {
 if(resource.url)
 {
  if(resource.url.indexOf("/top-search-queries-dl") > -1)
  {
   console.log(" resource url is " + resource.url);
   console.log("Downloading csv file");
   this.download(resource.url, 'ExportData.csv');
  }
 }
 
});
casper.run();
Post Comments and suggestions !!!!