Thursday, December 31, 2015

javax.net.ssl.SSLHandshakeException: Server chose unsupported or disabled protocol: SSLv3

If you get this error message "javax.net.ssl.SSLHandshakeException: Server chose unsupported or disabled protocol: SSLv3",
chances are that your JVM, for vulnerability issues connected to SSLv3, is configured to disable this protocol.
If you REALLY need to support SSLv3, check which file you are using for -Djava.security.properties=/path/to/yourfile, then edit yourfile and make sure your property:
jdk.tls.disabledAlgorithms=SSLv3, DH keySize < 768
doesn't contain SSLv3 (make it jdk.tls.disabledAlgorithms=DH keySize < 768)


Monday, December 21, 2015

Struts 1.2 in WebLogic 12.1.3, german characters encoding issue

"As of WebLogic Server 12.1.3, the default value of the encoding element for the jsp-descriptor element in weblogic.xml is UTF-8 for JSP pages. Prior to WebLogic Server 12.1.3, the default value for JSP encoding was ISO-8859-1."
If you have issues
1) Add <%@ page contentType="text/html;charset=UTF-8" %> line on top of every jsp page. 

 2) Add 
 <properties>
 <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
 <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
 </properties>

 In pom.xml  

 3) Add 
 <filter>
 <filter-name>struts2</filter-name>
 <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
 </filter>
 <mime-mapping>
 <extension>jsp</extension>
 <mime-type>text/html;charset=UTF-8</mime-type>
 </mime-mapping>
 In web.xml 

 4) Add 
 <jsp-config>
 <jsp-property-group > 
 <url-pattern>*.jsp</url-pattern>
 <page-encoding>UTF-8</page-encoding>
 </jsp-property-group>
 </jsp-config> in web.xml – 

5) Add <constant name="struts.i18n.encoding" value="UTF-8"/> In struts-config.xml 


 6) change text encoding to UTF-8 in the properties file. 

7) Add the below to your weblogic.xml.

