Tuesday, November 19, 2013

How to host a WCF in IIS and enable Windows Authentication

I came across a scenario where I wanted to deploy a web service in windows server. Since I am mainly familiar with Linux environment and Java technology it took a while for me to get it done. So here I am sharing the knowledge gathered by me for those who wants to achieve the same task with less time.

WCF is a runtime set of APIs in .NET framework to create Web services.
IIS is a Microsoft Web server.


Environment:

JDK 1.6
.NET 4.0
IIS 7.5
Windows 7 professional

When you type IIS on the search in Start menu and did not retrieve any related results you can follow below steps:

Go to Control Panel -> Programs -> Programs and Features and click on "Turn Windows Features on or off". Refer the attached diagram.



Make sure you have ticked what is shown in here to avoid getting exceptions when you deploy WCF in IIS and try to access it from the browser.


I mainly referred this link to create WCF application but did some slight changes on Web.config. (Important: Please create your application directory in C:\inetpub\wwwroot\ directory)

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
   <system.serviceModel>
      <bindings>
         <basicHttpBinding>
            <binding name="BasicHttpEndpointBinding">
               <security mode="TransportCredentialOnly">
                  <transport clientCredentialType="Windows" />
               </security>
            </binding>
         </basicHttpBinding>
      </bindings>
      <services>
         <service name="Microsoft.ServiceModel.Samples.CalculatorService">
            <endpoint address="" binding="basicHttpBinding" contract="Microsoft.ServiceModel.Samples.ICalculator" />
            <endpoint address="mex" binding="basicHttpBinding" contract="IMetadataExchange" />
         </service>
      </services>
      <behaviors>
         <serviceBehaviors>
            <behavior>
               <serviceMetadata httpGetEnabled="true" />
            </behavior>
         </serviceBehaviors>
      </behaviors>
   </system.serviceModel>
  <system.diagnostics>
    <sources>
      <source name="System.ServiceModel"
              switchValue="Information, ActivityTracing"
              propagateActivity="true" >
        <listeners>
             <add name="xml"/>
        </listeners>
      </source>
      <source name="System.ServiceModel.MessageLogging">
        <listeners>
            <add name="xml"/>
        </listeners>
      </source>
      <source name="myUserTraceSource"
              switchValue="Information, ActivityTracing">
        <listeners>
            <add name="xml"/>
        </listeners>
      </source>
    </sources>
    <sharedListeners>
        <add name="xml"
             type="System.Diagnostics.XmlWriterTraceListener"
             initializeData="Error.svclog" />
    </sharedListeners>
  </system.diagnostics>
</configuration>

In order to create the application you need to first go to "IIS Manager" and expand the node and go to "Default Web Site" and right click on it as follows.


Now go to the application you have created and select it. In the feature view, under IIS click on "Authentication" and disable "Anonymous Authentication" and enable "Windows Authentication".

Now you need to add users in order to use windows authentication.
For that go to Computer Management -> Local Users and Groups -> Users and create new user. Uncheck "User must change password at next logon" and click "User cannot change password" and "Password never expires".

Then go to Computer Management -> Local Users and Groups ->Groups and select "IIS_IUSERS". Write click on it and click on All Tasks->Add to Group and add the user created in the previous step.

Now when you type the app url in browser you should be prompted to enter credentials.


Saturday, November 16, 2013

Access SOAP fault data in fault sequence when Store and Forward Messaging Patterns is used in WSO2 ESB with WSO2 MB or ActiveMQ

Use case 1: WSO2 ESB with ActiveMQ

Steps:

1. Follow this to configure ESB 4.7.0 with ActiveMQ. First start ActiveMQ
and then start ESB.
2. Sample synpase configuration is provided below. Copy it to Home/Manage/Service Bus/Source view and save it.

