Tuesday, 22 September 2015

SOA Suite 11g: Unable to start domain



If you have recently installed

Created a domain and then tried to start it only to find it fails with the error:
 
Error occurred during initialization of VM
Could not reserve enough space for object heap
Could not create the Java virtual machine.
then edit the file




<domain home>\bin\setSOADomainEnv.cmd or sh (depending on your platform) and modify the line:
 
set DEFAULT_MEM_ARGS=-Xms512m -Xmx1024m


 
to something like:



set DEFAULT_MEM_ARGS=-Xms512m -Xmx768m
 
Start the weblogic server again. It should work.

Thursday, 11 December 2014

Disabling/Enabling the Oracle Service Bus Proxy or Business Services using Java code

When to use disable/enable using Java code:-

(i)the endpoint becomes unreachable
(ii)the endpoint still alive but the response becomes slow and results in SLA violation

If the problem on the endpoint persists and cannot be resolved quickly, a possible action can be to stop the Proxy Service for not receiving requests anymore until the problem is sorted out. We can manually disable the Proxy Service via OSB console or WLST to achieve this.  There is alternative approach available to disable Proxy Service automatically via OSB's Java API due to endpoint abnormalities.

Create a java code:-

package com.oracle.demo;


import java.io.IOException;
import java.net.MalformedURLException;
import java.util.Hashtable;

import com.bea.wli.sb.management.configuration.SessionManagementMBean;
import javax.management.MBeanServerConnection;
import javax.management.ObjectName;
import javax.management.remote.JMXConnector;
import javax.management.remote.JMXConnectorFactory;
import javax.management.remote.JMXServiceURL;
import javax.naming.Context;
import weblogic.management.mbeanservers.domainruntime.DomainRuntimeServiceMBean;
import weblogic.management.jmx.MBeanServerInvocationHandler;

import com.bea.wli.config.Ref;
import com.bea.wli.sb.management.configuration.ProxyServiceConfigurationMBean;

public class ServiceManager {

    private static JMXConnector initConnection(String hostname, int port,
            String username, String password)
    throws IOException,MalformedURLException
    {
        JMXServiceURL serviceURL =
        new JMXServiceURL("t3", hostname, port,
        "/jndi/" + DomainRuntimeServiceMBean.MBEANSERVER_JNDI_NAME);

        Hashtable<String, String> h = new Hashtable<String, String>();
        h.put(Context.SECURITY_PRINCIPAL, username);
        h.put(Context.SECURITY_CREDENTIALS, password);
        h.put(JMXConnectorFactory.PROTOCOL_PROVIDER_PACKAGES, "weblogic.management.remote");

        return JMXConnectorFactory.connect(serviceURL, h);
    }

    private static Ref convertServiceURI2Ref(String resType,String serviceuri){
        Ref ref = null;
        if((serviceuri.equals(""))||(serviceuri==null))
                return ref;

        String[] uriData = serviceuri.split("/");
        ref = new Ref(resType,uriData);
        return ref;
    }

    public static void changeProxyServiceStatus(String serviceref,boolean status)throws Exception{
        JMXConnector conn = null;
        SessionManagementMBean sm = null;
        String sessionName = "Session.ByApp." + System.currentTimeMillis();

        try{

            conn = initConnection("localhost", 7001, "weblogic", "welcome1");
            MBeanServerConnection mbconn = conn.getMBeanServerConnection();
            DomainRuntimeServiceMBean domainService = (DomainRuntimeServiceMBean) MBeanServerInvocationHandler.
                 newProxyInstance(mbconn, new ObjectName(DomainRuntimeServiceMBean.OBJECT_NAME));

            sm = (SessionManagementMBean) domainService.
                 findService(SessionManagementMBean.NAME,
                             SessionManagementMBean.TYPE, null);

            sm.createSession(sessionName);

            ProxyServiceConfigurationMBean proxyConfigMBean = (ProxyServiceConfigurationMBean) domainService.
             findService(ProxyServiceConfigurationMBean.NAME + "." + sessionName,
                     ProxyServiceConfigurationMBean.TYPE, null);
            Ref ref = convertServiceURI2Ref("ProxyService",serviceref);
            String msg = "";
            if(!status){
               proxyConfigMBean.disableService(ref);
               msg="Disabled the Proxy Service : " + serviceref;
            }
            else {          
                proxyConfigMBean.enableService(ref);  
                msg="enabled the Proxy Service : " + serviceref;
            }                              

            sm.activateSession(sessionName, msg);
            System.out.println(msg);
            conn.close();
        }catch(Exception ex){
            if(null != sm) {
                try{
                    sm.discardSession(sessionName);
                }catch(Exception e) {
                    System.out.println("discard session error");
                }
            }
            throw ex;
        }finally{
            if(null != conn)
                try{
                    conn.close();
                }catch(Exception e) {
                    e.printStackTrace();
                }
        }
    }
}

