Start server from command line
cd c:\ibm\web*\app*\bin
startServer server1 -profileName AppSrv01
Stop server from command line
cd c:\ibm\web*\app*\bin
stopServer server1 -profileName AppSrv01
Attempt to organize my tech notes
Start server from command line
cd c:\ibm\web*\app*\bin
startServer server1 -profileName AppSrv01
Stop server from command line
cd c:\ibm\web*\app*\bin
stopServer server1 -profileName AppSrv01
Learnt from https://helpdeskgeek.com/how-to/generate-a-list-of-installed-programs-in-windows/
Run cmd prompt as Administrator
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.
C:\windows\system32>wmic
wmic:root\cli>/output:C:\InstallList.txt product get name,version
wmic:root\cli>
Error
Caused by: java.lang.UnsupportedOperationException: Operation [getContextClassLoader] is not supported in jcl-over-slf4j. See also http://www.slf4j.org/codes.html#unsupported_operation_in_jcl_over_slf4j
Solution
Add -Dorg.apache.commons.logging.LogFactory=org.apache.commons.logging.impl.SLF4JLogFactory
to VM arguments when running main.
Error
org.apache.axis2.AxisFault: WSWS7130E: No Secure Sockets Layer (SSL) configuration is available
Solution
Section Issue with Using IBM’s JAX-WS runtime at the below link
http://btarlton.blogspot.com/2013/03/ever-have-trouble-using-ssl-to-call-web.html
Error
org.apache.commons.discovery.DiscoveryException: No implementation defined for org.apache.commons.logging.LogFactory
Download jars from Apache Commons Logging and add to classpath
https://commons.apache.org/proper/commons-logging/download_logging.cgi
Set Basic Auth
//basic auth
BindingProvider bp = (BindingProvider)proxy._getDescriptor().getProxy();
bp.getRequestContext().put(BindingProvider.USERNAME_PROPERTY, “username”);
bp.getRequestContext().put(BindingProvider.PASSWORD_PROPERTY, “password”);
Print certain element as XML
https://stackoverflow.com/questions/2461232/jaxb-entity-print-out-as-xml
public String toXml(JAXBElement element) {
try {
JAXBContext jc = JAXBContext.newInstance(element.getValue().getClass());
Marshaller marshaller = jc.createMarshaller();
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
marshaller.marshal(element, baos);
return baos.toString();
} catch (Exception e) {
e.printStackTrace();
}
return "";
}
Print entire response XML
public void toXml() {
try {
JAXBContext ctx = JAXBContext.newInstance(User.class);
Marshaller marshaller = ctx.createMarshaller();
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
marshaller.marshal(this, System.out);
}
catch (Exception e) {
e.printStackTrace();
}
}
Call it like:
log.info("Customers sent: "+user.toXml());
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
public class FormatXSDCForContract {
private static FileWriter fw = null;
private static String [] baseDir = {
“C:\\sherFinancialServicesV4”,
“C:\\sherFinancialServicesV4-New”,
};
private static String [] filePath = {
“xmlns\\sher\\net\\mdm\\types\\common\\v4_0”,
“xmlns\\sher\\net\\mdm\\types\\contract\\domain\\v5_0”,
“xmlns\\sher\\net\\mdm\\types\\contract\\service\\contract\\v5_0”,
“xmlns\\sher\\net\\mdm\\types\\chain\\domain\\v5_0”,
“xmlns\\sher\\net\\mdm\\types\\party\\domain\\v5_0”,
“xmlns\\sher\\net\\mdm\\types\\party\\service\\party\\v5_0”
};
private static String [] fileName = {
“common.xsd”,
“domain.xsd”,
“domain.xsd”,
“domain.xsd”,
“party.xsd”
};
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
System.out.println(FormatXSD.class.getPackage());
for (int i = 0; i < baseDir.length; i++){
for (int j = 0; j < filePath.length; j++){
try {
File inputFile = new File(baseDir[i]+”\\”+filePath[j]+”\\”+fileName[j]);
File outFile = new File(baseDir[i]+”\\copy\\”+filePath[j]);
outFile.mkdirs();
fw = new FileWriter(outFile+”\\”+fileName[j]);
String input=””;
Map ctMap = new HashMap<String, StringBuilder>();
readALineAtATime(inputFile, ctMap);
fw.close();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}
private static void readALineAtATime(File inputFile, Map<String, StringBuilder> ctMap) throws FileNotFoundException, IOException {
BufferedReader br = new BufferedReader(new FileReader(inputFile));
String line;
String ctName = null;
boolean firstLine = true;
while ((line = br.readLine()) != null) {
ctName = checkLineForComplexType(line, ctMap, ctName);
}
br.close();
// sort the keys
Set<String> keySet = ctMap.keySet();
Iterator<String> it = keySet.iterator();
List<String> keyList = new ArrayList<String>();
while (it.hasNext()){
keyList.add(it.next());
}
Collections.sort(keyList);
//print the keys
it = keyList.iterator();
while (it.hasNext()){
String key = it.next();
StringBuilder sb = ctMap.get(key);
//System.out.println(sb);
writeToFile(sb);
}
//close
fw.close();
}
private static String checkLineForComplexType(String input, Map<String, StringBuilder> ctMap, String ctName) {
StringBuilder sb = new StringBuilder();
if (input.contains(“<?xml version=”)){
sb.append(input);
ctName = “1”;
ctMap.put(ctName, sb);
}else if (input.contains(“<xsd:complexType name=”)){
int start = input.indexOf(“\””);
int end = input.indexOf(“\”>”);
ctName = input.substring(start+1, end);
sb.append(input);
ctMap.put(ctName, sb);
}else{
sb = ctMap.get(ctName);
sb.append(“\n”);
sb.append(input);
ctMap.put(ctName, sb);
}
return ctName;
}
private static void writeToFile(StringBuilder line) {
try {
fw.append(line);
fw.append(“\n”);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
public class FormatXSD {
private static FileWriter fw = null;
private static String [] baseDir = {
“C:\\sherpartyV5”,
“C:\\sherpartyV5-New”,
};
private static String [] filePath = {
“xmlns\\sher\\net\\mdm\\types\\common\\v5_0”,
“xmlns\\sher\\net\\mdm\\types\\contract\\domain\\v5_0”,
“xmlns\\sher\\net\\mdm\\types\\chain\\domain\\v5_0”,
“xmlns\\sher\\net\\mdm\\types\\party\\domain\\v5_0”,
“xmlns\\sher\\net\\mdm\\types\\party\\service\\party\\v5_0”
};
private static String [] fileName = {
“common.xsd”,
“domain.xsd”,
“domain.xsd”,
“domain.xsd”,
“party.xsd”
};
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
System.out.println(FormatXSD.class.getPackage());
for (int i = 0; i < baseDir.length; i++){
for (int j = 0; j < filePath.length; j++){
try {
File inputFile = new File(baseDir[i]+”\\”+filePath[j]+”\\”+fileName[j]);
File outFile = new File(baseDir[i]+”\\copy\\”+filePath[j]);
outFile.mkdirs();
fw = new FileWriter(outFile+”\\”+fileName[j]);
String input=””;
Map ctMap = new HashMap<String, StringBuilder>();
readALineAtATime(inputFile, ctMap);
fw.close();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}
private static void readALineAtATime(File inputFile, Map<String, StringBuilder> ctMap) throws FileNotFoundException, IOException {
BufferedReader br = new BufferedReader(new FileReader(inputFile));
String line;
String ctName = null;
boolean firstLine = true;
while ((line = br.readLine()) != null) {
ctName = checkLineForComplexType(line, ctMap, ctName);
}
br.close();
// sort the keys
Set<String> keySet = ctMap.keySet();
Iterator<String> it = keySet.iterator();
List<String> keyList = new ArrayList<String>();
while (it.hasNext()){
keyList.add(it.next());
}
Collections.sort(keyList);
//print the keys
it = keyList.iterator();
while (it.hasNext()){
String key = it.next();
StringBuilder sb = ctMap.get(key);
//System.out.println(sb);
writeToFile(sb);
}
//close
fw.close();
}
private static String checkLineForComplexType(String input, Map<String, StringBuilder> ctMap, String ctName) {
StringBuilder sb = new StringBuilder();
if (input.contains(“<?xml version=”)){
sb.append(input);
ctName = “1”;
ctMap.put(ctName, sb);
}else if (input.contains(“<xsd:complexType name=”)){
int start = input.indexOf(“\””);
int end = input.indexOf(“\”>”);
ctName = input.substring(start+1, end);
sb.append(input);
ctMap.put(ctName, sb);
}else{
sb = ctMap.get(ctName);
sb.append(“\n”);
sb.append(input);
ctMap.put(ctName, sb);
}
return ctName;
}
private static void writeToFile(StringBuilder line) {
try {
fw.append(line);
fw.append(“\n”);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
public class FormatXSD {
private static FileWriter fw = null;
private static String [] baseDir = {
“C:\\sherpartyV5”,
“C:\\sherpartyV5-New”,
};
private static String [] filePath = {
“xmlns\\sher\\net\\mdm\\types\\common\\v5_0”,
“xmlns\\sher\\net\\mdm\\types\\contract\\domain\\v5_0”,
“xmlns\\sher\\net\\mdm\\types\\chain\\domain\\v5_0”,
“xmlns\\sher\\net\\mdm\\types\\party\\domain\\v5_0”,
“xmlns\\sher\\net\\mdm\\types\\party\\service\\party\\v5_0”
};
private static String [] fileName = {
“common.xsd”,
“domain.xsd”,
“domain.xsd”,
“domain.xsd”,
“party.xsd”
};
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
System.out.println(FormatXSD.class.getPackage());
for (int i = 0; i < baseDir.length; i++){
for (int j = 0; j < filePath.length; j++){
try {
File inputFile = new File(baseDir[i]+”\\”+filePath[j]+”\\”+fileName[j]);
File outFile = new File(baseDir[i]+”\\copy\\”+filePath[j]);
outFile.mkdirs();
fw = new FileWriter(outFile+”\\”+fileName[j]);
String input=””;
Map ctMap = new HashMap<String, StringBuilder>();
readALineAtATime(inputFile, ctMap);
fw.close();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}
private static void readALineAtATime(File inputFile, Map<String, StringBuilder> ctMap) throws FileNotFoundException, IOException {
BufferedReader br = new BufferedReader(new FileReader(inputFile));
String line;
String ctName = null;
boolean firstLine = true;
while ((line = br.readLine()) != null) {
ctName = checkLineForComplexType(line, ctMap, ctName);
}
br.close();
// sort the keys
Set<String> keySet = ctMap.keySet();
Iterator<String> it = keySet.iterator();
List<String> keyList = new ArrayList<String>();
while (it.hasNext()){
keyList.add(it.next());
}
Collections.sort(keyList);
//print the keys
it = keyList.iterator();
while (it.hasNext()){
String key = it.next();
StringBuilder sb = ctMap.get(key);
//System.out.println(sb);
writeToFile(sb);
}
//close
fw.close();
}
private static String checkLineForComplexType(String input, Map<String, StringBuilder> ctMap, String ctName) {
StringBuilder sb = new StringBuilder();
if (input.contains(“<?xml version=”)){
sb.append(input);
ctName = “1”;
ctMap.put(ctName, sb);
}else if (input.contains(“<xsd:complexType name=”)){
int start = input.indexOf(“\””);
int end = input.indexOf(“\”>”);
ctName = input.substring(start+1, end);
sb.append(input);
ctMap.put(ctName, sb);
}else{
sb = ctMap.get(ctName);
sb.append(“\n”);
sb.append(input);
ctMap.put(ctName, sb);
}
return ctName;
}
private static void writeToFile(StringBuilder line) {
try {
fw.append(line);
fw.append(“\n”);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
mport java.sql.Timestamp;
import java.util.Random;
public class IdGen {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
//Timestamp(System.currentTimeMillis());
Timestamp aTimestamp = new Timestamp(System.currentTimeMillis());
String timestamprandom=aTimestamp.toString();
String timestampRandom=timestamprandom.replaceAll(“[-:. ]”,””).trim();
String Id=”123456789012345678″+timestampRandom.trim();
int IdLength=Id.length();
Random random = new Random();
int randomInt = 0;
if(IdLength < 35)
Id = Id.substring(0, IdLength);
else
for(; Id.length() < 35; Id = (new StringBuilder()).append(Id).append(String.valueOf(randomInt)).toString())
randomInt = random.nextInt(10);
System.out.println(Id);
}
}
import java.util.Properties;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
/**
*
*/
public class DumpJNDI {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
try {
Properties props = new Properties();
props.put(“java.naming.factory.initial”, “com.ibm.websphere.naming.WsnInitialContextFactory”);
props.put(“java.naming.provider.url”, “iiop://hostname:2809/”);
Context context = new InitialContext(props);
//Context context = new InitialContext();
Object obj = context.lookup(“java:comp/env/service/MDMQSWSService”);
} catch (NamingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
public class CreateForIn {
private static FileWriter fw = null;
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
String inputFile = “C:\\InSQLInput.txt”;
String input=””;
try {
readALineAtATime(inputFile);
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
private static void readALineAtATime(String inputFile) throws FileNotFoundException, IOException {
BufferedReader br = new BufferedReader(new FileReader(inputFile));
String line;
System.out.println(“Begin:::”);
while ((line = br.readLine()) != null) {
genSQL(line);
}
br.close();
fw.close();
System.out.println(“End:::”);
}
private static void genSQL(String line) {
try{
// TODO Auto-generated method stub
String newValue = “‘”+line.trim()+”‘,”;
writeToFile(newValue);
}catch(Exception e){
e.printStackTrace();
}
}
private static void writeToFile(String line) {
// TODO Auto-generated method stub
//BufferedWriter br = new BufferedReader(new FileReader(inputFile));
try {
if (fw == null)
fw = new FileWriter(“C:\\InSQLOutput.txt”);
fw.append(line);
fw.append(“\n”);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.Vector;
public class CRDupeRemovalSQL {
private static FileWriter fw = null;
private static Map<String, List<String>> map = new HashMap<String, List<String>>();
private static Map<String, Integer> countMap = new HashMap<String, Integer>();
/**
* @param args
* @throws Exception
*/
public static void main(String[] args) throws Exception {
String inputFile = “C:\\crdupesplusrl_sorted.del”;
//String inputFile = “C:\\test.del”;
System.out.println(“Reading input file ” + inputFile + ” … “);
String input=””;
try {
readALineAtATime(inputFile);
removeOldest();
getFileWriter(null);
genSQL();
closeFileWriter();
getFileWriter(“verification”);
genVerificationSQL();
closeFileWriter();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
private static void readALineAtATime(String inputFile) throws FileNotFoundException, IOException {
BufferedReader br = new BufferedReader(new FileReader(inputFile));
String line;
System.out.println(“Begin read:::”);
while ((line = br.readLine()) != null) {
// Business key is cont_id + contract component id + contract role
if (!hasRoleLocation(line)){
System.out.println(“No role location”);
System.out.println(getBusinessKey(line));
if(map.get(getBusinessKey(line))!=null){
System.out.println(“Not first set”);
List<String> list = map.get(getBusinessKey(line));
list.add(getPrimaryKey(line));
map.put(getBusinessKey(line), list);
}else{
System.out.println(“First set”);
List<String> list = new ArrayList<String>();
list.add(getPrimaryKey(line));
map.put(getBusinessKey(line), list);
}
}
if (countMap.get(getBusinessKey(line)) == null){
System.out.println(“Count First set”);
countMap.put(getBusinessKey(line), 1);
System.out.println(countMap.get(getBusinessKey(line)));
}
else{
System.out.println(“Count Not First set”);
countMap.put(getBusinessKey(line), countMap.get(getBusinessKey(line))+1);
System.out.println(countMap.get(getBusinessKey(line)));
}
}
br.close();
System.out.println(“End read:::”);
}
private static boolean hasRoleLocation(String line) {
String [] tokens = line.split(“,”);
for (int i = 0; i < tokens.length; i++){
if (i == 20){
return true;
}
}
return false;
}
private static String getLUD(String line) {
String [] tokens = line.split(“,”);
return tokens[11];
}
private static String getBusinessKey(String line) {
String [] tokens = line.split(“,”);
Vector vec = new Vector();
StringBuffer businessKey = new StringBuffer();
for (int i = 0; i < tokens.length; i++){
if (i == 1 || i == 2 || i == 3){
businessKey.append(tokens[i]);
}
}
return businessKey.toString();
}
private static String getPrimaryKey(String line) {
String [] tokens = line.split(“,”);
return tokens[0];
}
private static void removeOldest() throws Exception {
System.out.println(“Begin removeOldest:::”);
Set<String> keySet = map.keySet();
Iterator it = keySet.iterator();
while(it.hasNext()){
String key = (String)it.next();
List<String> list = map.get(key);
Integer cardinailty = countMap.get(key);
if (list.size() == cardinailty)
list.remove(0);
if (list.size() > cardinailty){
System.out.println(“list size::”+list.size());
System.out.println(“cardinailty::”+cardinailty);
System.out.println();
System.out.println(key);
printList(list);
throw new Exception(“List is bigger than cardinality”);
}
}
System.out.println(“End removeOldest:::”);
}
private static void printList(List<String> list) {
Iterator<String> it = list.iterator();
while(it.hasNext()){
System.out.println(it.next());
}
}
private static void writeToFile(String updateStr) {
try {
fw.append(updateStr);
fw.append(“\n”);
fw.flush();
} catch (IOException e) {
e.printStackTrace();
}
}
private static void writeToLine(String updateStr) {
try {
fw.append(updateStr);
fw.flush();
} catch (IOException e) {
e.printStackTrace();
}
}
private static void getFileWriter(String type) {
try {
if (fw == null){
if (type == null)
fw = new FileWriter(“C:\\DuplicateCRsEndDate.sql”);
else
fw = new FileWriter(“C:\\PreRunVerification.sql”);
}
} catch (IOException e) {
e.printStackTrace();
}
}
private static void closeFileWriter() {
try {
if (fw != null){
fw.close();
fw = null;
}
} catch (IOException e) {
e.printStackTrace();
}
}
private static void genSQL() {
System.out.println(“Begin genSQL:::”);
try{
Set<String> keySet = map.keySet();
Iterator it = keySet.iterator();
while(it.hasNext()){
List<String> list = map.get(it.next());
if (!list.isEmpty()){
Iterator listIt = list.iterator();
while (listIt.hasNext()){
System.out.println(“SQL created”);
//StringBuffer sb = new StringBuffer(“UPDATE CONTRACTROLE SET END_DT = CURRENT TIMESTAMP, LAST_UPDATE_DT = CURRENT TIMESTAMP, LAST_UPDATE_USER = ‘SQLPatch-06Apr2016’ WHERE CONTRACT_ROLE_ID = “+listIt.next());
writeToFile(“UPDATE CONTRACTROLE SET END_DT = CURRENT TIMESTAMP, LAST_UPDATE_DT = CURRENT TIMESTAMP, LAST_UPDATE_USER = ‘SQLPatch-06Apr2016’ WHERE CONTRACT_ROLE_ID = “+listIt.next()+”;”);
}
}
}
writeToFile(“COMMIT;”);
}catch(Exception e){
e.printStackTrace();
}
System.out.println(“End genSQL:::”);
}
private static void genVerificationSQL() {
System.out.println(“Begin genVerificationSQL:::”);
try{
writeToLine(“SELECT COUNT(*) FROM ROLELOCATION WHERE CONTRACT_ROLE_ID IN (“);
Set<String> keySet = map.keySet();
Iterator it = keySet.iterator();
while(it.hasNext()){
List<String> list = map.get(it.next());
if (!list.isEmpty()){
Iterator listIt = list.iterator();
while (listIt.hasNext()){
writeToLine(listIt.next()+”,”);
}
}
}
writeToFile(“0);”);
}catch(Exception e){
e.printStackTrace();
}
System.out.println(“End genVerificationSQL:::”);
}
}