Category: Linux

Installing Java on Ubuntu : double trouble

Installing JDK/JVM on Ubuntu
1. Download “jdk-6u29-linux-i586.bin” (or jdk-6u29-linux-x64.bin), NOT “jdk-6u29-linux-i586-rpm.bin”
* If there is no bin (it’s probably within tar.gz package)
  • RPM doesn’t work well on Ubuntu
2. Chmod 777 filename
3. run file
4. set “alternatives” for java
5. done!
Working with “alternatives” in Ubuntu:
sudo update-alternatives –list <name>
ex:
sudo update-alternatives –list java

sudo update-alternatives –install <link> <name> <path> <priority>
ex:
sudo update-alternatives –install “/usr/bin/java” “java” “/opt/java/32/jre1.6.0_16/bin/java” 1

sudo update-alternatives –set <name> <path>
ex:
sudo update-alternatives –set java /opt/java/32/jre1.6.0_16/bin/java

ORA-00957: duplicate column name with Hibernate

This error was particularly annoying, because it didn’t appear on my local machine, but only on the remote environment. Environments were exactly the same: Apache versions, Oracle driver versions,  the same DB is used. Everything else is same, because builds are managed by IVY. 

Looking at SQL that was generated, Hibernate was generating duplicate column names when an entity with several JOINED entities was being retrieved. I couldn’t set alias for related entities because I am using Criteria API and all relationships are configured by annotations.

I am still not sure what is the problem. The way I solved it is by making all related entities load LAZILY. Please let me know if someone finds an answer to this.

org.tigris.subversion.javahl.ClientException: svn: No repository found in …

This happened when I was trying to use repository from Eclipse using Subclipse plugin. The first time I was setting up repository in Eclipse I specified password based authentication, password was memorized and never asked again (because I clicked on checkbox to memorize it).

Because Subclipse and JavaHL got compatibility issues, and the error was mentioning JavaHL I was thinking problem is still with Subclipse and JavaHL versions incompatibility. Tried to re-install different Subclipse versions. Didn’t help.

So, here goes solution:

1. Clean passwords saved in Eclipse. Remove .keyring file from (eclipse_installed_dir/configuration/org.eclipse.core.runtime/)

2. Change authentication type to File based and specify path to your ~/.ssh/id_rsa (note, not id_rsa.pub)

3. Do any SVN action (update / commit / checkout … )

Deploy multiple virtual hosts on Tomcat 6

Dedicated to those of you who have spent TOO much time on this way under-documented topic:

First let’s start with a tomcat file structure.

TOMCAT FILE STRUCTURE

1. webapps – folder where applications should be placed to run (unless unpackWARs is set to false)
2. work/Catalina/host_name – place where temporary files are created when Tomcat is running, eg: servlet classes
When “unpackWARs” is set to false (in server.xml) entire site structure is created
* we should not care about this directory much because it is generated dynamically each time

DEPLOYING HOSTS without actual file structure
Add line as follows, and that’s it:

<Host name=”xxx” appBase=”webapps”
unpackWARs=”false” autoDeploy=”true”
xmlValidation=”false” xmlNamespaceAware=”false” >
<Context path=”” docBase=”/wherever/xxx.war” debug=”0″ reloadable=”true”/>
</Host>

* note: this way application FILE STRUCTURE is not created, probably because “webapps” folder cannot be used. Not sure about this one though, whatever the reason is what is important that no error messages are generated and application gets created in work/Catalina directory and, apparently, works happily from there.

– The problem with this approach is that if we cannot deploy web application that will read files on the server side.
– Application will fail to find files on the server, because files do not exists. Actually they exist in work/Catalina directory, however it is not the path application looks for while running. Application MUST be physically located in WEBAPPS directory for files to be found.

DEPLOYING HOSTS with actual file structure (THE RIGHT WAY!)
Add line as follows:

<Host name=”xxx” appBase=”webapps/xxx”
unpackWARs=”false” autoDeploy=”true”
xmlValidation=”false” xmlNamespaceAware=”false” >
<Context path=”” docBase=”/wherever/xxx.war” debug=”0″ reloadable=”true”/>
</Host>

Create directory in webapps folder called xxx. Copy-paste “manager” and “host-manager” directories from “webapps” directory to this directory. This step is very important, otherwise you will get this extremely annoying error in log files:

SEVERE: Error starting static Resources

…xxx/host-manager does not exist or is not a readable directory

Some online documentation will claim that you will need to mess with /conf/Catalina/xxx folder. Maybe with older Tomcat versions you will need to do that. I tested with version 6.0.32, all files in that folder are automatically generated.

Hope it makes someone’s life easier!

Starting research of a distributed DB

Our current billing system is becoming insufficient for handling real-time billing and real-time business operations  simultaneously. Hence, I am starting to look for better solutions. Right now system is running on Oracle (on a fast machine), but because tables have grown too big search times are taking longer and longer.

There are several paths to take:
– backup monthly or quarterly data, thus making tables smaller (but because system uses past data from time to time, especially when client asks for an old data, this does not seem a viable approach…)
– buy a stronger machine (not a long-term solution, and I don’t think top-management will approve anyways…)
– make a clustered distributed database (this seems like a good idea, but the system will need to be slightly redesigned, not sure to what extent though, in addition making Oracle clusters is a little of a hassle)
– make a real-time one-way replication of a database and assign purely SELECT queries to it (also sounds good,  but need to analyze proportion of select statements during overloads, less hassle but is it really gonna be useful)
– install another Open Source distributed database  and move non-integral high-load tables there (no experience with Open Source databases, will it be possible to extract and separate necessary tables, this is a very good in the long run tough)
 

In addition to those things, there is a need to virtualize servers (basically move them to virtual machines), because occasionally failing hardware (especially that unknown-brand made-in-China server) is driving me mad.

How to change root password in FreeBSD

1. Turn the system off.
2. Hit ESC when the OS boots up
3. Choose to boot into Single User Mode (option 4)
4. Select the default shell (/bin/sh)
5. When the machine is booted up and you see the prompt, enter:
* mount -u /
* mount -a
6. Type passwd to reset the password
7. Enter the new password and confirm it
8. Type reboot to reboot the machine (or press the shutdown button to reboot)