Wednesday, November 30, 2016

Error: unable to write 'random state'

Environment:  Ubuntu 15.10

Situation: Generating Open SSL keys

Error:
 unable to write 'random state'  

Analysis:

This happens due to .rnd file in home directory is owned by root rather than current user account. Giving permission to that file through user account, this can be resolve.

Solution:

Identify the current user
 echo $USER  

Give permissions
 sudo chown user:user ~/.rnd  

* Replace user with current user





Thursday, August 11, 2016

[Error]Host name verification failed for host


Environment: Integration scenario of WSO2 ESB with WSO2 IS
                         JDK 1.8

Precondition:  IS is in remote server
                       IS and ESB should be up and running
                       ESB contain proxy which is going to call IS endpoint

Situation: Invoke ESB proxy service.

Error:

 [2016-08-12 10:46:32,329] ERROR - TargetHandler I/O error: Host name verification failed for host : ***.**.**.*  
 javax.net.ssl.SSLException: Host name verification failed for host : ***.**.**.*  
      at org.apache.synapse.transport.http.conn.ClientSSLSetupHandler.verify(ClientSSLSetupHandler.java:162)  
      at org.apache.http.nio.reactor.ssl.SSLIOSession.doHandshake(SSLIOSession.java:291)  
      at org.apache.http.nio.reactor.ssl.SSLIOSession.isAppInputReady(SSLIOSession.java:391)  
      at org.apache.http.impl.nio.reactor.AbstractIODispatch.inputReady(AbstractIODispatch.java:119)  
      at org.apache.http.impl.nio.reactor.BaseIOReactor.readable(BaseIOReactor.java:159)  
      at org.apache.http.impl.nio.reactor.AbstractIOReactor.processEvent(AbstractIOReactor.java:338)  
      at org.apache.http.impl.nio.reactor.AbstractIOReactor.processEvents(AbstractIOReactor.java:316)  
      at org.apache.http.impl.nio.reactor.AbstractIOReactor.execute(AbstractIOReactor.java:277)  
      at org.apache.http.impl.nio.reactor.BaseIOReactor.execute(BaseIOReactor.java:105)  
      at org.apache.http.impl.nio.reactor.AbstractMultiworkerIOReactor$Worker.run(AbstractMultiworkerIOReactor.java:586)  
      at java.lang.Thread.run(Thread.java:745)  

Solution:

Disable Host verification via ESB 
  • Navigate to axis2.xml ($ESB_HOME/repository/conf/axis2/axis2.xml) 
  • Uncomment following and add relevant value;
  <!--<parameter name="HostnameVerifier">DefaultAndLocalhost</parameter>-->  
  <!--supports Strict|AllowAll|DefaultAndLocalhost or the default if none specified -->  

In here it will allow all hosts;

 <parameter name="HostnameVerifier">AllowAll</parameter>  

Restart ESB to apply changes :)

Monday, July 25, 2016

[WSO2][ESB][JMS] Getting error with IBM MQ jars

Environment: ESB 5.0.0
                       IBM MQ version 8
                       Java 1.8

Precondition: ESB should contain suitable jars of IBM MQ

Situation: Going to start ESB server and getting the error

Error:

Caused by: java.lang.ClassNotFoundException: javax.jms.JMSRuntimeException cannot be found by com.ibm.mq.allclient_1.0.0

Solution:

Remove following line from <ESB_Home>\repository\conf\etc\launch.ini.

  • javax.jms,\

Friday, July 22, 2016

[WSO2][ESB] Converting SOAP response to JSON and missing a part

Environment: ESB 4.9.0
                         Java 1.8.0
             
Preconditions: Create a proxy which will convert SOAP response into JSON format (within the out sequence)

Sample out sequence:

<outSequence xmlns="http://ws.apache.org/ns/synapse">
   <property name="messageType" value="application/json" scope="axis2" type="STRING"></property>
   <send></send>
</outSequence> 

Error: It will only convert part of the response into JSON.

