Dec 30, 2010

create / install new subversion (svn) server as a windows service

Not once i have been asked how to create a new service for the subversion aka svn server in windows.

So, the solution in command line is very simple:
sc create Subversion binpath= "c:\SVN\svn-win32-1.6.2\bin\svnserve.exe --service --root c:\SVN\Repository" displayname= "Subversion" depend= Tcpip

displayname = can be anything

Hoped i helped a bit,
Dor

Dec 27, 2010

Websphere dump file analyaze

Download this file ha408.jar

Then run it using this command line for example:
"java -Xmx1200m -jar ha408.jar"

* The Xmx can be also 1024 or 512 it depends.

Than after the application is running, you can open the "*.phd" files from websphere to analyze.

Dor

Dec 26, 2010

eclipse plugin for classdiagram

I use and also it' s my recommendation to use a plugin named : ObjectAid,
 very simple tool very simple installation and way of working.

You can remove it on anytime you think it's not good.

Regards,

Dor



Dec 23, 2010

generating unique id (uuid)

One line of java code : UUID.randomUUID().toString()

load certificates in java

Just add this line below to your context listener for example.


System.setProperty("javax.net.ssl.trustStore", "c:/certificates/certificates_storage_file");
System.setProperty("javax.net.ssl.trustStorePassword", "password");

Simple as that.

Dor

Dec 19, 2010

Using platform encoding (Cp1252 actually) to copy filtered resources

Simple solution, just add utf-8 as a property like this:

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
Apache maven.
Hoped it helped, 
Dor

Element 'filters' cannot have character [children], because the type's content type is element-only. maven

Go this error while adding filter to web.xml.
My mistake was that i forgot creating the <filter> tag inside the <filters>.
I did this:
 <filters>src/main/filters/filter.properties</filters> instead of doing this:
 <filters><filter>src/main/filters/filter.properties</filter></filters>

Minor mistake that can happen in one minute out of focus.

Hoped it helped,
Dor

Dec 6, 2010

An internal error occurred during: "Refreshing external folders". java.lang.NullPointerException

Exception occurred to me after upgrading and using the eclipse helios with gwt 2.1 new plugin.
Don't know if both connected or not or maybe it's subversion problem.
I have looked and googled for solutions but nothing yet over the web.

What's helped me:
Closing all the projects in eclipse.
Opening all the projects.
This probably synchronize eclipse with the file system. Then Project->Clean all.

That's it, worked for me, hoped that it will help you also.

Dor

Nov 24, 2010

insert ampersand in oracle table

Hi,
This solution will work everywhere, no matter if you are using TOAD,sql plus, pl sql developer.
let's say we want to insert this "hello&world" inside a table that includes key's and values.
And our key, let's say is "title"
For example :
insert into table_name (keys,values) values ('title','hello'||chr(38)||'world');
That's the whole story.
Hoped i helped,
Dor

Nov 23, 2010

World Community Grid

If you want to volunteer your computer cpu, if you have computer idle time or if you just a good person who want to assist fighting cancer, HIV etc. Come and join the World Community Grid like i did.
The project is being supported by IBM and Berkeley university.
One of my favourite distribute computing project.

at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:111)

Hi,
My Configuration is as follow: WebSphere Application Server 6.1.0.19, it seems that this is sort of bug they have.
Offered solutions:
Hopefully it helps,
Recommended link to look over : Click Here.
Dor

SRVE0255E: A WebGroup/Virtual Host to handle /mytest has not been defined.

Hi,
Check that all of your EAR's or WAR's deployed because it's seems that one of them
is missing, that was my problem regard this issue.
Dor

Websphere admin console doesn't work on MyEclipse

Hi All,
Working with MyEclipse Blue Edition and WAS 6.1, Suddenly WAS admin stopped from being working on MyEclipse and throwing exceptions in the console.
Solution for this problem, by steps:
1) Find the directory named "optionalLibraries\Apache\Struts\1.2.4"
2) Copy "commons-validator.jar" into your "lib\ext" directory.
3) Stop the server and Start it again.
Hoping that it will help you also if this is your case.
Dor

Loading order in websphere application server

Hi,
Definition is simple, follow the orders,  Enter the following (bullets as steps):
  • WAS admin console
  • Enterprise Applications
  • Select the first EAR for example
  • Startup Behavior
  • In the "Startup Order" Enter a weight.
  • The weights are like priorities of loading, the lowest is first one to be loaded etc.
Dor

WSVR0204I: Application: EAR Application build level: Unknown

Hi,
This is not and error and still everything will continue to run on websphere. Something went wrong with the EAR build or deploy to the Websphere application server.
Bye,
Dor

Skype & Websphere Application Server

Hi,
Skype default working port is 80 as well as the websphere application server.
Offered solutions:
  • Change skype port (Tools; Options; Advance; unmark "use port 80... etc").
  • Change websphere application server port.
