Friday, November 8, 2013

[Jdeveloper] java.net.ConnectException: Connection refused: connect; No available router to destination

Error:-


java.lang.RuntimeException: javax.naming.CommunicationException [Root exception is java.net.ConnectException: t3s://hostname.mycompany.com:8001: Destination unreachable; nested exception is:
    java.net.ConnectException: Connection refused: connect; No available router to destination]
    at oracle.tip.tools.ide.fabric.asbrowser.WeblogicSOAServer.initPartitions(WeblogicSOAServer.java:89)
    at oracle.tip.tools.ide.fabric.asbrowser.WeblogicSOAServer.(WeblogicSOAServer.java:68)
    at oracle.tip.tools.ide.fabric.asbrowser.ASBrowserHelper.listWeblogicSOAServers(ASBrowserHelper.java:275)
    at oracle.tip.tools.ide.fabric.asbrowser.ASBrowserHelper.listSOAServers(ASBrowserHelper.java:201)
    at oracle.tip.tools.ide.fabric.asbrowser.ASBrowserHelper$RunnableListSOAServers.run(ASBrowserHelper.java:333)
    at oracle.ide.dialogs.ProgressBar.run(ProgressBar.java:655)
    at java.lang.Thread.run(Thread.java:662)
Caused by: javax.naming.CommunicationException [Root exception is java.net.ConnectException: t3s://hostname.mycompany.com:8001: Destination unreachable; nested exception is:
    java.net.ConnectException: Connection refused: connect; No available router to destination]
    at weblogic.jndi.internal.ExceptionTranslator.toNamingException(ExceptionTranslator.java:40)
    at weblogic.jndi.WLInitialContextFactoryDelegate.toNamingException(WLInitialContextFactoryDelegate.java:788)
    at weblogic.jndi.WLInitialContextFactoryDelegate.getInitialContext(WLInitialContextFactoryDelegate.java:368)
    at weblogic.jndi.Environment.getContext(Environment.java:315)
    at weblogic.jndi.Environment.getContext(Environment.java:285)
    at weblogic.jndi.WLInitialContextFactory.getInitialContext(WLInitialContextFactory.java:117)
    at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:667)
    at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288)
    at javax.naming.InitialContext.init(InitialContext.java:223)
    at javax.naming.InitialContext.(InitialContext.java:197)
    at oracle.soa.management.internal.facade.ServerManagerImpl.(ServerManagerImpl.java:76)
    at oracle.soa.management.internal.facade.ServerManagerFactoryImpl.createServerManager(ServerManagerFactoryImpl.java:28)
    at oracle.tip.tools.ide.fabric.asbrowser.WeblogicSOAServer.initPartitions(WeblogicSOAServer.java:85)
    ... 6 more
Caused by: java.net.ConnectException: t3s://hostname.mycompany.com:8001: Destination unreachable; nested exception is:
    java.net.ConnectException: Connection refused: connect; No available router to destination
    at weblogic.rjvm.RJVMFinder.findOrCreateInternal(RJVMFinder.java:216)
    at weblogic.rjvm.RJVMFinder.findOrCreate(RJVMFinder.java:170)
    at weblogic.rjvm.ServerURL.findOrCreateRJVM(ServerURL.java:153)
    at weblogic.jndi.WLInitialContextFactoryDelegate.getInitialContext(WLInitialContextFactoryDelegate.java:353)
    ... 16 more
Caused by: java.rmi.ConnectException: Destination unreachable; nested exception is:
    java.net.ConnectException: Connection refused: connect; No available router to destination
    at weblogic.rjvm.ConnectionManager.bootstrap(ConnectionManager.java:470)
    at weblogic.rjvm.ConnectionManager.bootstrap(ConnectionManager.java:321)
    at weblogic.rjvm.RJVMManager.findOrCreateRemoteInternal(RJVMManager.java:254)
    at weblogic.rjvm.RJVMManager.findOrCreate(RJVMManager.java:197)
    at weblogic.rjvm.RJVMFinder.findOrCreateRemoteServer(RJVMFinder.java:238)
    at weblogic.rjvm.RJVMFinder.findOrCreateInternal(RJVMFinder.java:200)