Use the below Jar files in libraries and classpath:-


















These jar files can be attached from following locations
$MW_Home/Oracle_OSB1/modules/com.bea.common.configfwk_1.7.0.0.jar
$MW_Home/Oracle_OSB1/lib/sb-kernel-api.jar

$MW_Home\wlserver_10.3\server\lib\weblogic.jar

Create a Jar file of this java code and then create a OSB proxy service to Use it using javacallout as below



















Provide the name of proxy service in Java.lang.String parameter and set the boolean as false. As we need to disable the proxy right now.

Here we have the result after running above proxy















The above Java code can be modified to enable/disable Business service as well.

Monday, 8 December 2014

java.sql.SQLException: JDBC LLR, table verify failed for table 'DEV_SOAINFRA.WL_LLR_ADMINSERVER'

After Creating two domain I encountered following issue while starting weblogic server for the second domain created

Error:-

javax.transaction.SystemException: Failed to call registerLoggingResourceTransac
tions() weblogic.transaction.loggingresource.LoggingResourceException: weblogic.
transaction.loggingresource.LoggingResourceException: java.sql.SQLException: JDB
C LLR, table verify failed for table 'DEV_SOAINFRA.WL_LLR_ADMINSERVER', row 'JDB
C LLR Domain//Server' record had unexpected value 'soa_domain//AdminServer' expe
cted 'base_domain//AdminServer'*** ONLY the original domain and server that crea
tes an LLR table may access it ***

Solution 1:-

If the Domain name was changed and do not want to change database properties then an update to the table WL_LLR_ADMINSERVER can be done:

i.e.
Start sqlplus
then run the below Update query
update DEV_SOAINFRA.WL_LLR_ADMINSERVER
set    RECORDSTR = 'base_domain//AdminServer'
where  XIDSTR    = 'JDBC LLR Domain//Server';
commit;

Solution 2:-

Reconfigure the Point base database information differently for each domain if you have more than one domain. This involves changing the database port and name in below two files in domain

In setDomainEnv.cmd (or .sh) file inside DOMAIN_HOME/bin directory change Point base port number and DB name.

set POINTBASE_PORT=9094
set POINTBASE_DBNAME=weblogic_2



jdbc:pointbase:server://localhost:9094/weblogic_2


In wlsbjmsrpDataSource-jdbc.xml file inside DOMAIN_HOME/config/jdbc directory change below entries with updated pointbase database port and name (this will be in two places in the file)



Saturday, 6 December 2014

Could not find the specific JMSServer requested with the JMS adapter Error [JMSExceptions:045103]

Error:

Getting the following fault when invoking a SOA Suite 11g composite that uses a JMS adapter to produce message:
<fault>
  <bpelFault>
    <faultType>0</faultType>
    <bindingFault>
      <part  name="summary">
        <summary>
          Exception occured when binding was invoked. Exception occured during invocation of JCA binding: "JCA Binding execute of Reference operation 'Produce_message' failed due to: ERRJMS_ERR_CR_QUEUE_PROD.ERRJMS_ERR_CR_QUEUE_PROD. Unable to create Queue producer due to JMSException. Please examine the log file to determine the problem. ". The invoked JCA adapter raised a resource exception. Please examine the above error message carefully to determine a resolution.
        </summary>
      </part>
      <part  name="detail">
        <detail>
          [JMSExceptions:045103]While trying to find a topic or a queue we could not find the specific JMSServer requested. The linked exception may contain more information about the reason for failure.
        </detail>
      </part>
      <part  name="code">
        <code>null</code>
      </part>
    </bindingFault>
  </bpelFault>
</fault>

Solution:

The subdeployment on which the queue is associate with is target to an invalid JMS Server. In this case, the JMS Server was referencing a persistent file store that did not exist.

After parsing log files, you may find the following error:
<Dec 25, 2011 7:30:41 PM EST> <Warning> <Management> <BEA-141197> <The deployment of TestJMSServer failed.
weblogic.management.DeploymentException: Internal error activating the JMS Server TestJMSServer: weblogic.management.DeploymentException: The persistent store "TestFileStore" does not exist at weblogic.jms.deployer.BEAdminHandler.activate(BEAdminHandler.java:215)
        at weblogic.management.utils.GenericManagedService.activateDeployment(GenericManagedService.java:239)