Only one solution is enough.

at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:111)

Hi,
My Configuration is as follow: WebSphere Application Server 6.1.0.19, it seems that this is sort of bug they have.
Offered solutions:
Hopefully it helps,
Recommended link to look over : Click Here.
Dor

Initializing LdapContextSource localy instead of using spring xml

If you decide to work with internal coded LdapContextSource initialize instead of using spring injection (external application context xml file). There is one important thing you shouldn't forget:
Call "afterPropertiesSet()" method to finish up initialization.
Failing to do so would probably led you to this failure / exception as i had:
"org.springframework.ldap.core.support.AbstractContextSource.getAuthenticatedEnv(AbstractContextSource.java:449) etc.."
Hopefully that this helps...
Dor

Eclipse is running in a JRE, but a JDK is required

Hi,
1) Right click on windows eclipse shortcut.
2) add in the end of the Target "-vm pathtojdkliberary"
3) Ensure that the JRE library is setup correctly within eclipse-&gt;preferences-&gt;JRE
Solution refers both to MyEclipse (not matter if its the Blue version or the regular) and Eclipse.
That's it.
Dor

JSON to java object, Java object to JSON

Hi,
Using the ObjectMapper from Codehaus to convert java object into json and the opposite direction, from json to java object.
Java object to JSON, code example:
OutputStream outputStream = new ByteArrayOutputStream();
new ObjectMapper().writeValue(outputStream , obj);
return outputStream .toString();
JSON to Java object, code example:
new ObjectMapper().readValue(jsonStr, Person.class);
Notes:
1. Don't forget to handle exceptions that might occur when converting using the jackson mapper.
2. Consider using / creating the mapper once as static for wide application usage.
3. The code above is an example, exception handling needed in real code.
Good day,
Dor

opensymphony quartz cronexpression example

Several Quartz cron expressions:
This should be familiar for UNIX/Linux users.
1) "0 0/2 * * * ?" will run every 2 minutes.
2) "0/10 0 * * * ?" will run every 10 seconds.
3) "0 22 11 * * ? 2009" will run every day during 2009 on 11:22am
Hopefully it helps,
Dor

Axis2 WSDL2Java to work with Salesforce API

Hi All,
After drilling down the web i have found a several ways to generate the java classes from Salesforce wsdl. I decided to publish this because i had enought.
I am using the partner.wsdl from salesforce, Myeclipse 6.5, and maven.
This what i have found, if you have anything to say write a comment, its important:
Don't forgot the add the axis2 directory to you path.
1) %AXIS2_HOME%\bin\wsdl2java -Eofv -g -uw -u -uri c:\salesforces\partner.wsdl -o c:\salesforce\generate -p com.test.salesforce
2) %AXIS2_HOME%\bin\wsdl2java -uri c:\salesforce\partner.wsdl -l java -d xmlbeans -p com.test.salesforce -sn SforceService -o c:\salesforce\generate
Bye,
Dor

Exception in thread "main" Java.lang.NoSuchFieldError: TRACE

Exception in thread "main" Java.lang.NoSuchFieldError: TRACE
at org.jboss.logging.Log4jLoggerPlugin.isTraceEnabled(Log4jLoggerPlugin.java:85)
at org.jboss.logging.Logger.isTraceEnabled(Logger.java:122)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:622)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:589)
at javax.naming.InitialContext.lookup(InitialContext.java:351)
at com.cognizant.util.ServiceHelper.initQueueService(ServiceHelper.java:153)
at com.cognizant.main.StartUp.(StartUp.java:28)
at com.cognizant.main.StartUp.main(StartUp.java:46)
solution
Upgrade your log4j version to 1.2.12 or higher in your classpath.

Spring LDAP dynamic connecting

Hi,
Lately i saw a question in one of spring ldap forums, were one of guys there asked this question:
How can i connect ldap without using spring xml (application context xml file).
My answer to him was that that i prefer and need in my project to use it dynamically intead of known configuration that can be configured in spring application context file (beans).
This was my solution for him:
LdapContextSource ldapContextSource = new LdapContextSource();
ldapContextSource.setUrl("ldap://localhost:portnumber");
ldapContextSource.setBase("ou=users, ou=system");//*
ldapContextSource.setUserDn("username to connect");
ldapContextSource.setPassword("password");
ldapContextSource.afterPropertiesSet();
//* the base is not necessary needed, it depends what do you need.
Bye,
Dor

Unexpected error: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty

Hi,
This exception might occur in:
1) Your key store file is corrupt and you should create it again.
(send a post if you need any help)
2) Your application failed loading the certificates key store (mentioned above).
Hoped i helped,
Dor

bad major version at offset=6

