Labels

Showing posts with label coding. Show all posts
Showing posts with label coding. Show all posts

Friday, August 19, 2016

Sharing Subscribers' Application and Subscriptions with Other Subscribers + WSO2 APIM

Hi All,

It is really easy to share your subscriptions within your team or organization.  Please follow the below steps which shows how to configure and use.

STEPS
1.  Go to the api-manager.xml file and Uncomment the <GroupingExtractor> element.
  path - wso2am-1.10.0/repository/conf/api-manager.xml
2. Start the server.
3. If you dont have any API's created. Create and publish an API from the APIM publisher
4. Login to the API Store and go to the signup page. Fill the user details and click more details add an organization name

5. login using that and user and create application and subscribe
6. sign-out from that user and create a new user with the same organization name.  login from that user you can get the first users applications and subscriptions.


If you have any issues feel free to drop a comment.
Have Fun !!!

Tuesday, July 26, 2016

Retry when Call Mediator fails in In-Sequence WSO2 ESB

Hi All,
This blog post is to show how you could retry when the there is an issue in the in-sequence.

Flow
when the proxy is invoked it will hit the in-sequence(foo) and if there is an issue, onError sequence will be called(retryError).
In the bellow retryError sequence it will check if the error is occurred from login request failure, then it will retry (call back) the foo .
I have specified the retry count as 2 and have added a tread sleep between retries.

How to configure
1. Add this foo sequence as a seperate sequence and use in the proxy service In-Sequence
 Add an onError option to the sequence
e.g -

<sequence name="foo" onError="retryError" xmlns="http://ws.apache.org/ns/synapse">
    <log>
        <property name="Test" value="Inside the in sequence"/>
    </log>
    <call blocking="true">
        <endpoint>
            <address uri="http://localhost:9000/services/SimpleStockQuoteService"/>
        </endpoint>
    </call>
</sequence>
2. Create a new sequence retryError and the bellow code
<?xml version="1.0" encoding="UTF-8"?>
<sequence name="retryError" xmlns="http://ws.apache.org/ns/synapse">
    <filter xmlns:ns="http://org.apache.synapse/xsd"
        xmlns:ns3="http://org.apache.synapse/xsd" xpath="get-property('retry_count')">
        <then>
            <property expression="number(get-property('retry_count'))+1"
                name="retry_count" scope="default"/>
            <filter xpath="get-property('retry_count') > 2">
                <then>
                    <log/>
                    <drop/>
                </then>
                <else>
                    <script language="js"><![CDATA[java.lang.Thread.sleep(5000);]]></script>
                    <clone continueParent="true" sequential="false">
                        <target sequence="foo"/>
                    </clone>
                </else>
            </filter>
        </then>
        <else>
            <script language="js"><![CDATA[java.lang.Thread.sleep(5000);]]></script>
            <property name="retry_count" scope="default" type="STRING" value="1"/>
            <clone continueParent="true" sequential="false">
                <target sequence="foo"/>
            </clone>
        </else>
    </filter>
</sequence>

 If you have an easy way to do this feel free to comment

Have Fun !!!!

Friday, July 22, 2016

Transforming a Json Request In WSO2 API Cloud

Hi All,

If you require to transform an incoming Json request to a Json request  of a different format (Add extra values). You can simply do it by changing the default mediation flow.
This post is to show how you could archive that in a simple and easy steps.

Payload sent from user to the backend

  "tutorials": {
        "id": "wso2",
        "topic": "REST Service",
        "description": "This is REST Service Example by WSO2."
    }


Modified payload sent to backend - (Add the username of the user to the payload data )

{
  "data": {
    "tutorials": {
      "id": "wso2",
      "topic": "REST Service",
      "description": "This is REST Service Example by WSO2."
    }
  },
  "user": "vinurid.wso2.com@testuser"
}


All you have to do is write a custom sequence that modify the payload using PayloadFactory Mediator.
If you want to know more details about the mediator can follow this WSO2 Documentation - https://docs.wso2.com/display/ESB490/PayloadFactory+Mediator

This is a sample sequence that you can use to do the above Payload transformation. You have to save the bellow sequence to an xml file and add to the in-sequence in the API.

<sequence xmlns="http://ws.apache.org/ns/synapse" name="CustomerSequence">
         <payloadFactory media-type="json">
            <format>{"data":$1, "user":"$2"}</format>
            <args>
               <arg evaluator="json" expression="json-eval($)"/>
            <arg expression="$ctx:api.ut.userId"/>
            </args>
         </payloadFactory>
</sequence>


You could follow the bellow video on step by step guidance on how to do this in WSO2 Cloud.
Content in the video
1. Creating an API in WSO2 Cloud.
2. Change the mediation flow in the API in-sequence
3. Show the sequence that added to the in-sequence
4. publish the API
5. Subscribe to the newly created API in WSO2 API Cloud
6. Invoke the API. (Video shows the payload which user sent to the backend)
7. Shows the output for the request
8. Shows the in-coming request in the backend logs. (Request that sent to the backend from the WSO2 API Cloud)




Sunday, June 26, 2016

Enabling APIM - BPS Workflow Integration In a Cluster + WSO2

Hi All,

This Post show how you could configure WSO2 APIM workflows in a cluster.
Please Note this post is based on the bellow documentation, more like a summary of what you really should do.
https://docs.wso2.com/display/AM1100/Configuring+Workflows+in+a+Cluster
https://docs.wso2.com/display/AM1100/Adding+an+Application+Creation+Workflow

WSO2 Product Versions -
wso2bps 3.5.1
wso2am 1.10.0

Setup Information

  1. 2 bps nodes clustered with a LB
  • <bps1 IP> hostname /IP of the bps node 1
  • <bps2 IP> hostname /IP of the bps node 2
  • <bpsLB IP> hostname /IP of the bps LB
  1. 2 APIM store nodes clustered  with a LB

Important Notes -

  • Assuming that the admin role is not changed.
  • All bps and apim nodes are running in a separate servers and started using offset 0
  • Configuring the Admin Dashboard in store side.
  • Please note both nodes should have the correct server certificates and the client-truststore should know both sides as well

Setting up APIM store node

  1. Change the workFlowServerURL in the admin dashboard configuration. wso2am-1.10.0/repository/deployment/server/jaggeryapps/admin-dashboard/site/conf/site.json
"workFlowServerURL": "https://<bpsLB>:9443/services/",
  1. Changed the WorkflowCallbackService.xml to point the store node.
Since we are configuring the admin-dashboard of the store side, keeping it as  localhost:9443
/wso2am-1.10.0/repository/deployment/server/synapse-configs/default/proxy-services/WorkflowCallbackService.xml
  1. Login to the API Store management console and change the WorkFlowExtensions callbackURL and serviceEndpoint in the registry.
/_system/governance/apimgt/applicationdata/workflow-extensions.xml
E.g - comment the simple workflow executor and enable WS Workflow Executor

<ApplicationCreation executor="org.wso2.carbon.apimgt.impl.workflow.ApplicationCreationWSWorkflowExecutor">
        <Property name="serviceEndpoint"> http://<bpsLB IP>:9763/services/ApplicationApprovalWorkFlowProcess/  </Property>
        <Property name="username">userName</Property>
        <Property name="password">Password</Property>
        <Property name="callbackURL">https://<storeLB IP>:8243/services/WorkflowCallbackService</Property>
    </ApplicationCreation>

Setting Up BPS Node


  1. <BPS_HOME>/repository/conf/humantask.xml file and <BPS_HOME>/repository/conf/b4p-coordination-config.xml file and set the TaskCoordinationEnabled property to true.