Sample Response:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"       xmlns:xsd="http://www.w3.org/2001/XMLSchema"   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<ns1:easyDownloadResponse xmlns:ns1="http://usermanage.ivas.huawei.com" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<easyDownloadReturn href="#id0"/>
</ns1:easyDownloadResponse>
<multiRef xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns2="http://response.usermanage.ivas.huawei.com" id="id0" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="ns2:EasyDownloadResp">
<eventClassName xsi:type="xsd:string" xsi:nil="true"/>
<failedResources xsi:type="soapenc:Array" xsi:nil="true"/>
<operationID xsi:type="xsd:long">0</operationID>
<resultCode xsi:type="xsd:int">0</resultCode>
<resultInfo xsi:type="xsd:string" xsi:nil="true"/>
<returnCode xsi:type="xsd:string">000000</returnCode>
<toneTransactionID xsi:type="soapenc:Array" xsi:nil="true"/>
<transactionID xsi:type="xsd:string" xsi:nil="true"/>
</multiRef>
</soapenv:Body> </soapenv:Envelope> 

Converted JSON :

{"easyDownloadResponse":{"@encodingStyle":"http://schemas.xmlsoap.org/soap/encoding/","easyDownloadReturn":{"@href":"#id0"}}}

Solution:

Add JSON conversion property as follows:

<outSequence xmlns="http://ws.apache.org/ns/synapse">
   <property name="messageType" value="application/json/badgerfish" scope="axis2" type="STRING"></property>
   <send></send>
</outSequence>


Sunday, July 17, 2016

[WSO2][ESB][Cluster] Task Scheduling Error

Environment:  ESB 4.9.0
                        Java: 1.8.0
                        Clustered Environment (2 worker nodes with a manager node)
                        Added inbound endpoints for JMS transport

Preconditions: All nodes in cluster should be down

Situation: Start manager node. Can be seen following error.
                 When start worker nodes also can be seen the error.

Error:

 [2016-06-21 06:11:17,741] ERROR - NTaskTaskManager Scheduling task [[NTask::-1234::JMSListener3-JMS--SYNAPSE_INBOUND_ENDPOINT]::JMS--SYNAPSE_INBOUND_ENDPOINT] FAILED. Error: No available task nodes for resolving a task location  
 org.wso2.carbon.ntask.common.TaskException: No available task nodes for resolving a task location  
   at org.wso2.carbon.ntask.core.impl.clustered.ClusteredTaskManager.getTaskLocation(ClusteredTaskManager.java:232)  
   at org.wso2.carbon.ntask.core.impl.clustered.ClusteredTaskManager.locateMemberForTask(ClusteredTaskManager.java:209)  
   at org.wso2.carbon.ntask.core.impl.clustered.ClusteredTaskManager.getMemberIdFromTaskName(ClusteredTaskManager.java:283)  
   at org.wso2.carbon.ntask.core.impl.clustered.ClusteredTaskManager.scheduleTask(ClusteredTaskManager.java:91)  
   at org.wso2.carbon.mediation.ntask.NTaskTaskManager.schedule(NTaskTaskManager.java:103)  
   at org.wso2.carbon.mediation.ntask.NTaskTaskManager.init(NTaskTaskManager.java:350)  
   at org.wso2.carbon.mediation.ntask.NTaskTaskManager.update(NTaskTaskManager.java:363)  
   at org.wso2.carbon.mediation.ntask.internal.NtaskService.updateAndCleanupObservers(NtaskService.java:103)  
   at org.wso2.carbon.mediation.ntask.internal.NtaskService.setConfigurationContextService(NtaskService.java:96)  
   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)  

Solution:  Start worker nodes in worker profile as follows;

sh wso2server.sh -DworkerNode=true
When you are starting manager node, it may pop up the same error. Because worker nodes are not up yet. After worker nodes are active, you should not get the similar error again.

Relevant issue reported in StackOverflow: http://stackoverflow.com/questions/38051732/wso2-esb-cluster-environment-task-sheduling/


Tuesday, July 12, 2016

[WSO2][ESB][JMS] Configuring jms message store without message processor

Environment - ESB 4.9.0
                         Oracle jdk1.8.0_72
                         MB 3.1.0

Preconditions: ESB should be configured with MB
                          ESB and MB should  up and running