<definitions xmlns="http://ws.apache.org/ns/synapse">
   <registry provider="org.wso2.carbon.mediation.registry.WSO2Registry">
      <parameter name="cachableDuration">15000</parameter>
   </registry>
   <proxy name="JMSProxy" startonload="true" trace="disable" transports="https http">
      <description>
      <target>
         <insequence>
            <log level="full">
            <property name="target.endpoint" value="AxisEp">
            <property name="FORCE_ERROR_ON_SOAP_FAULT" value="true">
            <store messagestore="JMSMS">

         </store></property></property></log></insequence>
      </target>
   </description></proxy>
  <endpoint name="AxisEp">
      <address uri="http://localhost:9000/services/echo">
         <suspendonfailure>
            <errorcodes>-1</errorcodes>
            <progressionfactor>1.0</progressionfactor>
         </suspendonfailure>
      </address>
</endpoint>
   <sequence name="Axis_Ok"></sequence>
   <sequence name="Axis_Fault">
      <log category="ERROR" level="custom">
         <property expression="get-property('ERROR_MESSAGE')" name="ERROR_MESSAGE" xmlns:ns="http://org.apache.synapse/xsd"></property>
         <property expression="get-property('ERROR_CODE')" name="ERROR_CODE" xmlns:ns="http://org.apache.synapse/xsd"></property>
         <property expression="get-property('ERROR_DETAIL')" name="ERROR_DETAIL" xmlns:ns="http://org.apache.synapse/xsd"></property>
      </log>

   </sequence>
   <sequence name="fault">
      <log level="full">
         <property name="MESSAGE" value="Executing default 'fault' sequence"></property>
         <property expression="get-property('ERROR_CODE')" name="ERROR_CODE"></property>
         <property expression="get-property('ERROR_MESSAGE')" name="ERROR_MESSAGE"></property>
      </log>
      <drop>
   </drop></sequence>
   <sequence name="main">
      <in>
         <log level="full"></log>
         <filter regex="http://localhost:9000.*" source="get-property('To')">
            <send>
         </send></filter>
      </in>
      <out>
         <send>
      </send></out>
      <description>The main sequence for the message mediation</description>
   </sequence>
   <messagestore class="org.wso2.carbon.message.store.persistence.jms.JMSMessageStore" name="JMSMS">
      <parameter name="java.naming.factory.initial">org.apache.activemq.jndi.ActiveMQInitialContextFactory</parameter>
      <parameter name="store.jms.cache.connection">false</parameter>
      <parameter name="java.naming.provider.url">tcp://localhost:61616</parameter>
      <parameter name="store.jms.JMSSpecVersion">1.1</parameter>
    <parameter name="store.jms.destination">JMSMS</parameter>
   </messagestore>
   <messageprocessor class="org.apache.synapse.message.processors.forward.ScheduledMessageForwardingProcessor" messagestore="JMSMS" name="SampleMessageForwardingProcessor">
      <parameter name="message.processor.reply.sequence">Axis_Ok</parameter>
      <parameter name="max.delivery.attempts">4</parameter>
      <parameter name="interval">1000</parameter>
  <parameter name="message.processor.fault.sequence">Axis_Fault</parameter>
   </messageprocessor>
</definitions>


 3. Download the Echo.aar and copy it to /samples/axis2Server/repository/services/ folder. The go to /samples/axis2Server location from terminal and run "sh axis2server.sh".
4. Now you can use soapUI to send the fault request. Create a new project with provided wsdl below:

http://localhost:8280/services/JMSProxy?wsdl

and open echoInt request and set a string as follows in order to get a soap fault from Echo service:

<soapenv:envelope xmlns:echo="http://echo.services.core.carbon.wso2.org" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
   <soapenv:header>
   <soapenv:body>
      <echo:echoint>
         <!--Optional:-->
         <in>hi</in>
      </echo:echoint>
   </soapenv:body>
</soapenv:header></soapenv:envelope>

Use case 2: WSO2 ESB with WSO2 MB

1. Follow this to configure ESB 4.7.0 with WSO2 MB. First start MB
and then start ESB.
2. Sample synpase configuration is provided below. Copy it to Home/Manage/Service Bus/Source view and save it.

