Brian Nettles
It's my blog and I share.


 

Archive for the ‘Information Technology’ Category

No connection properties specified - the user must supply JDBC connections

Thursday, June 26th, 2008

Was trying to get setup with Hibernate and ran into the following error and stack trace:

INFO: using JDK 1.4 java.sql.Timestamp handling
Dec 26, 2007 11:40:40 AM org.hibernate.connection.UserSuppliedConnectionProvider configure
WARNING: No connection properties specified - the user must supply JDBC connections
Exception in thread "AWT-EventQueue-0" org.hibernate.HibernateException: Hibernate Dialect
must be explicitly set
    at org.hibernate.dialect.DialectFactory.determineDialect(DialectFactory.java:57)
    at org.hibernate.dialect.DialectFactory.buildDialect(DialectFactory.java:39)
    at org.hibernate.cfg.SettingsFactory.determineDialect(SettingsFactory.java:426)
    at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:128)
    at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2009)
    at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1292)

This error occured as Hibernate was unable to locate the hibernate.cfg.xml file. To fix this, I had to change the way of calling the Hibernate Configuration class. For some reason, in my web based applications, the first example of calling the class worked perfectly. It did not work in my Swing application so I changed to the the second version below:

Version 1:
Configuration configuration = new org.hibernate.cfg.Configuration();

Version 2:
org.hibernate.cfg.Configuration configuration = new org.hibernate.cfg.Configuration().configure(”/hibernate.cfg.xml”);

java.lang.NoClassDefFoundError: net/sf/cglib/proxy/CallbackFilter

Thursday, June 26th, 2008

Ran across this error while setting up an application using Hibernate. After googling it some, I came across a thread (in Spanish) referencing the need to include the cglib-2.1.3.jar. That may have fixed the problem; nevertheless, the problem had to do with not including all of the hibernate jar files found in the hibernate-3-X-X.ga.zip file. There are more jar files needed than just hibernate.jar. Make certain you include all of jar files that are in the lib folder of the downloaded uncompressed hibernate file. If all of the files are included, you should not run into this error.

org.hibernate.MappingNotFoundException: resource: /Entry.hbm.xml not found

Thursday, June 26th, 2008

Ran across this error while building the Swing application with Hibernate. Originally, the Entry.hbm.xml file was placed deep in the directory structure next to the java class called Entry.java. Several ways of naming the xml file where tried. The only solution that worked in this case was to move the file outside of the classpath structure and place it in the root directory next to the hibernate.cfg.xml file.

An OSCommerce Review

Friday, June 20th, 2008

I give OSCommerce a C rating.
OSCommerce is an open source shopping cart for the web. It is free to download and fairly simple (but not without flaw) to install on a Red Hat Linux machine. I have now done two implementations of OS Commerce. The first was for a site that sells Tire Chains. The second site is one that sells camping gear.

Now, I don’t wish to offend anyone on the development team who spent long hard hours unrewarded without pay. I am using this program on two websites. I greatly appreciate your contributions.

Installation (B)
The installation was mostly straight forward. Create a website space in apache, add a subdirectory called catalog, and unzip the tar file into the catalog subdirectory. Remember to follow the instructions in the README.txt file.

My only issue came after installation, I had issues with certain images not wanting to display. My fix was an undesirable hack be removing some .htaccess files that were blocking access to the path. Check the logs for the paths that are being blocked. There is probably a better fix available - I simply was not able to find it.

Admin Console (B)
The console has a lot of good functionality. You can populate your shopping cart from within this console and manage your users. What I found lacking was the ability to have a backdoor to give discounts to individuals or to create orders bypassing the payment system directly used in the websites. Backdoor approaches for managing orders may have been nice; but not necessary as basic functionality. Working with Images I found to be tricky. I ended up taking a standard templated size for my product images of 428 x 300 and populated all of the product with that size.