Situation: Create a proxy in ESB which will send incoming message in to jms message store 

 <proxy name="InformationIncome" startOnLoad="true" trace="disable" transports="http https">  
     <description/>  
     <target>  
       <inSequence>  
         <log level="full"/>  
         <property name="FORCE_SC_ACCEPTED" scope="axis2" value="true"/>  
         <property name="OUT_ONLY" value="true"/>  
         <property name="content-Type" scope="transport"  
           type="STRING" value="application/json"/>  
         <property name="messageType" scope="axis2" type="STRING" value="application/json"/>  
         <payloadFactory media-type="json">  
           <format>  
         {  
         "processDefinitionId":"myProcess:6:25188",  
         "variables": [  
          {  
           "name":"text",  
           "value":"$1"  
          }  
         ]  
       }   
       </format>  
           <args>  
             <arg evaluator="json" expression="$.text"/>  
           </args>  
         </payloadFactory>  
         <header  
           expression="fn:concat('Basic ', base64Encode('admin:admin'))"  
           name="Authorization" scope="transport"/>  
         <log level="full"/>  
         <store messageStore="InformationIncomeMS"/>  
       </inSequence>  
     </target>  
   </proxy>  

  <messageStore  
     class="org.apache.synapse.message.store.impl.jms.JmsStore" name="InformationIncomeMS">  
     <parameter name="store.jms.destination">JMSQueue</parameter>  
     <parameter name="store.producer.guaranteed.delivery.enable">false</parameter>  
     <parameter name="java.naming.factory.initial">org.wso2.andes.jndi.PropertiesFileInitialContextFactory</parameter>  
     <parameter name="java.naming.provider.url">repository/conf/jndi.properties</parameter>  
     <parameter name="store.jms.JMSSpecVersion">1.1</parameter>  
   </messageStore>  

Add another proxy which will listen to message store queue.
 <proxy name="JMSQueue" startOnLoad="true" trace="disable" transports="jms">  
     <description/>  
     <target>  
       <inSequence>  
         <log level="full">  
           <property name="Message" value="==============This is listening sequence======"/>  
         </log>  
       </inSequence>  
     </target>  
   </proxy>  

Publish a message to Proxy.

Error:
 [2016-07-12 17:51:05,124] ERROR - BaseUtils Unsupported JMS message type org.wso2.andes.client.message.JMSObjectMessage  
 [2016-07-12 17:51:05,125] ERROR - JMSMessageReceiver Unknown error processing message  
 org.apache.axis2.transport.base.BaseTransportException: Unsupported JMS message type org.wso2.andes.client.message.JMSObjectMessage  
      at org.apache.axis2.transport.base.BaseUtils.handleException(BaseUtils.java:168)  
      at org.apache.axis2.transport.jms.JMSUtils.setSOAPEnvelope(JMSUtils.java:177)  
      at org.apache.axis2.transport.jms.JMSMessageReceiver.processThoughEngine(JMSMessageReceiver.java:195)  
      at org.apache.axis2.transport.jms.JMSMessageReceiver.onMessage(JMSMessageReceiver.java:122)  
      at org.apache.axis2.transport.jms.ServiceTaskManager$MessageListenerTask.handleMessage(ServiceTaskManager.java:575)  
      at org.apache.axis2.transport.jms.ServiceTaskManager$MessageListenerTask.run(ServiceTaskManager.java:468)  
      at org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerPool.java:172)  
      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)  


Solution:

Add a message processor to handle messages in message store
   <messageProcessor  
     class="org.apache.synapse.message.processor.impl.forwarder.ScheduledMessageForwardingProcessor"  
     messageStore="InformationIncomeMS" name="testP" targetEndpoint="aspnet">  
     <parameter name="client.retry.interval">1000</parameter>  
     <parameter name="throttle">false</parameter>  
     <parameter name="max.delivery.attempts">4</parameter>  
     <parameter name="member.count">1</parameter>  
     <parameter name="max.delivery.drop">Enabled</parameter>  
     <parameter name="interval">1000</parameter>  
     <parameter name="is.active">true</parameter>  
     <parameter name="target.endpoint">aspnet</parameter>  
   </messageProcessor>  



Sample code for endpoint:

 <endpoint xmlns="http://ws.apache.org/ns/synapse" name="aspnet">  
   <address uri="http://localhost:9000/services/SimpleStockQuoteService">  
    <suspendOnFailure>  
      <progressionFactor>1.0</progressionFactor>  
    </suspendOnFailure>  
    <markForSuspension>  
      <retriesBeforeSuspension>0</retriesBeforeSuspension>  
      <retryDelay>0</retryDelay>  
    </markForSuspension>  
   </address>  
 </endpoint>  

Analysis:


