Theme Graphic
Theme Graphic

Varun's Blog

An attempt to learn by sharing knowledge with others. You are welcome to give your valuable opinions.

Subscribe

Author

Welcome to my blog. I am from Amritsar, India. Since 1999, I have been working in software industry. At the start of my career I worked on C/C++, CGI-Perl and ASP for few months each. But after about a year from start, it has been Java/J2ee throughout. Right now, we, a small team, are trying to make a small venture grow. Recently we started working on JSF, JBoss Seam and JPA in our project.

Archive

Tags

Posted on Tuesday, November 09, 2010 at 3:29 AM

apt-get install subversion – Package subversion is not available

On Ubuntu

$apt-get install subversion


Reading package lists… Done Building dependency tree Reading state information… Done Package subversion is not available, but is referred to by another package. This may mean that the package is missing, has been obsoleted, or is only available from another source

Solution

Go to System > Administration > Software Sources

Check all options (main, universe, restricted and multiverse – actually only main is required but in case you run into more problems, check all), close

Now run apt-get install subversion, it should work!!

Posted on Tuesday, November 09, 2010 at 3:22 AM

svn switch –relocate syntax and “client is too old to work with working copy”

I don’t think there is a provision in subclipse plugin to support --relocate tag with switch. You can use svn command line tool for this as below.

Example 1:

  • Go inside the folder on command line (suppose folder svn+ssh://abc.com/home/SVN/myproj/trunk is checked out on local machine under folder myproject):
cd myproject

  • Run this command to switch the SVN pointer from svn+ssh://abc.com/home/SVN/myproj/trunk to svn+ssh://def.com/home/svn/myproj/trunk
svn switch --relocate svn+ssh://abc.com/home/SVN/myproj/trunk svn+ssh://def.com/home/svn/myproj/trunk .

You should be done now!! Just go to eclipse and refresh project. You can restart eclipse if there’s still some problem. For other exceptions see ‘troubleshooting’ section below.

Example 2: In case your local machine username and svn username are different:

svn switch --relocate svn+ssh://abc.com/home/SVN/myproj/trunk svn+ssh://SVNUserName@def.com/home/svn/myproj/trunk ....
Comments: 0 Tags: SVN, switch, --relocate

Posted on Tuesday, November 09, 2010 at 2:50 AM

Subclipse Update Problem – eclipse 3.6 helios

Problem:

An error occurred while collecting items to be installed session context was:(profile=epp.package.java, phase=org.eclipse.equinox.internal.p2.engine.phases.Collect, operand=, action=). No repository found containing: osgi.bundle,org.eclipse.team.cvs.ssh,3.2.100.I20090508-2000

Solution:

When you update there is a checkbox on update window (last item):

“Contact all update sites during install to find required software”

Uncheck it – This should fix the problem and save a lot of time as well!!
Comments: 0 Tags: Eclipse, Update, Subclipse, helios

Posted on Tuesday, June 29, 2010 at 12:36 PM

DAO with JPA (and service layer/EJB3-Session Beans) or not

There is a lot of discussion on internet about whether to have DAOs or not with JPA and service layer or with session beans (which is the service layer).

My personal opinion is more favored towards DAO layer and some reasons for this are following:

1. In most of the database driven projects (except the simple ones), programmers will need to do more than direct fetch/store db calls. Even if Entity relationships are well defined what about reporting data and conditional data you will have to fetch (like fetch all users having bought products above price tag $300 in last 6 weeks). Pretty soon programmers may be writing native queries (sometimes for performance reason, which is valid). If there's no DAO layer, session beans may get heavily loaded with sql code rather than java code. If we push the sql code down to DAO layer, session beans will be much more focused on processing logic, easier to read and clean...

Posted on Wednesday, December 02, 2009 at 12:42 AM

Jboss AS - Access static files from external folder

Environment Linux, jboss-4.2.2.GA

1. Open /opt/jboss/server/<instance>/deploy/jboss-web.deployer/server.xml

2. Define new context under <Host name="localhost".......> tag for external folder:

<Context path="/myreports" docBase="/home/data/reports" reloadable="true"> </Context>

3. Restart Jboss

This means static files under /home/data/reports folder will be available by using following URL syntax:

http://server:port/myreports/filename

Note : When I type http://server:port/myreports in address bar of browser I see 404 error. I am still looking into how to allow directory listing of external folder. If you know, please share.

Posted on Wednesday, September 23, 2009 at 1:25 AM

An error has occurred in this dialog. Error:30 unspecified error

Couple of days back I tried to upgrade IE6 to IE8 on my XP machine. It did not work as expected, instead started giving kernel32.dll errors. To revert back I uninstalled IE8 and went back to IE6. But today when I started my computer there were strange problems, some of which are:

1. Oracle 11g won't come up. When I went to services, clicking any service name will show error dialogs ("An error has occurred in this dialog. Error:30 unspecified error" )

2. I was unable to type anything into textboxes in IE6. They were kind of disabled.

3. IE6>Help>About showed a similar error message

After much research I found the reason of this to be some missing entries from registry on my system.

Here's the solution that worked for me:
  • Open cmd
  • Type following one by one and press Enter:
regsvr32 mshtmled.dll regsvr32 jscript.dll regsvr32 /i mshtml.dll

It works now Good Luck!!
Comments: 0 Tags: Windows XP, IE6

Posted on Wednesday, August 05, 2009 at 4:03 AM

Host Credentials ERROR Invalid username and or password Oracle 11g

On Windows XP do following:

Go to Control Panel > Administrative Tools > Local Security Policy > Local Policies > User Rights Assignment

Search "Log on as batch job", double click it, click Add User or Group and add the userid you are trying to use under Oracle 11g. Once you do so, you should be able to login under Oracle 11g using this user's credentials.

Comments: 1 Tags: None

Posted on Sunday, May 17, 2009 at 10:40 PM

Linux "grep and copy"

Suppose I have a folder hierarchy as below:

f1 > f2

f2 > f3

f2 > f4

f4 > f5

I want to find all files in f1 or any of its descendant folder that contain text "I am a match" and copy them into f1's parent folder (whatever that is).

To accomplish above, run any of following commands from within f1 folder:

i) cp `grep -rl "i am a match" *` ..