Shipping Cost (D)
Certain modules exist out of the box; however, none of them were satisfactory to my needs unless I offered free shipping. I am creating a UPS Module which should most certainly be an out of the box item. My module is not yet ready for production use and it will probably be another two months from now before I will be able to get back to it to perfect it.

Credit Card Processing (D)
The Pay Pal module is very simple to implement. However, there is one huge flaw. If the user does not click on the very final link in paypal, the purchase will not get registered in the OSCommerce system; however, the purchasers credit card will get charged. That is really bad.

I tried signing up for payquake and all they offered was another Authorize.net payment gateway. PayQuake had no knowlege on how to use the out of the box module in OSCommerce and refused to support it. I personally refuse to go with Authorize.net as my experience with their customer service is probably the worst I have seen in a large company in my life-that is a topic for another day.

So I have concluded that I am having to piggybacking off of the out of the box credit card module with my own customizations to make it process credit card transactions in real time.

Basically, most non-programmers will be completely stuck at this point with no good alternative but to either switch shopping carts or pay someone to do some programming for them.

Theme Support (F)
Most open source web applications have strong theme support. This allows you to set up your own look and feel without disturbing application logic. Examples of this are Wordpress, Simple Machines Forum, and PHPBB–all of which have very good separations of display code from the application logic. OSCommerce display logic is very much embedded into the application logic. This causes two problems:

1. If you do know know php, then you will have a very difficult time doing any real customizing to your look and feel.

2. If you wish to upgrade to a newer out of the box version of OSCommerce, your look and feel will have to be redone. Upgrades in wordpress happen often for security reasons. It would be disasterous for the bloggers if thier themes were destroyed during every upgrade.

Customization (B+)
Some of the out of the box open source software programs are very rigid and difficult to customize. This largely depends on how much abstraction has been added. I personally hate overly abstracted programs because it takes longer to learn the abstraction then it does to just change plain old simple code. In my opinion, PHPBB and Media Wiki are examples of overly abstracted programs. Wordpress, Simple Machines Forums, and OSCommerce are not. As a result, it is not difficult to make a lot of basic changes that you or your client may desire in the shopping cart.

Conclusion (C)
If you do not have any PHP programming skills and you have no money to pay for a programmer, I would avoid this platform. Unfortunately, I do not have a good alternative for you. A friend of mine recommended Zencart. If you are a php programmer-or can afford one, with a little bit of effort, you can go a long ways with OSCommerce. It has its flaws, but it does work for me.

Automate Website Monitoring

Wednesday, June 11th, 2008

Some instability on one of the servers I manage has brought up the need to setup automated monitoring that will send email alerts in the event that a website is down. In looking at possible solutions, I was considering several alternatives. Two of them that stood out the strongest are as follows:

1. Use Powershell on a Windows Server.
2. Use a scripting language on one of our externally hosted Linux servers.

Using Powershell did look like a viable alternative. The only problem is that I have never used Powershell before and I decided that the learning curve to implement a solution was not one that I am ready to go through. Maybe later. Nevertheless, Dmitry Sotnikov has a good blog where he describes how he did it for the http://powergui.org website using Powershell.

Monitor Website Availability

What I choose to do instead was use Perl and the Crontab to set up monitoring.

I tested the setup on three different Linux Servers–all three are Red Hat Linux Enterprise Servers version 4.0 or 5.0. Below is the script that I created using Perl:


$mailprogpath='/usr/sbin/sendmail';

use lib '/var/www/cgi-bin/libwww-perl-5.69/lib';
use LWP::Simple;

$location = "http://mywebsite.com";

if(get($location))
{
    print "success";
}else
{
    # need to send email
    open (MAIL, "|$mailprogpath -t") or die ("Can't access $mailprogpath\n");
    $recipient_address = "brian.nettles\@domainname.com";
    print MAIL "To: $recipient_address\n";
    print MAIL "From: donotreply\@domainname.com\n";
    print MAIL "Subject:  $location Down\n\n";
    print MAIL "$location request timed out.  Website may be down.\n";
    close (MAIL);
}