Once we store messages in a message store we need to use message processor to process the stored messages. When a message stored in a JMS Message Store, that message is getting serialized before storing it in the JMS Queue. After serializing, it is saved as Object message. It is the implementation behavior and it is getting deserialized when it is processed by the message processor. Basically, without using the message processor, can not consume that message.


Monday, May 9, 2016

When stop ActiveMQ server, it gives an error

Environment - Active MQ 5.11
                          Oracle jdk1.8.0_72

Preconditions: Active MQ should be installed. 

Situation: Stop ActiveMq service.

Error:

 dilshani@dilshani-ThinkPad-X1-Carbon-3rd:~$ sudo /etc/init.d/activemq stop  
 INFO: Loading '/etc/default/activemq'  
 INFO: Using java '/usr/lib/jvm/java-7-oracle/bin/java'  
 INFO: changing to user 'activemq' to invoke java  
 INFO: Waiting at least seconds for regular process termination of pid '7966' :   
 Java Runtime: Oracle Corporation 1.7.0_80 /usr/lib/jvm/java-7-oracle/jre  
  Heap sizes: current=117248k free=116018k max=1745920k  
   JVM args: -Dactivemq.classpath=/opt/apache-activemq-5.11.1/conf: -Dactivemq.home=/opt/apache-activemq-5.11.1 -Dactivemq.base=/opt/apache-activemq-5.11.1 -Dactivemq.conf=/opt/apache-activemq-5.11.1/conf -Dactivemq.data=/opt/apache-activemq-5.11.1/data  
 Extensions classpath:  
  [/opt/apache-activemq-5.11.1/lib,/opt/apache-activemq-5.11.1/lib/camel,/opt/apache-activemq-5.11.1/lib/optional,/opt/apache-activemq-5.11.1/lib/web,/opt/apache-activemq-5.11.1/lib/extra]  
 ACTIVEMQ_HOME: /opt/apache-activemq-5.11.1  
 ACTIVEMQ_BASE: /opt/apache-activemq-5.11.1  
 ACTIVEMQ_CONF: /opt/apache-activemq-5.11.1/conf  
 ACTIVEMQ_DATA: /opt/apache-activemq-5.11.1/data  
 Connecting to pid: 7966  
 INFO: failed to resolve jmxUrl for pid:7966, using default JMX url  
 Connecting to JMX URL: service:jmx:rmi:///jndi/rmi://localhost:1099/jmxrmi  
 ERROR: java.lang.RuntimeException: Failed to execute stop task. Reason: java.io.IOException: Failed to retrieve RMIServer stub: javax.naming.ServiceUnavailableException [Root exception is java.rmi.ConnectException: Connection refused to host: localhost; nested exception is:   
      java.net.ConnectException: Connection refused]  
 java.lang.RuntimeException: Failed to execute stop task. Reason: java.io.IOException: Failed to retrieve RMIServer stub: javax.naming.ServiceUnavailableException [Root exception is java.rmi.ConnectException: Connection refused to host: localhost; nested exception is:   
      java.net.ConnectException: Connection refused]  
      at org.apache.activemq.console.command.ShutdownCommand.runTask(ShutdownCommand.java:116)  
      at org.apache.activemq.console.command.AbstractCommand.execute(AbstractCommand.java:57)  
      at org.apache.activemq.console.command.AbstractJmxCommand.execute(AbstractJmxCommand.java:387)  
      at org.apache.activemq.console.command.ShellCommand.runTask(ShellCommand.java:150)  
      at org.apache.activemq.console.command.AbstractCommand.execute(AbstractCommand.java:57)  
      at org.apache.activemq.console.command.ShellCommand.main(ShellCommand.java:104)  
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)  
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)  
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)  
      at java.lang.reflect.Method.invoke(Method.java:606)  
      at org.apache.activemq.console.Main.runTaskClass(Main.java:262)  
      at org.apache.activemq.console.Main.main(Main.java:115)  
 ERROR: java.lang.Exception: java.io.IOException: Failed to retrieve RMIServer stub: javax.naming.ServiceUnavailableException [Root exception is java.rmi.ConnectException: Connection refused to host: localhost; nested exception is:   
      java.net.ConnectException: Connection refused]  
 java.lang.Exception: java.io.IOException: Failed to retrieve RMIServer stub: javax.naming.ServiceUnavailableException [Root exception is java.rmi.ConnectException: Connection refused to host: localhost; nested exception is:   
      java.net.ConnectException: Connection refused]  
      at org.apache.activemq.console.command.ShutdownCommand.runTask(ShutdownCommand.java:117)  
      at org.apache.activemq.console.command.AbstractCommand.execute(AbstractCommand.java:57)  
      at org.apache.activemq.console.command.AbstractJmxCommand.execute(AbstractJmxCommand.java:387)  
      at org.apache.activemq.console.command.ShellCommand.runTask(ShellCommand.java:150)  
      at org.apache.activemq.console.command.AbstractCommand.execute(AbstractCommand.java:57)  
      at org.apache.activemq.console.command.ShellCommand.main(ShellCommand.java:104)  
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)  
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)  
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)  
      at java.lang.reflect.Method.invoke(Method.java:606)  
      at org.apache.activemq.console.Main.runTaskClass(Main.java:262)  
      at org.apache.activemq.console.Main.main(Main.java:115)  
 Caused by: java.io.IOException: Failed to retrieve RMIServer stub: javax.naming.ServiceUnavailableException [Root exception is java.rmi.ConnectException: Connection refused to host: localhost; nested exception is:   
      java.net.ConnectException: Connection refused]  
      at javax.management.remote.rmi.RMIConnector.connect(RMIConnector.java:369)  
      at javax.management.remote.JMXConnectorFactory.connect(JMXConnectorFactory.java:268)  
      at javax.management.remote.JMXConnectorFactory.connect(JMXConnectorFactory.java:227)  
      at org.apache.activemq.console.command.AbstractJmxCommand.createJmxConnector(AbstractJmxCommand.java:279)  
      at org.apache.activemq.console.command.AbstractJmxCommand.createJmxConnection(AbstractJmxCommand.java:302)  
      at org.apache.activemq.console.command.ShutdownCommand.runTask(ShutdownCommand.java:81)  
      ... 11 more  
 Caused by: javax.naming.ServiceUnavailableException [Root exception is java.rmi.ConnectException: Connection refused to host: localhost; nested exception is:   
      java.net.ConnectException: Connection refused]  
      at com.sun.jndi.rmi.registry.RegistryContext.lookup(RegistryContext.java:118)  
      at com.sun.jndi.toolkit.url.GenericURLContext.lookup(GenericURLContext.java:203)  
      at javax.naming.InitialContext.lookup(InitialContext.java:411)  
      at javax.management.remote.rmi.RMIConnector.findRMIServerJNDI(RMIConnector.java:1929)  
      at javax.management.remote.rmi.RMIConnector.findRMIServer(RMIConnector.java:1896)  
      at javax.management.remote.rmi.RMIConnector.connect(RMIConnector.java:286)  
      ... 16 more  
 Caused by: java.rmi.ConnectException: Connection refused to host: localhost; nested exception is:   
      java.net.ConnectException: Connection refused  
      at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:619)  
      at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:216)  
      at sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:202)  
      at sun.rmi.server.UnicastRef.newCall(UnicastRef.java:341)  
      at sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source)  
      at com.sun.jndi.rmi.registry.RegistryContext.lookup(RegistryContext.java:114)  
      ... 21 more  
 Caused by: java.net.ConnectException: Connection refused  
      at java.net.PlainSocketImpl.socketConnect(Native Method)  
      at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:339)  
      at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:200)  
      at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:182)  
      at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)  
      at java.net.Socket.connect(Socket.java:579)  
      at java.net.Socket.connect(Socket.java:528)  
      at java.net.Socket.<init>(Socket.java:425)  
      at java.net.Socket.<init>(Socket.java:208)  
      at sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(RMIDirectSocketFactory.java:40)  
      at sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(RMIMasterSocketFactory.java:147)  
      at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:613)  
      ... 26 more  
 ...................  



Solution:

1. Go to {ACTIVEMQ_HOME}/conf/activemq.xml

2. Edit as follows:

<!-- 
     The managementContext is used to configure how ActiveMQ is exposed in 
     JMX. By default, ActiveMQ uses the MBean server that is started by 
     the JVM. For more information, see: 

         http://activemq.apache.org/jmx.html 
 -->
 <managementContext>
   <managementContext createConnector="false"/>
 </managementContext>

Change managementContext createConnector="false" as managementContext createConnector="true"


3. Save and exit.


4. Restart computer.

Now activemq will stop its' processes without any errors...