><definitions xmlns="http://ws.apache.org/ns/synapse">
   <registry provider="org.wso2.carbon.mediation.registry.WSO2Registry">
      <parameter name="cachableDuration">15000</parameter>
   </registry>
   <proxy name="JMSProxy" startonload="true" trace="disable" transports="https http">
      <description>
      <target>
         <insequence>
            <log level="full">
            <property name="target.endpoint" value="AxisEp">
            <property name="FORCE_ERROR_ON_SOAP_FAULT" value="true">
            <store messagestore="JMSMS">

         </store></property></property></log></insequence>
      </target>
   </description></proxy>
  <endpoint name="AxisEp">
      <address uri="http://localhost:9000/services/echo">
         <suspendonfailure>
            <errorcodes>-1</errorcodes>
            <progressionfactor>1.0</progressionfactor>
         </suspendonfailure>
      </address>
</endpoint>
   <sequence name="Axis_Ok"></sequence>
   <sequence name="Axis_Fault">
      <log category="ERROR" level="custom">
         <property expression="get-property('ERROR_MESSAGE')" name="ERROR_MESSAGE" xmlns:ns="http://org.apache.synapse/xsd"></property>
         <property expression="get-property('ERROR_CODE')" name="ERROR_CODE" xmlns:ns="http://org.apache.synapse/xsd"></property>
         <property expression="get-property('ERROR_DETAIL')" name="ERROR_DETAIL" xmlns:ns="http://org.apache.synapse/xsd"></property>
      </log>

   </sequence>
   <sequence name="fault">
      <log level="full">
         <property name="MESSAGE" value="Executing default 'fault' sequence"></property>
         <property expression="get-property('ERROR_CODE')" name="ERROR_CODE"></property>
         <property expression="get-property('ERROR_MESSAGE')" name="ERROR_MESSAGE"></property>
      </log>
      <drop>
   </drop></sequence>
   <sequence name="main">
      <in>
         <log level="full"></log>
         <filter regex="http://localhost:9000.*" source="get-property('To')">
            <send>
         </send></filter>
      </in>
      <out>
         <send>
      </send></out>
      <description>The main sequence for the message mediation</description>
   </sequence>
      <messagestore class="org.wso2.carbon.message.store.persistence.jms.JMSMessageStore" name="JMSMS">
      <parameter name="java.naming.factory.initial">org.wso2.andes.jndi.PropertiesFileInitialContextFactory</parameter>
      <parameter name="store.jms.cache.connection">false</parameter>
      <parameter name="java.naming.provider.url">repository/conf/jndi.properties</parameter>
      <parameter name="store.jms.JMSSpecVersion">1.1</parameter>
      <parameter name="store.jms.destination">JMSMS</parameter>
   </messagestore>
   <messageprocessor class="org.apache.synapse.message.processors.forward.ScheduledMessageForwardingProcessor" messagestore="JMSMS" name="MyMsgProc">
      <parameter name="message.processor.reply.sequence">Axis_Ok</parameter>
      <parameter name="max.delivery.attempts">4</parameter>
      <parameter name="interval">5000</parameter>
      <parameter name="message.processor.fault.sequence">Axis_Fault</parameter>
   </messageprocessor>
</definitions>
3. Follow the 3rd and 4th steps in use case 1.

Note:

For both the cases you need to get a console output simillar to follows:
ERROR - ERROR_MESSAGE = Invalid value "hi" for element in, ERROR_CODE = Client, ERROR_DETAIL =
[2013-11-16 15:41:15,013] ERROR - LogMediator To: /services/FaultTestProxy.FaultTestProxyHttpsSoap11Endpoint, WSAction: urn:mediate, SOAPAction: urn:mediate, MessageID: urn:uuid:268e04bb-9020-4640-b543-d8720e9b2142, Direction: request, Envelope: axis2ns2:ClientInvalid value "punnadi" for element in




Thursday, September 26, 2013

Useful Linux commands

De/Compress


If you want to compress all the content in your current directory use:

zip -r  <zip_file_name>   .

If you want to decompress all the content in your zip file to given directory use:

unzip <zip_file_name>  -d <directory_name>


SCP

