Quantcast
Channel: Java mon amour
Viewing all 1124 articles
Browse latest View live

Web Application for File Upload with streaming

$
0
0
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.


Minimalistic Java application to encode/decode in Base64

$
0
0
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 ");
            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)

WebLogic MemorySessionContext

$
0
0
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...

Hunting the Permgen classloader memory leak

$
0
0

ORA-24756: transaction does not exist

$
0
0
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>


ulimit and lsof

$
0
0
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 .

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

$
0
0
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...

Automate mouse click repetitions with Auto Mouse Click

$
0
0
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.

ContextClassLoader, SystemClassLoader, CurrentClassLoader

$
0
0
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

How to generate a OutOfMemoryError PERMGEN

$
0
0
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

Missing JAVA_VENDOR and JAVA_HOME in WebLogic silent installation

$
0
0
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

GIT: First steps with JGit

$
0
0
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.

Deleting a non empty directory with find -delete

$
0
0

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


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

$
0
0
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.

Starting a Managed Server with WLST and NodeManager

$
0
0
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()




Liquibase in Action

$
0
0
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.

Which wlst.sh?

$
0
0
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

Popular products in the CM and Build World

$
0
0
In the Hudson Plugin list you find a lot of references to available products and standards:

Atlassian Crowd a single sign-on solution


Artifactory

"Artifactory acts as a proxy between your build tool (Maven, Ant, Ivy, Gradle etc.) and the outside world."


Serena Dimensions CM , SVN on steroids


Bamboo Hudson's sister


Concordion must be some GreenPepper thingie - IMHO a paradigm difficult to implement

Crap4j a code complexity discovery tool

Fortify 360
"Fortify 360 is a suite of tightly integrated solutions for identifying, prioritizing, and fixing security vulnerabilities in software"


let us not mention Emma, Clover, FindBugs, Fitnesse, Maven, Ivy, Gradle , Checkstyle, PMD, Cobertura, Grinder, JDepend, JavaTest, JMeter, JUnit, Robot Framework, Sonar, TestNG, Canoo WebTest, Eclipse Buckminster


Here http://www.javacodegeeks.com/2011/07/java-tools-source-code-optimization-and.html an excellent presentation of a few of these products.

JKS keystore password vs key password

$
0
0
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

OSB developer questions

$
0
0
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)
Viewing all 1124 articles
Browse latest View live