Cause:-

The issue was caused by incorrect password of the identity keystore. Below message was seen in the log.

<Nov 8, 2013 4:16:53 AM PST> <Error> <Security> <BEA-090133> <Could not load a JKS keystore from the file /u02/shared/certs/keystore/DemoIdentity.jks. Exception: java.io.IOException: Keystore was tampered with, or password was incorrect>
<Nov 8, 2013 4:16:53 AM PST> <Emergency> <Security> <BEA-090034> <Not listening for SSL, java.io.IOException: Failed to load identity keystore of type JKS from file /u02/shared/certs/keystore/DemoIdentity.jks on server SOA_MngdSvr1.>

Fix:-

1. Update correct password for identity and trust keystores under "keystores" and "SSL" tab for Admin and Managed Servers.
2. Do "Restart SSL" for all the admin and managed servers for which password has been updated. Verify in the log that keystores are loaded without any error now.
3. Try deployment from JDev now.

Tuesday, October 29, 2013

[JDeveloper] javax.net.ssl.SSLKeyException: [Security:090542] Certificate chain received from soa-dev.corp.xxx.com - 10.XXX.XXX.XXX was not trusted causing handshake failure

 ISSUE:-


CAUSE:-

This issue is because the client (JDev) is not trusting the certificate chain received from the server. So the solution here is to add the certificate of the server into trust store of Jdeveloper.

SOLUTION:-

1.       Open JDeveloper
2.       Goto Tools -> Preferences -> Credentials




1
3. Go to the location mentioned in “Client Trusted Certificate Keystore”
4. Backup DemoTrust.jks
5. Import the public key/certificate of the server you are trying to connect into  DemoTrust.jks.
6. Restart Jdev
7. Try now

Friday, October 25, 2013

JAVA API to abort RUNNING SOA Composite Instances

I got a requirement from our client to create a JAVA API that can abort all the RUNNING composite instances. This was required as purging script do not purge composite instances in running instances.
JAVA API Source Code-

import java.util.Hashtable;
import java.util.List;
import javax.naming.Context;
import oracle.soa.management.facade.Component;
import oracle.soa.management.facade.ComponentInstance;
import oracle.soa.management.facade.Composite;
import oracle.soa.management.facade.Locator;
import oracle.soa.management.facade.LocatorFactory;
import oracle.soa.management.util.ComponentInstanceFilter;
import oracle.soa.management.util.CompositeInstanceFilter;
import oracle.soa.management.facade.CompositeInstance;
import oracle.soa.management.CompositeDN;