If you want to copy a file from your machine to remote machine specific directoy

scp <path_to_the_file_to_be_copied> <remote_machine_username>@<remote_machine_ip>:<full_path_to_destination>

If you want to copy a file from remote machine to your machine

scp <full_path_to_destination_in_local_machine> <remote_machine_username>@<remote_machine_ip>:<path_to_the_file_to_be_copied>


Share local files with others via simple HTTP Server with python

Go to directory where there is the file to be shared from terminal and type:

python -m SimpleHTTPServer

Now share local ip with others and they can download the file you shared with below link:

http://<ip>:8000/

Tuesday, September 10, 2013

How to setup clustered environment in a single machine with 2 WSO2 ESB nodes and 2 WSO2 MB with external zookeeper and Cassendra

Env: ESB 4.7.0 MB 2.1.0

Cassandra Setup
---------------

Cassandra.yaml:
    - seeds: "127.0.0.1"
    listen_address: localhost
    rpc_address: localhost


WSO2 MB Cluster Setup
---------------------

Server 1: localhost
Server 2: localhost


Server 1:
---------

carbon.xml:
    <HostName>localhost</HostName>
    <offset>5</offset>

zoo.cfg:

# The number of milliseconds of each tick
tickTime=2000
# The number of ticks that the initial
# synchronization phase can take
initLimit=10
# The number of ticks that can pass between
# sending a request and getting an acknowledgement
syncLimit=5
# the directory where the snapshot is stored.
dataDir=./../data
# the port at which the clients will connect
clientPort=2181
clientPortAddress=localhost

authProvider.1=org.apache.zookeeper.server.auth.SASLAuthenticationProvider

#requireClientAuthScheme=sasl

# renew server-side ticket once an hour. 1000*60*60 = 3600000 milliseconds

jaasLoginRenew=3600000

conf/advanced/qpid-config.xml:

<enabled>true</enabled>     
<OnceInOrderSupportEnabled>false</OnceInOrderSupportEnabled>
<externalCassandraServerRequired>true</externalCassandraServerRequired>
 <externalZookeeperServerRequired>true</externalZookeeperServerRequired>
<coordination>
    <ZooKeeperConnection>127.0.0.1:2181</ZooKeeperConnection>
    <ReferenceTime>2012-02-29 08:08:08</ReferenceTime>
</coordination>



conf/advanced/qpid-virtualhosts.xml:

<class>org.wso2.andes.server.store.CassandraMessageStore</class>
<username>admin</username>
<password>admin</password>
<cluster>ClusterOne</cluster>
<idGenerator>org.wso2.andes.server.cluster.coordination.TimeStampBasedMessageIdGenerator</idGenerator>
<connectionString>localhost:9160</connectionString>


Server 2:
---------

carbon.xml:
    <HostName>localhost</HostName>
    <offset>6</offset>

zoo.cfg:

# The number of milliseconds of each tick
tickTime=2000
# The number of ticks that the initial
# synchronization phase can take
initLimit=10
# The number of ticks that can pass between
# sending a request and getting an acknowledgement
syncLimit=5
# the directory where the snapshot is stored.
dataDir=./../data
# the port at which the clients will connect
clientPort=2181
clientPortAddress=localhost

authProvider.1=org.apache.zookeeper.server.auth.SASLAuthenticationProvider

#requireClientAuthScheme=sasl

# renew server-side ticket once an hour. 1000*60*60 = 3600000 milliseconds

jaasLoginRenew=3600000


conf/advanced/qpid-config.xml:

<enabled>true</enabled>     
<OnceInOrderSupportEnabled>false</OnceInOrderSupportEnabled>
<externalCassandraServerRequired>true</externalCassandraServerRequired>
 <externalZookeeperServerRequired>true</externalZookeeperServerRequired>
<coordination>
    <ZooKeeperConnection>127.0.0.1:2181</ZooKeeperConnection>
    <ReferenceTime>2012-02-29 08:08:08</ReferenceTime>
</coordination>

conf/advanced/qpid-virtualhosts.xml:

