This Blog is first of all memos for me!! From time to time I get exposed to new and cool stuff for developers and architects ,most of the time its a solution for a problem or tips or tricks, so, I would like to track my memos and share it with you, it can save your time and nervous, I hope you will enjoy it - by Yaniv Tzanany.
Search This Blog
Tuesday, December 16, 2008
Linux - how to determine file type (32 bit or 64 bit)
so the command is:
file [name file ]
the output will be the file type (32/64).
for more information
man file
Set Linux/Unix prompt and getting previous command
you just need to export & declare the PS1 environment parameter.
e.g.
export PS1='$USER@$HOSTNAME $PWD >'
will give you prompt like this:
root@myLinux /usr/src >
you can change your prompt to be as you want .
sometime the current shell could not show you the previous command when you press the up arrow key, to make it work ,in the shell prompt type:
set -o emacs
Wednesday, December 10, 2008
LDAP error code
i found a list that can help to understand the reason in case you need it:
525 - user not found
52e - invalid credentials
530 - not permitted to logon at this time
531 - not permitted to logon from this workstation
532 - password expired
533 - account disabled
701 - account expired
773 - user must reset password
775 - account locked
more details for the code above you can find here Active Directory LDAP Errors.
Tuesday, November 25, 2008
job's memory/process usage under UNIX
ps -e -o "%z %C %U %p %t %c" |sort -n
%z ought to show the virtual size of each process in KB , and we sort the output from min usage to max.
very good tips about Managing processes on AIX Systems
Printing stack trace - just before crashing under linux/gcc
1. to free up some resource before the crash
2. to give a hint to the developer what happen - or even in production .
3. some exception i could catch even into catch(...)
the next code sample runs under linux , and compile with g++, i couldn't find an easy way to do it under windows (via VC++) as on linux , and in my case i need it under linux.
the idea is to register for any signal you want to handle , and in your function handler you need to write your cleaner, or print out the trace.
Do NOT FORGET in case of handler function you have to call to exit method , if you don't you will get into endless loop.
if you want to get the function name in your stack trace , ADD -rdynamic flag to your link settings.
here are some resources i used:
linux backtrace , generate a stacktrace
here is my sample test:
#include <iostream>
extern "C"
{
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
}
#include <fstream>
#include <csignal>
#include <execinfo.h>
void PrintStack()
{
//backtrace_symbols_fd(array, size, 2);
// ADD -rdynamic flag to your link , to get method name and not hex address
void * array[25];
int nSize = backtrace(array, 25);
char ** symbols = backtrace_symbols(array, nSize);
for (int i = 0; i < nSize; i++)
{
printf("%s \n", symbols[i] );
}
if(symbols)
free(symbols);
}
void intrupt(int sig)
{
//..necessary cleanup operations before terminating
printf("handling signal no. %d - Interactive attention signal \n",sig);
PrintStack();
exit(sig);
}
void term(int sig)
{
//..necessary cleanup operations before terminating
printf("handling signal no. %d - Termination request made to the program \n",sig);
exit(sig);
}
void abort(int sig)
{
//..necessary cleanup operations before terminating
// cout << "handling signal no." << sig << endl << "Abnormal termination" << endl;
printf("handling signal no. %d - Abnormal termination \n",sig);
exit(sig);
}
void floatingPoint(int sig)
{
//..necessary cleanup operations before terminating
printf("handling signal no. %d - Abnormal termination floatingPoint \n",sig);
PrintStack();
exit(sig);
}
void IllegalInstruction(int sig)
{
//..necessary cleanup operations before terminating
printf("handling signal no. %d - Abnormal termination IllegalInstruction \n",sig);
exit(sig);
}
void IllegalStorage(int sig)
{
//..necessary cleanup operations before terminating
printf("handling signal no. %d - Abnormal termination IllegalStorage \n",sig);
PrintStack();
// no log when there is no exit here on aix ,
//on linux its in recursion so you have to call exit
exit(sig);
}
void foo()
{
int arrInt[4] = {1,2,3,4};
for(int i = 0 ; i < 2000;i++)
{
printf(" iRet index = %d , val= %d ........... ...\n",i,arrInt[i]);
}
}
void foo3()
{
char* data = 0 ;
int iRet = strlen(data);
printf(" strlen(data) = %d ........... ...\n",iRet);
strcpy(data, "hellozadsfaddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd");
printf(" dataLinux = %s ........... ...\n",data);
}
void foo2()
{
foo3();
}
class Crash
{
public:
void fooArrayOutOfIndex()
{
int arrInt[4] = {1,2,3,4};
for(int i = 0 ; i < 2000;i++)
{
printf(" iRet index = %d , val= %d ........... ...\n",i,arrInt[i]);
}
};
void foo3()
{
char* data = 0 ;
int iRet = strlen(data);
printf(" strlen(data) = %d ........... ...\n",iRet);
strcpy(data, "hellozadsfaddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd");
printf(" dataLinux = %s ........... ...\n",data);
};
void fooNullPointerAccess()
{
foo3();
};
void fooLoop()
{
while(true)
{
}
};
};
int main ( int argc, char * * argv ) {
signal(SIGINT , intrupt); // register a SIGINT handler
signal(SIGTERM , term); // register a SIGTERM handler
signal(SIGABRT , abort); // register a SIGABRT handler
signal(SIGFPE , floatingPoint); // register a SIGFPE handler
signal(SIGILL , IllegalInstruction); // register a Illegal instruction handler
signal(SIGSEGV , IllegalStorage); // register a Illegal storage handler
int iRet;
bool bErr = false;
printf("Starting Server on queue %s...\n","Demo test");
try
{
printf("IN TRY........... ...\n");
iRet = 0;
iRet = iRet/0.;
printf(" iRet = %d ........... ...\n",iRet);
//foo();
// foo2();
Crash crsh;
// crsh.fooArrayOutOfIndex();
crsh.fooNullPointerAccess();
// crsh.fooLoop();
}
catch(...)
{
bErr = true;
printf("***************** ERROR ****************** .\n");
}
printf("Connected and Running ... \n");
printf("END Server \n ");
return 1;
}
enjoy
Yaniv
Friday, November 21, 2008
Monday, November 10, 2008
LDAP with java
one of the complete and best sample you can find here - This is sample program that show how to authenticate with for example a Windows Active Directory:
Active Directory LDAP and Java.
second there is a very good tutorial for JNDI & Ldap that you can find here:
Your guide to The JNDI Tutorial .
another good link with java/c#/c samples -> A Beginner's Guide to LDAP Development
a very good book you can find here LDAP-Programming-With-Java
And here is a tip to find all the ldap attributes:
To discover more LDAP attributes, go to the command prompt, type:
CSVDE -f Exportfile.csv. Then open Exportfile.csv with Excel.exe.
Alternatively, use ADSI Edit and right click the container objects.
enjoy
Saturday, October 25, 2008
How to sort XML without XSL in the .NET Framework
basically i use it in this way too:
XmlDocument doc = new XmlDocument();
doc.LoadXml(mergeXML);
XPathNavigator navigator = doc.CreateNavigator();
XPathExpression expression = navigator.Compile("Messages/Message/Date");
expression.AddSort("@tick", XmlSortOrder.Descending, XmlCaseOrder.UpperFirst, string.Empty, XmlDataType.Number);
XPathNodeIterator iterator = navigator.Select(expression);
StringBuilder sb = new StringBuilder();
foreach (XPathNavigator item in iterator)
{
// we have here the Date node we want the Message node
sb.Append(((XmlNode)item.UnderlyingObject).ParentNode.OuterXml);
}
Execute command from .NET
private static void RunCommand(bool bWaitForExit, string commandName, string arguments, ref string outPut, ref string error)
{
try
{
System.Diagnostics.Process proc = new System.Diagnostics.Process();
proc.EnableRaisingEvents = false;
proc.StartInfo.FileName = commandName;
// Redirect the error stream of the child process.
proc.StartInfo.UseShellExecute = false;
proc.StartInfo.RedirectStandardError = true;
proc.StartInfo.RedirectStandardInput = true;
proc.StartInfo.RedirectStandardOutput = true;
// arguments = Server.HtmlDecode(arguments);
arguments = arguments.Trim();
if (arguments.Length != 0) //in case of empty string
proc.StartInfo.Arguments = arguments;
proc.Start();
outPut = proc.StandardOutput.ReadToEnd();
error = proc.StandardError.ReadToEnd();
if (bWaitForExit)
proc.WaitForExit();
}
catch (Exception ex)
{
error = ex.Message;
outPut = error;
}
}
enjoy
Thursday, September 25, 2008
.Net Tips
http://msdn2.microsoft.com/en-us/library/aa288436(VS.71).aspx
2. dump all method from dll
comand:
link /dump /exports c:\WINDOWS\system32\kernel32.dll
3. create dll introb for com object
e.g. :
tlbimp c:\windows\system32\quartz.dll /out:QuartzTypeLib.dll
4. Remote debugging setup is greatly simplified in Visual Studio 2005. All remote debugging scenarios except T-SQL debugging use the Remote Debugging Monitor (msvsmon.exe). The Machine Debug Manager (mdm.exe), previously required for some debugging scenarios, has been eliminated. In addition, msvsmon.exe now has a graphical user interface in place of the previous command-line interface
How to: Set Up Remote Debugging
Friday, September 19, 2008
Configure Network Tracing - in .NET
you can follow this guide How to: Configure Network Tracing.
Wednesday, September 17, 2008
java to c++ bridge
1. NoodleGlue an Open source solution - you can read about it here -> Bridging C/C++ and Java.you can download it from here JavaOSG Bindings.
2. Jace is a set of C++ and Java libraries and programs based on JNI that make it incredibly easy to write C++ code that integrates with the Java Virtual Machine (JVM). Jace is like Alphawork's easyJNI, but easier to use, with more features, and more power .
3. There are many solutions for bridging C++ classes in Java, you can read and compare the suggested solution here Urakawa Project f2f Report: Java - C++ Bridge .
Yaniv
Wednesday, September 10, 2008
WebSphere filter in version 6.1.0.0 Vs 6.1.0.17
In Version 6.1.0.0 (before I set the path 17) , my web xml contains the next filter declaration
<filter>
<filter-name>WSConfigFilter</filter-name>
<filter-class>com.fis.infra.presentation.web.services.weblogic.filter.WSConfigFilter</filter-class>
<init-param>
<param-name>LoginWebService</param-name>
<param-value>GUIWebServices/services/LoginFacade?WSDL</param-value>
</init-param>
<init-param>
<param-name>PresentationWebService</param-name>
<param-value>GUIWebServices/services/PresentationFacade?WSDL</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>WSConfigFilter</filter-name>
<url-pattern>/Infrastructure/RTInfra/WS_Client/WSConfig.xml</url-pattern>
</filter-mapping>
We access to this file WSConfig.xml in the login ( maybe the first page/data from server) ,I would like to generate this file in the server.
On version 6.1.0.0 this filter get invoked as you ask this file , after I installed the patch (6.1.0.17) this filter is not invoked only after he found this page ( I create it manually ).
The Solution:
After digging in the web i came up with this problem from IBM PK33090; 6.1: A filter that serves a file does not popup an alert message
So you can follow the instruction how to add Webcontainer custom property , and add the relvant property to solved this issue:
1. In the administrative console, click "Servers" and under Servers click "Application Servers"
2. Click on the server to which the custom property is to be applied
3. Under "Configuration" and "Container settings" click "Web Container Settings" and under Web Container Settings click "Web Container"
4. Under "Configuration" and "Additional Properties" click "Custom Properties"
5. In the Custom Properties page, click "New"
6. “Name" = com.ibm.ws.webcontainer.invokefilterscompatibility “Value”= true .
7. Click "Apply" or "OK"
8. Click "Save" in the "Messages" box which appears
9. Restart the server for the custom property to take effect
and than i saw my filter get invoked as usual.
WebSphere tips
2. If you go to Application servers > server1 > Process Definition > Java Virtual Machine and checked the "Verbose garbage collection " check box , after restarting the server you can see all GC activities in server log directory under file native_stderr.log , to analyse this file you can download an IBM tool from here ->IBM Pattern Modeling and Analysis Tool for Java Garbage Collector
3. In the post i wrote before this one i mention how to get a full trace from your web sphere application , to analyse this trace you can use the next tool from IBM ->IBM Trace and Request Analyzer for WebSphere Application Server
4. To debug your deployed application on websphere follow the next steps:
in the admin console - Application servers > server1 > Process Definition > Java Virtual Machine checked the "Debug Mode " , by doing so the parameters that in the "Debug arguments" text box will be added to the server when restarting , usually the parameters looks like this "-Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket, server=y,suspend=n,address=7777" , so after restarting your server open your Eclipse (in this case) and you just need to attach to a "remote java application" and put in the server name (where the websphere server is running ) and the port number you set/have from the address (i.e. 7777), and pray :)
5. very good article about java performance on AIX you can find here Maximizing Java performance on AIX
6. here are some WebSphere Tuning links
WebSphere Tuning Tips
WebSphere tuning for the impatient: How to get 80% of the performance improvement with 20% of the effort
Tuning performance
Java virtual machine settings
DB2 tuning parameters
Solving memory problems in WebSphere applications
Monday, September 8, 2008
Trace configuration for Web Sphere
1) Trace the application flow from application server startup (for this you will require to setup the application and also WebSphere to use datasources).
Please use the following trace String:
*=info:com.ibm.ws.webservices.*=all:WAS.j2c=all:RRA=all:WAS.database=all:Messaging=all:JMSApi=all:Transaction=all
See instructions below for tracing setup:
1. In the Application Server Administrative Console, expand Troubleshooting and select Logs and Trace.
2. In the Logging and Tracing page, select your server and then Diagnostic Trace.
3. Ensure that Enable Log is selected.
4. Under Trace Output, select File, and accept the defaults.
5. Click OK and save your configuration.
6. Again, expand Troubleshooting and select Logs and Trace.
7. In the Logging and Tracing page, select your server and then Change Log Detail Levels.
8. Enter the following trace string:
*=info:com.ibm.ws.webservices.*=all:WAS.j2c=all:RRA=all:WAS.database=all:Messaging=all:JMSApi=all:Transaction=all
NOTE: Please ensure you have setup at least 10 historical files of at least 50 MB each to ensure the whole test is captured from startup.
..
you can see the trace.log file under your your log directory .
Wednesday, September 3, 2008
DB2 JDBC Driver Secrets
http://www.db2ude.com/?q=node/75
and some more tips with Query optimization in DB2 using REOPT
http://www.db2ude.com/?q=node/73
enjoy
Tuesday, September 2, 2008
WebSphere usefull links for tips
1. Web Sphere profiles / Servers
a. What is a profile , how to manage/create/control servers
http://publib.boulder.ibm.com/infocenter/wasinfo/v6r1/index.jsp?topic=/com.ibm.websphere.base.doc/info/aes/ae/tpro_profiles.html
b. Control servers via Command line
You can explor the commands
under \installDir\Profiles\myProfileName\bin
For example, to start server1
through the command line I'm running the startserver server1 from the next
directory
C:\Program Files\IBM\WebSphere\AppServer\profiles\AppSrv01\bin
c. Servers logs
\installDir\Profiles\myProfileName\logs\AppServerName
For example, the full path for
the log files under my profile is
C:\Program Files\IBM\WebSphere\AppServer\profiles\AppSrv01\logs\server1
d. Administration console.
To access the admin console:
Start->Programs->IBM WebSphere->Application
Server V6.1->profiles->profileName->Administrative Console
http://publib.boulder.ibm.com/infocenter/wasinfo/v6r1/index.jsp?topic=/com.ibm.websphere.base.doc/info/aes/ae/welcadminconsole.html
e. Is there a node manager.
The WebSphere ND (Network Deployment)
product enables you to manage nodes
http://publib.boulder.ibm.com/infocenter/wasinfo/v6r1/index.jsp?topic=/com.ibm.websphere.nd.doc/info/ae/ae/tagt_svr_conf_nodes.html
f. 1-N servers
in one profile and how to control each one .
http://publib.boulder.ibm.com/infocenter/wasinfo/v6r1/index.jsp?topic=/com.ibm.websphere.base.doc/info/aes/ae/tpro_profiles.html
2. WEB Sphere File
architecture, main configuration file names.
http://publib.boulder.ibm.com/infocenter/wasinfo/v6r1/index.jsp?topic=/com.ibm.websphere.base.doc/info/aes/ae/tcfg_data.html
3. Control the start-up
parameters (-DXXXX=YYYY ) , adding custom parameters.
http://publib.boulder.ibm.com/infocenter/wasinfo/v6r1/index.jsp?topic=/com.ibm.websphere.base.doc/info/aes/ae/trun_app_startup.html
4. Adding application
specific parameter (environment variable )
http://publib.boulder.ibm.com/infocenter/wasinfo/v6r1/index.jsp?topic=/com.ibm.websphere.base.doc/info/aes/ae/tcws_variable.html
5. Supported JVM version – how to change the JVM version if needed.
http://publib.boulder.ibm.com/infocenter/wasinfo/v6r1/index.jsp?topic=/com.ibm.websphere.base.doc/info/aes/ae/urun_rconfproc_jvm.html
6. Eclipse and Web
sphere - how to debug deployed application
http://publib.boulder.ibm.com/infocenter/wasinfo/v6r1/index.jsp?topic=/com.ibm.websphere.base.doc/info/aes/ae/ttrb_debugwsa.html
7. Create Data source name (connection pooling)
http://publib.boulder.ibm.com/infocenter/wasinfo/v6r1/index.jsp?topic=/com.ibm.websphere.base.doc/info/aes/ae/tdat_tccrtprovds.html
8. Performance tips and tricks
http://publib.boulder.ibm.com/infocenter/wasinfo/v6r1/index.jsp?topic=/com.ibm.websphere.base.doc/info/aes/ae/welc6toptuning.html
9. Deployment issues,
export web services via Web sphere .
10. Deploy software on
web sphere
http://publib.boulder.ibm.com/infocenter/wasinfo/v6r1/index.jsp?topic=/com.ibm.websphere.base.doc/info/aes/ae/trun_appl.html
11. Apache web With Web sphere integration.
http://publib.boulder.ibm.com/infocenter/wasinfo/v6r1/index.jsp?topic=/com.ibm.websphere.base.doc/info/aes/ae/twsv_plugin.html
I hope I wrote all the necessary things .
Saturday, August 9, 2008
Hosting a Windows Form Control in a web page
for the sample code and the rest of this article , follow the next link
Hosting a Windows Form Control in a web page
Accessing server side from client side via XMLHTTP
That shows how to access server side from client side, via XMLHTTP object.
This sample with asp page.
Enjoy
XMLHTTP ActiveX objects offer alternative to accessing ASP session variables
Monday, August 4, 2008
Find open ports on windows
- Find all open ports -> netstat
- All listening ports -> netstat -an | find /i "listening"
- see what ports your computer actually communicates with -> netstat -an |find /i "established"
- find specified open port -> netstat -an | find /i "8989"
- find open ports and their process ID -> netstat -ao | find /i "listening"
Sunday, August 3, 2008
Add definition to web sphere JVM
go to :
Application servers > server1 > Process Definition > Java Virtual Machine > Custom Properties
and add your parameter .
Web services links
http://www.artima.com/lejava/articles/threeminutes2.html
http://www.inf.fu-berlin.de/lehre/SS03/19560-P/Docs/JWSDP/tutorial/doc/JAXRPC3.html
http://www.ibm.com/developerworks/webservices/library/ws-javaclient/index.html
http://edocs.bea.com/wls/docs70/webserv/client.html#1024463
http://edocs.bea.com/wls/docs92/webserv/client.html#1024463
http://www.ibm.com/developerworks/library/x-tipjaxrpc/index.html
http://www.xmethods.net/ve2/index.po
Wednesday, July 9, 2008
WebSphere WS interoperability with Axis2
Web services interoperability with the WebSphere Web Services Feature Pack and Apache Axis2
enjoy it
Tuesday, June 24, 2008
Consume Web-Services from C++
gSOAP is a cross-platform development toolkit for C and C++ SOAP XML Web services (SOAP1.1/1.2,WSDL1.1). gSOAP supports XML serialization of native C/C++ data types. Includes SOAP/XML engine, Web server, stub/skeleton compiler, WSDL tools, and much more.
download gSOAP Toolkit latest version OR visit gSOAP page for complete info.
If you will follow the next link you will find a step by step demo to consume j2ee WS, this demo on Windows via VC++ .Use gSOAP to consume J2EE Web services created by WSAD through HTTP and HTTPS
Monday, June 23, 2008
Understanding Malicious Content Mitigation for Web Developers
you can find the complete article and solutions HERE
Thursday, June 19, 2008
Java stored procedure in Oracle
So I ask the COBOL developer to create a shell script in SUN to activate his COBOL program, and I created a JAVA class that runs as a Stored procedure and activate this script , and get the result from the stdoutput .
The C++ developers only needs to call to the stored procedure, and we are there.
BTW - the Oracle and my scripts file are on the same server.
A very good example how to do it , you can find here
An Introduction to Java Stored Modules in Oracle
and here
Shell Commands From PL/SQL
Last one - > another Step by step article and Demo
Java Stored Procedure in Oracle, Database Interaction
Enjoy
Show computers network
net view
The net command is used to update, fix, or view the network or network settings.
for more information and syntax samples go to here Microsoft DOS net command
Friday, June 13, 2008
URL Mapping in asp.net
this is very easy to implement in asp.net 2.0, just add to your web.config file the urlMappings tag.
i.e.
<urlmappings enabled="true">
<add url="~/Home.aspx" mappedurl="~/Default.aspx?tab=home" >
</urlmappings>
Thursday, June 12, 2008
Web developer site
Edward Tanguay's Web Developer Site
MQ message length
The problem is :
An error message that we get from the MQ server, while trying to send/put a large XML data.
When I said large I mean bigger than 4M bytes .
i made some investigation here and i found out that there is a limit of the maximum message length (MAXMSGL) that
you can put in the Queue.
The MAXMSGL parameter appears in three places:
In the Channel level -> specifies the maximum length of a message that can be transmitted on the channel, in bytes.
In the Queue Manger level -> Maximum message length in bytes.
In the Queues level - as above.
The default in all the above places is – 4194304 bytes that’s 4M bytes.
To solve this limit I suggest to:
set the MAXMSGL parameter in the channel level to Zero (0) ,
That’s mean that maximum message length will be taken from the Queue Manger.
Increase the MAXMSGL parameter in the Queue Manger level .
"On AIX, Compaq NonStop Kernel, Compaq OpenVMS Alpha, HP-UX, z/OS, OS/2, OS/400, Solaris,
Windows, plus WebSphere MQ clients connected to these systems, the maximum message length is 100 MB (104 857 600 bytes)."
How to increase it ?
You can do it very easily from WebSphere MQ explorer, right click on the channel OR Queue manager -> properties
In the Extended Tab look for the "maximum message length" parameter and make the change there.
From the command line ( on all platform ):
runmqsc QM_MGR_1
ALTER QMGR MAXMSGL (10485760) // i.e set it to 10M bytes
ALTER CHANNEL(SYSTEM.ADMIN.SVRCONN) CHLTYPE(SVRCONN) MAXMSGL(0)
notes:
DO NOT FORGET TO CHANGE YOUR SOURCE CODE IF NEEDED.
set the MaximumMessageLength on the channel too, so the actull size will get from the Queue manager.
m_Channel.setMaximumMessageLength(0);
I hope you will find this information useful for your project.
enjoy
Yaniv Tzanany
Wednesday, June 11, 2008
TECH-ED 2008 צפה בהקלטות של ההרצאות
http://www.microsoft.com/israel/techedevent/list.aspx
Find open ports on linux
Find specific port :
netstat -a grep [port no] (i.e. netstat -a grep 7071)
OR
netstat -pln
find program that listening on specific port :
netstat -anp grep [port no]
Tuesday, June 10, 2008
Weblogic connection pooling - jdbc configuration
Oracle OCI works well with the CLOB / BLOB.
The query test impact performance on Oracle 9x , the "select from DUAL" – affect performance . on oracle 10 the problem fixed .
The queries from Oracle DUAL table are very common.
As of the v$SQLAREA each query uses about 5 logical reads.
In order to wrap-up the pace of retrieving data please use X$DUAL instead of using the DUAL table.
Below is a prescription on the way to implement it and fix this issue on oracle 9x:
sqlplus /nolog
connect / as sysdba
create view dual_view as select dummy from x$dual;
grant select on dual_view to public;
rename dual to dual_table;
rename dual_view to dual;
exit