public class abortComposite {
        public abortComposite() {
        super();
        }
        public void abortRunningComposite() {
        Locator locator = null;
        Hashtable jndiProps = new Hashtable();
        //Connection Details to Connect to Server
        jndiProps.put(Context.PROVIDER_URL, "t3://hostname:portnumber/soa-infra");
        jndiProps.put(Context.INITIAL_CONTEXT_FACTORY,  "weblogic.jndi.WLInitialContextFactory");
        jndiProps.put(Context.SECURITY_PRINCIPAL, "weblogic");
        jndiProps.put(Context.SECURITY_CREDENTIALS, "password");
        jndiProps.put("dedicated.connection", "true");

        try {
                //Connect to SOA Server
                locator = LocatorFactory.createLocator(jndiProps);
                System.out.println("Connected to SOA Server.");
                java.util.List
compositeDN=locator.listComposites();
                CompositeInstanceFilter filter = new CompositeInstanceFilter();
                //Set Minimum Creation Time
                filter.setMinCreationDate(new java.util.Date("Tue Aug 10 13:22:02 PDT 2013"));
                //Set Maximum Creation Time
                filter.setMaxCreationDate(new java.util.Date("Tue Aug 30 13:22:02 PDT 2013"));
                //Set for RUNNING State
                filter.setState(0);
                Composite composite=null;
                List
obInstances=null;
                //For each of the returned composite
                for (CompositeDN compositeDN1 : compositeDN) {
                        composite = locator.lookupComposite(compositeDN1);
                        //Get composite instances by filter
                        obInstances = composite.getInstances(filter);
                        //for each of the returned composite instances
                        for (CompositeInstance instance : obInstances) {
                                System.out.println(" DN: " + instance.getCompositeDN() + " Instance: " + instance.getId() + " creation-date: " + instance.getCreationDate() + " state (" + instance.getState() + "): " + getStateAsString(instance.getState()));
                                //Set up a component filter
                                ComponentInstanceFilter cInstanceFilter = new ComponentInstanceFilter();
                                //Get child component instances
                                List
childComponentInstances = instance.getChildComponentInstances(cInstanceFilter);
                                //For each child component instance
                                 for (ComponentInstance cInstance : childComponentInstances) {
                                        System.out.println(" -> componentinstance: " + cInstance.getComponentName() + " type: " + cInstance.getServiceEngine().getEngineType() + " state: " +getStateAsString(cInstance.getState()));
                                        System.out.println("State: "+cInstance.getNormalizedStateAsString());
                                        }
                                instance.abort();
                                }
                                obInstances=null;
                }
        }
        catch (Exception e) {
        System.out.println("Exception in API " + e);
        }
        }
        private String getStateAsString(int state){
                //Note that this is dependent on whether the composite state is captured or not
                if (state == CompositeInstance.STATE_COMPLETED_SUCCESSFULLY)
                        return ("success");
                else if (state == CompositeInstance.STATE_FAULTED)
                        return ("faulted");
                else if (state == CompositeInstance.STATE_RECOVERY_REQUIRED)
                        return ("recovery required");
                else if (state == CompositeInstance.STATE_RUNNING)
                        return ("running");
                else if (state == CompositeInstance.STATE_STALE)
                        return ("stale");
                else
                        return ("unknown");
        }

        public static void main(String[] args) {
        abortComposite  abortcomposite=new abortComposite();
        abortcomposite.abortRunningComposite();
        }
}
 


Steps:-
Set Classpath
export CLASSPATH=$CLASSPATH:$ORACLE_FMW_HOME/oracle_common/soa/modules/oracle.soa.mgmt_11.1.1/soa-infra-mgmt.jar:$ORACLE_FMW_HOME/oracle_common/modules/oracle.fabriccommon_11.1.1/fabric-common.jar:$ORACLE_FMW_HOME/wlserver_10.3/server/lib/weblogic.jar:$ORACLE_FMW_HOME/oracle_common/modules/oracle.jrf_11.1.1/jrf-api.jar

Compile the code
javac abortComposite.java

Execute the Code
java abortComposite

Friday, September 13, 2013

keytool error: java.lang.Exception: Input not an X.509 certificate

Problem Statement:-

While importing .pem format certificate in weblogic keystore using keytool command error was thrown as below
keytool error: java.lang.Exception: Input not an X.509 certificate



Background:-


I converted .p7b to .pem format using below command
openssl pkcs7 -print_certs -in ABC.p7b -inform der -out ABC.pem

and then tried importing it using keytool command 
keytool -importcert -alias ABC -file ABC.pem -keystore demoidentity.jks -storepass password

Cause:-

ABC.pem contains extra lines as highlighted below

subject=/serialNumber=6npr-psjxdqgGUW/7AUAFQC-27Xr/C=US/ST=California/L=Sunnyvale/O=ABC/CN=b2btest.abc.net
issuer=/C=US/O=GeoTrust, Inc./CN=GeoTrust SSL CA
-----BEGIN CERTIFICATE-----

Solution:-
Remove ALL the occurrence of highlighted line in the pem file and re-try.