<charset-params>
 <input-charset>
   <resource-path>/*</resource-path>
   <java-charset-name>ISO8859-1</java-charset-name>
 </input-charset>
</charset-params> 


(see oracle Support "Default JSP Encoding Changed to UTF-8 (Doc ID 2053210.1)" )

(it should be ISO8859-1, not ISO8859_1)

Also, to determine which encoding you are actually using, check in your html for "<meta http-equiv="content-type" content="text/html; charset=utf-8" /> " . And in the browser (IE in my case) you have a menu "view-encoding"...



Friday, December 18, 2015

Umlaut in emails

If in an email you see f�r instead of für, chances are that your weblogic/JavaMail is not using the right encoding (presumably UTF-8)

You can try several options:

-Dfile.encoding=UTF-8
change the template to use escaped (HTML) charachers
see https://issues.apache.org/jira/browse/GERONIMO-5022 :
message.setSubject(subject,"UTF-8");
message.setText(text, "UTF-8");
properties.setProperty("mail.mime.charset","UTF8");






Tuesday, December 15, 2015

org.eclipse.persistence.indirection.IndirectSet locking

one has to be careful with Lazy loading of entities (i.e. INDIRECTION)

http://grepcode.com/file/repo1.maven.org/maven2/org.eclipse.persistence/eclipselink/2.5.1/org/eclipse/persistence/indirection/IndirectSet.java#IndirectSet.getDelegate%28%29

in fact the getDelegate() code contains a synchronized clause, so one can easily end up in a series of blocked threads like the one below waiting on lock 0x0000000785157eb8 :

"[STUCK] ExecuteThread: '33' for queue: 'weblogic.kernel.Default (self-tuning)'" daemon prio=10 tid=0x00007f93100206f0 nid=0x17fc waiting for monitor entry [0x00007f9384ecb000]
   java.lang.Thread.State: BLOCKED (on object monitor)
 at org.eclipse.persistence.indirection.IndirectSet.getDelegate(IndirectSet.java:373)
 - waiting to lock <0x0000000785157eb8> (a org.eclipse.persistence.indirection.IndirectSet)
 at org.eclipse.persistence.indirection.IndirectSet.hashCode(IndirectSet.java:419)
 at java.util.WeakHashMap.hash(WeakHashMap.java:365)
 at java.util.WeakHashMap.getEntry(WeakHashMap.java:494)
 at java.util.WeakHashMap.containsKey(WeakHashMap.java:485)
 at org.apache.commons.lang.builder.ToStringStyle.isRegistered(ToStringStyle.java:162)
 at org.apache.commons.lang.builder.ToStringStyle.appendInternal(ToStringStyle.java:461)
 at org.apache.commons.lang.builder.ToStringStyle.append(ToStringStyle.java:435)
 at org.apache.commons.lang.builder.ToStringBuilder.append(ToStringBuilder.java:851)
 at org.apache.commons.lang.builder.ReflectionToStringBuilder.appendFieldsIn(ReflectionToStringBuilder.java:606)
 at org.apache.commons.lang.builder.ReflectionToStringBuilder.toString(ReflectionToStringBuilder.java:765)
 at org.apache.commons.lang.builder.ReflectionToStringBuilder.toString(ReflectionToStringBuilder.java:287)
 at org.apache.commons.lang.builder.ReflectionToStringBuilder.toString(ReflectionToStringBuilder.java:153)



"[STUCK] ExecuteThread: '50' for queue: 'weblogic.kernel.Default (self-tuning)'" daemon prio=10 tid=0x00007f931003e400 nid=0x2d37 runnable [0x00007f9371cf9000]
   java.lang.Thread.State: TIMED_WAITING (parking)
 at sun.misc.Unsafe.park(Native Method)
 at java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:349)
 at com.lmax.disruptor.MultiProducerSequencer.next(MultiProducerSequencer.java:133)
 at com.lmax.disruptor.MultiProducerSequencer.next(MultiProducerSequencer.java:102)
 at com.lmax.disruptor.RingBuffer.next(RingBuffer.java:207)
....
 at org.eclipse.persistence.logging.JavaLog.internalLog(JavaLog.java:290)
 at org.eclipse.persistence.logging.JavaLog.log(JavaLog.java:261)
 at org.eclipse.persistence.internal.sessions.AbstractSession.log(AbstractSession.java:3491)
 at org.eclipse.persistence.internal.sessions.AbstractSession.log(AbstractSession.java:4731)
 at org.eclipse.persistence.internal.sessions.AbstractSession.log(AbstractSession.java:4705)
 at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1839)
 at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1786)
 at org.eclipse.persistence.internal.indirection.QueryBasedValueHolder.instantiate(QueryBasedValueHolder.java:129)
 at org.eclipse.persistence.internal.indirection.QueryBasedValueHolder.instantiate(QueryBasedValueHolder.java:116)
 at org.eclipse.persistence.internal.indirection.DatabaseValueHolder.getValue(DatabaseValueHolder.java:89)
 - locked <0x00000007811573d8> (a org.eclipse.persistence.internal.indirection.QueryBasedValueHolder)
 at org.eclipse.persistence.internal.indirection.UnitOfWorkValueHolder.instantiateImpl(UnitOfWorkValueHolder.java:173)
 at org.eclipse.persistence.internal.indirection.UnitOfWorkValueHolder.instantiate(UnitOfWorkValueHolder.java:234)
 at org.eclipse.persistence.internal.indirection.DatabaseValueHolder.getValue(DatabaseValueHolder.java:89)
 - locked <0x0000000785157ee8> (a org.eclipse.persistence.internal.indirection.UnitOfWorkQueryValueHolder)
 at org.eclipse.persistence.indirection.IndirectSet.buildDelegate(IndirectSet.java:211)
 at org.eclipse.persistence.indirection.IndirectSet.getDelegate(IndirectSet.java:375)
 - locked <0x0000000785157eb8> (a org.eclipse.persistence.indirection.IndirectSet)
 at org.eclipse.persistence.indirection.IndirectSet.hashCode(IndirectSet.java:419)
 at java.util.WeakHashMap.hash(WeakHashMap.java:365)
 at java.util.WeakHashMap.getEntry(WeakHashMap.java:494)
 at java.util.WeakHashMap.containsKey(WeakHashMap.java:485)




My 2 cents: LAZY loading should NOT be really the default, unless you REALLY have performance issues (I know, EclipseLink site says the opposite). The effect of loading an object ANYWHERE in your code, while you are for instance in the middle of doing logging, can be really disruptive.



Monday, December 14, 2015

Online Java Thread Dump Analyzer

http://spotify.github.io/threaddump-analyzer/

simple and cool.... it's just what you need in 95% of the cases



Friday, December 11, 2015

Java Mission Control JMC video training

Very good overall coverage of JMC features







weblogic.utils.StackTraceDisabled.unknownMethod()

in recent (>= 12.1.2 ) versions of WLS, as stated in Oracle Doc ID 1624363.1:
"In production mode of WLS 12.1.2, the full Java exception stack trace is not returned to the ejb caller when an exception is thrown."
so all you get on the client is a "weblogic.utils.StackTraceDisabled.unknownMethod()"
Just add -Dweblogic.PrintStackTraceInProduction=true (I guess both on the client and on the server, if they are on different WLS instances...)


Sunday, December 6, 2015

Debugging SSL with javax.net.debug=all

This is a guide to interpreting the output of -Djavax.net.debug=all:
https://docs.oracle.com/javase/7/docs/technotes/guides/security/jsse/ReadDebug.html
and this is what I get
https://gist.github.com/vernetto/4b5c1e5b9562143998e0
by running this code with args[0]=www.usps.com (code courtesy of the excellent book "Java Network Programming, 4th Edition" that I highly recommend reading)



import java.io.*;
import javax.net.ssl.*;

public class HTTPSClient {

  public static void main(String[] args) {

    if (args.length == 0) {
      System.out.println("Usage: java HTTPSClient2 host");
      return;
    }

    int port = 443; // default https port
    String host = args[0];

    SSLSocketFactory factory
        = (SSLSocketFactory) SSLSocketFactory.getDefault();
    SSLSocket socket = null;
    try {
      socket = (SSLSocket) factory.createSocket(host, port);

      // enable all the suites
      String[] supported = socket.getSupportedCipherSuites();
      socket.setEnabledCipherSuites(supported);

      Writer out = new OutputStreamWriter(socket.getOutputStream(), "UTF-8");
      // https requires the full URL in the GET line
      out.write("GET http://" + host + "/ HTTP/1.1\r\n");
      out.write("Host: " + host + "\r\n");
      out.write("\r\n");
      out.flush();

      // read response
      BufferedReader in = new BufferedReader(
          new InputStreamReader(socket.getInputStream()));

      // read the header
      String s;
      while (!(s = in.readLine()).equals("")) {
        System.out.println(s);
      }
      System.out.println();

      // read the length
      String contentLength = in.readLine();
      int length = Integer.MAX_VALUE;
      try {
        length = Integer.parseInt(contentLength.trim(), 16);
      } catch (NumberFormatException ex) {
        // This server doesn't send the content-length
        // in the first line of the response body
      }
      System.out.println(contentLength);

      int c;
      int i = 0;
      while ((c = in.read()) != -1 && i++ < length) {
        System.out.write(c);
      }

      System.out.println();
    } catch (IOException ex) {
      System.err.println(ex);
    } finally {
        try {
          if (socket != null) socket.close();
        } catch (IOException e) {}
    }
  }
}





Friday, December 4, 2015

java.lang.ArrayStoreException

When creating an array, remember that it will be not of the type declared for the variable, but of the type decided in the initializer:


public class ArrayStoreExceptinTest {
 public static void main(String[] args) {
  System.out.println("starting");

  // test 1: all ok

  Object[] myarray1 = new Object[2];
  System.out.println("myarray1 " + myarray1.getClass().getName());
  myarray1[0] = new Integer(0);
  myarray1[1] = new String("");
  myarray1[1] = new Integer(0);

  // test 2: fails with java.lang.ArrayStoreException
  try {
   Object[] myarray2 = new String[2];
   System.out.println("myarray2 " + myarray2.getClass().getName());
   myarray2[0] = new Integer(0);
  } catch (Exception e) {
   e.printStackTrace();
  }

  // test 3: all ok
  Animal[] myarray3 = new Animal[] { new Cat(), new Dog() };
  System.out.println("myarray3 " + myarray3.getClass().getName());
  myarray3[0] = new Dog();

  try {
   // test 4: fails with java.lang.ArrayStoreException
   Animal[] myarray4 = new Cat[] { new Cat(), new Cat() };
   System.out.println("myarray4 " + myarray4.getClass().getName());
   myarray4[0] = new Dog();
  } catch (Exception e) {
   e.printStackTrace();
  }

 }
}

interface Animal {

}

class Dog implements Animal {

}

class Cat implements Animal {

}



this is the output:

starting
myarray1 [Ljava.lang.Object;
myarray2 [Ljava.lang.String;
java.lang.ArrayStoreException: java.lang.Integer
 at ArrayStoreExceptinTest.main(ArrayStoreExceptinTest.java:18)
myarray3 [LAnimal;
myarray4 [LCat;
java.lang.ArrayStoreException: Dog
 at ArrayStoreExceptinTest.main(ArrayStoreExceptinTest.java:32)



so if you initialize an Animal[] as a Cat[], you can't assign to a member a variable of type Dog, even if a Dog is an Animal...


Thursday, November 26, 2015

Find all Java classes implementing a given interface.... reflections!

https://code.google.com/p/reflections/

Download the ÜBER JAR here https://code.google.com/p/reflections/downloads/detail?name=reflections-0.9.9-RC1-uberjar.jar&can=2&q=


package pierre.reflections;
import java.net.URL;
import java.util.Set;

import org.reflections.Reflections;



public class FindInterfaceImplementations {
 public static void main(String[] args) {
  Reflections reflections = new Reflections();
  Set<URL> urls = reflections.getConfiguration().getUrls();
  for (URL item : urls) {
   System.out.println(item.toString());
  }
  Set<Class<? extends javax.enterprise.inject.spi.InjectionTargetFactory>> classes = reflections.getSubTypesOf(javax.enterprise.inject.spi.InjectionTargetFactory.class);
  System.out.println(classes.size());
 }

}



This version will load only classes under the "oracle" package:



package com.pierre.typequerylanguage;

import java.io.File;
import java.util.Set;

import org.reflections.Reflections;

import oracle.ucp.ConnectionAffinityCallback;

public class FindInterfaceImplementation {
 public static boolean VERBOSE = true;

 public static void main(String[] args) {
  if (VERBOSE) {
   System.out.println("searching in the following jars:");
   System.out.println(System.getProperty("java.class.path").replace(File.pathSeparatorChar, '\n'));
  }
  Reflections reflections = new Reflections("oracle");
  System.out.println("searching now");
  
  
  Set<Class<? extends ConnectionAffinityCallback>> classes = reflections.getSubTypesOf(oracle.ucp.ConnectionAffinityCallback.class);
  for (Class clazz : classes) {
   System.out.println("found: " + clazz.getCanonicalName());
  }
  System.out.println("searching done");
 }

}





Sunday, November 15, 2015

WLS 12.2.1 QUICK installer ignores response file

I was trying to install fmw_12.2.1.0.0_wls_quick.jar using the usual command line:
/usr/java/jdk1.8.0_65/bin/java -jar /opt/install/fmw_12.2.1.0.0_wls_quick.jar -silent -logLevel finest -debug -responseFile /opt/install/installfmw1221.rsp -invPtrLoc /etc/oraInst.loc
in vain... it would keep saying "Oracle Home not found, using default /tmp/hsperfdata_wls122/wls1221 " even if there is a variable ORACLE_HOME=/opt/oracle/fmw1221 in my response file.

Then I run "/usr/java/jdk1.8.0_65/bin/java -jar /opt/install/fmw_12.2.1.0.0_wls_quick.jar –help" and I my attention is drawn on this statement:
-responseFile   
        Location of the response file containing input for OUI. Ignored by quick installers.



So... the right syntax for QUICK installer is:

/usr/java/jdk1.8.0_65/bin/java -jar /opt/install/fmw_12.2.1.0.0_wls_quick.jar -silent -logLevel finest -debug ORACLE_HOME=/opt/oracle/fmw1221 -invPtrLoc /etc/oraInst.loc



Thursday, November 12, 2015

SCAN and REDIRECT with Oracle RAC

If you access a ORACLE RAC, be aware that you must open a firewall rule not only for the SCAN listener, but also to all the RAC instances. Connections are NOT routed via the SCAN listeners, they are merely client-side redirected.

Failure to do so will result in the connection fail with a Socket Timeout Exception. You will be puzzled because the telnet to the listener works... the problem is that your JDBC driver is trying to connect ALSO to the instance on a different IP (possibly also PORT...).... so you should test with telnet also the RAC instance!

import java.sql.DriverManager;
import java.sql.SQLException;

public class DBPing {
        public static void main(String[] args) throws ClassNotFoundException, SQLException {
                Class.forName("oracle.jdbc.driver.OracleDriver");
                System.out.println("length " + args.length);
                String user = args[0];
                String password = args[1];
                String url = args[2];
                String now = new java.util.Date().toString();
                System.out.println(now + " user= " + user + " password=" + password + " url=" + url);
                java.sql.Connection conn = DriverManager.getConnection(url, user, password);
                System.out.println("ok");
        }
}


java -cp /acme/appsrv/bin/wl12.1a/oracle_common/modules/oracle.jdbc_12.1.0/ojdbc6.jar:/home/userpippo DBPing dbusername dbpassword "jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=dbhostname-scan)(PORT=1522))(CONNECT_DATA=(SERVICE_NAME=myservicename)))" &^

The program will wait for connection for a while, then timeout. If you netstat BEFORE the timeout:

netstat -an | grep 1522

you will discover which IP corresponds to the RAC INSTANCE:

tcp 0 1 10.11.12.13:59482 44.55.66.222:1522 SYN_SENT

What is 44.55.66.222 ? It's NOT the dbhostname-scan IP, but rather the IP of a RAC instance.... the SCAN listener tells the Oracle JDBC driver to do a redirect to a new IP/PORT where the RAC instance is running.

What is SYN_SENT ? http://serverfault.com/questions/328361/tcptrack-shows-syn-sent-connections-does-that-mean-the-syn-package-reached-the .... which means that the JDBC driver sent a SYN, but the server didn't reply (because the firewall blocked the communication).

Here some doc on SCAN.
See also Oracle Support note "Port 1521 Open on Firewall But Unable to Connect Due to Errors: ORA-12535,TNS-12203 (Doc ID 361284.1)"


Sunday, November 8, 2015

JMC: how to capture details of caught and unlogged exceptions

It happens occasionally that inexperienced programmers catch an exception and ignore it, or they catch it and throw another exception without reporting the full details of the root cause.

This situation turns naturally in an operational nightmare.

But Java Mission Control can really help you out. Let´s run this code (remember the -XX:+UnlockCommercialFeatures -XX:+FlightRecorder ) :
public class ThrowsException {
 public static void main(String[] args) {
  while (true) {
   try {
    Thread.sleep(1000);
    throw new Exception("ciao bella gioia");
   }
   catch (Throwable t) {
   }
  }
 }
}


I run the JMC flight recorder, then go to the Code/Exceptions tab and this is what I get:



Saturday, November 7, 2015

Java Mission Control JMC with Java 7 u79

jmc is installed OOTB with this jmc.ini file:

-startup
../lib/missioncontrol/plugins/org.eclipse.equinox.launcher_1.3.0.v20140415-2008.jar
--launcher.library
../lib/missioncontrol/plugins/org.eclipse.equinox.launcher.win32.win32.x86_64_1.1.200.v20141007-2033
--launcher.appendVmargs
-vm
../jre/bin/
-vmargs
-XX:+UseG1GC
-XX:+UnlockCommercialFeatures
-XX:+FlightRecorder
-XX:FlightRecorderOptions=defaultrecording=true
-Djava.net.preferIPv4Stack=true


unfortunately it doesn't discover my local JVM (run with a JDK java!)

I get this error message:



"no local (attachable) JVM were detected". The JMC help says:
Why does Java Mission Control fail to find any local JVMs?
Consider the following:

•Make sure that you are using JAVA_HOME/bin/jmc to start the JMC client.


•If you are running JMC from Eclipse, make sure that Eclipse is running on a JDK (not JRE).


•Make sure that there is a directory named hsperfdata_username in the system's tmp directory, that it is writable by the user running JMC, and that the file system supports access control lists (ACLs).



First in the jmc.ini file I change ../jre/bin/ into C:\pierre\Java\jdk1.7.0_79\bin, then I select the C:\temp\hsperfdata_pierre folder and make it R/W (it was readonly!) and give full control to everyone. This time around all works fine. So sad that I don't get a better error message from JMC.... it would have been so simple just to display me a stacktrace or something more detailed. Even running "jmc -debug" didn't help...

If zou forget to run your program under test with the JMC options "-XX:+UnlockCommercialFeatures -XX:+FlightRecorder", you get this message:

Flight Recorder features are not enabled. To enable this you need to use a Java 7u4 or later JVM started with -XX:+UnlockCommercialFeatures -XX:+FlightRecorder.



Thursday, November 5, 2015

Limiting concurrent MDB pumping messages from a JMS (or MQ) queue (throttle)

you can use work managers with max-threads-constraint, or max-beans-in-free-pool : this is the ultimate source of truth... remember that by default you have only 16 concurrent beans registered as consumers on a queue:

https://docs.oracle.com/cd/E24329_01/web.1211/e24390/mdbtuning.htm#PERFM274



Sunday, November 1, 2015

JProfiler: Ingo Kegel man of the year

I was looking for training material on JProfiler and I found some 15 videos on youtube created by Ingo Kegel. He is really very professional! Thanks a lot Ingo! Ingo for President!


















Book: Pro JSF and HTML5



The book does a very good job at explaining the intricate history and structure of JSF framework, particularly regarding the CDI aspects. So definitely I would recommend it as an introduction to JSF.

However, I shake in terror at the idea of having to use JSF to develop font end application. The whole EL stuff reminds me of the days I have wasted trying to make JSTL tag library code work which fails silently... and JEE CDI seems to me another "magic under the hood" that becomes quite impossible to debug once anything goes wrong.

Besides, any attempt to write anything dynamic in a XML-like fashion should be straight away punished with 25 lashes on the back bottom. And any attempt to build complex expressions in a xhtml page using a combination of {, #, :, . , not validated by a compiler, is bound only to waste your life troubleshooting.

So, the learning curve is steep and the ways you can break the structure and waste days without any progress, infinite. It's a pity that frameworks like Vaadin don't get much attention and investment from big companies...

IMHO the root issue is that anybody with 2 hands and without at least a PhD in Mathematics can hack together a makeshift framework - glue, duct tape and some strings - and, if he hits the right market at the right time, find people who adopt it - for lack of a better alternative.



Saturday, October 31, 2015

Getting started with JSF and CDI and Primefaces

I have followed this tutorial http://reka-neva.blogspot.ch/2014/08/weblogic-jsf-2-tutorial.html


Deploy the application to a running WLS and test with http://localhost:7001/JSFWeb

You can login using this username/pw: ADMIN/password



The Java code uses the annotations
javax.enterprise.context.SessionScoped
javax.enterprise.inject.Model
javax.inject.Inject
javax.enterprise.inject.Produces


On the other hand, much more efficient if this approach https://www.mkyong.com/jsf2/primefaces/primefaces-hello-world-example/

and the code is https://github.com/vernetto/primefaces

Excellent article on JSF and CDI: https://dzone.com/articles/in-practice-dependency-injection-with-java-ee


Thursday, October 29, 2015

javax.transaction.SystemException: SubCoordinator not available

If you see this "javax.transaction.SystemException: SubCoordinator not available" in the logs, AND you have recently moved your domain to new servers, it could very well be that you need to purge your TLOG DB tables (of file store).. in fact, IP address of previous servers is still hardcoded in the TLOG info, so those TX will still linger around failing recovery until the Abandon Timeout is hit (read the "Moving the Server" chapter here http://docs.oracle.com/cd/E24329_01/web.1211/e24377/trxman.htm#WLJTA176 " the server identity may no longer match the information stored in the transaction logs"

Wednesday, October 28, 2015

installing WLS 12.2.1 on Linux RHEL 6.5

Download the generic installer fmw_12.2.1.0.0_wls.jar from http://www.oracle.com/technetwork/middleware/fusion-middleware/downloads/index.html and put into /opt/install/
Download Java 8 JDK from http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
install this one:
http://download.oracle.com/otn-pub/java/jdk/8u65-b17/jdk-8u65-linux-x64.rpm


rpm -i jdk-8u65-linux-x64.rpm

you should now find /usr/java/jdk1.8.0_65/bin/java

groupadd oracle
useradd oracle -g oracle
su - oracle
/usr/java/jdk1.8.0_65/bin/java -jar /tmp/fmw_12.2.1.0.0_wls.jar


this fails because I don't have X11, so I have to do silent installation the error message is:


/usr/java/jdk1.8.0_111/bin/java -jar /opt/install/fmw_12.2.1.0.0_wls.jar
Launcher log file is /tmp/OraInstall2017-01-02_09-52-00AM/launcher2017-01-02_09-52-00AM.log.
Extracting files.........
Starting Oracle Universal Installer

Checking if CPU speed is above 300 MHz.   Actual 2593.750 MHz    Passed
Checking monitor: must be configured to display at least 256 colors.  DISPLAY environment variable not set.    Failed <<<<
Checking swap space: must be greater than 512 MB.   Actual 3999 MB    Passed
Checking if this platform requires a 64-bit JVM.   Actual 64    Passed (64-bit not required)
Checking temp space: must be greater than 300 MB.   Actual 4663 MB    Passed

Some system prerequisite checks failed.
You must fulfill these requirements before continuing with the installation.

Continue? (yes [y] / no [n]) [n]
n
You have confirmed that the product cannot be installed on this platform.
Quitting the installation.

Exiting Oracle Universal Installer.
Log(s) for this session can be found in /tmp/OraInstall2017-01-02_09-52-00AM/launcher2017-01-02_09-52-00AM.log.


you should prepare this silent file ( see doc here https://docs.oracle.com/middleware/1212/core/OUIRF/silent.htm#OUIRF329 )

vi installfmw.rsp

(see here for sample response files for WLS 12.2.1)


[ENGINE]
 
#DO NOT CHANGE THIS.
Response File Version=1.0.0.0.0
 
[GENERIC]
 
#The oracle home location. This can be an existing Oracle Home or a new Oracle Home
ORACLE_HOME=/opt/oracle/fmw
 
#Set this variable value to the Installation Type selected. e.g. Fusion Middleware Infrastructure, Fusion Middleware Infrastructure With Examples.
INSTALL_TYPE=WebLogic Server
 
#Provide the My Oracle Support Username. If you wish to ignore Oracle Configuration Manager configuration provide empty string for user name.
MYORACLESUPPORT_USERNAME=
 
#Provide the My Oracle Support Password
MYORACLESUPPORT_PASSWORD=
 
#Set this to true if you wish to decline the security updates. Setting this to true and providing empty string for My Oracle Support username will ignore the Oracle Configuration Manager configuration
DECLINE_SECURITY_UPDATES=true
 
#Set this to true if My Oracle Support Password is specified
SECURITY_UPDATES_VIA_MYORACLESUPPORT=false
 
#Provide the Proxy Host
PROXY_HOST=
 
#Provide the Proxy Port
PROXY_PORT=
 
#Provide the Proxy Username
PROXY_USER=
 
#Provide the Proxy Password
PROXY_PWD=
 
#Type String (URL format) Indicates the OCM Repeater URL which should be of the format [scheme[Http/Https]]://[repeater host]:[repeater port]
COLLECTOR_SUPPORTHUB_URL=



as root:
vi /etc/oraInst.loc

inventory_loc=/opt/oracle/inventory
inst_group=oinstall


chmod 777 /etc/oraInst.loc

mkdir -p /opt/oracle/inventory
chown oracle:oinstall /opt/oracle/inventory
mkdir /opt/oracle/fmw
chown oracle:oinstall /opt/oracle/fmw

su - oracle

/usr/java/jdk1.8.0_65/bin/java -jar /opt/install/fmw_12.2.1.0.0_wls.jar -silent -responseFile /opt/install/installfmw.rsp -invPtrLoc /etc/oraInst.loc



no more stinky cmd prompt in Windows: use cmder instead!

http://cmder.net/

Download the "full" edition from https://github.com/cmderdev/cmder/releases . Unzip. Run cmder.

If you install the version from the main page you get a "api-ms-win-crt-runtime-l1-1-0.dll missing" error.

It looks definitely more feature-rich than the STINKY cmd prompt from Windows.

Sunday, October 25, 2015

OSB Cluster

Create a new Domain, using the "OSB Production" template
Create it in "Production" mode
Create MS osb_server1 and osb_server2 and put them into a cluster.

You will notice that this deployment:

"ALSB Cluster Singleton Marker Application" is targeted to osb_server1

wlsbJMSServer_auto_1 and 2 are targeted to osb_server1 and 2

WseeJmsServer_auto_1 and 2 are targeted to osb_server1 and 2

wli.reporting.purge.queue is deployed to wlsbJMSServer_auto_1

all the reporting, email file ftp sftp transport JMS queues are created as Distributed Destinations and targeted to the cluster
(wlsb.internal.transport.task.queue.ftp_auto_1, wlsb.internal.transport.task.queue.sftp_auto_1, wlsb.internal.transport.task.queue.email_auto_1, wlsb.internal.transport.task.queue.file_auto_1, QueueIn_auto_1, wli.reporting.jmsprovider.queue_auto_1, wli.reporting.jmsprovider_error.queue_auto_1)


DefaultCallbackQueue-WseeJmsServer_auto_1/2 and DefaultQueue-WseeJmsServer_auto_1/2 are deployed to either server



see here


for File, FTP, email:
"the poller on only one managed server will poll for a given proxy service"

SOA Architect Questions

How would you monitor a WebLogic instance (hint: console, Nagios/ Oracle Enterprise Manager and or Grid Control/ HP Open View)

Need for SOA Governance?

Have you read some EAI books, and which EAI patterns do you remember?

Do you know which are the main internal variable in OSB?( Hint: body, inbound, outbound)

If a process is long running, with human interaction, how would you manage it? (hint asynchronous)

Explain me how you would handle errors in OSB (hint: eror handler stage level, proxy level, …)

How do you monitor performance and response time and Errors using the OSB console? (hint SLA -Alert, logging and reporting actions)

What is a fault in OSB? How is represented? (hint: $fault details, ….)

Which problem do you face when deploying an integration solution to a new environment, and how do you solve this (customization plans/files)

When is it necessary to apply compensation? (hint error handling, non transactional)

Which features are available in BPEL which are not in a general purpose programming language like Java?

How would you test an integration solution?

What is JNDI?

You have a CSV or EDI file, how do you tranform it in XML?

What is Oracle RAC? How do you configure WebLogic to take advantage of RAC (hint: Multidatasource)

Which options do you have to enforce data integrity in a DB (constraints, triggers, range check, not null, foreign keys)

What is a WSDL?

How can we reuse services?

How would you configure WebLogic domains without using manual operations (hint: WLST, domain templates)

Difference between a Proxy service and Business Service?

What are JMX Beans, what to they do …how can we use it

How would you create and monitor a JMS queue with scripts? (hint: WLST, eventually Java)

Can you start and stop a WebLogic server from WLST, and how? (hint: nmConnect, nmStart, Node Manager)

Which options do you have to target a JMS queue? (hint: cluster, individual WLS server, individual JMS server, subdeployments)

How do you ensure that operations can continue without disruption even if a WLS instance goes down
(hint: cluster, whole server migration, service migration, load balancing with failover)

How do you change the log properties? Which are the main logs you have for weblogic and osb?

Which metrics would you monitor in WLS for a JDBC Data Source?

How would you implement the following integration interface?
. Our source system is sending the requests via FTP (it writes into ftp) and the target destination is a database. (hint database and ftp adapters).
. we want the implementation not to manage the connection details to the ftp or the database (JCA)
. We want messages to be persisted (persistent stores, jms queues)
. control error (error handler strategies)
. monitor the execution (tracking actions logging messages) end to end (messages id)
. in case something is failing we want ensure the database integrity so if we update the database and before ending the process something fails we want the database to be back to the original status( XA)
. The source message has a different format than the target (hint: xquery, xslt)
. we want to ensure that messages are processed in order (sequences, unit of order)
. We need to ensure that the message we send and we receive is valid according to the input and output schemas (hint validate actions)
. While mapping the values some of them , for example currency or country codes are represented in a different format in each system. For example EURO and EUR, POUND and PND, ... (Hint: domain value mapping)
. We want the service to be reused and accessible from multiple systems (service registry and service repository)
. Finally we would like to have the schemas in a repository (metadata repository) "
Please explain how to create a queue in FIFO mode in Weblogic? (Hint :one consumer)

What is a Canonical Data model? (hint common data, reusability)

Would you mind to explain the difference between async and synch behaviour?

Can you explain me something about ORM (Object Relational Mapping)

How do you ensure that a request is persisted and executed even in case of system crash (hint: persistence, transactions)

What is a transactional resource? What is a XA interface?

How do you configure a UnitofOrder in Weblogic? A persistent store? A remotequeue?

Is it possible a Managed server continue providing services in spite of shutting down the admin server? How to?

WebLogic Administrator Questions

How can you see if your OS is running a 64 or 32 bit OS

Can you explain me the basic Linux directory structure (/var/log/, /etc, /opt. /dev, /users)

How can you see how much disk space is left

Can you see what processes are running

Name some scheduling techniques

What is VM ware, have you ever worked with it, name some vendors

how do you check the hostname of a machine

Can you explain me something about Domain Names, how can you override domain names

Name some infrastructure monitoring software (Nagios/ Big Brother/ HP Open View)

Would you mind to explain me what a Proxy service is?

Would you mind to explain me what Business service is?

What are JMX Beans, what to they do …how can we use it

Name some Monitoring Best Practices for Middleware environments

Name some Monitoring Products for Middleware environments

How is your knowledge of Oracle Enterprise Manager and or Grid Control

What is the difference between tablespace/ schema

What is the difference between active and passive FTP

What is the difference between SFTP and FTPS

Name some Configuration Management Systems, (Puppet / CFEngine) have you ever worked with it

Do an analysis of a problem in a 4 tier system…from frontend to backend…where do you start/ escalate

What can you tell about SMNP, (trap destination/ trap translator)
How would you create and monitor a JMS queue with scripts? (hint: WLST, eventually Java)

Can you start and stop a WebLogic server from WLST, and how? (hint: nmConnect, nmStart, Node Manager)

Which options do you have to target a JMS queue? (hint: cluster, individual WLS server, individual JMS server, subdeployments)

Why would you use a Distributed Queue? (hint: high availability, load balancing)

How do you ensure that operations can continue without disruption even if a WLS instance goes down
(hint: cluster, whole server migration, service migration, load balancing with failover)

How to you check for Stuck Threads in WLS (hint: thread dump)

How do you update a Deployment (deployment plan)

Which are some common JCA Adapter and how do you set them up (hint: FTPAdapter, FileAdapter)

How to verify which Patches are applied to WLS, and how to apply a new Patch ?

How do you change the log properties? Which are the main logs you have for weblogic and osb?

Which metrics would you monitor in WLS for a JDBC Data Source?

What does a 'lock' mean when you startup weblogic? How to solve it?

In linux what command tells you the dependencies of a .so file

How can you see what processes are holding which ports (hint netstat -antpu)

Can you explain something about certificates (SSL technology , hint : public private key)

Can you explain me something about ORM (Object Relational Mapping)

Name some storage technologies (RAID - vs Striped), what are the advantages disadvantages

What can you tell about ORACLE RAC technology

How do you configure a UnitofOrder in Weblogic?A persistent store? A remotequeue?

Is it possible a Managed server continue providing services in spite of shutting down the admin server? How to?

OSB developer questions

How do you check the linux distribution version

How can you see if your OS is running a 64 or 32 bit OS

Can you explain me the basic Linux directory structure (/var/log/, /etc, /opt. /dev, /users)

How can you see how much disk space is left

Can you see what processes are running

What is the difference between an abstract class and an interface

Can you name some JAVA open source frameworks

What is the difference between a script and a programming language (to fill time….idle talk)

Would you mind to explain me what a Proxy service is?

Would you mind to explain me what Business service is?

What do you use for mapping in OSB?

When do you use Xpath?

What is a XSD? What is a simple type? What is a complex type?

What is a Namespace?

How do you define a list of elements?

How do you call (invoke) a service?

How do you create a FILE adapter?

How do you test a HTTP service? (hint: OSB Console, SOAPUI…)

How do you monitor a BPEL execution? Which is the tool provided in SOA for doing it?

What is the structure of a WSDL
"Are you familiar with OSB and SOA suite, so In which case you would use OSB and in which one you would use SOA?

Tell me advantages and disadvantages."

Would you mind to tell me which are your prefered options for reporting and tracking information in OSB?

A Proxy or Business service points to endpoints (URIs) that will differ in each environment (DEV, TST, PROD…). How could you deploy your interface and change those endpoint URIs without modifying them manually? Which tool is provided by OSB?

Is is it possible to use java programs in OSB? How do you do it? (hint: java callout, custom xpath)

In case you want to implement an interface that processes in parallel, How do you do it in OSB?

How could you obtain a data from the database based on an id? Do you know how to do a lookup (hint: multiple options are available)?

Which are the main actions provided by OSB for invoking services?
"Imagine we are going to design the schemas for a renting agency
This schema is for defining the message that will be used when a customer rents a car
please provide me per each situation how you would implement it in XSD
- You can rent a car or a lorry, both contains similar fields (price, number of days to be rented, ...)
but they also have different elements specific to the type of vehicle. Please tell me the mode you would implement
it for reusing the common elements. (hint: extending or aggregating)"
"In the rent contract when you specify the vehicle you can choose lorry or car and it's mandatory to have one of the 2.
explain me how to represent that concept in XSD. (hint: choice, minoccur, maxoccur)"

In SOA/XSLT which function is used for getting a value from the database based on a value you pass?
"How can you map standard definitions like currency, country, ... that have a different representation in the Source system and in the target system?
for example EUR in system A and EU in system B represents Euro (hint: DVM lookup)"

How could you implement sequences in SOA? (hint: mediator sequencer)

Are you able to define custom XPATH functions?

How could you implement a synchronous BPEL process? and Asynchronous?

If an error occurs in a Message Flow, which options do you have to handle it?
"If you need to implement file poller Interface that transforms the message and then sends the message to a FTP.
How could you do it? and In case you want to raise an error if it takes longer than 90 seconds ? How could you do it? (hint: timeout, alert)"
"If you need the messages to be sent in order so the behaviour will be First Input and First Output,

How did you implement it? (hint: single consumer)"

How can you see what processes are holding which ports (hint netstat -antpu)

Can you explain something about certificates (SSL technology , hint : public private key)

Can you explain me something about ORM (Object Relational Mapping)

Would you mind to give me a sample of an scenario when you need to use Publish, CallBack and Route actions?
Explain the reason of choosing that action.

Can you explain me how to configure a transactional proxy service? Which are the main OSB actions involved?

Which properties are used? Which Qos will you use?"

Which kind of objects could be handled by OSB from a Java Callout? (hint: primitive types, arrays)

JKS keystore password vs key password

Something for me confusing (I get confused quite easily) is the relation between a JKS keystore password and a key password.
Some facts:
  • a .key file SHOULD always be protected by password.
  • a .jks store SHOULD always be protected by password.
  • not necessarily these 2 passwords should match


Once you have added a .key into a JKS, you can change the key's PW like this:
keytool -keypasswd -keystore keystore.jks -alias 

You can change the JKS PW like this:
keytool -storepasswd -new new_storepass -keystore keystore.jks


See also the excellent JKS guide and this very good FAQ
This is the keytool doc



Which wlst.sh?

I have installed only OSB (if you install SOA Suite, you will get more instances of wlst.sh :o) )

cd $ORACLE_HOME

find . -name wlst.sh

./Oracle_OSB1/harvester/wlst.sh
./Oracle_OSB1/common/bin/wlst.sh
./wlserver_10.3/common/bin/wlst.sh
./oracle_common/common/bin/wlst.sh


So, which one are you supposed to use?


There is also a

./oracle_common/common/bin/setWlstEnv.sh

which is invoked by everybody.


When using OSB, you should use the ./Oracle_OSB1/common/bin/wlst.sh
Remember that you should first change dir:

cd ./Oracle_OSB1/common/bin/
. ./wlst.sh

this gives me a "command not found /bin/java "

So I do

cd $DOMAIN_HOME
. ./setDomainEnv.sh
java weblogic.WLST

Liquibase in Action

Download the product from http://sourceforge.net/projects/liquibase/files/Liquibase%20Core/liquibase-3.1.1-bin.zip/download

Unzip it on your local drive

Type "liquibase" , you will get a pretty help. We learn that we have several areas:
Standard Commands (update, rollback..)
Diff commands
Maintenance Commands

We learn that some parameters are required (changeLogFile, username and pw, DB url) and other optional (drive, logfile...).

All the default parameters can be stored in liquibase.properties. More info here

vi liquibase.properties
driver: oracle.jdbc.OracleDriver
classpath: /opt/oracle/fmw11_1_1_5/wlserver_10.3/server/lib/ojdbc6.jar
url: jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=myrachost.acme.com)(PORT=1522))(CONNECT_DATA=(SERVICE_NAME=d01osb_app.acme.com)))
username: pl1_soainfra
password: pl1_acme
mkdir data
I try first an export:
java -jar liquibase.jar --changeLogFile="./data/myexportfile.xml" --diffTypes="data" generateChangeLog
you must provide an extension (.xml) in the filename, otherwise you get "Liquibase generateChangeLog Failed: No serializer associated with the filename or extension '/data/myexportfile'"

A sample entry generated is:
    <changeSet author="soa (generated)" id="1395989865665-193">
        <insert tableName="BPM_MEASUREMENT_ACTION_SEQ">
            <column name="SEQ_NAME" value="ACTION_SEQ"/>
            <column name="SEQ_COUNT" valueNumeric="0"/>
        </insert>
    </changeSet>


The changelog file is a huge file not very easy to read. If I do 2 subsequent changelogs, the differences are many even if schema/data are the same... not very intuitive.

Now I try:
java -jar liquibase.jar updateSQL
Errors:
--changeLogFile is required

I try again:
java -jar liquibase.jar --changeLogFile=./data/myexportfile.xml updateSQL


-- Changeset ./data/myexportfile.xml::1395989865665-193::soa (generated)
INSERT INTO PL1_SOAINFRA.BPM_MEASUREMENT_ACTION_SEQ (SEQ_NAME, SEQ_COUNT) VALUES ('ACTION_SEQ', 0);


INSERT INTO PL1_SOAINFRA.DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, LIQUIBASE) VALUES ('1395989865665-193', 'soa (generated)', './data/myexportfile.xml', SYSTIMESTAMP, 193, '7:f8ab8f75bd7c0bafd9cd43fd119e4340', 'insert', '', 'EXECUTED', '3.1.1');

so basically for each row in the DB (in this case it's a definition of a sequence, not a row) it produces the SQL and the reference to the changeset element.

Starting a Managed Server with WLST and NodeManager

1) factor out commonly used constants into a setenv.sh file:

#!/bin/sh

#prefix for domain 
PREF=osbpr1
Interface=bond0
AdminIP=10.56.5.119
NetMask=255.255.255.0

JAVA_HOME="/opt/oracle/java"
MW_HOME="/opt/oracle/fmw"
WL_HOME="${MW_HOME}/wlserver_10.3"

DOM_HOME=/opt/oracle/domains

LOG_HOME=/var/log/weblogic
# home of certificates
CERT_HOME=/opt/oracle/certs

JAVA_VERSION=java-1.6.0-sun-1.6.0.29.x86_64


2) prepare a NodeManager userConfigFile:

/opt/oracle/domains/osbdv1do/nmuserconfigfile.secure

containing
weblogic.management.username={AES}hU8qRGjiFmqK6kHqG8yZlpXTD+KZGjld85q7sIgMP4w\=
weblogic.management.password={AES}xF+6rgG5NqNYBxDzqR/MlLlR1iYSqQezJrJ+Mi52gTc\=


and a userKeyFile /opt/oracle/domains/osbdv1do/nmuserkeyfile.secure



3) Prepare a startAdmin.py file (in reality it can start ANY server, not only the admin):

adminName = sys.argv[1]
domainName = sys.argv[2]
nmHost = sys.argv[3]

nmPort = '5556'
domHome='/opt/oracle/domains/' + domainName

print nmHost, nmPort, domainName, adminName

# -----------------------------------------------------------------------------
# connect to NodeManager
# -----------------------------------------------------------------------------
nmConnect( userConfigFile=domHome + '/nmuserconfigfile.secure', userKeyFile=domHome + '/nmuserkeyfile.secure', host=nmHost, port=nmPort, domainName=domainName, domainDir=domHome, nmType='plain' )

# -----------------------------------------------------------------------------
# start the server
# -----------------------------------------------------------------------------
try:

    nmStart( adminName, domHome )

except:
    nmDisconnect()
    exit('y', 4)


nmDisconnect()





Using Oracle pre-built VM for Oracle VM Manager and Server

No need to install from scratch, you can use these 2 prebuilt VMs:

http://www.oracle.com/technetwork/server-storage/vm/template-1482544.html

I download and "import appliance" OracleVMManager3.2.4-b524.ova into VirtualBox. Check that you have 4 GB ram and accept EULA.

Could not start the machine Oracle VM Manager 3.2.4-b524 because the following physical network interfaces were not found:
eth0 (adapter 1)
You can either change the machine's network settings or stop the machine.


"change network settings" and use "host only network". Assign static IP 10.0.0.50, netmask 255.255.255.0, gateway 10.0.0.1, DNS server 10.0.0.1, hostname = ovmm.my.company.com (maybe also 192.168.56.1 could do for gateway and dns)

OVM should start.

Open firefox, log into https://localhost:7002/ovm/console with admin/Welcome1

If your screen gets locked, remember that ovm password is Welcome1.

Now you can import appliance OracleVMServer3.2.4-b525.ova in VirtualBox.

Could not start the machine Oracle VM Server 3.2.4-b525 because the following physical network interfaces were not found:
eth0 (adapter 1), eth1 (adapter 2)
You can either change the machine's network settings or stop the machine.


assign "host only" in the vm settings.

Assign static IP 10.0.0.51, netmask 255.255.255.0, gateway 10.0.0.1, DNS server 10.0.0.1, hostname = ovms1.my.company.com

one the OVM Server is up, you can connect from the OVM Manager opening a terminal windowd : ssh root@10.0.0.51 (pw is ovsroot)

In reality one should use IPs in the range 192.168.56.*



References

http://www.oracle.com/technetwork/systems/hands-on-labs/deploy-rac-ovm-cluster-2101019.html?msgid=3-9568010570#2 cool lab on how to setup a OVMManager/Server environment.



Deleting a non empty directory with find -delete

mkdir  /opt/oracle/Pipposcriptsstaging/PippoScripts-1.23
mkdir  /opt/oracle/Pipposcriptsstaging/PippoScripts-1.22

(put some content in both folders)

this will fail:

find /opt/oracle/Pipposcriptsstaging/  -type d -name "PippoScripts*" ! -name "PippoScripts-1.22" -delete


because find -delete can only remove empty folders (don't try the -maxdepth, -depth, -mindepth, -prune options, they won't work)


For some REALLY weird reason, this command too will fail:

find /opt/oracle/Pipposcriptsstaging/  -type d -name "PippoScripts*" ! -name "PippoScripts-1.22" -exec rm -rf '{}' \;
find: `/opt/oracle/Pipposcriptsstaging/PippoScripts-1.23': No such file or directory

but it actually deletes the PippoScripts-1.23 folder (WEIRD!)


The only way to make it work:

find /opt/oracle/Pipposcriptsstaging/PippoScripts-1.23 -type f  -delete

find /opt/oracle/Pipposcriptsstaging/PippoScripts-1.23 -type d  -delete




GIT: First steps with JGit

If you need a Java API for GIT, forget about JavaGit (it's just a wrapper around GIT CLI) and EGit - which internally uses JGit.

http://eclipse.org/jgit/

Useful snippets here https://github.com/centic9/jgit-cookbook

Download the library JAR here org.eclipse.jgit.jar, or if using maven consider using the dependency:
<dependency>
  <groupId>org.eclipse.jgit</groupId>
  <artifactId>org.eclipse.jgit</artifactId>
  <version>3.5.0.201409260305-r</version>
</dependency>


(the jar should end up in \org\eclipse\jgit\org.eclipse.jgit\3.5.0.201409260305-r inside your stink-maven repo)

Looking at the examples, you must have a LOCAL repository.... there doesn't seem to be a way to query a remote repository, like one hosted on Stash, without first doing a git clone.... I look rather for a REST-based API, this one https://bitbucket.org/atlassianlabs/stash-java-client seems quite promising.



Missing JAVA_VENDOR and JAVA_HOME in WebLogic silent installation

in $DOMAIN_HOME/bin/SetDomainEnv.sh I keep finding:

BEA_JAVA_HOME=""
export BEA_JAVA_HOME

SUN_JAVA_HOME=""
export SUN_JAVA_HOME

if [ "${JAVA_VENDOR}" = "Oracle" ] ; then

(and JAVA_VENDOR is not declared, and *_JAVA_HOME is blank... so WLS fails when started complaining about missing JAVA_HOME....)

The secret is that you should declare (export) these 2 environment variables BEFORE you run the weblogic installation:
export JAVA_VENDOR=Sun
export JAVA_HOME=/usr/java/jdk1.7.0_55/
java -d64 -Xmx1024m -Djava.io.tmpdir=/opt/oracle/temp -jar /software/wls1036_generic.jar -mode=silent -silent_xml=/software/weblogic_silent_install.xml



Why those 2 values cannot be part of the silent installer xml, no clue!

Here is the official doc of the silent installer http://docs.oracle.com/cd/E15523_01/doc.1111/e14142/appendix.htm#WLSIG185



How to generate a OutOfMemoryError PERMGEN

Inspired by a very interesting presentation by Pierre-Hugues Charbonneau:

I have partially copied his code to generate a OOM PERMGEN:
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.HashMap;
import java.util.Map;

public class ClassLoaderLeak {
    private static Map leakingMap = new HashMap ();
    public static void main(String[] args) {
 try {
     for (int i = 0; i < 100000; i++) {
  String dummyCLURLString = "file:" + i + ".jar";
  URL[] dummyCLURL = new URL[] { new URL(dummyCLURLString) };
  URLClassLoader urlClassLoader = new URLClassLoader(dummyCLURL);
  Class[] arg1 = new Class[] {Aclass.class}; 
  InvocationHandler arg2 = new InvocationHandler() {
      @Override
      public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
   return null;
      }
  };
  Aclass aclass = (Aclass)Proxy.newProxyInstance(urlClassLoader, arg1, arg2);
  leakingMap.put(dummyCLURLString, aclass);
  Thread.sleep(10);
     }
 } catch (Exception e) {
     e.printStackTrace();
 }

    }

}

run it with "java -XX:+HeapDumpOnOutOfMemoryError -XX:MaxPermSize=64m -Xmx256m ClassLoaderLeak

you will see the PermGen space quickly fill up until you get a OOM error

You should see something like
java.lang.OutOfMemoryError: PermGen space  
Dumping heap to java_pid15744.hprof ...
Heap dump file created [154441412 bytes in 1.982 secs]

Now open Eclipse MAT, open the java_pid15744.hprof file and run the Java Basics / Classloader Explorer tool:

You will see several thousands (in my case, 27k) instances of URLClassLoader accumulated in the PERMGEN

ContextClassLoader, SystemClassLoader, CurrentClassLoader

If you run this code as a Java Application (no JEE container):

public class BootstrapCLTest {
    public static void main(String[] args) {
 BootstrapCLTest bootstrapCLTest = new BootstrapCLTest();
 bootstrapCLTest.go();
    }

    private void go() {

 System.out.println("1 " + String.class.getClassLoader());
 System.out.println("2 " + ClassLoader.getSystemClassLoader ());
 System.out.println("3 " + this.getClass().getClassLoader());
 System.out.println("4 " + Thread.currentThread().getContextClassLoader());
 System.out.println("5 " + Thread.currentThread().getContextClassLoader().getParent());
 System.out.println("6 " + Thread.currentThread().getContextClassLoader().getParent().getParent());
    }

}



you get this (parentesis are mine):

1 null (=bootstrap CL)
2 sun.misc.Launcher$AppClassLoader@1bd06bf (=application CL)
3 sun.misc.Launcher$AppClassLoader@1bd06bf (=application CL)
4 sun.misc.Launcher$AppClassLoader@1bd06bf (=application CL)
5 sun.misc.Launcher$ExtClassLoader@1061299 (=extension CL)
6 null (=bootstrap CL)


that is, in this simple case the SystemClassLoader == ApplicationClassLoader == ContextClassLoader

The first null is because the String class is loaded by the Bootstrap classloader, which is NOT represented as a ClassLoader object. The Bootstrap will then load the Extension CL, who in turn loads the Application CL.

Running a similar code in a JSP is more interesting, because here the JEE container (WebLogic in this case) will add its own CL:

 System.out.println("1 " + String.class.getClassLoader());
 System.out.println("2 " + ClassLoader.getSystemClassLoader ());
 System.out.println("3 " + this.getClass().getClassLoader());
 System.out.println("4 " + Thread.currentThread().getContextClassLoader());
 System.out.println("5 " + Thread.currentThread().getContextClassLoader().getParent());
 System.out.println("6 " + Thread.currentThread().getContextClassLoader().getParent().getParent());
 System.out.println("7 " + Thread.currentThread().getContextClassLoader().getParent().getParent().getParent());
 System.out.println("8 " + Thread.currentThread().getContextClassLoader().getParent().getParent().getParent().getParent());
 System.out.println("9 " + Thread.currentThread().getContextClassLoader().getParent().getParent().getParent().getParent().getParent());
 System.out.println("10 " + Thread.currentThread().getContextClassLoader().getParent().getParent().getParent().getParent().getParent().getParent());


the result is:

1 null
2 sun.misc.Launcher$AppClassLoader@fc5b01
3 weblogic.servlet.jsp.JspClassLoader@1bfdb6f finder: weblogic.utils.classloaders.CodeGenClassFinder@137e701 annotation:
4 weblogic.utils.classloaders.ChangeAwareClassLoader@1cc3dd4 finder: weblogic.utils.classloaders.CodeGenClassFinder@11f2691 annotation: _auto_generated_ear_@CLTestWeb
5 weblogic.utils.classloaders.FilteringClassLoader@1d16e3 finder: weblogic.utils.classloaders.CodeGenClassFinder@1c9a7b5 annotation: _auto_generated_ear_@CLTestWeb
6 weblogic.utils.classloaders.GenericClassLoader@ceb98d finder: weblogic.utils.classloaders.CodeGenClassFinder@217181 annotation: _auto_generated_ear_@
7 weblogic.utils.classloaders.FilteringClassLoader@1a308be finder: weblogic.utils.classloaders.CodeGenClassFinder@92f8f0 annotation:
8 weblogic.utils.classloaders.GenericClassLoader@1865594 finder: weblogic.utils.classloaders.CodeGenClassFinder@fcfe6b annotation:
9 sun.misc.Launcher$AppClassLoader@fc5b01
10 sun.misc.Launcher$ExtClassLoader@1353d27

that is, WebLogic inserts 2 layers of GenericClassLoader or ChangeAwareClassLoader plus FilteringClassLoader between the War Application and the System Classloader.

See also http://www.javamonamour.org/2015/09/playing-with-cat-and-classloaders.html



Friday, October 23, 2015

Automate mouse click repetitions with Auto Mouse Click

http://www.murgee.com/auto-mouse-click/

First, assign the "find mouse position" to F6 (you don't want to have to manually find a X-Y coordinate...)... and don't forget to define F7 as Stop... all the rest is pretty straightforward. Click on AAutoMouseClick.exe, it doesn't require Admin privileges.

Tuesday, October 20, 2015

WebLogic: difference between self-tuning-thread-pool-size-max and shared-capacity-for-work-managers

self-tuning-thread-pool-size-max

https://docs.oracle.com/middleware/1212/wls/WLACH/pagehelp/Corecoreserverserverconfigtuningtitle.html
Sets the maximum thread pool size of the self-tuning thread pool.

The self-tuning thread pool starts with the default size of 1. It grows and shrinks automatically as required. Setting this attribute changes the default max pool size. The active thread count will never increase beyond this value. This value defines the maximum number of threads permitted in the server. Note that the server will add threads only if it improves throughput. Measurements are taken every 2 seconds and the decision to increase or decrease the thread count is based on the current throughput measurement versus past values.



shared-capacity-for-work-managers

https://docs.oracle.com/cd/E24329_01/web.1211/e24432/overload.htm#CNFGD148
In WebLogic Server, all requests, whether related to system administration or application activity—are processed by a single thread pool. An administrator can throttle the thread pool by defining a maximum queue length. Beyond the configured value, WebLogic Server will refuse requests, except for requests on administration channels.
When the maximum number of enqueued requests is reached, WebLogic Server immediately starts rejecting:
• Web application requests.
• Non-transactional RMI requests with a low fair share, beginning with those with the lowest fair share.
If the overload condition continues to persist, higher priority requests will start getting rejected, with the exception of JMS and transaction-related requests, for which overload management is provided by the JMS and the transaction manager.
Throttle the thread pool by setting the Shared Capacity For Work Managers field in the Administration Console (see Environments > Servers > server_name > Configuration > Overload). The default value of this field is 65536.
Work Managers and Thread Pool Throttling
An administrator can configure Work Managers to manage the thread pool at a more granular level, for sets of requests that have similar performance, availability, or reliability requirements. A Work Manager can specify the maximum requests of a particular request class that can be queued. The maximum requests defined in a Work Manager works with the global thread pool value. The limit that is reached first is honored.


So, the first acts on the MAX NUMBER OF THREADS, the second on the MAX NUMBER OF REQUESTS WAITING IN A QUEUE.

My impression is that finding the right mix for your case might require some tests...



ulimit and lsof

PID of WLS is 29518
to count how many file descriptors are held by a process:
ls /proc/29518/fd | wc -l
666

funnily this doesn’t match the count reported by lsof ( one day I will discover why):

lsof -p 29518 | wc -l
1288

to know the limit for the specific process:

cat /proc/29518/limits
Limit Soft Limit Hard Limit Units
Max cpu time unlimited unlimited seconds
Max file size unlimited unlimited bytes
Max data size unlimited unlimited bytes
Max stack size 10485760 unlimited bytes
Max core file size 0 0 bytes
Max resident set unlimited unlimited bytes
Max processes 32000 32000 processes
Max open files 1024 1024 files
Max locked memory 65536 65536 bytes
Max address space unlimited unlimited bytes
Max file locks unlimited unlimited locks
Max pending signals 515304 515304 signals
Max msgqueue size 819200 819200 bytes
Max nice priority 0 0
Max realtime priority 0 0
Max realtime timeout unlimited unlimited us

which is different for the limit set by default for a user:

ulimit -a
core file size (blocks, -c) 0
data seg size (kbytes, -d) unlimited
scheduling priority (-e) 0
file size (blocks, -f) unlimited
pending signals (-i) 515304
max locked memory (kbytes, -l) 64
max memory size (kbytes, -m) unlimited
open files (-n) 8192
pipe size (512 bytes, -p) 8
POSIX message queues (bytes, -q) 819200
real-time priority (-r) 0
stack size (kbytes, -s) 10240
cpu time (seconds, -t) unlimited
max user processes (-u) 1024
virtual memory (kbytes, -v) unlimited
file locks (-x) unlimited

To set the limit for a process open by the current shell :

ulimit -n MAX_FD_PER_PROCESS


In Linux, this is a PER-PROCESS limit! You cannot directly limit the number of Files opened by a User! You can only set a max-processes-per-user with ulimit -u MAX .
to check the actual limits for a process:
cat /proc//limits
cat /etc/security/limits.conf to check the hard limits for all users. If you try to set a ulimit larger than that. you get a ulimit: open files: cannot modify limit: Operation not permitted


ORA-24756: transaction does not exist

Here is the stacktrace:

java.sql.SQLException: 
ORA-24756: transaction does not exist at 
oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:450) at 
oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:392) at 
oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:385) at 
oracle.jdbc.driver.T4CTTIfun.processError(T4CTTIfun.java:1018) at 
oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:522) at 
oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:257) at 
oracle.jdbc.driver.T4CTTIOtxen.doOTXEN(T4CTTIOtxen.java:166) at 
oracle.jdbc.driver.T4CXAResource.doTransaction(T4CXAResource.java:757) at 
oracle.jdbc.driver.T4CXAResource.doPrepare(T4CXAResource.java:518) at 
oracle.jdbc.xa.client.OracleXAResource.prepare(OracleXAResource.java:713)


If you get this error, you must be using Oracle RAC and XA.

You must carefully craft the various timeouts in WebLogic and in Oracle DB.

See Oracle note "Troubleshooting ORA-24756 while Running an XA Program or MSDTC with the Oracle RDBMS (Doc ID 1076242.6)". THE rule is: global transaction timeout < session timeout < distributed_lock_timeout . See also "Recommended Timeout Configuration When Using an External Transaction Processing Monitor and XA with Oracle (Doc ID 338880.1)" .

Each MDB has a specific timeout, but this should not be involved in the issue (this in the weblogic.ejb.jar.xml DD https://docs.oracle.com/cd/E13222_01/wls/docs103/ejb/DDreference-ejb-jar.html )

<transaction-descriptor>
 <trans-timeout-seconds>2400</trans-timeout-seconds>
 </transaction-descriptor>


So you should end up with this configuration in config.xml and the "$XA_DATASOURCE"jdbc.xml

> config/jdbc/<datasource>-jdbc.xml
 <jdbc-xa-params>
 <keep-xa-conn-till-tx-complete>true</keep-xa-conn-till-tx-complete>
 <xa-end-only-once>true</xa-end-only-once>
 <xa-set-transaction-timeout>true</xa-set-transaction-timeout>
 <xa-transaction-timeout>3300</xa-transaction-timeout>
 <xa-retry-duration-seconds>3600</xa-retry-duration-seconds>
 </jdbc-xa-params>

> config/config.xml
 <jta>
 <timeout-seconds>3000</timeout-seconds>
 <forget-heuristics>false</forget-heuristics>
 <max-resource-requests-on-server>1000</max-resource-requests-on-server>
 </jta>




Tuesday, October 13, 2015

WebLogic MemorySessionContext

We had some PROD OutOfMemory recently.... done a heap dump and seen that we were in this situation: http://xmlandmore.blogspot.ch/2013/03/analyzing-performance-issue-caused-by.html

One instance of "weblogic.servlet.internal.session.MemorySessionContext" loaded by "sun.misc.Launcher$AppClassLoader @ 0x7818fbb60" occupies 732'427'648 (82.97%) bytes. The memory is accumulated in one instance of "java.util.Hashtable$Entry[]" loaded by "".

Keywords
weblogic.servlet.internal.session.MemorySessionContext
java.util.Hashtable$Entry[]
sun.misc.Launcher$AppClassLoader @ 0x7818fbb60




and this is the "Shortest Paths to the Accumulation Point" in Eclipse MAT:


java.util.Hashtable$Entry[383] @ 0x7b0455fd8
 1'552 732'427'400 
\table java.util.Hashtable @ 0x7823d6118
 48 732'427'488 
.\openSessions weblogic.servlet.internal.session.MemorySessionContext @ 0x7823d60e8
 48 732'427'648 
..+sessionContext weblogic.servlet.internal.WebAppServletContext @ 0x782310e88
 208 452'632 
..|+[0] java.lang.Object[1] @ 0x7812d7e28
 24 24 
..||\array java.util.concurrent.CopyOnWriteArrayList @ 0x7812d7de0
 24 96 
..||.\initializedContexts com.sun.faces.config.ConfigManager @ 0x7812d7dd0
 16 112 
..||..\CONFIG_MANAGER class com.sun.faces.config.ConfigManager @ 0x776ab8198
 64 100'560 
..||...\[17] java.lang.Object[2560] @ 0x78235eb90
 10'256 10'256 
..||....\elementData java.util.Vector @ 0x78235ae78
 32 10'288 
..||.....\classes weblogic.utils.classloaders.ChangeAwareClassLoader @ 0x78233c758
 104 9'648'032 
..||......+contextClassLoader com.iona.corba.art.workqueue.AutomaticWorkQueueThreadPool$WorkQueueThread @ 0x783f0a9f0 [ORB=_it_orb_id_1,Pool=1]::id-10 Thread
 120 2'184 
..||......+contextClassLoader com.iona.corba.art.workqueue.AutomaticWorkQueueThreadPool$WorkQueueThread @ 0x783f0b2d8 [ORB=_it_orb_id_1,Pool=1]::id-9 Thread
 120 2'184 
..||......+contextClassLoader com.iona.corba.art.workqueue.AutomaticWorkQueueThreadPool$WorkQueueThread @ 0x783f0bb60 [ORB=_it_orb_id_1,Pool=1]::id-8 Thread
 120 2'192 
..||......+contextClassLoader com.iona.corba.art.workqueue.AutomaticWorkQueueThreadPool$WorkQueueThread @ 0x783f12410 [ORB=_it_orb_id_1,Pool=1]::id-7 Thread
 120 2'192 
..||......+contextClassLoader com.iona.corba.art.workqueue.AutomaticWorkQueueThreadPool$WorkQueueThread @ 0x783f12cd8 [ORB=_it_orb_id_1,Pool=1]::id-6 Thread
 120 2'192 
..||......+contextClassLoader com.iona.corba.art.workqueue.AutomaticWorkQueueThreadPool$WorkQueueThread @ 0x783f13560 [ORB=_it_orb_id_1,Pool=1]::id-5 Thread
 120 2'304 
..||......+contextClassLoader com.iona.corba.art.workqueue.AutomaticWorkQueueThreadPool$WorkQueueThread @ 0x783f13e60 [ORB=_it_orb_id_1,Pool=1]::id-4 Thread
 120 2'232 
..||......+contextClassLoader com.iona.corba.art.workqueue.AutomaticWorkQueueThreadPool$WorkQueueThread @ 0x783f1a680 [ORB=_it_orb_id_1,Pool=1]::id-3 Thread
 120 2'160 
..||......+contextClassLoader com.iona.corba.art.workqueue.AutomaticWorkQueueThreadPool$WorkQueueThread @ 0x783f1aef0 [ORB=_it_orb_id_1,Pool=1]::id-2 Thread
 120 2'304 
..||......+contextClassLoader com.iona.corba.art.workqueue.AutomaticWorkQueueThreadPool$WorkQueueThread @ 0x783f1b7a0 [ORB=_it_orb_id_1,Pool=1]::id-1 Thread
 120 2'304 
..||......+contextClassLoader java.lang.Thread @ 0x7da0b6650 Keep-Alive-Timer »
 112 176 
..||......+classloader java.security.ProtectionDomain @ 0x78235b0b0 »
 40 232 
..||......\Total: 12 entries
   
..|+context weblogic.servlet.internal.WebAppRuntimeMBeanImpl @ 0x7824209f8 »
 



It turned out indeed that the session timeout was indeed waaay too long...



Monday, October 12, 2015

Minimalistic Java application to encode/decode in Base64

If your Outlook blocks all kind of attachments, you have here the FINAL resolution to the problem (Outlook doesn't check for Base64 text attachments)


import sun.misc.BASE64Decoder;
import sun.misc.BASE64Encoder;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;

public class Decoder {

    public static void main(String[] args) throws Exception {
        if (args.length < 3) {
            System.out.println("Usage: java EncodeFileWithBASE64 d|e <inputFile> <outputFile>");
            return;
        }
        String op = args[0];
        String inputFile = args[1];
        String outputFile = args[2];


        if (op.equalsIgnoreCase("e")) {
            BASE64Encoder encoder = new BASE64Encoder();
            encoder.encode(
                    new FileInputStream(inputFile),
                    new FileOutputStream(outputFile)
            );
        } else {
            BASE64Decoder decoder = new BASE64Decoder();
            decoder.decodeBuffer(new FileInputStream(inputFile),
                    new FileOutputStream(outputFile));


        }
    }
}






If you put in in Eclipse you get an error, and this is how to solve it: http://stackoverflow.com/questions/5549464/import-sun-misc-base64encoder-results-in-error-compiled-in-eclipse (it's easier to ignore errors than using an Apache Commons library)

Go to Window-->Preferences-->Java-->Compiler-->Error/Warnings.
 Select Deprecated and Restricted API. Change it to warning.
 Change forbidden and Discouraged Reference and change it to warning. 
You can also use this online application



Saturday, October 10, 2015

Web Application for File Upload with streaming

This gives you an entire working example (worth 1000 user manual pages) http://www.codejava.net/java-ee/servlet/apache-commons-fileupload-example-with-servlet-and-jsp .... I have tested it and put in https://github.com/vernetto/WebFileUploader (just git clone it and run it).

Here the user guide of Apache FileUpload module:

http://commons.apache.org/proper/commons-fileupload/using.html

Create a webapp

Download commons-io jar http://commons.apache.org/proper/commons-io/download_io.cgi and commons-fileupload jar http://commons.apache.org/proper/commons-fileupload/download_fileupload.cgi and place them in WEB-INF/lib

Well actually rather than putting here snippets of code, here is the whole NON-Streaming example https://github.com/vernetto/WebFileUploader and here the STREAMING example https://github.com/vernetto/WebFileUploaderStreaming

I have tested with a 4GB file and memory occupation on the server (and Garbage Collection) was really minimal... transfer speed was also decent (say 2 minutes for a 4GB file....).

Here https://raw.githubusercontent.com/vernetto/WebFileUploaderStreaming/master/WebFileUploaderStreaming.war you can download the war file directly.



Friday, October 9, 2015

WebLogic JNDIServiceLocator

Today there was a JNDI lookup failing across 2 clusters hosted on same machine but different NIC:
WLS_FW.JNDIServiceLocator BEA-000000
Error loading /somepath from 111.222.123.123:6481
java.lang.NullPointerException
 at weblogic.utils.io.ChunkedDataOutputStream.writeUTFChars(ChunkedDataOutputStream.java:181)
 at weblogic.utils.io.ChunkedDataOutputStream.writeUTF(ChunkedDataOutputStream.java:141)
 at weblogic.workarea.StringWorkContext.writeContext(StringWorkContext.java:32)
 at weblogic.rjvm.MsgAbbrevOutputStream.writeContext(MsgAbbrevOutputStream.java:124)
 at weblogic.rjvm.MsgAbbrevOutputStream$NestedObjectOutputStream.writeContext(MsgAbbrevOutputStream.java:751)
 at weblogic.workarea.spi.WorkContextEntryImpl.write(WorkContextEntryImpl.java:85)
 at weblogic.workarea.WorkContextLocalMap.sendRequest(WorkContextLocalMap.java:150)
 at weblogic.rmi.provider.WorkServiceContext.writeExternal(WorkServiceContext.java:56)
 at java.io.ObjectOutputStream.writeExternalData(ObjectOutputStream.java:1458)
 at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1429)
 at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1177)
 at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:347)
 at weblogic.rjvm.MsgAbbrevOutputStream.writeObject(MsgAbbrevOutputStream.java:627)
 at weblogic.rjvm.MsgAbbrevOutputStream.marshalUserCustomCallData(MsgAbbrevOutputStream.java:357)
 at weblogic.rjvm.BasicOutboundRequest.transferThreadLocalContext(BasicOutboundRequest.java:126)
 at weblogic.rmi.internal.BasicRemoteRef.getOutboundRequest(BasicRemoteRef.java:204)
 at weblogic.rmi.cluster.ClusterableRemoteRef.invoke(ClusterableRemoteRef.java:465)
 at weblogic.rmi.cluster.ClusterableRemoteRef.invoke(ClusterableRemoteRef.java:285)
 at weblogic.jndi.internal.ServerNamingNode_12130_WLStub.lookup(Unknown Source)
 at weblogic.jndi.internal.WLContextImpl.lookup(WLContextImpl.java:440)
 at weblogic.jndi.internal.WLContextImpl.lookup(WLContextImpl.java:426)



The issue is still under investigation... these flags might help:
-Dweblogic.kernel.debug=true
-Dweblogic.debug.DebugConnection=true 
-Dweblogic.StdoutDebugEnabled=true 
-Dweblogic.log.LogSeverity=Debug 
-Dweblogic.log.LoggerSeverity=Debug



I could not find documentation of how internally WebLogic implements the RJVM communication protocol...



Lync copy and paste nightmare

Very unfortunately I have to use Lync as a chat platform. Some stuff is pretty cool, but there are 2 TERRIBLE issues:

one is that you select some text (ANY text), copy and paste (in any way you want) and what you paste is A BIG MESS including stuff who is miles away from your selection. I ended up ALWAYS pasting first into notepad, then selectin again only the stuff I need.

the other is that it's TERRIBLY slow (tens of seconds) at delivering messages....sometimes you get the notification that you got a message (often showing the WRONG username as author), then you have to wait patiently many seconds to get the text.

On the whole, I would rather have a less feature-rich chat, but more reliable and fast. This is typical Microsoft product, overloaded with features but clumsy and slow and full of bugs.

Sunday, October 4, 2015

Digging in JNDI

JNDI is a bit of a mystery for me...whenever I get an exception like:

javax.naming.NameNotFoundException: While trying to look up comp/env/jms/CF1 in /app/webapp/rocAdmin/1482669104.; remaining name "comp/env/jms/CF1" at weblogic.jndi.internal.BasicNamingNode.newNameNotFoundException(BasicNamingNode.java:1180) at weblogic.jndi.internal.ApplicationNamingNode.lookup(ApplicationNamingNode.java:143) at weblogic.jndi.internal.WLEventContextImpl.lookup(WLEventContextImpl.java:253) at weblogic.jndi.internal.WLContextImpl.lookup(WLContextImpl.java:426) at weblogic.jndi.factories.java.ReadOnlyContextWrapper.lookup(ReadOnlyContextWrapper.java:45) at weblogic.jndi.internal.AbstractURLContext.lookup(AbstractURLContext.java:130) at javax.naming.InitialContext.lookup(InitialContext.java:411) ...

I scratch my head ... So I wrote some code to dump the content of the InitialContext (it runs in a EJB timer to avoid having to create a client:
package com.pierre;

import javax.ejb.Schedule;
import javax.ejb.Stateless;
import javax.ejb.Timer;
import javax.naming.Binding;
import javax.naming.InitialContext;
import javax.naming.NamingEnumeration;
import javax.naming.NamingException;

@Stateless
public class PVTimer {

    /**
     * Default constructor.
     */
    public PVTimer() {
 // TODO Auto-generated constructor stub
    }

    @SuppressWarnings("unused")
    @Schedule(second = "*/10", minute = "*", hour = "*", dayOfWeek = "*", dayOfMonth = "*", month = "*", year = "*", info = "MyTimer")
    private void scheduledTimeout(final Timer t) {
 System.out.println("@Schedule called at: " + new java.util.Date());
 try {
     System.out.println();
     InitialContext ic = new InitialContext();
     NamingEnumeration names = ic.listBindings("");
     printNames(names, "all");
     NamingEnumeration jms = ic.listBindings("jms");
     printNames(jms, "jms");
     System.out.println();
 } catch (Throwable t1) {
     t1.printStackTrace();
 }

    }

    private void printNames(NamingEnumeration names, String title)
     throws NamingException {
 int count = 1;
 while (names.hasMore()) {
     Binding next = names.next();
     System.out.println(title + " " + count + " ToString=" + next.toString() + " Name=" + next.getName() + " Classname=" + next.getClassName() + " getObject=" + next.getObject());
     count++;
 }
    }
}