<TaskCoordinationEnabled>true</TaskCoordinationEnabled>
  1. Copy the following from the <APIM_HOME>/business-processes/epr folder to the <BPS_HOME>/repository/conf/epr folder. If the <BPS_HOME>/repository/conf/epr folder does not exist, please create it.
  • In the *CallbackService.epr file change the Address to <storeLB ip> and  also change the username and password
  • In the *Service.epr change the  Address to store node ip or localhost and also change the username and password
  1. Unzip the <APIM_HOME>/business-processes/user-signup/BPEL/*  (Similar to all the other workflows)
  • Change the address port to 9443 in the ApprovalTask wsdl file e.g - UserApprovalTask.wsdl
  • In the CallbackService WSDL point the address elements to <storeLB IP>
  1. Zip back the files and upload it into the BPS.
  2. Unzip the <APIM_HOME>/business-processes/<workflow name>/HumanTask fie.
  • Change the port to 9763 in ApprovalTask WSDL
  1. Zip back the files and upload it into the BPS Human Task.

Create an Application In store side and login to the admin dashboard to check if workflows working properly.

Have Fun !!! 
 

Friday, June 24, 2016

Gadgets Wont display for the IP address ERROR {org.apache.shindig.gadgets.render.DefaultServiceFetcher} + WSO2 Dashboard

Hi All,
I got this error accessing the DAS Dashboard (Portal) from the IP address instead of localhost.

ERROR {org.apache.shindig.gadgets.render.DefaultServiceFetcher} -  Services methods from the https://IP:9443/shindig/rpc endpoint could not be fetched. The following error occurred: javax.net.ssl.SSLException: hostname in certificate didn't match: <IP> != <localhost>. {org.apache.shindig.gadgets.render.DefaultServiceFetcher}
TID: [-1] [] [2016-06-10 12:07:50,257]  INFO {org.apache.shindig.gadgets.http.BasicHttpFetcher} -  The following exception occurred when fetching https://IP:9443/portal/store/carbon.super/gadget/Message_Table/index.xml: 11 ms elapsed. {org.apache.shindig.gadgets.http.BasicHttpFetcher}
TID: [-1] [] [2016-06-10 12:07:50,259]  INFO {org.apache.shindig.gadgets.http.BasicHttpFetcher} -   {org.apache.shindig.gadgets.http.BasicHttpFetcher}
javax.net.ssl.SSLException: hostname in certificate didn't match: <IP> != <localhost>
        at org.apache.http.conn.ssl.AbstractVerifier.verify(AbstractVerifier.java:238)
        at org.apache.http.conn.ssl.BrowserCompatHostnameVerifier.verify(BrowserCompatHostnameVerifier.java:54)
        at org.apache.http.conn.ssl.AbstractVerifier.verify(AbstractVerifier.java:159)
        at org.apache.http.conn.ssl.AbstractVerifier.verify(AbstractVerifier.java:140)
        at org.apache.http.conn.ssl.SSLSocketFactory.verifyHostname(SSLSocketFactory.java:561)
        at org.apache.http.conn.ssl.SSLSocketFactory.connectSocket(SSLSocketFactory.java:536)
        at org.apache.http.conn.ssl.SSLSocketFactory.connectSocket(SSLSocketFactory.java:403)
        at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:177)
        at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:144)
        at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:131)
        at org.apache.http.impl.client.DefaultRequestDirector.tryConnect(DefaultRequestDirector.java:611)
        at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:446)
        at org.apache.http.impl.client.AbstractHttpClient.doExecute(AbstractHttpClient.java:863)
        at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:115)
        at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:57)
        at org.apache.shindig.gadgets.http.BasicHttpFetcher.fetch(BasicHttpFetcher.java:359)
        at org.apache.shindig.gadgets.http.DefaultRequestPipeline.fetchResponse(DefaultRequestPipeline.java:191)
        at org.apache.shindig.gadgets.http.DefaultRequestPipeline.execute(DefaultRequestPipeline.java:135)
        at org.apache.shindig.gadgets.AbstractSpecFactory.fetchFromNetwork(AbstractSpecFactory.java:134)
        at org.apache.shindig.gadgets.AbstractSpecFactory.getSpec(AbstractSpecFactory.java:94)
        at org.apache.shindig.gadgets.DefaultGadgetSpecFactory.getGadgetSpec(DefaultGadgetSpecFactory.java:75)
        at org.apache.shindig.gadgets.process.Processor.process(Processor.java:104)
        at org.apache.shindig.gadgets.servlet.GadgetsHandlerService.getMetadata(GadgetsHandlerService.java:210)
        at org.apache.shindig.gadgets.servlet.GadgetsHandler$5.call(GadgetsHandler.java:307)
        at org.apache.shindig.gadgets.servlet.GadgetsHandler$5.call(GadgetsHandler.java:304)
        at java.util.concurrent.FutureTask.run(FutureTask.java:262)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
        at java.util.concurrent.FutureTask.run(FutureTask.java:262)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
        at java.lang.Thread.run(Thread.java:745)


If you are also facing the same issueAll you have to do is add a self sign certificate for the server DAS is running.
You could use the bellow article on creating the certificate.
http://wso2.com/library/knowledge-base/2011/08/adding-ca-certificate-authority-signed-certificate-wso2-products/

Not Retrieving Pending Tasks. Check BPS Connectivity + WSO2 APIM 1.10

Hi All,
I got this issue when configuring the APIM workflow support.  Because of this issue APIM admin dashboard cannot retrieve any of the pending tasks which needed to be approve.

WARN {JAGGERY.site.blocks.user.login.ajax.login:jag}- Not Retrieving Pending Tasks. Check BPS Connectivity {JAGGERY.site.blocks.user.login.ajax.login:jag}

WSO2 Versions - 
API Manager 1.10
BPS 3.5.1

Please find the Bellow steps to Identify the correct issue (debug) and fix.

- This issue can mainly occur due to an incorrect bps path given for the workFlowServerURL in the Admin Dashboard.
Verify the workFlowServerURL in the site.json file.
 <APIM HOME>/repository/deployment/server/jaggeryapps/admin-dashboard/site/conf/site.json 

- If your issue is still exists, this can be occur due to a connection timeout or a certificate issues. Easiest way to verify the issue is by putting a log to the login.jag
<APIM HOME>/repository/deployment/server/jaggeryapps/admin-dashboard/modules/user/login.jag

grep the code and find the WARN message "Not Retrieving Pending Tasks" 
Add the bellow mention error log to the code and test again. You will get the full stack trace and it will be easy to identify the main issue.
} catch(e) {
    log.error(e);
    log.warn("Not Retrieving Pending Tasks. Check BPS Connectivity");
}

Thursday, September 3, 2015

Error - Cannot run program "chmod": CreateProcess error=2, The system cannot find the file specified in wso2 BAM

Hi,
I got this error when starting the WSO2 BAM in Windows Machine.
I had struggle with this error for a few hours and finally got it working.

ERROR {org.apache.hadoop.hive.ql.exec.ExecDriver} -  Job Submission failed with exception 'java.io.IOException(Cannot run program "chmod": CreateProcess error=2, The system cannot find the file specified)'
java.io.IOException: Cannot run program "chmod": CreateProcess error=2, The system cannot find the file specified
 at java.lang.ProcessBuilder.start(ProcessBuilder.java:1047)
 at org.apache.hadoop.util.Shell.runCommand(Shell.java:200)
 at org.apache.hadoop.util.Shell.run(Shell.java:182)
 at org.apache.hadoop.util.Shell$ShellCommandExecutor.execute(Shell.java:375)
 at org.apache.hadoop.util.Shell.execCommand(Shell.java:461)
 at org.apache.hadoop.util.Shell.execCommand(Shell.java:444)
 at org.apache.hadoop.fs.RawLocalFileSystem.execCommand(RawLocalFileSystem.java:553)
 at org.apache.hadoop.fs.RawLocalFileSystem.execSetPermission(RawLocalFileSystem.java:545)
 at org.apache.hadoop.fs.RawLocalFileSystem.setPermission(RawLocalFileSystem.java:531)
 at org.apache.hadoop.fs.RawLocalFileSystem.mkdirs(RawLocalFileSystem.java:324)
 at org.apache.hadoop.fs.FilterFileSystem.mkdirs(FilterFileSystem.java:183)
 at org.apache.hadoop.mapreduce.JobSubmissionFiles.getStagingDir(JobSubmissionFiles.java:116)
 at org.apache.hadoop.mapred.JobClient$2.run(JobClient.java:798)
 at org.apache.hadoop.mapred.JobClient$2.run(JobClient.java:792)
 at java.security.AccessController.doPrivileged(Native Method)
 at javax.security.auth.Subject.doAs(Subject.java:415)
 at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1123)
 at org.apache.hadoop.mapred.JobClient.submitJobInternal(JobClient.java:792)
 at org.apache.hadoop.mapred.JobClient.submitJob(JobClient.java:766)
 at org.apache.hadoop.hive.ql.exec.ExecDriver.execute(ExecDriver.java:460)
 at org.apache.hadoop.hive.ql.exec.ExecDriver.main(ExecDriver.java:733)
 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.hadoop.util.RunJar.main(RunJar.java:156)
Caused by: java.io.IOException: CreateProcess error=2, The system cannot find the file specified
 at java.lang.ProcessImpl.create(Native Method)
 at java.lang.ProcessImpl.(ProcessImpl.java:385)
 at java.lang.ProcessImpl.start(ProcessImpl.java:136)
 at java.lang.ProcessBuilder.start(ProcessBuilder.java:1028)
 ... 25 more
 {org.apache.hadoop.hive.ql.exec.ExecDriver}
TID: [0] [BAM] [2015-09-03 12:58:12,130] ERROR {org.apache.hadoop.hive.ql.exec.Task} -  Execution failed with exit status: 2 {org.apache.hadoop.hive.ql.exec.Task}
TID: [0] [BAM] [2015-09-03 12:58:12,130] ERROR {org.apache.hadoop.hive.ql.exec.Task} -  Obtaining error information {org.apache.hadoop.hive.ql.exec.Task}
TID: [0] [BAM] [2015-09-03 12:58:12,130] ERROR {org.apache.hadoop.hive.ql.exec.Task} -  
Task failed!
Task ID:
  Stage-0

Logs:
 {org.apache.hadoop.hive.ql.exec.Task}
TID: [0] [BAM] [2015-09-03 12:58:12,130] ERROR {org.apache.hadoop.hive.ql.exec.Task} -  C:\Users\wso2\Desktop\ME\WSO2BA~1.0\WSO2BA~1.0\bin\../repository/logs//wso2carbon.log {org.apache.hadoop.hive.ql.exec.Task}
TID: [0] [BAM] [2015-09-03 12:58:12,130] ERROR {org.apache.hadoop.hive.ql.exec.ExecDriver} -  Execution failed with exit status: 2 {org.apache.hadoop.hive.ql.exec.ExecDriver}
TID: [0] [BAM] [2015-09-03 12:58:12,130] ERROR {org.apache.hadoop.hive.ql.Driver} -  FAILED: Execution Error, return code 2 from org.apache.hadoop.hive.ql.exec.MapRedTask {org.apache.hadoop.hive.ql.Driver}
TID: [0] [BAM] [2015-09-03 12:58:12,130] ERROR {org.wso2.carbon.analytics.hive.impl.HiveExecutorServiceImpl} -  Error executing query: Query returned non-zero code: 9, cause: FAILED: Execution Error, return code 2 from org.apache.hadoop.hive.ql.exec.MapRedTask {org.wso2.carbon.analytics.hive.impl.HiveExecutorServiceImpl}
java.sql.SQLException: Query returned non-zero code: 9, cause: FAILED: Execution Error, return code 2 from org.apache.hadoop.hive.ql.exec.MapRedTask
 at org.apache.hadoop.hive.jdbc.HiveStatement.executeQuery(HiveStatement.java:189)
 at org.wso2.carbon.analytics.hive.impl.HiveExecutorServiceImpl$ScriptCallable.executeHiveQuery(HiveExecutorServiceImpl.java:599)
 at org.wso2.carbon.analytics.hive.impl.HiveExecutorServiceImpl$ScriptCallable.call(HiveExecutorServiceImpl.java:304)
 at org.wso2.carbon.analytics.hive.impl.HiveExecutorServiceImpl$ScriptCallable.call(HiveExecutorServiceImpl.java:192)
 at java.util.concurrent.FutureTask.run(FutureTask.java:262)
 at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
 at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
 at java.lang.Thread.run(Thread.java:745)
TID: [0] [BAM] [2015-09-03 12:58:12,130] ERROR {org.wso2.carbon.analytics.hive.impl.HiveExecutorServiceImpl} -  Error while executing Hive script.
Query returned non-zero code: 9, cause: FAILED: Execution Error, return code 2 from org.apache.hadoop.hive.ql.exec.MapRedTask {org.wso2.carbon.analytics.hive.impl.HiveExecutorServiceImpl}
java.sql.SQLException: Query returned non-zero code: 9, cause: FAILED: Execution Error, return code 2 from org.apache.hadoop.hive.ql.exec.MapRedTask
 at org.apache.hadoop.hive.jdbc.HiveStatement.executeQuery(HiveStatement.java:189)
 at org.wso2.carbon.analytics.hive.impl.HiveExecutorServiceImpl$ScriptCallable.executeHiveQuery(HiveExecutorServiceImpl.java:599)
 at org.wso2.carbon.analytics.hive.impl.HiveExecutorServiceImpl$ScriptCallable.call(HiveExecutorServiceImpl.java:304)
 at org.wso2.carbon.analytics.hive.impl.HiveExecutorServiceImpl$ScriptCallable.call(HiveExecutorServiceImpl.java:192)
 at java.util.concurrent.FutureTask.run(FutureTask.java:262)
 at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
 at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
 at java.lang.Thread.run(Thread.java:745)
TID: [0] [BAM] [2015-09-03 12:58:12,130] ERROR {org.wso2.carbon.analytics.hive.task.HiveScriptExecutorTask} -  Error while executing script : am_stats_analyzer {org.wso2.carbon.analytics.hive.task.HiveScriptExecutorTask}


If you are facing the same error there is 2 main things you have to clarify in-order to get it working properly.

1. Check If you have correctly added the cygwin in the windows system Path variable. Check if there is any spaces and file path is correct.
2. If the 1st step is properly done and you still getting the above error then that means you haven't install cygwin properly.  When you install the cygwin make sure you have installed basic,  net (OpenSSH,tcp_wrapper packages)  and security related cygwin packages. 

using those 2 steps you can get rid of this unwanted error.
Hope this post saved your time 
Thanks,
~Vinu~

Monday, April 20, 2015

ERROR - MailTransportSender Error creating mail message or sending it to the configured server + wso2

Hi Friends,

If you are getting the below error, when trying to send a mail. This occurs due to a simple issue :)
I got this issue while configuring WSO2 ESB to send mails.

 ERROR - MailTransportSender Error creating mail message or sending it to the configured server  
 javax.mail.AuthenticationFailedException  
 at javax.mail.Service.connect(Service.java:306)  
 at javax.mail.Service.connect(Service.java:156)  
 at javax.mail.Service.connect(Service.java:105)  
 at javax.mail.Transport.send0(Transport.java:168)  
 at javax.mail.Transport.send(Transport.java:98)  
 at org.apache.axis2.transport.mail.MailTransportSender.sendMail(MailTransportSender.java:489)  
 at org.apache.axis2.transport.mail.MailTransportSender.sendMessage(MailTransportSender.java:175)  
 at org.apache.axis2.transport.base.AbstractTransportSender.invoke(AbstractTransportSender.java:112)  
 at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:442)  
 at org.apache.axis2.description.OutOnlyAxisOperationClient.executeImpl(OutOnlyAxisOperation.java:297)  
 at org.apache.axis2.client.OperationClient.execute(OperationClient.java:149)  
 at org.apache.synapse.core.axis2.Axis2FlexibleMEPClient.send(Axis2FlexibleMEPClient.java:482)  
 at org.apache.synapse.core.axis2.Axis2Sender.sendOn(Axis2Sender.java:59)  
 at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.send(Axis2SynapseEnvironment.java:338)  
 at org.apache.synapse.endpoints.AbstractEndpoint.send(AbstractEndpoint.java:333)  
 at org.apache.synapse.endpoints.AddressEndpoint.send(AddressEndpoint.java:59)  
 at org.apache.synapse.mediators.builtin.SendMediator.mediate(SendMediator.java:97)  
 at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:77)  
 at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:47)  
 at org.apache.synapse.mediators.base.SequenceMediator.mediate(SequenceMediator.java:131)  
 at org.apache.synapse.mediators.MediatorFaultHandler.onFault(MediatorFaultHandler.java:85)  
 at org.apache.synapse.FaultHandler.handleFault(FaultHandler.java:54)  
 at org.apache.synapse.endpoints.AbstractEndpoint.invokeNextFaultHandler(AbstractEndpoint.java:640)  
 at org.apache.synapse.endpoints.AbstractEndpoint.onFault(AbstractEndpoint.java:475)  
 at org.apache.synapse.endpoints.AddressEndpoint.onFault(AddressEndpoint.java:43)  
 at org.apache.synapse.FaultHandler.handleFault(FaultHandler.java:102)  
 at org.apache.synapse.core.axis2.SynapseCallbackReceiver.handleMessage(SynapseCallbackReceiver.java:252)  
 at org.apache.synapse.core.axis2.SynapseCallbackReceiver.receive(SynapseCallbackReceiver.java:170)  
 at org.apache.synapse.transport.passthru.TargetErrorHandler$1.run(TargetErrorHandler.java:134)  
 at org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerPool.java:172)  
 at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)  
 at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)  
 at java.lang.Thread.run(Thread.java:745)  
 [2015-04-20 16:28:31,370] ERROR - MailTransportSender Error generating mail message  
 org.apache.axis2.AxisFault: Error creating mail message or sending it to the configured server  
 at org.apache.axis2.transport.base.AbstractTransportSender.handleException(AbstractTransportSender.java:226)  
 at org.apache.axis2.transport.mail.MailTransportSender.sendMail(MailTransportSender.java:500)  
 at org.apache.axis2.transport.mail.MailTransportSender.sendMessage(MailTransportSender.java:175)  
 at org.apache.axis2.transport.base.AbstractTransportSender.invoke(AbstractTransportSender.java:112)  
 at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:442)  
 at org.apache.axis2.description.OutOnlyAxisOperationClient.executeImpl(OutOnlyAxisOperation.java:297)  
 at org.apache.axis2.client.OperationClient.execute(OperationClient.java:149)  
 at org.apache.synapse.core.axis2.Axis2FlexibleMEPClient.send(Axis2FlexibleMEPClient.java:482)  
 at org.apache.synapse.core.axis2.Axis2Sender.sendOn(Axis2Sender.java:59)  
 at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.send(Axis2SynapseEnvironment.java:338)  
 at org.apache.synapse.endpoints.AbstractEndpoint.send(AbstractEndpoint.java:333)  
 at org.apache.synapse.endpoints.AddressEndpoint.send(AddressEndpoint.java:59)  
 at org.apache.synapse.mediators.builtin.SendMediator.mediate(SendMediator.java:97)  
 at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:77)  
 at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:47)  
 at org.apache.synapse.mediators.base.SequenceMediator.mediate(SequenceMediator.java:131)  
 at org.apache.synapse.mediators.MediatorFaultHandler.onFault(MediatorFaultHandler.java:85)  
 at org.apache.synapse.FaultHandler.handleFault(FaultHandler.java:54)  
 at org.apache.synapse.endpoints.AbstractEndpoint.invokeNextFaultHandler(AbstractEndpoint.java:640)  
 at org.apache.synapse.endpoints.AbstractEndpoint.onFault(AbstractEndpoint.java:475)  
 at org.apache.synapse.endpoints.AddressEndpoint.onFault(AddressEndpoint.java:43)  
 at org.apache.synapse.FaultHandler.handleFault(FaultHandler.java:102)  
 at org.apache.synapse.core.axis2.SynapseCallbackReceiver.handleMessage(SynapseCallbackReceiver.java:252)  
 at org.apache.synapse.core.axis2.SynapseCallbackReceiver.receive(SynapseCallbackReceiver.java:170)  
 at org.apache.synapse.transport.passthru.TargetErrorHandler$1.run(TargetErrorHandler.java:134)  
 at org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerPool.java:172)  
 at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)  
 at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)  
 at java.lang.Thread.run(Thread.java:745)  
 Caused by: javax.mail.AuthenticationFailedException  
 at javax.mail.Service.connect(Service.java:306)  
 at javax.mail.Service.connect(Service.java:156)  
 at javax.mail.Service.connect(Service.java:105)  
 at javax.mail.Transport.send0(Transport.java:168)  
 at javax.mail.Transport.send(Transport.java:98)  
 at org.apache.axis2.transport.mail.MailTransportSender.sendMail(MailTransportSender.java:489)  
 ... 27 more  

First thing you should do is check if you have configure the MailTransportSender property correctly in the axis2.xml file
which is in $Carbon.Home/repository/conf/axis2/axis2.xml

   <transportSender name="mailto" class="org.apache.axis2.transport.mail.MailTransportSender">  
     <parameter name="mail.smtp.from">vinurip1@gmail.com</parameter>  
     <parameter name="mail.smtp.user">vinurip1</parameter>  
     <parameter name="mail.smtp.password">mypassword</parameter>  
     <parameter name="mail.smtp.host">smtp.gmail.com</parameter>c  
     <parameter name="mail.smtp.port">587</parameter>  
     <parameter name="mail.smtp.starttls.enable">true</parameter>  
     <parameter name="mail.smtp.auth">true</parameter>  
   </transportSender>  


If all you details are correct but still get the issue go to you mail account and check for the permission. In Gmail they send a mail saying "blocked a sign-in attempt" or similar.

If this is also not working feel free to put a comment and ask questions :)

Best Regards,
~Vinu~

Friday, April 17, 2015

How to Edit the Contents of a .Jar File Without Extracting on a Mac

Hi friends,

Well this post will show you how to edit the content of a jar file without extracting the jar file in 4 simple steps. Works most of the time and it will save time to extract jar and back aging creating so on.

You cannot edit the class files ONLY the config files like xmls

STEP 1

Go to the file location from the terminal and open it from the vi /vim editor

STEP 2

You will get a list of files in the jar after doing Step 1. Select the file you want to edit by using up and down keys and press ENTER

STEP 3

After completing the Step 2 you will be able to  open the file you chose. edit the content as you prefer and press "esc" escape key and ":wq!" to save and quit (Normal vi commands)

STEP 4 

You will be direct to the same screen in Step 2 after saving the content. press "esc" escape key and ":q!" to quit (Normal vi commands)


That is it. so you don't have to extract to edit the content and save the time :)
let me know if this works or you found much simpler way to do it

Thank you
Best Regards,
~Vinu~

Wednesday, February 4, 2015

How to access Carbon data-source from master-datasources.xml WSO2

This post is related to getting carbon datasource from master-datasource.xml file.

Accessing the carbon data-source is pretty much easy all you have to do is use Lookup to read the datasource


master-datasources.xml
 <datasource>  
             <name>test_db</name>  
             <description>The datasource used for </description>  
             <jndiConfig>  
                     <name>jdbc/test_db</name>  
             </jndiConfig>  
             <definition type="RDBMS">  
                     <configuration>  
                             <url>jdbc:mysql://localhost:3306/test_db?autoReconnect=true</url>  
                             <username>root</username>  
                             <password>root</password>  
                             <driverClassName>com.mysql.jdbc.Driver</driverClassName>  
                             <maxActive>50</maxActive>  
                             <maxWait>60000</maxWait>  
                             <testOnBorrow>true</testOnBorrow>  
                             <validationQuery>SELECT 1</validationQuery>  
                             <validationInterval>30000</validationInterval>  
                     </configuration>  
             </definition>  
 </datasource>  


When getting the master-datasource,we should do the lookup from carbon super tenant.
If currently in the carbon super tenant there are two ways to get the datasource 

but the Second way is much easier.

    Hashtable env = new Hashtable();  
    env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.rmi.registry.RegistryContextFactory");  
    env.put(Context.PROVIDER_URL, "rmi://localhost:2199");  
    InitialContext ctx = new InitialContext(env);  
    DataSource ds = (DataSource) ctx.lookup("jdbc/test_db");  

E.g. 2
 dataSource = (DataSource) InitialContext.doLookup("jdbc/test_db");  

If not in carbon super tenant, you should switch the tenant flow and get the datasource and switch it back.
(If you know any other easy way feel free to put a comment  :) )
  //super tenant credentials  
       int tenantId= MultitenantConstants.SUPER_TENANT_ID;  
       String tenantDomain=MultitenantConstants.SUPER_TENANT_DOMAIN_NAME;  
       //changing the tenant flow to the supper tenant  
       Connection conn=null;  
       try{  
         PrivilegedCarbonContext.startTenantFlow();  
         PrivilegedCarbonContext privilegedCarbonContext =    PrivilegedCarbonContext.getThreadLocalCarbonContext();  
         privilegedCarbonContext.setTenantId(tenantId);  
         privilegedCarbonContext.setTenantDomain(tenantDomain);  
         //getting the cloud-mgt datasource connection  
         DataSource ds = (DataSource) privilegedCarbonContext.getJNDIContext().lookup("jdbc/test_db");  
         conn = ds.getConnection();  
       } catch (NamingException e) {  
          log.error("Error while getting the DataSource" +e);  
          e.printStackTrace();  
       } catch (SQLException e) {  
          e.printStackTrace();  
       } finally {  
          //Ending the tenant flow  
          PrivilegedCarbonContext.endTenantFlow();  
          return conn;  
       }  

pretty simple hope this post help you,

Have fun friends.

Monday, November 24, 2014

select2 selectable group and Select All function

Hi All,

If you want to select all the child element when selecting the group name, using select2 this is the post for you.  I have added the select All chcekbox also.

here is the html part you need to add.
<input type="hidden" id="fruitSelect" value="" style="width:300px;" /><br />
<br/><input type="checkbox" id="checkbox" />Select All
<br />
<button type="button" id="showValue">Show Value</button><br />
<br />
<div id="output">
</div> 


add the following to the Javascript  file, inside the $document.ready function.
 var FRUIT_GROUPS = [  
   {  
     id: '',  
     text: 'Citrus',  
     children: [  
       { id: 'c1', text: 'Grapefruit' },  
       { id: 'c2', text: 'Orange' },  
       { id: 'c3', text: 'Lemon' },  
       { id: 'c4', text: 'Lime' }  
     ]  
   },  
   {  
     id: '',  
     text: 'Other',  
     children: [  
       { id: 'o1', text: 'Apple' },  
       { id: 'o2', text: 'Mango' },  
       { id: 'o3', text: 'Banana' }  
     ]  
   }  
 ];  
 $('#fruitSelect').select2({  
   multiple: true,  
   placeholder: "Select fruits...",  
   data: FRUIT_GROUPS,  
   query: function(options) {  
     var selectedIds = options.element.select2('val');  
     var selectableGroups = $.map(this.data, function(group) {  
       var areChildrenAllSelected = true;  
       $.each(group.children, function(i, child) {  
         if (selectedIds.indexOf(child.id) < 0) {  
           areChildrenAllSelected = false;  
           return false; // Short-circuit $.each()  
         }  
       });  
       return !areChildrenAllSelected ? group : null;  
     });  
     options.callback({ results: selectableGroups });  
   }  
 }).on('select2-selecting', function(e) {  
   var $select = $(this);  
   if (e.val == '') {  
     e.preventDefault();  
     $select.select2('data', $select.select2('data').concat(e.choice.children));  
     $select.select2('close');  
   }  
 });  
 $('#showValue').click(function() {  
   $('#output').text($('#fruitSelect').val());  
 });  
 $("#checkbox").click(function(){  
  if($("#checkbox").is(':checked') ){  
  $('#fruitSelect').select2("val", "");  
  for(var index in FRUIT_GROUPS){  
    $('#fruitSelect').select2('data', $('#fruitSelect').select2('data').concat(FRUIT_GROUPS[index].children));  
  }}else{  
      $('#fruitSelect').select2("val", "");  
    }  
  });   

Demo

I have added the demo for the easiness of understanding.  I haven't describe the code much since its easy to understand. if you have any questions feel free to ask.

Have Fun.

Thursday, October 16, 2014

Setting Up MYSQL in Mac OS X

There are many ways to do this,  I was able to set up mysql using this way.

Use this tutorial to setting up the mysql in mac. 

but after you complete those steps and still you can't get the mysql running without using these commands 

alias mysql=/usr/local/mysql/bin/mysql
alias mysqladmin=/usr/local/mysql/bin/mysqladmin

All you have to do is change the add  few lines to the .bash_profile 
export the mysql and add it to the path as shown below.

export MYSQL=/usr/local/mysql/bin/
export PATH=$JAVA_HOME/bin:$M2_HOME/bin:$CATALINA_HOME/bin:$ANT_HOME/bin:$MYSQL:$PATH


After adding those Don't forget to source the file and check if its correctly configured 

Vinuris-MacBook-Pro:~ vinurip$ source .bash_profile 
Vinuris-MacBook-Pro:~ vinurip$ echo $MYSQL
/usr/local/mysql/bin/
Vinuris-MacBook-Pro:~ vinurip$ 

Thats all you have to do,  I hope this might help some one
feel free to put comments
Best Regards
~Vinuri~

Saturday, March 15, 2014

jniopencv_core.dll Can't find dependent libraries

Hi friends,

just adding this post to remember the issues I face when developing the eye gaze estimation (iLie) project and also as a help to others who face the same issues.

this is the Exception I got when first ran the javacv app
 Exception in thread "Thread-0" java.lang.UnsatisfiedLinkError: C:\Users\Dell\AppData\Local\Temp\javacpp2600960031292\jniopencv_core.dll: Can't find dependent libraries  
 at java.lang.ClassLoader$NativeLibrary.load(Native Method)  
 at java.lang.ClassLoader.loadLibrary1(ClassLoader.java:1965)  
 at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1890)  
 at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1851)  
 at java.lang.Runtime.load0(Runtime.java:795)  
 at java.lang.System.load(System.java:1062)  
 at com.googlecode.javacpp.Loader.loadLibrary(Loader.java:418)  
 at com.googlecode.javacpp.Loader.load(Loader.java:368)  
 at com.googlecode.javacpp.Loader.load(Loader.java:315)  
 at com.googlecode.javacv.cpp.opencv_core.<clinit>(opencv_core.java:131)  
 at java.lang.Class.forName0(Native Method)  
 at java.lang.Class.forName(Class.java:270)  
 at com.googlecode.javacpp.Loader.load(Loader.java:334)  
 at com.googlecode.javacv.cpp.opencv_imgproc.<clinit>(opencv_imgproc.java:96)  
 at java.lang.Class.forName0(Native Method)  
 at java.lang.Class.forName(Class.java:270)  
 at com.googlecode.javacpp.Loader.load(Loader.java:334)  
 at com.googlecode.javacv.cpp.opencv_objdetect.<clinit>(opencv_objdetect.java:96)  
 at java.lang.Class.forName0(Native Method)  
 at java.lang.Class.forName(Class.java:270)  
 at com.googlecode.javacpp.Loader.load(Loader.java:334)  
 at com.googlecode.javacpp.Loader.load(Loader.java:315)  
 at com.googlecode.javacv.cpp.opencv_objdetect$CvHaarClassifierCascade.<clinit>(opencv_objdetect.java:175)  
 at gaze.tracking.run(tracking.java:211)  
 at java.lang.Thread.run(Thread.java:744)  

Solution and the issue was openCv version and javaCv versions are not matching :(  when your choosing the javaCv make sure to check the compatible openCv version :D 

have fun Friends 


Thursday, March 21, 2013

More in MYSQL, Getting a count of rows from a result set

Hi friends,

There were few interesting things I have tried out these days from that this is the first query.

Getting a count of rows from a result set 

It's a simple an easy query Only thing have to do is take the result set query and think of it as a table

E.g. -  You want to get the total number of users who buy apples more than 2 times .You got a table  as records_of_the_month and in that you have  columns which has buyers_name, name_of_product


so in the First Step what I did is get the people who buy apples more than 2 times.

 SELECT buyers_name, count(*) FROM records_of_the_month WHERE name_of _product ='apple' group by  buyers_name having count(*) >2;

In the second step I got the total number of  people who buy apples more than 2 times.

  SELECT count(*)  FROM  (SELECT buyers_name, count(*) FROM records_of_the_month WHERE name_of_product ='apple' 
group by  buyers_name having count(*) >2 ) tt

This is just a simple mysql query I have learned recently There is some more interesting  queries I'll put a other post to that :)

Have Fun !!!!!!!!!!!!!!!!

Monday, December 3, 2012

Setting up maven in fedora

Hii Friends,

 Setting up Maven in fedora is really simple if you know how to do it.  This post is for people who is new to Maven and to those who haven't set up Maven before.

There is only Few Steps you have to follow to set up Maven in fedora.

1. Download Maven 3.0.4 (Binary tar.gz) from here. http://maven.apache.org/download.html  
 
2.  Extract the tar.gz file and get the path of the directory. 

E.g. - /home/vinu/software/apache-maven-3.0.4

3. Now we have to add the path in to the bash profile

       go to the bash profile    [vinu@localhost ~]$ vi .bash_profile 
 


Add the M2_HOME after the JAVA_HOME in the bash_profile 


export JAVA_HOME=/home/vinu/software/Compressed/jdk1.7.0_09
export M2_HOME=/home/vinu/software/apache-maven-3.0.4
PATH=$PATH:$HOME/.local/bin:$HOME/bin:$JAVA_HOME/bin:$M2_HOME/bin
export PATH


4. And don't forget to Source the bash profile

[vinu@localhost ~]$ source .bash_profile
         
Okiii we are done setting up Maven :) just to check whether it works properly type this in the terminal
[vinu@localhost ~]$  mvn --version

Hope you get something similar to this 

Apache Maven 3.0.4 (r1232337; 2012-01-17 14:14:56+0530)
Maven home: /home/vinu/software/apache-maven-3.0.4
Java version: 1.7.0_09, vendor: Oracle Corporation
Java home: /home/vinu/software/Compressed/jdk1.7.0_09/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "3.3.4-5.fc17.x86_64", arch: "amd64", family: "unix"



hahah thats all ..........................
Its really Simple :) if u guys have any questions or any thing feel free to put a comment 

Have Fun friends.

Monday, October 8, 2012

Setting up a Moodle Site


Hi Friends,


I have learned how to setup the moodle and play around with it. It is really simple to install and use. Moodle is an Open source, Course Management System (CMS) also known as a Learning Management System (LMS). There are so many things you can do using moodle :)


Lets see how to install Moodle to the local machine.(in similar way you can setup it in a web server)

  •  First of all Go to the Moodle web site and download the required Moodle package.( Before downloading check the required PHP and Mysql versions)
  • If you are using xampp put the unzipped file(moodle) in to the htdocs.
  • Create a database as MoodleDB(can give any name ) and change the collation to UTF8_Unicode_ci
Now its almost done , now only few more steps to do to finish installing Moodle.

STEP 1
it's simple few steps more , just go to chrome and type 
http://localhost/moodle/ 
(Make sure the Apache is  running )

You will get this installation page , choose English and click next. click on next to all the other pages until u get in to the step 2

STEP 2

Give the database name as MoodleDB (one we created in the beginning), Give the username and password. leave the other fields as it is. and click on next.
Click on the continue button until u get into step 3

STEP 3


 Fill the necessary details and click on Update profile

STEP4



Give a name for the site and fill other details and click on Save changers.
Now we are done installing moodle to the local machine. You can play around with it and find new interesting features in it.

 hope you guys can install it using those steps easily Have fun friends.

Sunday, January 8, 2012

Creating a shopping cart GUI

hi friends,
I have done a simple shopping cart GUI class using. It is really easy to create this GUI.
I have applied  Action listener to submit and remove buttons. those will call some other classes that are not exactly related to the creation of GUI class.

I have used Box layout a lot doing this GUI. but its really simple hope u guys can understand this easily





import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.SQLException;
import java.util.Enumeration;

import javax.swing.*;


public class lap extends JFrame implements ActionListener{

public JButton btnP,btnR,Sub,btnD,btnH,btnV,rem;
public JRadioButton Rb1,Rb2,Rb3,Rb4,ans,Rb10;
public JRadioButton Rb5,Rb6,Rb7,Rb8,Rb9;
public JRadioButton Rb11,Rb12,Rb13,Rb14,Rb15;
public JRadioButton Rb20,Rb16,Rb17,Rb18,Rb19;
public JRadioButton Rb25,Rb21,Rb22,Rb23,Rb24;
public JLabel pl1,pl2,pl3,pl4,pl5;
public ButtonGroup BG1,BG2,BG3,BG4,BG5;
public JLabel l1,l2,l3,l4,l5;
public Container con;
public String[] Sary;
public lap() {
Sary= new String[5];
for(int x=0;x<Sary.length;x++)
       Sary[x]=" ";
this.setVisible(true);
this.setSize(600,435);
con= getContentPane();
con.setLayout(null);
final Box b1= Box.createVerticalBox();
final Box b2= Box.createVerticalBox();
final Box b3= Box.createVerticalBox();
final Box b4= Box.createVerticalBox();
final Box b5= Box.createVerticalBox();
final Box first= Box.createVerticalBox();
final Box buy= Box.createVerticalBox();
final Box choz= Box.createVerticalBox();
con.setBackground(Color.white);
l1= new JLabel("");
l2= new JLabel("");
l3= new JLabel("");
l4= new JLabel("");
l5= new JLabel("");
first.setVisible(true);
first.setBounds(125, 0, 275, 450);
first.setBorder(BorderFactory.createTitledBorder(" "));
con.add(first);
buy.setVisible(true);
buy.setBounds(400, 0, 200, 450);
buy.setBorder(BorderFactory.createTitledBorder("Selected items"));
con.add(buy);
BG1=new ButtonGroup();
BG2= new ButtonGroup();
BG3= new ButtonGroup();
BG4= new ButtonGroup();
BG5= new ButtonGroup();

//Processors
Rb1= new JRadioButton("Core i3 2.10Ghz(2310M)");
Rb2= new JRadioButton("Core i5 2.30Ghz(2410M)");
Rb3= new JRadioButton("Core i5 2.40Ghz(2430M))");
Rb4= new JRadioButton("Core i7 2.0Ghz(QM2630)");
Rb5= new JRadioButton("Core-i7 2.2Ghz(QM2670)");
pl1=new JLabel("Price - Rs.123 ");
pl2=new JLabel("Price - Rs 2 "); 
pl3=new JLabel("Price - Rs 3 ");
pl4=new JLabel("Price - Rs 4 ");
pl5=new JLabel("Price - Rs 5 ");
ImageIcon p1 = new ImageIcon("images\\p1.jpg");
JLabel Lp1 = new JLabel(" ", p1, JLabel.CENTER);
BG1.add(Rb1);
BG1.add(Rb2);
BG1.add(Rb3);
BG1.add(Rb4);
BG1.add(Rb5);
b1.add( Box.createRigidArea(new Dimension(0,10)));

b1.add(Rb1);
b1.add(pl1);
b1.add( Box.createRigidArea(new Dimension(0,8)));
b1.add(Rb2);
b1.add(pl2);
b1.add( Box.createRigidArea(new Dimension(0,8)));
b1.add(Rb3);
b1.add(pl3);
b1.add( Box.createRigidArea(new Dimension(0,8)));
b1.add(Rb4);
b1.add(pl4);
b1.add( Box.createRigidArea(new Dimension(0,8)));
b1.add(Rb5);
b1.add(pl5);
b1.add(Lp1);
Rb1.addActionListener( new ActionListener() {           
            public void actionPerformed(ActionEvent e) {{
            Sary[0]= Rb1.getText(); 
             l2.setText(Sary[0]);
            }}});
Rb2.addActionListener( new ActionListener() {           
            public void actionPerformed(ActionEvent e) {{
            Sary[0]= Rb2.getText(); 
             l2.setText(Sary[0]);
            }}});
Rb3.addActionListener( new ActionListener() {           
            public void actionPerformed(ActionEvent e) {{
            Sary[0]= Rb3.getText(); 
             l2.setText(Sary[0]);
            }}});
Rb4.addActionListener( new ActionListener() {           
            public void actionPerformed(ActionEvent e) {{
            Sary[0]= Rb4.getText(); 
             l2.setText(Sary[0]);
            }}});
Rb5.addActionListener( new ActionListener() {           
            public void actionPerformed(ActionEvent e) {{
            Sary[0]= Rb5.getText(); 
             l2.setText(Sary[0]);
            }}});
b1.setVisible(false);
b1.setBounds(125, 0, 275, 450);
b1.setBorder(BorderFactory.createTitledBorder(" "));
btnP=new JButton(" Processors ");
btnP.setMaximumSize(new Dimension(120, 25));

con.add(b1);
btnP.addActionListener(new ActionListener() {
         public void actionPerformed(ActionEvent e) {
         b1.setVisible(true); 
         b2.setVisible(false);
         b3.setVisible(false);
         b4.setVisible(false);
         b5.setVisible(false);
         first.setVisible(false);
         }});
//Ram
Rb10= new JRadioButton("1GB DDR3");
Rb9= new JRadioButton("2GB DDR3");
Rb6= new JRadioButton("4GB DDR3");
Rb7= new JRadioButton("6GB DDR3");
Rb8= new JRadioButton("8GB DDR3");
pl1=new JLabel("Price - Rs.223 ");
pl2=new JLabel("Price - Rs 2 "); 
pl3=new JLabel("Price - Rs 3 ");
pl4=new JLabel("Price - Rs 222 ");
pl5=new JLabel("Price - Rs 22222 ");
ImageIcon r1 = new ImageIcon("images\\R1.jpg");
JLabel R1 = new JLabel(" ", r1, JLabel.CENTER);
BG2.add(Rb10);
BG2.add(Rb9);
BG2.add(Rb6);
BG2.add(Rb7);
BG2.add(Rb8);
b2.add( Box.createRigidArea(new Dimension(0,20)));
b2.add(Rb10);
b2.add(pl1);
b2.add( Box.createRigidArea(new Dimension(0,8)));
b2.add(Rb9);
b2.add(pl2);
b2.add( Box.createRigidArea(new Dimension(0,8)));
b2.add(Rb6);
b2.add(pl3);
b2.add( Box.createRigidArea(new Dimension(0,8)));
b2.add(Rb7);
b2.add(pl4);
b2.add( Box.createRigidArea(new Dimension(0,8)));
b2.add(Rb8);
b2.add(pl5);
b2.add( Box.createRigidArea(new Dimension(0,10)));
b2.add(R1);
Rb9.addActionListener( new ActionListener() {           
            public void actionPerformed(ActionEvent e) {{
            Sary[1]= Rb9.getText(); 
             l3.setText(Sary[1]);
            }}});
Rb10.addActionListener( new ActionListener() {           
            public void actionPerformed(ActionEvent e) {{
            Sary[1]= Rb10.getText(); 
             l3.setText(Sary[1]);
            }}});
Rb6.addActionListener( new ActionListener() {           
            public void actionPerformed(ActionEvent e) {{
            Sary[1]= Rb6.getText(); 
             l3.setText(Sary[1]);
            }}});
Rb7.addActionListener( new ActionListener() {           
            public void actionPerformed(ActionEvent e) {{
            Sary[1]= Rb7.getText(); 
             l3.setText(Sary[1]);
            }}});
Rb8.addActionListener( new ActionListener() {           
            public void actionPerformed(ActionEvent e) {{
            Sary[1]= Rb8.getText(); 
             l3.setText(Sary[1]);
            }}});
b2.setVisible(false);
b2.setBounds(125, 0, 275, 450);
b2.setBorder(BorderFactory.createTitledBorder(" "));
btnR=new JButton("RAM");
btnR.setMaximumSize(new Dimension(120, 25));
con.add(b2);
btnR.addActionListener(new ActionListener() {
         public void actionPerformed(ActionEvent e) {
         b2.setVisible(true);   
         b1.setVisible(false);
         b3.setVisible(false);
         b4.setVisible(false);
         b5.setVisible(false);
         first.setVisible(false);
         
         }});
//Hard
Rb11= new JRadioButton("250GB");
Rb12= new JRadioButton("320GB");
Rb13= new JRadioButton("500GB");
Rb14= new JRadioButton("640GB");
Rb15= new JRadioButton("750GB");
pl1=new JLabel("Price - Rs.323 ");
pl2=new JLabel("Price - Rs 33 "); 
pl3=new JLabel("Price - Rs 3 ");
pl4=new JLabel("Price - Rs 3322 ");
pl5=new JLabel("Price - Rs 32222 ");
ImageIcon h1 = new ImageIcon("images\\Lh1.jpg");
JLabel hd1 = new JLabel(" ", h1, JLabel.CENTER);
BG3.add(Rb15);
BG3.add(Rb11);
BG3.add(Rb12);
BG3.add(Rb13);
BG3.add(Rb14);
b3.add( Box.createRigidArea(new Dimension(0,20)));
b3.add(Rb15);
b3.add(pl1);
b3.add( Box.createRigidArea(new Dimension(0,8)));
b3.add(Rb11);
b3.add(pl2);
b3.add( Box.createRigidArea(new Dimension(0,8)));
b3.add(Rb12);
b3.add(pl3);
b3.add( Box.createRigidArea(new Dimension(0,8)));
b3.add(Rb13);
b3.add(pl4);
b3.add( Box.createRigidArea(new Dimension(0,8)));
b3.add(Rb14);
b3.add(pl5);
// b3.add( Box.createRigidArea(new Dimension(0,10)));
b3.add(hd1);
Rb15.addActionListener( new ActionListener() {           
            public void actionPerformed(ActionEvent e) {{
            Sary[2]= Rb15.getText(); 
             l4.setText(Sary[2]);
            }}});
Rb11.addActionListener( new ActionListener() {           
            public void actionPerformed(ActionEvent e) {{
            Sary[2]= Rb11.getText(); 
             l4.setText(Sary[2]);
            }}});
Rb12.addActionListener( new ActionListener() {           
            public void actionPerformed(ActionEvent e) {{
            Sary[2]= Rb12.getText(); 
             l4.setText(Sary[2]);
            }}});
Rb13.addActionListener( new ActionListener() {           
            public void actionPerformed(ActionEvent e) {{
            Sary[2]= Rb13.getText(); 
             l4.setText(Sary[2]);
            }}});
Rb14.addActionListener( new ActionListener() {           
            public void actionPerformed(ActionEvent e) {{
            Sary[2]= Rb14.getText(); 
             l4.setText(Sary[2]);
            }}});
b3.setVisible(false);
b3.setBounds(125, 0, 275, 450);
b3.setBorder(BorderFactory.createTitledBorder(" "));
btnH=new JButton("HDD");
btnH.setMaximumSize(new Dimension(120, 25));
con.add(b3);
btnH.addActionListener(new ActionListener() {
         public void actionPerformed(ActionEvent e) {
         b3.setVisible(true);   
         b1.setVisible(false);
         b2.setVisible(false);
         b4.setVisible(false);
         b5.setVisible(false);
         first.setVisible(false);
         
         }});
//Disply
Rb20= new JRadioButton("14\" WXGA");
Rb19= new JRadioButton("14.1\" wxga");
Rb16= new JRadioButton("15\" XGA ");
Rb17= new JRadioButton("15.4\"WXGA");
Rb18= new JRadioButton("17\"WUXGA");
pl1=new JLabel("Price - Rs.423 ");
pl2=new JLabel("Price - Rs 43 "); 
pl3=new JLabel("Price - Rs 4 ");
pl4=new JLabel("Price - Rs 4322 ");
pl5=new JLabel("Price - Rs 42222 ");
Rb19.addActionListener( new ActionListener() {           
            public void actionPerformed(ActionEvent e) {{
            Sary[3]= Rb19.getText(); 
             l5.setText(Sary[3]);
            }}});
Rb20.addActionListener( new ActionListener() {           
            public void actionPerformed(ActionEvent e) {{
            Sary[3]= Rb20.getText(); 
             l5.setText(Sary[3]);
            }}});
Rb16.addActionListener( new ActionListener() {           
            public void actionPerformed(ActionEvent e) {{
            Sary[3]= Rb16.getText(); 
             l5.setText(Sary[3]);
            }}});
Rb17.addActionListener( new ActionListener() {           
            public void actionPerformed(ActionEvent e) {{
            Sary[3]= Rb17.getText(); 
             l5.setText(Sary[3]);
            }}});
Rb18.addActionListener( new ActionListener() {           
            public void actionPerformed(ActionEvent e) {{
            Sary[3]= Rb18.getText(); 
             l5.setText(Sary[3]);
            }}});
ImageIcon s1 = new ImageIcon("images\\LS1.jpg");
JLabel ls1 = new JLabel(" ", s1, JLabel.CENTER);
BG4.add(Rb20);
BG4.add(Rb19);
BG4.add(Rb16);
BG4.add(Rb17);
BG4.add(Rb18);
b4.add( Box.createRigidArea(new Dimension(0,50)));
b4.add(Rb20);
b4.add(pl1);
b4.add( Box.createRigidArea(new Dimension(0,8)));
b4.add(Rb19);
b4.add(pl2);
b4.add( Box.createRigidArea(new Dimension(0,8)));
b4.add(Rb16);
b4.add(pl3);
b4.add( Box.createRigidArea(new Dimension(0,8)));
b4.add(Rb17);
b4.add(pl4);
b4.add( Box.createRigidArea(new Dimension(0,8)));
b4.add(Rb18);
b4.add(pl5);
b4.add(ls1);
b4.setVisible(false);
b4.setBounds(125, 0, 275, 450);
b4.setBorder(BorderFactory.createTitledBorder(" "));
btnV=new JButton("SCREEN");
btnV.setMaximumSize(new Dimension(120, 25));
con.add(b4);
btnV.addActionListener(new ActionListener() {
         public void actionPerformed(ActionEvent e) {
         b4.setVisible(true);   
         b1.setVisible(false);
         b3.setVisible(false);
         b2.setVisible(false);
         b5.setVisible(false);
         first.setVisible(false);
         
         }});
//typ
pl1=new JLabel("Price - Rs.423 ");
pl2=new JLabel("Price - Rs 43 "); 
pl3=new JLabel("Price - Rs 4 ");
pl4=new JLabel("Price - Rs 4322 ");
pl5=new JLabel("Price - Rs 42222 ");
final Box hb1= Box.createHorizontalBox();
final Box hb2= Box.createHorizontalBox();
final Box hb3= Box.createHorizontalBox();
final Box hb4= Box.createHorizontalBox();
final Box hb11= Box.createHorizontalBox();
final Box hb12= Box.createHorizontalBox();
;
ImageIcon i1 = new ImageIcon("images\\LM1.jpg");
JLabel LM1 = new JLabel(" ", i1, JLabel.CENTER);
ImageIcon i2 = new ImageIcon("images\\LM2.jpg");
JLabel LM2 = new JLabel(" ", i2, JLabel.CENTER);
ImageIcon i3 = new ImageIcon("images\\LM3.jpg");
JLabel LM3 = new JLabel(" ", i3, JLabel.CENTER);
ImageIcon i4 = new ImageIcon("images\\LM4.jpg");
JLabel LM4 = new JLabel(" ", i4, JLabel.CENTER);
ImageIcon i5 = new ImageIcon("images\\LM5.jpg");
JLabel LM5 = new JLabel(" ", i5, JLabel.CENTER);
Rb21= new JRadioButton("HP Probook 4530s");
Rb22= new JRadioButton("HP Pavilion DV6");
Rb23= new JRadioButton("Dell Vostro");
Rb24= new JRadioButton("Dell Inspiron N5110");
Rb25= new JRadioButton("Acer Aspire 5750");
BG5.add(Rb21);
BG5.add(Rb22);
BG5.add(Rb23);
BG5.add(Rb24);
BG5.add(Rb25);
// b5.add( Box.createRigidArea(new Dimension(0,50)));
hb1.add(LM1);
hb2.add(Rb21);
hb11.add(pl1);
hb11.add( Box.createRigidArea(new Dimension(10,0)));
hb11.add(pl2);
hb1.add(LM2);
hb2.add(Rb22);
b5.add(hb1);
b5.add(hb2);
b5.add(hb11);
//b5.add( Box.createRigidArea(new Dimension(0,5)));
hb3.add(LM3);
hb4.add(Rb23);
hb3.add(LM4);
hb4.add(Rb24);
hb12.add(pl3);
hb12.add( Box.createRigidArea(new Dimension(10,0)));
hb12.add(pl4);
b5.add(hb3);
b5.add(hb4);
b5.add(hb12);
b5.add(LM5);
b5.add(Rb25);
b5.add(pl5);

Rb21.addActionListener( new ActionListener() {           
            public void actionPerformed(ActionEvent e) {{
            Sary[4]= Rb21.getText(); 
             l1.setText(Sary[4]);
            }}});
Rb22.addActionListener( new ActionListener() {           
            public void actionPerformed(ActionEvent e) {{
            Sary[4]= Rb22.getText(); 
             l1.setText(Sary[4]);
            }}});
Rb23.addActionListener( new ActionListener() {           
            public void actionPerformed(ActionEvent e) {{
            Sary[4]= Rb23.getText(); 
             l1.setText(Sary[4]);
            }}});
Rb24.addActionListener( new ActionListener() {           
            public void actionPerformed(ActionEvent e) {{
            Sary[4]= Rb24.getText(); 
             l1.setText(Sary[4]);
            }}});
Rb25.addActionListener( new ActionListener() {           
            public void actionPerformed(ActionEvent e) {{
            Sary[4]= Rb25.getText(); 
             l1.setText(Sary[4]);
            }}});
b5.setVisible(false);
b5.setBounds(125, 0, 275, 450);
b5.setBorder(BorderFactory.createTitledBorder(" "));
btnD=new JButton("MODEL");
btnD.setMaximumSize(new Dimension(120, 25));
con.add(b5);
btnD.addActionListener(new ActionListener() {
         public void actionPerformed(ActionEvent e) {
         b5.setVisible(true);   
         b1.setVisible(false);
         b3.setVisible(false);
         b4.setVisible(false);
         b2.setVisible(false);
         first.setVisible(false);
         
         }});
//Submit
Sub = new JButton(" SUBMIT ");
Sub.setMaximumSize(new Dimension(120, 25));
Sub.addActionListener(new ActionListener() {
         public void actionPerformed(ActionEvent e) {
         
                  for(int x=0;x<Sary.length;x++)
                 System.out.println(Sary[x]);
                  
                  ProductsSelectionLaptop1 PSL1 =new ProductsSelectionLaptop1();
                  
                  try {
                 setVisible(false);
PSL1.getPrice(Sary);
} catch (ClassNotFoundException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
} catch (SQLException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
         }});
buy.add(l1);
buy.add(l2);
buy.add(l3);
buy.add(l4);
buy.add(l5);
//remove
rem = new JButton(" Remove ");
rem.setMaximumSize(new Dimension(120, 25));
rem.addActionListener(new ActionListener() {
         public void actionPerformed(ActionEvent e) {
         for(int x=0;x<Sary.length;x++)
                 Sary[x]=" ";
         
         l1.setText(" ");
         l2.setText(" ");
         l3.setText(" ");
         l4.setText(" ");
         l5.setText(" ");
                   
         }});

choz.add( Box.createRigidArea(new Dimension(0,50)));
choz.add(btnD);
choz.add( Box.createRigidArea(new Dimension(0,5)));
choz.add(btnP);
choz.add( Box.createRigidArea(new Dimension(0,5)));
choz.add(btnR);
choz.add( Box.createRigidArea(new Dimension(0,5)));
choz.add(btnH);
choz.add( Box.createRigidArea(new Dimension(0,5)));
choz.add(btnV);
buy.add( Box.createRigidArea(new Dimension(0,50)));
ImageIcon image = new ImageIcon("images\\1.jpg");
JLabel label1 = new JLabel(" ", image, JLabel.CENTER);
buy.add(label1);
buy.add(Sub);
buy.add(rem);
choz.setBorder(BorderFactory.createTitledBorder("Choose "));
choz.setBounds(0, 0, 125, 450);
con.add(choz);
}
  
   public void back(String[] ar){
    for(int x=0;x<5;x++){
    Sary[x]= ar[x];
    }
   
            l2.setText(Sary[0]);
            l3.setText(Sary[1]);
            l4.setText(Sary[2]);
            l5.setText(Sary[3]);
            l1.setText(Sary[4]);
            
   }


@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
}

}