<class>org.wso2.andes.server.store.CassandraMessageStore</class>
<username>admin</username>
<password>admin</password>
<cluster>ClusterOne</cluster>
<idGenerator>org.wso2.andes.server.cluster.coordination.TimeStampBasedMessageIdGenerator</idGenerator>
<connectionString>localhost:9160</connectionString>
              
              
WSO2 ESB 4.7 Setup
------------------
Node 1:
-------
carbon.xml:
    <offset>0</offset>

axis2.xml:
   <!--Uncomment this and configure as appropriate for JMS transport support with WSO2 MB 2.x.x -->              
    <transportReceiver name="jms" class="org.apache.axis2.transport.jms.JMSListener">
        <parameter name="myTopicConnectionFactory" locked="false">
           <parameter name="java.naming.factory.initial" locked="false">org.wso2.andes.jndi.PropertiesFileInitialContextFactory</parameter>
            <parameter name="java.naming.provider.url" locked="false">repository/conf/jndi.properties</parameter>
            <parameter name="transport.jms.ConnectionFactoryJNDIName" locked="false">TopicConnectionFactory</parameter>
            <parameter name="transport.jms.ConnectionFactoryType" locked="false">topic</parameter>
        <parameter name="transport.jms.SessionAcknowledgement" locked="false">CLIENT_ACKNOWLEDGE</parameter>                      
        </parameter>

        <parameter name="myQueueConnectionFactory" locked="false">
            <parameter name="java.naming.factory.initial" locked="false">org.wso2.andes.jndi.PropertiesFileInitialContextFactory</parameter>
            <parameter name="java.naming.provider.url" locked="false">repository/conf/jndi.properties</parameter>
            <parameter name="transport.jms.ConnectionFactoryJNDIName" locked="false">QueueConnectionFactory</parameter>
        <parameter name="transport.jms.SessionTransacted">true</parameter>                      
            <parameter name="transport.jms.ConnectionFactoryType" locked="false">queue</parameter>
        <parameter name="transport.jms.SessionAcknowledgement" locked="false">CLIENT_ACKNOWLEDGE</parameter>                    
        </parameter>

        <parameter name="default" locked="false">
            <parameter name="java.naming.factory.initial" locked="false">org.wso2.andes.jndi.PropertiesFileInitialContextFactory</parameter>
            <parameter name="java.naming.provider.url" locked="false">repository/conf/jndi.properties</parameter>
            <parameter name="transport.jms.ConnectionFactoryJNDIName" locked="false">QueueConnectionFactory</parameter>
            <parameter name="transport.jms.ConnectionFactoryType" locked="false">queue</parameter>
        <parameter name="transport.jms.SessionTransacted">true</parameter>                      
        <parameter name="transport.jms.SessionAcknowledgement" locked="false">CLIENT_ACKNOWLEDGE</parameter>                      
        </parameter>
    </transportReceiver>
      
   <!-- uncomment this and configure to use connection pools for sending messages-->      

    
repository/conf/jndi.properties:

# register some connection factories
# connectionfactory.[jndiname] = [ConnectionURL]
connectionfactory.QueueConnectionFactory = amqp://admin:admin@clientID/carbon?brokerlist='tcp://localhost:5677'
connectionfactory.TopicConnectionFactory = amqp://admin:admin@clientID/carbon?brokerlist='tcp://localhost:5677'

# register some queues in JNDI using the form
# queue.[jndiName] = [physicalName]
queue.MyQueue = example.MyQueue

# register some topics in JNDI using the form
# topic.[jndiName] = [physicalName]
topic.MyTopic = example.MyTopic
     

Copy Lib from MB_HOME/client-lib to  ESB_HOME/repository/components/lib
andes-client-0.13.wso2v8
geronimo-jms_1.1_spec-1.1.0.wso2v1

Node 2:
-------

carbon.xml:
    <offset>1</offset>