Hi,
Mainly happens or appears when you have a different java versions installed in your IDE / Server.
Try to be consist with the versions you are working with or compiling with or working in the server you have.
Bye,
Dor

Generate random passwords

Hi,
Here is a simple way with no effort to create random passwords like with the characters you want.
You will need this member:
private static final String charset = "aAbBcCdD$#eEf!=m2MnN3oOp4P8VwWx9XyY0zZ";
And this method:
public String getPasswordString(int length) {
Random randomSeed = new Random(System.currentTimeMillis());
StringBuilder result= new StringBuilder();
for (int i = 0; i < length; i++) {
int pos = randomSeed .nextInt(charset.length());
result.append(charset.charAt(pos));
}
return result.toString();
}
Of course there is another way by using the UUID object:
UUID.randomUUID().toString();
Or maybe using an external third party library.
Hoped i helped,
Dor

Uncaught exception: java.lang.OutOfMemoryError: PermGen space

Hi,
Cause:
Memory leak or imperfect memory management of one of your modules.
Solutions:
  1. Restart what you have done all over, if it was a server for example. This may happen when one of your    modules failed to be removed from memory.
  2. Increasing your heap memory buy running with 
Dor

Delete a service on windows xp

A little tip,
Have you ever wanted to have a simple way to delete unnecessary windows service ?
There is a simple way:
Enter on your on risk to "Start;Run;regedit".
Open "HKEY_LOCAL_MACHINE";"SYSTEM";"CurrentControlSet";"Services"
Select the service you want to delete, right click over it and delete it.
Finally, reset your computer.

Javascript regular expression

Hi,
Nice online javascript regular expression checker that i have found good.
Dor

HtmlSelectOneMenu does not have a converter

Hi,
Lately i had this exception, i "googled" to seek for an answer but nothing unambiguous.
My assumption is the usage of none string object as an id within the SelectedItem object.
By the book it said that it should be supported but in the real world it seems that it doesn't.
My temporary solution for this is:
1) Changing the id into string object.
or
2) Using toString() method which inhertied from the Object base class.
Hoping that it helps,
Dor

ParserInitializationException: Error initializing parser

Using apache commons net,
If you are trying to connect using FtpClient but it fails with the above exception.
Try this solution:
FTPClientConfig ftpClientConfig = new FTPClientConfig(FTPClientConfig.SYST_UNIX);
ftpClient.configure(ftpClientConfig);
FTPClientConfig constant list includes many types. For me, this type works.
Dor

is not recognized as valid Java method annotated with @HttpMethod.

Can occur if by mistake you mixed the usage of @GET and @FormParam instead of using @PathParam.

Change IE "View Source" editor

Hi Everyone,
You probably tought about this but never checked.
How simple is it to replace the default Notepad editor within IE with another one, for example the notepad++.
So i have checked this out and look how simple it is:  From what i have checked, it is working also on IE7.
Do it on your own risk:
1) Start;Run;regedit
2) Go to HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\
3) Add new key with the name "View Source Editor"
4) To the previous one, add new key with the name "Editor Name"
5) Change its default data value by pressing right click on "(Default)", then "Modify"
6) In the value add the exact location of your editor, for example "c:\notepad++.exe"
That's ,
Dor

Why i need the serialVersionUID?

Hi,
So many times i have been asked "what's for", "why i need it". It is very that you add this static variable to you class. The reason is simple, run time calculation cost for computing this UID can result in unexpected class exception, performance etc.
The object is needed for serialization process and deserialization.
I recommend you also to read http://java.sun.com/j2se/1.5.0/docs/api/java/io/Serializable.html.
Regards,
Dor

Fail to convert to internal representation

Hi,
Once it happened to me, you figure out what's wrong, write it down for just in case.
Then it happens to your friend.
It means that one of the types defined in your hibernate hbm file or annotated is wrong.
For example if you need to represent in your hbm file a boolean as the primitive type or it's appropriate wrapper, you may use "yes_no" as the type.
Dor

get heap dump

get into command line.
use jmap tool which can be located within bin directory of your jdk installation directory.
you can run it alone and see all of its parameters or use this example:
"jmap -dump:format=b,file=heap.bin [pid]"
[pid] should be replaced with the appropriate process identifier (use task manager to get it).
Hopefully that helps a bit,
Dor

read heap dump

I suggest using eclipse MAT plug in, which can be found here.
After installing the plug in, use file->Open and open the heap.bin you have created (jmap for example).
It will take a while, depends on your computer hardware, but in the end, you would be able to analyaze this memory dump.
Hopefully it helps,
DOr

This application is out of date, please click the refresh button on your browser. ( Expecting version 5 from client, got 6. )

Common issue after upgrading to GWT 2.1 from previous versions.
If you got this exception, probably you application has gwt-servlet.jar which belongs to the previous version.
Replace it or remove and let you environment to create it instead of the old one.
Worked for me.
Hoping it helps,
Dor