1. Navigate to the WebLogic Server Administration Console.

2. Expand soa_domain -> Services -> Messaging -> JMS Modules

3. Click on your JMS module name

4. Click on the Subdeployments tab

5. Click on the subdeployment name

6. Target the subdeployment to a valid JMS Server

Wednesday, 26 November 2014

OSB MQTransport and MQ queue always publishes the messages in bytes and not in Text

One of the issue I got recently while publishing data from OSB 11g to MQ Queue which always publishes message in Byte format.

Using HermesJMS Queue Browser for MQ queue basically was able to see messages in byte format.
Though My BusinessService(Messaging Service>>Request Message Type (Text)) for publishing the messages on the MQ queue always publishes the messages in bytes and not in Text. Even when I tried to change it to text i still get the messages in the bytes format.

Reason:-
mq transport is not able to parse JMS headers . if u sending message from any jms client like Hermes it would have jms headers with the message and mq transport would fail to validate the payload

Workaround:-
I added the below RFH2 Headers as part of mq Transport Header using Transport Header activity in OSB,so basically Hermes JMS was able to intercept the RFH2 headers and display the payload in text format in Queue Browser.

'<RFH2Header>
<mcd><Msd>jms_text</Msd></mcd>
</RFH2Header>'

Split Join behavior in OSB or FlowN behavior in BPEL

Recently i encountered with one issue while working through split join in OSB. Declared the variable as global and used in for each for parallel processing which started behaving abruptly. Request was splitting abruptly.

Always be sure to declare the variables as local to for-each or FlowN. Which will give you the values specific to thread generated at runtime.

Happy testing parallel flows !!!

Friday, 12 October 2012

How to pass event from ADF page to BPEL process using Java API

Step1:- We can write Java API to publish event in EDN based on JMS or EDN based on AQ. This java API code need to insert in ADF page on Click button action.  By default EDN would be AQ based. For changing it to JMS based need to change one property in SOA server and restart.
Note:- We need to decide if we want to use EDN-AQ or EDN-JMS. The AQ implementation is the default EDN implementation but this requires some datasources to the soa-infra database. This can be Ok in a small server network but it will create dependency to this SOA Suite Server in  WebLogic Server.”    

Step 2:- I will explain here EDN based on JMS.
      Step 2(i):- For using EDN based on JMS we have to do below changes in enterprise manager
1.     Open the enterprise manager application | SOA | soa-infra
2.     Open the Common Properties Menu item of the SOA-Infrastructure menu
3.     Click on More SOA-Infra Advanced Configuration Properties.This will open the System MBean Browser. In this we can change the EdnJmsMode and set this to true. Restart the SOA Server and take a look at the monitoring of the EDN Queue jms/fabric/EDNQueue which by default present on server


SOAJMSModule located at the JMSModules of WebLogic you can see that the module already contains an EDN Queue and an EDN ConnectionFactory.



By default jms/fabric/EDNConnectionFactory, jms/fabric/EDNQueue will be there on server. Create a JMS Connection Factory called xaEDNConnectionFactory with JNDI name jms/fabric/xaEDNConnectionFactory, enable XA and targeted this to your WebLogic server.

Step 2(ii):- Configure a Foreign JNDI Provider to Enable Administration Server Applications to Publish Events to the SOA Server

1.Log in to the Oracle WebLogic Server Administration Console.
2.In the Domain Structure section, expand Services > Data Sources.
You must remove the EDN-DB JNDI sources to use EDN-JMS data sources.
3.Select the following EDN-DB JNDI data sources, and click Remove.
◦jdbc/EDNDataSource
◦jdbc/EDNLocalTxDataSource
If the event publisher is in an application (for example, ADF) running in a different cluster or even in a different domain from the SOA server for EDN, you must configure a foreign JNDI provider with the local JNDI names for the cluster mapping to JNDI names targeted to the SOA Infrastructure. Local and remote JNDI names are the same in the links.
4.In the Domain Structure section, expand Services > Foreign JNDI Providers.
5.Click New.
6.In the Name field, enter a name for the foreign JNDI provider.
7.Select targets for the new JNDI provider, and click Finish.
8.In the Name field, click the new JNDI provider.
9.Specify provider settings (the initial context factory, provider URL, and so on), and click Save.
Initial Context Factory:- weblogic.jndi.WLInitialContextFactory.
Provider URL:-  t3://hostname:soa_server_port.
User:- Enter the Oracle WebLogic Server user name.
Password and Confirm Password:- Enter the password for the Oracle WebLogic Server user name.
10.Click the Links tab.
11.Click New to create a foreign JNDI link.
12.Enter a name, then specify the local and remote JNDI name of jms/fabric/EDNConnectionFactory.
13.Repeat Step 12, and specify a name and the local and remote JNDI name of jms/fabric/xaEDNConnectionFactory.Repeat Step 12, and specify a name and the local and remote JNDI name of jms/fabric/EDNQueue.
Once complete, three links are created.
14.Restart the targeted servers.
15.Confirm the new JNDI provider links in the JNDI tree view.