and this is the result:

all 1 ToString=weblogic: weblogic.jndi.internal.WLEventContextImpl:EventContext (weblogic) Name=weblogic Classname=weblogic.jndi.internal.WLEventContextImpl getObject=EventContext (weblogic)
all 2 ToString=__WL_GlobalJavaApp: weblogic.jndi.internal.WLEventContextImpl:EventContext (__WL_GlobalJavaApp) Name=__WL_GlobalJavaApp Classname=weblogic.jndi.internal.WLEventContextImpl getObject=EventContext (__WL_GlobalJavaApp)
all 3 ToString=PVEarPVEjbProject_jarPVStateless_PVStatelessRemote: com.pierre.PVStateless_fcmphc_PVStatelessRemoteImpl:com.pierre.PVStateless_fcmphc_PVStatelessRemoteImpl@e964ee Name=PVEarPVEjbProject_jarPVStateless_PVStatelessRemote Classname=com.pierre.PVStateless_fcmphc_PVStatelessRemoteImpl getObject=com.pierre.PVStateless_fcmphc_PVStatelessRemoteImpl@e964ee
all 4 ToString=ejb: weblogic.jndi.internal.WLEventContextImpl:EventContext (ejb) Name=ejb Classname=weblogic.jndi.internal.WLEventContextImpl getObject=EventContext (ejb)
all 5 ToString=jms: weblogic.jndi.internal.WLEventContextImpl:EventContext (jms) Name=jms Classname=weblogic.jndi.internal.WLEventContextImpl getObject=EventContext (jms)
all 6 ToString=PVEarPVEjbProject_jarPVStateless_Home: weblogic.ejb.container.internal.StatelessEJBHomeImpl:weblogic.ejb.container.internal.StatelessEJBHomeImpl@f229af Name=PVEarPVEjbProject_jarPVStateless_Home Classname=weblogic.ejb.container.internal.StatelessEJBHomeImpl getObject=weblogic.ejb.container.internal.StatelessEJBHomeImpl@f229af
all 7 ToString=javax: weblogic.jndi.internal.WLEventContextImpl:EventContext (javax) Name=javax Classname=weblogic.jndi.internal.WLEventContextImpl getObject=EventContext (javax)
all 8 ToString=java:global: weblogic.jndi.internal.WLEventContextImpl:EventContext (java:global) Name=java:global Classname=weblogic.jndi.internal.WLEventContextImpl getObject=EventContext (java:global)
all 9 ToString=mejbmejb_jarMejb_EO: weblogic.management.j2ee.mejb.Mejb_dj5nps_EOImpl:ClusterableRemoteRef(4485985896511196818S:169.254.152.121:pvdomain:AdminServer [4485985896511196818S:169.254.152.121:pvdomain:AdminServer/294])/294 Name=mejbmejb_jarMejb_EO Classname=weblogic.management.j2ee.mejb.Mejb_dj5nps_EOImpl getObject=ClusterableRemoteRef(4485985896511196818S:169.254.152.121:pvdomain:AdminServer [4485985896511196818S:169.254.152.121:pvdomain:AdminServer/294])/294
all 10 ToString=_WL_internal_0Z7vb3dMvYJ62jEwg8odDkTCYHT0HwjvQwlqEb8FYeA1jZjPDZBGLEATyZk7rdEu: weblogic.jndi.internal.WLEventContextImpl:EventContext (_WL_internal_0Z7vb3dMvYJ62jEwg8odDkTCYHT0HwjvQwlqEb8FYeA1jZjPDZBGLEATyZk7rdEu) Name=_WL_internal_0Z7vb3dMvYJ62jEwg8odDkTCYHT0HwjvQwlqEb8FYeA1jZjPDZBGLEATyZk7rdEu Classname=weblogic.jndi.internal.WLEventContextImpl getObject=EventContext (_WL_internal_0Z7vb3dMvYJ62jEwg8odDkTCYHT0HwjvQwlqEb8FYeA1jZjPDZBGLEATyZk7rdEu)
jms 1 ToString=PVQueue: weblogic.jms.common.DestinationImpl:SystemModule-0!Queue-0 Name=PVQueue Classname=weblogic.jms.common.DestinationImpl getObject=SystemModule-0!Queue-0
jms 2 ToString=PVConnectionFactory: weblogic.jms.client.JMSXAConnectionFactory:weblogic.jms.client.JMSXAConnectionFactory@1a31048 Name=PVConnectionFactory Classname=weblogic.jms.client.JMSXAConnectionFactory getObject=weblogic.jms.client.JMSXAConnectionFactory@1a31048
jms 3 ToString=PVConnectionFactoryLocal: weblogic.jms.client.JMSXAConnectionFactory:weblogic.jms.client.JMSXAConnectionFactory@10414e6 Name=PVConnectionFactoryLocal Classname=weblogic.jms.client.JMSXAConnectionFactory getObject=weblogic.jms.client.JMSXAConnectionFactory@10414e6