gwt datetimeformat

DateBox startDate = new DateBox();
DefaultFormat dateFormat = new DefaultFormat(){
DateTimeFormat dateTimeFormat = DateTimeFormat.getFormat("MM/dd/yyyy");
@Override
public String format(DateBox box, Date date){
           if (date == null) {
               return "";
            } else {
                return dateTimeFormat.format(date);
            }
  }
};
// attaching formatter
startDate.setFormat(dateFormat);
That's all. Your date would be formatted as MM/dd/yyyy
You can find some more formatters at Google gwt site.
Or GWT in Practice
bye,
Dor

gin.jar

Hi,
Currently there is no jar to download and you must do the job by your self.
To compile gin with ant, svn checkout the latest version from google trunk.
You need to set up a user / system environment variable, restart your IDE and then use ant on build.xml
The new "gin.jar" file will be created in the out\dist directory.
That suite for me. You can also click here for more help.
Dor

gwt compile speed

Hi,
Wondered if there is a solution for gwt permutation compile time, some way to speed it up, because 12 permutation compilation takes time, So there is one,
by adding the following option inside the compiler arguments:
"-localWorkers 2"
The "2" is the number of cores you got on the compiling computer and can be changed.
Hoped i helped,
Dor

IsSerializable

Hi,
Once i was asked by one of our developers, why can't i use the regular Serialzable marker instead of using
IsSerializable.
Simple answer is: You can but, there are several manners that should be take in considerations when doing that.
Better, read Google reference.
Regards,
Dor

JBoss deployment sequence

I have found two possible ways of changing jboss deployment sequence. If you know more, share with us.
  1. Edit "org.jboss.deployment.MainDeployer-xmbean.xml" file, which can be foundon "jbossdirectory\server\default\conf\xmdesc" directory. Inside the file you have a line like this "100:deployer,100:deployer.xml,200:sar,200:service.xml,300:rar,300:ds.xml,500:jar,600:war,600:wsr,600:ear,700:zip,900:last"This section defines the priority or sequence of *.sar for example before *.rar. You can switch between *.sar to be 700 for example and it will run after deploying the war. I would use it only for test environment but not for deployment or release. Choosing this option for my opinion is not a good design.
  2. In case you have a jboss service like i did as a "SAR" file, you can add a dependency tags into the "jboss-service.xml" file. For example: jboss:service=invoker,type=jrmp
Have a good day,
Dor

JBoss deployment sequence

I have found two possible ways of changing jboss deployment sequence. If you know more, share with us.
  1. Edit "org.jboss.deployment.MainDeployer-xmbean.xml" file, which can be foundon "jbossdirectory\server\default\conf\xmdesc" directory. Inside the file you have a line like this "100:deployer,100:deployer.xml,200:sar,200:service.xml,300:rar,300:ds.xml,500:jar,600:war,600:wsr,600:ear,700:zip,900:last"This section defines the priority or sequence of *.sar for example before *.rar. You can switch between *.sar to be 700 for example and it will run after deploying the war. I would use it only for test environment but not for deployment or release. Choosing this option for my opinion is not a good design.
  2. In case you have a jboss service like i did as a "SAR" file, you can add a dependency tags into the "jboss-service.xml" file. For example: jboss:service=invoker,type=jrmp
Have a good day,
Dor

svn: Directory .svn containing working copy admin area is missing

Cause:
admin directory inside the .svn directory is missing.
Or you have deleted some of the inner directories inside above .svn directory or the directory it self.
Possible Solutions:
  • Checkout your project again.
  • Undo your delete process before.
Dor

Attempted to lock an already-locked dir

Hi,
It happens sometimes, uncleared to me why, but the solution is simple:
  • Enter to the problematic directory, inside that directory enter ".svn" directory and delete the ".lock" file. Then try to do what you tried before again and see if its OK.
  • Exit your IDE, do the first solution, seek for temp files in that directory too and delete them also. Then try to do what you tried before again and see if its OK.
Else, You got a problem... :) and you need to find more help..
Dor

Buildfile: build.xml does not exist!

If you got this error, try running your build file like this:
"ant -buildfile filepath\filename.xml"
You need also to have %JAVA_HOME%\bin and %ANT_HOME%\bin defined in your path.

reset svn eclipse password

This is a windows installation solution, for Linux installations please check the web.
1) Go to, C:\Documents and Settings\yourusername\Application Data\Subversion\auth\svn.simple
2) Delete the file

WARNING: Application does not specify an API level requirement!

Using Eclipse 3.6, My application is for Froyo and according to this link (click here) i need 8 as the minimum sdk version number.
Add this tag below to your manifest file, usually named like "AndroidManifest.xml"
<uses-sdk android:minSdkVersion="8" />