axis2.xml:
   <!--Uncomment this and configure as appropriate for JMS transport support with WSO2 MB 2.x.x -->              
    <transportReceiver name="jms" class="org.apache.axis2.transport.jms.JMSListener">
        <parameter name="myTopicConnectionFactory" locked="false">
           <parameter name="java.naming.factory.initial" locked="false">org.wso2.andes.jndi.PropertiesFileInitialContextFactory</parameter>
            <parameter name="java.naming.provider.url" locked="false">repository/conf/jndi.properties</parameter>
            <parameter name="transport.jms.ConnectionFactoryJNDIName" locked="false">TopicConnectionFactory</parameter>
            <parameter name="transport.jms.ConnectionFactoryType" locked="false">topic</parameter>
        <parameter name="transport.jms.SessionAcknowledgement" locked="false">CLIENT_ACKNOWLEDGE</parameter>                      
        </parameter>

        <parameter name="myQueueConnectionFactory" locked="false">
            <parameter name="java.naming.factory.initial" locked="false">org.wso2.andes.jndi.PropertiesFileInitialContextFactory</parameter>
            <parameter name="java.naming.provider.url" locked="false">repository/conf/jndi.properties</parameter>
            <parameter name="transport.jms.ConnectionFactoryJNDIName" locked="false">QueueConnectionFactory</parameter>
        <parameter name="transport.jms.SessionTransacted">true</parameter>                      
            <parameter name="transport.jms.ConnectionFactoryType" locked="false">queue</parameter>
        <parameter name="transport.jms.SessionAcknowledgement" locked="false">CLIENT_ACKNOWLEDGE</parameter>                    
        </parameter>

        <parameter name="default" locked="false">
            <parameter name="java.naming.factory.initial" locked="false">org.wso2.andes.jndi.PropertiesFileInitialContextFactory</parameter>
            <parameter name="java.naming.provider.url" locked="false">repository/conf/jndi.properties</parameter>
            <parameter name="transport.jms.ConnectionFactoryJNDIName" locked="false">QueueConnectionFactory</parameter>
            <parameter name="transport.jms.ConnectionFactoryType" locked="false">queue</parameter>
        <parameter name="transport.jms.SessionTransacted">true</parameter>                      
        <parameter name="transport.jms.SessionAcknowledgement" locked="false">CLIENT_ACKNOWLEDGE</parameter>                      
        </parameter>
    </transportReceiver>
      
   <!-- uncomment this and configure to use connection pools for sending messages-->      
  

repository/conf/jndi.properties:

# register some connection factories
# connectionfactory.[jndiname] = [ConnectionURL]
connectionfactory.QueueConnectionFactory = amqp://admin:admin@clientID/carbon?brokerlist='tcp://localhost:5678'
connectionfactory.TopicConnectionFactory = amqp://admin:admin@clientID/carbon?brokerlist='tcp://localhost:5678'

# register some queues in JNDI using the form
# queue.[jndiName] = [physicalName]
queue.MyQueue = example.MyQueue

# register some topics in JNDI using the form
# topic.[jndiName] = [physicalName]
topic.MyTopic = example.MyTopic


Copy Lib from MB_HOME/client-lib to  ESB_HOME/repository/components/lib
andes-client-0.13.wso2v8
geronimo-jms_1.1_spec-1.1.0.wso2v1

How to configure Oracle database with WSO2 ESB, BAM and CEP clustered nodes




As depicted in the above diagram you need to create 5 new databases in Oracle (You can give any meaningful name).

For each database you need to run the oracle.sql file found under $ESB_HOME/dbscripts/ directory. This file has all the tables required by the usr_mgt and gov_registry databases (Both gov_registry and config_registry_<product> databases should have the same table structures.).Please note that all three ESB,CEP and BAM  packs has same content in the oracle.sql file found under dbscripts directory.

You can point to same database without having two databases for usr_mgt and gov_registry. But the recommended way is to have two different databases as depicted in the above diagram.


Note: I will follow the names i have mentioned in the diagram for convenience.


usr_mgt DB

1. create the database in Oracle.
# Modify below configurations by adding the new datasource:
    1. ESB
    $ESB_HOME/repository/conf/datasources/master-datasources.xml

    2. CEP
    $CEP_HOME/repository/conf/datasources/master-datasources.xml

    3. BAM
    $BAM_HOME/repository/conf/datasources/master-datasources.xml

