Social Icons

twitterfacebookgoogle pluslinkedinrss feed

Featured Posts

Sunday, September 14, 2014

Customizing Header and Footer of WSO2 API Manager Store

If you want to customize the header and footer of WSO2 API Manager Store application, this blog post will be explaining how to do that by adding a subtheme. 

Adding a Subtheme

1). Navigate to "\repository\deployment\server\jaggeryapps\store\site\themes\fancy\subthemes" directory.
2). Create a directory with the name of your subtheme. Here I am going to create a subtheme called "test"
3). Edit "repository\deployment\server\jaggeryapps\store\site\conf\site.json" file as below. This makes your sub theme as the default theme.

"theme" : {
        "base" : "fancy",
  "subtheme" : "test"
    },
Customize Header:

As an example, Here I am going to remove theme selection menu item from store header (theme selection will be appearing after user login into the store).

1). Create a directory called "templates" inside your subtheme directory.
2). Copy "template.jag" located in "\repository\deployment\server\jaggeryapps\store\site\themes\fancy\templates\user\login" 
into your new "templates" directory with the same "templates\user\login" directory structure.
3). To remove theme selection menu item, remove "<li class="dropdown settingsSection">...</li>" HTML tag section from the "template.jag". 

Customize Footer:

Here I am going to Remove documentation hyperlinks available in the API Store footer

1). Create a directory called "templates" inside your subtheme directory. Ignore this step if you have already done with the "Header customization"
2). Copy "template.jag" located in "\repository\deployment\server\jaggeryapps\store\site\themes\fancy\templates\page\base" 
 into your new "templates" directory with same "templates\page\base" directory structure.
3). To remove Docs link, you can find them inside the "row-fluid" div tag. Customize them according to your requirements.

Thursday, August 28, 2014

Host name verification failed for

Are you getting a "javax.net.ssl.SSLException: Host name verification failed for host" exception as below while trying to connect with a different host? 

TID: [0] [AM] [2014-08-28 14:41:51,936] ERROR {org.apache.synapse.transport.passthru.TargetHandler} - I/O error: Host name verification failed for host : vminstance.domain.com {org.apache.synapse.transport.passthru.TargetHandler}

javax.net.ssl.SSLException: Host name verification failed for host : vminstance.domain.com at org.apache.synapse.transport.http.conn.ClientSSLSetupHandler.verify(ClientSSLSetupHandler.java:152)
at org.apache.http.nio.reactor.ssl.SSLIOSession.doHandshake(SSLIOSession.java:285)
at org.apache.http.nio.reactor.ssl.SSLIOSession.isAppInputReady(SSLIOSession.java:380)
at org.apache.http.impl.nio.reactor.AbstractIODispatch.inputReady(AbstractIODispatch.java:118)
at org.apache.http.impl.nio.reactor.BaseIOReactor.readable(BaseIOReactor.java:160)
at org.apache.http.impl.nio.reactor.AbstractIOReactor.processEvent(AbstractIOReactor.java:342)
at org.apache.http.impl.nio.reactor.AbstractIOReactor.processEvents(AbstractIOReactor.java:320)
at org.apache.http.impl.nio.reactor.AbstractIOReactor.execute(AbstractIOReactor.java:280)
at org.apache.http.impl.nio.reactor.BaseIOReactor.execute(BaseIOReactor.java:106)
at org.apache.http.impl.nio.reactor.AbstractMultiworkerIOReactor$Worker.run(AbstractMultiworkerIOReactor.java:604)
at java.lang.Thread.run(Thread.java:745)


Reason is hostname verification is set to Default. So in order to get rid of this issue, modify the axis2.xml(https - transportSender) to turn Hostname Verification off as below.


&lt;parameter name="HostnameVerifier">AllowAll</parameter>

More Information about HostnameVerifier.

Saturday, June 07, 2014

WSO2 Governance Registry - Monitor database operations using log4jdbc

LOG4JDBC is a Java based database driver that can be used to log SQL and/or JDBC calls. So here I am going to show how to monitor JDBC operations on Governance Registry using log4jdbc.

Here I believe you have already configured Governance Registry instance with MySQL. If not, please follow the instruction available in the Governance Registry documentation.

1). Download the log4jdbc driver

 You can download log4jdbc driver from below location: https://code.google.com/p/log4jdbc/

2). Add log4jdbc driver

 Copy log4jdbc driver into CARBON_HOME/repository/components/lib directory.

3). Configure log4j.properties file.

Navigate to log4j.properties file located in CARBON_HOME/repository/conf/ directory and add below entry in to log4j.properties file.

# Log all JDBC calls except for ResultSet calls
log4j.logger.jdbc.audit=INFO,jdbc
log4j.additivity.jdbc.audit=false

# Log only JDBC calls to ResultSet objects
log4j.logger.jdbc.resultset=INFO,jdbc
log4j.additivity.jdbc.resultset=false