Step 2(iii):- ADF page will take two input parameter and will pass to xsd in API code and one create Event button .Java API code along with backing bean in ADF page:-
Need to add Libraries in View Controller to avoid any compilation error(i)SOA runtime (ii) Weblogic Remote Client (iii) JSF etc

package viewControler.backing;

import oracle.adf.view.rich.component.rich.RichDocument;
import oracle.adf.view.rich.component.rich.RichForm;
import oracle.adf.view.rich.component.rich.nav.RichCommandButton;

import java.util.Properties;


import javax.jms.Queue;
import javax.jms.QueueConnectionFactory;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;

import javax.transaction.UserTransaction;

import javax.xml.namespace.QName;

import oracle.adf.view.rich.component.rich.input.RichInputText;

import oracle.fabric.blocks.event.BusinessEventConnection;
import oracle.fabric.blocks.event.BusinessEventConnectionFactory;

import oracle.integration.platform.blocks.event.BusinessEventBuilder;
import oracle.integration.platform.blocks.event.jms.JmsRemoteBusinessEventConnectionFactory;

import oracle.soa.common.util.XMLUtil;


import org.w3c.dom.Element;
public class CallEventApI {
    public String cb1_action() {
        // Add event code here...
        // My SOA WebLogic variables
        // the business Event
//Enter name of business event
        String EmployeeEvent = "Event1";
//Enter target namespace of business event
        String NameSpace =
            "http://xmlns.oracle.com/SubscribedEventProject/EventDefinition1";
       
        String name = getIt1().getValue().toString();
        String id = getIt2().getValue().toString();
       //Enter the XSD payload
        String EmployeeEventBody =
            "<Employee xmlns=\"http://www.example.org\">" +
            "<Name>"+name+"</Name>" +
            "<Id>"+id+"</Id>" +
            "</Employee>";
       
        Element eventBody = null;
        try {
            eventBody =
                    XMLUtil.parseDocumentFromXMLString(
                        EmployeeEventBody.toString()).getDocumentElement();
        } catch (Exception e) {
            e.printStackTrace();
        }
       
        // EDN JMS environment
        String connFactName = "jms/fabric/EDNConnectionFactory";
        String xaConnFactName = "jms/fabric/xaEDNConnectionFactory";
        String queueName = "jms/fabric/EDNQueue";
       
        try {
            InitialContext context = new InitialContext();
            
                        // do a jndi lookup on the Server
                        UserTransaction userTransaction = (UserTransaction)context.lookup("javax.transaction.UserTransaction");
                        QueueConnectionFactory queueConnectionFactory = ((QueueConnectionFactory)context.lookup(connFactName));
                        QueueConnectionFactory xaQueueConnectionFactory = ((QueueConnectionFactory)context.lookup(xaConnFactName));
                        Queue jmsQueue = ((Queue)context.lookup(queueName));
            
       
            BusinessEventConnectionFactory factory =
                new JmsRemoteBusinessEventConnectionFactory(queueConnectionFactory,
                                                            xaQueueConnectionFactory,
                                                            jmsQueue,
                                                            userTransaction);
       
            BusinessEventConnection conn =
                factory.createBusinessEventConnection();
            
            // Create an event
            BusinessEventBuilder builder = BusinessEventBuilder.newInstance();
            builder.setEventName(new QName(NameSpace, EmployeeEvent));
            builder.setBody(eventBody);
            System.out.println("here called");
       
            // publish
            conn.publishEvent(builder.createEvent(), 4);
            conn.close();
       
        } catch (NamingException e) {
            e.printStackTrace();
        }
        return null;
    }
}

Step 3:- Deploy the ADF page as war file then open the page url and click the button.
Once event will be triggered from ADF page will put the message in jms/fabric/EDNQueue queue. Once message will reached to queue then it will automatically invoke Subscribed mediator as in Java API we are passing the Event name and namespace of EDL file and Input payload.

Hope this would be helpful.