So on the Linux server, I went into the directory where I store my crontab’d files and created a file called monitorwebsites.pland populated the file with the above script. I then tested the script by calling the following:

perl monitorwebsites.pl

It works well.

On one of the servers, I had an issue with use LWP::Simple;. The perl script would not run on that particular server as the LWP module was not loaded. I found some good instructions on how to load that module at the following url:

Installing LWP::Simple module, Do it yourself instructions

The next thing I needed was to schedule the Perl script in the Crontab. If you don’t know what the Crontab is, that is a scheduling device built into Linux/Unix systems to run automated tasks. I found some great instructions on how to setup the Crontab on Linux machines at the following URL:

Schedule Tasks on Linux Using Crontab

The first command here opens up the crontab so that you can add an entry. The second line below is the entry that calls on the script every fifteen minutes.

sudo crontab -e
*/15 * * * * perl /directoryforscripts/monitorwebsites.pl

This was pretty simple. Took me about 4 hours total to research, write, and implement this.

Configuring Tomcat to work with IIS

Saturday, June 7th, 2008

The first question is whether you should use Tomcat or Resin as your application server. Here are some quick pros and cons with each.

  • Pro for Tomcat - Third party software is more likely to run on Tomcat than Resin
  • Pro for Tomcat - Sessions don’t get lost on server restarts
  • Pro for Tomcat - Tomcat is built on open source standards and has more documentation
  • Pro for Tomcat - Tomcat is free
  • Pro for Resin - Resin is a lot easier to integrate with IIS than Tomcat

I have now set up Tomcat to work behind IIS more than once. I know the challenges that go along with it. If you miss one small item on the list that needs to be configured, your installation will fail. And the logs don’t always point you in the right direction. It truely is a challenge to make Tomcat and IIS work together, but once it does, you will be glad you did it.

1. Install Tomcat as a Windows Service
The simplest place to start is with tomcat. Make certain you download the version using the Windows installer and go ahead and install it as a service. Make certain you remove all spaces that are in your installation. After Tomcat is installed, point your browser to it at http://localhost:8080/. You should then get your Tomcat home page. Now lets get IIS to work with it prior to adding your own application to tomcat.

2. Add the Configuration and Connector Files
Create a directory in the Tomcat Home directory calle connectors. In the connectors directory, add a subdirectory for the name of your application such as “root”. Now in this connectors/root directory, add two files.

1. isapi_redirect-1.2.26.dll (or whatever the latest version is)
2. isapi_redirect-1.2.26.properties

You will need to download this isapi_redirect-1.2.xx.dll file from apache.org. Currently the url is http://tomcat.apache.org/download-connectors.cgi.

A sample of the isapi_redirect-1.2.26.properties files contains the following:

# Configuration file for the Jakarta ISAPI Redirector

# The path to the ISAPI Redirector Extension, relative to the website
# This must be in a virtual directory with execute privileges
extension_uri=/jakarta/isapi_redirect-1.2.26.dll

# Full path to the log file for the ISAPI Redirector
log_file=C:\Tomcat-5.5.25\logs\isapi_redirect.log

# Log level (debug, info, warn, error or trace)
log_level=debug

# Full path to the workers.properties file
worker_file=C:\Tomcat-5.5.25\conf\workers.properties

# Full path to the uriworkermap.properties file
worker_mount_file=C:\Tomcat-5.5.25\conf\uriworkermap.properties

Now we have two more configuration files to add. These two you should place in the conf directory:

1. workers.properties
2. uriworkermap.properties

A sample of the workers.properties is given below:

# Define 1 real worker using ajp13
worker.list=worker1

# Set properties for worker1 (ajp13)
worker.worker1.type=ajp13
worker.worker1.host=localhost
worker.worker1.port=8009

A sample of the uriworkermap.properties is given below:

/*=worker1
!/images/*=worker1
!*.jpg=worker1
!*.xmls=worker1
!*.gif=worker1
!*.bmp=worker1

For more information on these two files, search the following two urls:
http://tomcat.apache.org/connectors-doc/reference/workers.html
http://tomcat.apache.org/connectors-doc/reference/uriworkermap.html

3. Make the Registry Entries
Follow the example on this image by going into clicking start -> run -> regedit and the entries just like on this image. Click on the image to get a larger view of it.
Windows Registires

4. Configure IIS
Before you do anything with IIS, make certain you can see your web pages without interference from tomcat. Start by turning Tomcat and create a website and point it to the ROOT directory in the webapps directory of Tomcat. See if you can see the images when referencing them direct by url. ex. http://localhost/tomcat.gif. If you see the image, then you know IIS is working.

a. Add a new application pool that is copied from the default application pool.

 

b. Add a webservice extension and point it to the connectors.

c. Add a jakarta virtual directory

d. Make certain that every reference in this website to the application pool all point to the same newly created application pool.

e. Setup the isapi filter by calling it jakarta and point it to the isapi_redirect-1.2.26.dll file. After doing so, restart IIS and make certain you have a green arrow in place for the filter.
ISAPI Filters

Now try the url http://localhost without the reference to port 8080. If you see the default Tomcat application, you are in business.

5. Add your own application
Turn off Tomcat and rename the ROOT directory ROOT_ORIGINAL. Now recreate the ROOT folder and add your application into the ROOT directory. Now you can restart Tomcat, Restart IIS and check to see if your application shows up at http://localhost

If it doesn’t work, carefully check all of your settings.

6. Heap Size
Sometimes, your newly established application ends up running out of memory and therefore you need to adjust the heap size. This is done in the registries. Take a look at the image here. You may need to add a couple of entries to the registries as displayed here.

How to Redirect a Website to Remove the ‘www’

Friday, May 30th, 2008

Several months ago, I read in a blog where Matt Cutts spoke at a Wordpress Bootcamp. He specifically said that with Google, a website with www and the same website without the www are treated as two separate websites.  What I take from this is that if you trying to maximize your search engine results, it is better if you either stick with one or the other for your incoming links.

So the question comes up when using Apache as your webserver, how can you take your new website and redirect the www to the base url name.  In my example, I wanted http://www.wilderness-gear.com to redirect to http://wilderness-gear.com.  The answer is simple, use the .htaccess file.

Go to your base directory and check if you have a hidden file called .htaccess.  If you have one, then back it up immediately.  Your web application may be using it.  Wordpress does.  My example here is for a website that did not have an .htaccess file in the base directory.  So all I did was create the .htaccess file in the base directory and add the following:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.wilderness-gear\.com$ [NC]
RewriteRule ^(.*)$ http://wilderness-gear.com%{REQUEST_URI} [R=301,L]
</IfModule>

All done.  Now the http://www.wilderness-gear.com redirects to http://wilderness-gear.com.

mysqldump: Got error: 1146: Table ‘databasename.tablename’ doesn’t exist when doing LOCK TABLES

Monday, May 26th, 2008

Ran into this error tonight while copying tables from one database into another. 

I was using the mysqldump command as follows:

mysqldump -h localhost -u username -p --add-drop-table wildernessgear  wp_31_term_relationship /home/bnettles/wp_31_term_relationship.sql

This command was supposed to export just the one table wp_31_term_relationship.  I had already exported the 30 previous tables in the database.  All of a sudden this one was causing a problem with the following error message.

mysqldump: Got error: 1146: Table ‘wildernessgear.wp_31_term_relationship ‘ doesn’t exist when doing LOCK TABLES.

I searched the internet for a while and wasted a half an hour not being able to figure out how to unlock the tables.  Then I discovered the real problem.  The table did not exist.  There was a typo.  It was supposed to be wp_31_term_relationships with an “s” at the end, not wp_31_term_relationship.

Looks like Mysql is using the wrong error message in this case.


Blog Information Profile for Supertramp678