# user-mgt.xml  refer this data source. Therefore modify the below configurations accordingly.
    1. EBS
    $ESB_HOME/repository/conf/user-mgt.xml

    2. CEP
    $CEP_HOME/repository/conf/user-mgt.xml

    3. BAM
    $BAM_HOME/repository/conf/user-mgt.xml

E.g:
Say the database name you have given is "usr_mgt" in Oracle.
1Modify each master-datasources.xml file by adding new datasource.

       <datasource>
            <name>WSO2_USR_MGT_DB</name>
            <description>The datasource used for user manager</description>
            <jndiConfig>
                <name>jdbc/WSO2UsrMgtDB</name>
            </jndiConfig>
            <definition type="RDBMS">
                <configuration>
                    <url>jdbc:oracle:thin:@localhost:1521:usr_mgt</url>
                    <username>user</username>
                    <password>user123</password>
                    <driverClassName>oracle.jdbc.driver.OracleDriver</driverClassName>
                    <maxActive>80</maxActive>
                    <maxWait>60000</maxWait>
                    <minIdle>5</minIdle>
                    <testOnBorrow>true</testOnBorrow>
                    <validationQuery>SELECT 1</validationQuery>
                    <validationInterval>30000</validationInterval>
                </configuration>
            </definition>
        </datasource>

Modify the user-mgt.xml by pointing to the above created database.

<Property name="dataSource">jdbc/WSO2UsrMgtDB</Property>

gov_registry DB

1. create the database in Oracle.
# Modify below configurations by adding the new datasource:
    1. ESB
    $ESB_HOME/repository/conf/datasources/master-datasources.xml

    2. CEP
    $CEP_HOME/repository/conf/datasources/master-datasources.xml

    3. BAM
    $BAM_HOME/repository/conf/datasources/master-datasources.xml

# Registry.xml should refer this datasource. Therefore modify the below configurations accordingly.
Modify the mount path aswell.
    1. EBS
    $ESB_HOME/repository/conf/registry.xml

    2. CEP
    $CEP_HOME/repository/conf/registry.xml

    3. BAM
    $BAM_HOME/repository/conf/registry.xml

E.g:
Say the database name you have given is "gov_registry" in Oracle.
Modify each master-datasources.xml file by adding new datasource.

        <datasource>
            <name>WSO2_GOV_REGISTRY_DB</name>
            <description>The datasource used for governance registry</description>
            <jndiConfig>
                <name>jdbc/WSO2GovRegistryDB</name>
            </jndiConfig>
            <definition type="RDBMS">
                <configuration>
                    <url>jdbc:oracle:thin:@localhost:1521:gov_registry</url>
                    <username>user</username>
                    <password>user123</password>
                    <driverClassName>oracle.jdbc.driver.OracleDriver</driverClassName>
                    <maxActive>80</maxActive>
                    <maxWait>60000</maxWait>
                    <minIdle>5</minIdle>
                    <testOnBorrow>true</testOnBorrow>
                    <validationQuery>SELECT 1</validationQuery>
                    <validationInterval>30000</validationInterval>
                </configuration>
            </definition>
        </datasource>

Modify the registry.xml by pointing to the above created database.

<dbConfig name="governanceRegistry">
        <dataSource>jdbc/WSO2GovRegistryDB</dataSource>
</dbConfig>

<remoteInstance url="https://10.20.30.41:9443/registry">
    <id>governanceRegistryInstance</id>
    <dbConfig>governanceRegistry</dbConfig>
    <readOnly>true</readOnly>
    <registryRoot>/</registryRoot>
</remoteInstance>

<mount path="/_system/governance" overwrite="true">
    <instanceId>governanceRegistryInstance</instanceId>
    <targetPath>/_system/governance</targetPath>
</mount>

Config_registry DB

