How to detect bundle starts faliure(WSO2 Carbon) and how to fix it simply

WSO2 Carbon is based on set of OSGI bundles. when server starts those bundles must starts. But in some cases those may not start due to some reason. In most of issues we ask people to check weather bundles started or not. here i will briefly describe how to detect bundle start  failure and how to fix it without having any previous knowledge about osgi(I'm also not expert in osgi)Most of cases bundles will not start automatically may be they depend on some other bundle that did not started successfully or they may not included in bundledef file.we will see how to detect it

01.start wso2server in diagnose mode with osgi console by typing following  command in the command line
 sh wso2server.sh -DosgiConsole

you can get all osgi bundles information by typing ss in command line so you will be able to view bundles infomation

check weather your bundles state in order to use it, it must be activated.In cases it installed only we can start them manually by typing start command


if you see dependency or not listed in bundles list you have to manually add them to bundleinfo file.

in this case you can see we cant start this bundle because it depend on some other bundle that not listed so we have to manually add them to bundleinfo file.
Now you can see where is the root of error and we can fix it now

you can see file inside this filder

wso2stratos-manager-1.1.0-SNAPSHOT/repository/components/configuration/org.eclipse.equinox.simpleconfigurator/bunldles.info
This file contains all bundles that should be started


org.wso2.carbon.tenant.reg.agent.client,1.1.0.SNAPSHOT,plugins/org.wso2.carbon.tenant.reg.agent.client-1.1.0.SNAPSHOT.jar,4,true
org.wso2.carbon.tenant.reg.agent.service,1.1.0.SNAPSHOT,plugins/org.wso2.carbon.tenant.reg.agent.service-1.1.0.SNAPSHOT.jar,4,true
org.wso2.carbon.tenant.register.stub,3.2.0.SNAPSHOT,plugins/org.wso2.carbon.tenant.register.stub-3.2.0.SNAPSHOT.jar,4,true


so we will add new bundle that need to start as follows and put corressponding jar file in to repositary/components/pluggings folder

then you can start server again and you can check weather bundles started or not

How to fix error in svn due to locking "error-folder is already under version control"

When i try to add folder to svn this gives following error
sanjeewa@sanjeewa-laptop:~/trunck/carbon/service-stubs$ svn add org.wso2.carbon.usage.meteringsummarygenerationds.stub/
svn: Working copy '.' locked
svn: run 'svn cleanup' to remove locks (type 'svn help cleanup' for details)

then tried to clean up. it also gives following error
sanjeewa@sanjeewa-laptop:~/trunck/carbon/service-stubs$ svn cleanup
svn: 'org.wso2.carbon.usage.meteringsummarygenerationds.stub' is not a working copy directory

then i removed that folder by deleting and add new folder and try to add it
sanjeewa@sanjeewa-laptop:~/trunck/carbon/service-stubs$ svn add org.wso2.carbon.usage.meteringsummarygenerationds.stub/
svn: warning: 'org.wso2.carbon.usage.meteringsummarygenerationds.stub' is already under version control

So finally i found the way to solve it
01.first copy that folder to some other location(remove all .svn files inside)
02.then type svn clenup
03.then type svn revert command
svn revert org.wso2.carbon.usage.meteringsummarygenerationds.stub/
04.Copy back that folder to the location that we need
05.then add to svn
svn add org.wso2.carbon.usage.meteringsummarygenerationds.stub/

Mapping Data Between SQL Type and XSD Type

SQL typeXSD typeType restrictions
BigIntxsd:long
Binaryxsd:base64Binary
Bitxsd:boolean
Charxsd:string
DateTimexsd:dateTime

Decimalxsd:decimal
Float(53)xsd:double
GUID (same as UniqueIndentifier)xsd:string
Imagexsd:base64Binary
Intxsd:int
Moneyxsd:decimal


NCharxsd:string
NTextxsd:string
Numericxsd:decimal
NVarCharxsd:string
Realxsd:float
SmallIntxsd:short
SmallDateTimexsd:dateTime
SmallMoneyxsd:decimal

Sql_Variantxsd:anyType
Textxsd:string
TimeStampxsd:base64Binary (in SQL Server 2005 or later compatibility mode); xsd:long (in SQL Server 2000 compatibility mode)8
TinyIntxsd:unsignedByte
UDT (CLR style)xsd:base64Binary (in SQL Server 2005)Additional information about the actual type is provided within facets.
UDT (old style)Mapped to original base type
VarBinaryxsd:base64Binary
VarCharxsd:string
XMLxsd:any
XML (typed)xsd:anyXML schema that the XML is typed to is returned.

Brief Introduction to Rest full Web Services

Rest full Web Services
Representational State Transfer (REST) is an architectural style for building distributed systems. The Web is an example for such a system. REST-style applications can be built using a wide variety of technologies. REST's main principles are those of resource-oriented states and functionalities, the idea of a unique way of identifying resources, and the idea of how operations on these resources are defined in terms of a single protocol for interacting with resources. REST-oriented system design leads to systems which are open, scalable, extensible, and easy to understand.

REST Definition
REST is an acronym standing for Representational State Transfer.

Motivation for REST
The motivation for REST was to capture the characteristics of the Web which made the Web successful. Subsequently these characteristics are being used to guide the evolution of the Web.

REST Concepts
Resources are defined by URIs
Resources are manipulated through their representations
Messages are self-descriptive and stateless
There can be multiple representations for a resource
Application state is driven by resource manipulations

REST is built around the idea of simplifying agreement
nouns are required to name the resources that can be talked about
verbs are the operations that can be applied to named resources
content types define which information representations are available


For most applications, HTTP's basic methods are sufficient
GET: Fetching a resource (there must be no side-effects)
PUT: Transfers a resource to a server (overwriting if there already is one)
POST: Adds to an existing resource on the server
DELETE: Discards a resource (its name cannot be used anymore)
Expose directory structure-like URIs
From the standpoint of client applications addressing resources, the URIs determine how intuitive the REST Web service is going to be and whether the service is going to be used in ways that the designers can anticipate

 Stateless nature of restfull web services
REST Web services need to scale to meet increasingly high performance demands. Clusters of servers with load-balancing and failover capabilities, proxies, and gateways are typically arranged in a way that forms a service topology, which allows requests to be forwarded from one server to the other as needed to decrease the overall response time of a Web service call. Using intermediary servers to improve scale requires REST Web service clients to send complete, independent requests; that is, to send requests that include all data needed to be fulfilled so that the components in the intermediary servers may forward, route, and load-balance without any state being held locally in between requests.

How to generate Axiom OMElement Using input Stream

The method showed below is generate   Axiom OMElement  from input stream
  
   /**
     * @param inputStream Reads input stream that use to build OMElement
     * @return  OMElement that generated from input stream
     * @throws Exception at error in generating parser
     */
    public static OMElement buildOMElement(InputStream inputStream) throws Exception {
        XMLStreamReader parser;
        try {
            parser = XMLInputFactory.newInstance().createXMLStreamReader(inputStream);
        }
        catch (XMLStreamException e) {
            String msg = "Error in initializing the parser to build the OMElement.";
            log.error(msg, e);
            throw new Exception(msg, e);
        }
        finally {
           log.info("Reading data from configuration file");
        }
        StAXOMBuilder builder = new StAXOMBuilder(parser);
        return builder.getDocumentElement();
    }


we can call this method as follows

OMElement  element=buildOMElement(new FileInputStream("File path String"));

If you need more information go to this link

How to read user input at command line -Java


    public String readUserInput(String printMessage) throws IOException{
        System.out.println(printMessage);
        InputStreamReader isr = new InputStreamReader ( System.in );
        BufferedReader br = new BufferedReader (isr);
        String returnString;
        try {
            returnString=br.readLine();
        } catch (IOException e) {
           String message="error while reading user input";
           log.error(message,e);
           throw new IOException(e);
        }
        finally {
            br.close();
            isr.close()
        }
        return returnString;
    }

Get Present Working Directory in Java Code

Most of projects we don't use absolute path instead we use relative path thats best practice. in this discussion we will see how to get string name of current working folder so after that we can get relative path corresponding to that base location . so simple just few lines :)
   public static String getCurrentDirectory(){
        String cwd = null;
        try{
            cwd = new java.io.File( "." ).getCanonicalPath();

        } catch (java.io.IOException e)
        {
            log.error("Error in getting present working Directory");
        }
        return cwd;
    }

Empowering the Future of API Management: Unveiling the Journey of WSO2 API Platform for Kubernetes (APK) Project and the Anticipated Alpha Release

  Introduction In the ever-evolving realm of API management, our journey embarked on the APK project eight months ago, and now, with great a...