ii) grep -rl "i am a match" * | xargs -i cp {} ..
Comments: 2 Tags: Copy, Linx, grep, cp

Posted on Thursday, May 14, 2009 at 11:51 PM

Linux - Get full path of a running process

2 ways that I know to get the full path of a process in linux:

1. /proc/<pid>/exe is a symlink to the actual exe. Here's what I get for a program eclipse running on my machine under pid 4825 with this command:

localhost:/home/Office # ls -la /proc/4825/exe

lrwxrwxrwx 1 Office users 0 May 15 11:30 /proc/4825/exe -> /opt/eclipse/eclipse


2. with ps command we can get the full path:

localhost:/home/Office # ps -u -p 4825

Warning: bad ps syntax, perhaps a bogus '-'? See http://procps.sf.net/faq.html

USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND

Office 4825 0.0 0.1 81452 2872 ? S 11:07 0:00 /opt/eclipse/eclipse


localhost:/home/Office # ps agx | grep 4825...
Comments: 1 Tags: None

Posted on Monday, May 11, 2009 at 10:36 PM

Linux Truncate File

Commands to empty logfile

i) :>logfile - If logfile does not exist, this will create an empty logfile, otherwise it will empty the existing file.

ii) cat /dev/null > logfile - This is equivalent to above command.

Command to truncate logfile to specific size

  • Sometimes we want to bring the size of a file down to specific bytes instead of removing all contents. Following command will keep initial 1000 bytes of data in file and remove everything after that (hence truncating the file to 1000 bytes):
iii) dd if=/dev/null of=logfile seek=1 bs=1000

Here dd is equivalent to copy command, 'if' stands for 'input file', means read from given file (in above example reading from /dev/null means read 'nothing'), 'of' stands for output file (write into this file), 'seek' means skip given number of blocks before starting to write (in above command it will skip 1 block of data), where block size is given with 'bs'. So in summary above command says, write 'NOTHING' into 'logfile' BUT skip 1 block of 1000 bytes before starting to write. Hence we are left with a file of 1000 bytes...
Comments: 1 Tags: File, Linux, Log Analysis, truncate

Posted on Friday, April 17, 2009 at 3:27 AM

find: paths must precede expression

In Linux bash you may face an error while using wildcard * to search files. For e.g. trying to search all jar files with following command:

find . -name *.jar

will give following error:

find: paths must precede expression

Usage: find [-H] [-L] [-P] [path...] [expression]


Reason is that * is interpreted by shell itself before arguments are passed to find command. * will resolve to all folders and files within current folder, hence does not make much sense with .jar extension at the end. For this reason we need to escape * somehow so that it goes to find command as it is, without expanded by shell. There are 2 ways that I know;

find . -name \*.jar

second is

find . -name '*.jar'


Posted on Thursday, April 02, 2009 at 4:39 AM

AJAX Response Race Condition

I am working on a j2ee project in which a lot of UI screens are AJAX based. Recently we started facing problems on some screens, which were not updating correctly. On one of the screens we have a lot of options with checkboxes to select them. Each checkbox click submits an asynchronous request to the server. While testing we noticed that if we click multiple checkboxes swiftly, the response from server is not processed in expected order.

As an example suppose checking box1 should show 100 in a textbox, while checking box2 should show 200. If I swiftly click box1 and then box2 (before response of box1 is rendered) then I should still see box2's result as final. I should see 200. But this was not happening. We were noticing box2's result displayed first and then overwritten by box1's result...

Posted on Wednesday, March 18, 2009 at 11:53 PM

To the point tutorial to learn Java by Examples

I am working on a Java tutorial, which I stared for students back in University where I graduated from. I am on chapter 6 at the moment, if you are looking for a practical, informal, short tutorial on Java do go through it. It is posted at following link:

http://jvarun.wordpress.com/approach-java-a-tutorial-for-beginners/
Comments: 0 Tags: Java, Java Tutorial

Posted on Tuesday, March 17, 2009 at 1:07 AM

install CUPS-PDF on SUSE 64-bit

What is CUPS-PDF

CUPS-PDF acts as a virtual printer but instead of printing hard copies of your files, it prints PDF files as output. It appears as a printer under printer list on your machine, and if you select that you would get a pdf file as output. That means you can use it as a pdf converter utility.

Installation steps on SUSE 64-bit

1. Download CUPS-PDF software from (in tar.gz format) http://www.physik.uni-wuerzburg.de/~vrbehr/cups-pdf/download.shtml

At this time of writing, latest available version is 2.5.0 (cups-pdf_2.5.0.tar.gz)

2. Unzip this in a temp folder

tar xvfz cups-pdf_2.5.0.tar.gz
3. Goto cups-pdf-2.5.0/src folder and compile CUPS-PDF source:

gcc -O9 -s -o cups-pdf cups-pdf.c


4. Previous step will create executable file cups-pdf in src folder. Copy cups-pdf file to /usr/lib64/cups/backend...

 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.