Each 2 ESB,CEP and BAM Instances should have one Config database as depicted in the diagram.
# Modify below configurations by adding the new datasource:
    1. ESB
    $ESB_HOME/repository/conf/datasources/master-datasources.xml

    2. CEP
    $CEP_HOME/repository/conf/datasources/master-datasources.xml

    3. BAM
    $BAM_HOME/repository/conf/datasources/master-datasources.xml

# Registry.xml should refer this data source. Therefore modify the below configurations accordingly.
Modify the mount paths aswell.
    1. EBS
    $ESB_HOME/repository/conf/registry.xml

    2. CEP
    $CEP_HOME/repository/conf/registry.xml

    3. BAM
    $BAM_HOME/repository/conf/registry.xml

E.g:
Consider 2 ESB instances.
Say the database name you have given is "config_registry_esb" in Oracle.
Modify each master-datasources.xml file by adding new datasource.

        <datasource>
            <name>WSO2_CONFIG_REG_ESB</name>
            <description>The datasource used for config registry</description>
            <jndiConfig>
                <name>jdbc/WSO2ConfigRegESB</name>
            </jndiConfig>
            <definition type="RDBMS">
                <configuration>
                    <url>jdbc:oracle:thin:@localhost:1521:config_registry_esb/url>
                    <username>user</username>
                    <password>user123</password>
                    <driverClassName>oracle.jdbc.driver.OracleDriver</driverClassName>
                    <maxActive>80</maxActive>
                    <maxWait>60000</maxWait>
                    <minIdle>5</minIdle>
                    <testOnBorrow>true</testOnBorrow>
                    <validationQuery>SELECT 1</validationQuery>
                    <validationInterval>30000</validationInterval>
                </configuration>
            </definition>
        </datasource>

Modify each registry.xml by pointing to the above created database.

<dbConfig name="configRegistry">
        <dataSource>jdbc/WSO2ConfigRegESB</dataSource>
</dbConfig>

<remoteInstance url="https://10.20.30.41:9443/registry">
    <id>configRegistryInstance</id>
    <dbConfig>configRegistry</dbConfig>
    <readOnly>true</readOnly>
    <registryRoot>/</registryRoot>
</remoteInstance>

<mount path="/_system/config" overwrite="true">
    <instanceId>configRegistryInstance</instanceId>
    <targetPath>/_system/nodes</targetPath>
</mount>

Note: You need to do the same for 2 CEP and 2 BAM instances.

Friday, February 8, 2013

Jaspersoft Server Report Units - Passing the date/time formats at runtime to change the display format of date values

  • Create a report unit in Jaspersoft Server.
  •  Add 2 parameters     
    • parameter1 – Date value
1
1.      








    • parameter2- The Date format required to format the “parameter1”
Note: The formats which we can use here are only formats supported by java.text.SimpleDateFormat class.

e.g:        EEEE, dd MMMM yyyy HH:mm:ss zzzz
MM/dd/yy
dd/MM/yy
dd-MMM-yy
yyyy.MM.dd.HH.mm.ss
E, dd MMM yyyy HH:mm:ss Z



 
·     



  •    Now we need to drag and drop the “parameter1” value to the report Detail band and click on its parameters. Find the property called “Pattern Expression” and set “$P{parameter2}” as the value.






  • Now save the report and upload the file successfully to the jaspersoft server.
  • Define a report and run it (Either with default values or change the values).

Thursday, February 7, 2013

Remote Debugging on WebLogic Server with Eclipse


            1.  Go to the WebLogic Server domain installed directory and open the bin folder.
2.      Open the startWebLogic.sh file and add the statement highlighted in red as depicted in the below diagram:
JAVA_OPTIONS="-Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,address=8888,server=y,suspend=n"

3.      Go to the Eclipse IDE and open a new debug configuration create a new “Remote Java Application”.
4.      Modify the configuration in the Remote Java Application dialog as follows:
 The value set for the “address” in Step1 should be equal to the Port value. (e.g. 8888)
 
5.      Using the UNIX terminal go to the folder where the startWebLogic.sh file resides and type “./startWebLogic.sh” to start the WebLogic server and from Eclipse run the newly created debug configuration.