(I have a stateless EJB "PVStateless" in the same module , implementing a PVStatelessRemote interface.... plus a JMS queue "PVQueue" with JNDI name "jms/PVQueue" and a JMS CF "PVConnectionFactory" with JNDI name "jms/PVConnectionFactory"....

Interesting javadoc http://docs.oracle.com/javase/7/docs/api/javax/naming/Binding.html and http://docs.oracle.com/javase/7/docs/api/javax/naming/InitialContext.html



Tuesday, September 29, 2015

Testing OVAB 12

I download OVAB_12.1.2.0.0_Appliance_v1.0.ova from http://www.oracle.com/technetwork/middleware/ovab/downloads/index.html?ssSourceSiteId=ocomen . Attempts to install the product from its installer failed, because I could not install the dependencies.... so I would rather use the preinstalled VM.

Form VirtualBox I do Import Appliance.


and agree the EULA
I get this message:
Could not start the machine OVAB_12.1.2.0.0_Appliance_v1.0 because the following physical network interfaces were not found:

en0: Ethernet (adapter 1)

You can either change the machine's network settings or stop the machine.


the issue is easily fixed by validating the proposed settings change.
I setup the Linux OS installation (create a "oracle"user). Read the OVAB appliance instructions http://download.oracle.com/otn/nt/middleware/12c/121200/OVAB_12.1.2.0.0_Appliance_v1.0.pdf
Predefined users are ovab/oracle and root/oracle. I do cd /home/ovab/Oracle/Middleware/Oracle_Home and check that the installation is there.
Login as ovab/oracle, cd /home/ovab/bin/, nohup ./startDB.sh &, nohup ./startWLSAdminServer.sh & , ./startOVABStudio.sh 1

<Mar 8, 2015 8:16:51 AM EDT> <Critical> <WebLogicServer> <BEA-000386> <Server subsystem failed. Reason: java.lang.AssertionError: Could not obtain the localhost address. The most likely cause is an error in the network configuration of this machine.
java.lang.AssertionError: Could not obtain the localhost address. The most likely cause is an error in the network configuration of this machine.
        at weblogic.server.channels.AddressUtils$AddressMaker.getLocalHost(AddressUtils.java:38)
        at weblogic.server.channels.AddressUtils$AddressMaker.<clinit>(AddressUtils.java:33)
        at weblogic.server.channels.AddressUtils.getIPAny(AddressUtils.java:154)
        at weblogic.protocol.configuration.ChannelHelper.checkConsistency(ChannelHelper.java:61)
        at weblogic.server.channels.ChannelService.start(ChannelService.java:207)
        Truncated. see log file for complete stacktrace
Caused By: java.net.UnknownHostException: dhcppc4: dhcppc4
        at java.net.InetAddress.getLocalHost(InetAddress.java:1360)
        at weblogic.server.channels.AddressUtils$AddressMaker.getLocalHost(AddressUtils.java:36)
        at weblogic.server.channels.AddressUtils$AddressMaker.<clinit>(AddressUtils.java:33)
        at weblogic.server.channels.AddressUtils.getIPAny(AddressUtils.java:154)
        at weblogic.protocol.configuration.ChannelHelper.checkConsistency(ChannelHelper.java:62)
        Truncated. see log file for complete stacktrace
> 




hostname is dhcppc4

su - root (enter oracle), vi /etc/hosts, add line "127.0.0.1 dhcppc4", exit

now run: startWLSClusterServer.sh 1, startOPMN.sh, startOHS.sh, webtierStatus.sh,

References

Excellent presentation by the excellent Kai Yu:



go to minute 33 for OVAB-related stuff

here is the paper:

https://kyuoracleblog.files.wordpress.com/2013/05/2013_369_yu_ppr.pdf