# Log only the SQL that is executed.
log4j.logger.jdbc.sqlonly=DEBUG,sql
log4j.additivity.jdbc.sqlonly=false

# Log timing information about the SQL that is executed.
log4j.logger.jdbc.sqltiming=DEBUG,sqltiming
log4j.additivity.jdbc.sqltiming=false

# Log connection open/close events and connection number dump
log4j.logger.jdbc.connection=FATAL,connection
log4j.additivity.jdbc.connection=false

# the appender used for the JDBC API layer call logging above, sql only
log4j.appender.sql=org.apache.log4j.FileAppender
log4j.appender.sql.File=${carbon.home}/repository/logs/sql.log
log4j.appender.sql.Append=false
log4j.appender.sql.layout=org.apache.log4j.PatternLayout
log4j.appender.sql.layout.ConversionPattern=-----> %d{yyyy-MM-dd HH:mm:ss.SSS} %m%n%n

# the appender used for the JDBC API layer call logging above, sql timing
log4j.appender.sqltiming=org.apache.log4j.FileAppender
log4j.appender.sqltiming.File=${carbon.home}/repository/logs/sqltiming.log
log4j.appender.sqltiming.Append=false
log4j.appender.sqltiming.layout=org.apache.log4j.PatternLayout
log4j.appender.sqltiming.layout.ConversionPattern=-----> %d{yyyy-MM-dd HH:mm:ss.SSS} %m%n%n

# the appender used for the JDBC API layer call logging above
log4j.appender.jdbc=org.apache.log4j.FileAppender
log4j.appender.jdbc.File=${carbon.home}/repository/logs/jdbc.log
log4j.appender.jdbc.Append=false
log4j.appender.jdbc.layout=org.apache.log4j.PatternLayout
log4j.appender.jdbc.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss.SSS} %m%n

# the appender used for the JDBC Connection open and close events
log4j.appender.connection=org.apache.log4j.FileAppender
log4j.appender.connection.File=${carbon.home}/repository/logs/connection.log
log4j.appender.connection.Append=false
log4j.appender.connection.layout=org.apache.log4j.PatternLayout
log4j.appender.connection.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss.SSS} %m%n



4). Update the master-datasources.xml file

Update the master-datasources.xml file located in CARBON_HOME/repository/conf/datasources directory. There each datasource URL and Drivers as below

<url>jdbc:log4jdbc:mysql://localhost:3306/amdb?autoReconnect=true</url>
<driverClassName>net.sf.log4jdbc.DriverSpy</driverClassName>

5). Enjoy

Some database drvers may not support by default(ex :db2), there you can pass database driver name as VM argument

-Dlog4jdbc.drivers=com.ibm.db2.jcc.DB2Driver

Restart the server and enjoy your work with log4jdbc. Log files are created under CARBON_HOME/repository/logs/ directory. So using sqltiming.log file you can monitor execution time of each query.

PS : If  you want to simulate lower bandwidth situation, you can use trickle when the server is starting.
(More)
         Example sh wso2server.sh trickle -d 64 -u 64

Friday, February 14, 2014

WSO2 Governance Registry - Apply Tags using Handler

There can be scenarios, where users want to apply tags into their resources, while resource is inserted. I am writing this post based on my answer provided to this Stack Overflow question.

Question was on how to apply a tag into a service in WSO2 Governance Registry at the time of the service creation. We can use Registry Handler for achieving this requirement. Handlers are the well-known extension points in WSO2 Governance Registry.

"Handlers are pluggable components, that contain custom processing logic for handling resources. All handlers extend an abstract class named Handler, which provides default implementations for resource handling methods as well as a few utilities useful for concrete handler implementations."[WSO2 Governance Registry Docs]

I have modified handler sample, which is shipped with Governance Registry pack. Using above link please download the G-Reg pack and handler sample is located at GREG_HOME/samples/handler.

 
public void put(RequestContext requestContext) throws RegistryException {

 if (!CommonUtil.isUpdateLockAvailable()) {
            return;
        }
        CommonUtil.acquireUpdateLock();
        try {
   String resourcePath = requestContext.getResourcePath().getPath();
   Registry registry = requestContext.getRegistry();
   registry.applyTag(resourcePath, "CustomTag");

  } finally {
   CommonUtil.releaseUpdateLock();
  }
 }

Compiled jar file need to be added into GREG_HOME/repository/components/dropins folder and register handler using either management console or registry.xml file.

<handler class="org.wso2.carbon.registry.samples.handler.CustomServiceHandler">
    <filter class="org.wso2.carbon.registry.core.jdbc.handlers.filters.MediaTypeMatcher">
        <property name="mediaType">application/vnd.wso2-service+xml</property>
    </filter>
</handler>

When you are inserting a new service, this handler will get hit and it will add the given tag into the Service.