Showing posts with label Web Apps. Show all posts
Showing posts with label Web Apps. Show all posts

Sunday, December 30, 2007

Installing PHP 5.2.5 on Windows XP for Tomcat 6.0.13 - Issues resolved

I was playing around with the idea of doing a small personal PHP project, and I decided to do a fresh install of the latest version of PHP, which is 5.2.5. Since I'm already using the Apache Tomcat 6.0.13 server, I decided to run PHP on that instead of setting up the Apache HTTP server. I've done something similar before, so I didn't think it would be much of a problem. However, it is a bit more tricky than expected.

Windows PHP installer is broken

Initially, I used the Windows installer. The PHP install directory used was "C:\Program Files\PHP". Installing was a breeze and I could even use the php5srvlt.jar and put it into the WEBINF\lib directory without doing anything. The reflect.properties and servlet.properties files already have the line

library=php5servlet

instead of

library=phpsrvlt

So I followed the steps outlined. When I tried to access the test page, I got this.
HTTP Status 500 -
type Exception report

message
description The server encountered an internal error () that prevented it from fulfilling this request.

exception
javax.servlet.ServletException: Servlet.init() for servlet php threw exception
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
.....(edited for brevity)

root cause
java.lang.UnsatisfiedLinkError: C:\Program Files\PHP\php5servlet.dll: Can't find dependent libraries
java.lang.ClassLoader$NativeLibrary.load(Native Method)
.....(edited for brevity)

I checked the install directory and php5servlet.dll was there. What are the dependent libraries? After reading some of comments on Angusman's site and some discussions on Java forums, it turns out that the problem is due to missing DLLs. I downloaded a tool called Dependency Walker. It is very useful, I loaded php5servlet.dll and got the following.

Dependency Walker says php5ts.dll is missing

So php5ts.dll is missing. Searched for the file on PECL4WIN but could not find it. So I downloaded the zipped PHP files, then I noticed that there is an error in the original installer for PHP 5.2.5. Apparently the updated installer still has issue.

Steps I took to get it working

  1. Uninstall the initial install and remove all the files in the install directory

  2. Unzip the downloaded PHP zipped file into the install directory.

  3. Download php5servlet.dll from PECL4WIN and put it in the install directory. If you don't have it you will get an error message like:
    exception
    javax.servlet.ServletException: Servlet.init() for servlet php threw exception
    org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
    .....(edited for brevity)

    root cause
    java.lang.UnsatisfiedLinkError: no php5servlet in java.library.path
    java.lang.ClassLoader.loadLibrary(ClassLoader.java:1682)
    .....(edited for brevity)


  4. Edit the following paths in the php.ini file: include_path = "C:\Program Files\PHP\PEAR", doc_root = "C:\Program Files\Apache Software Foundation\apache-tomcat-6.0.13\webapps", extension_dir = "C:\Program Files\PHP\ext"

  5. Uncomment a few extensions in php.ini and ensure the DLLs are in the extension directory, eg curl or bz2

  6. Save the php.ini file.

  7. If you right-click and php.exe, php-cgi.exe and php-win.exe and see the properties, you will see this message "Security: This file came from another computer and might be blocked to help protect this computer." I chose to unblock, but I'm not sure if there's any issue leaving it on.
    Security message

  8. Create web.xml, php5srvlt.jar and test page like what Angusman says in the appropriate directory in the webserver. If php5srvlt.jar is not in the correct directory you'll get an error message like this:
    exception
    javax.servlet.ServletException: Wrapper cannot find servlet class net.php.servlet or a class it depends on
    org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
    .....(edited for brevity)

    root cause
    java.lang.ClassNotFoundException: net.php.servlet
    .....(edited for brevity)

    I already have them so I skipped this.

  9. Create the following environment variables PHP_HOME="C:\Program Files\PHP", PHP_HOME_EXT="%PHP_HOME%\ext", PHPRC="%PHP_HOME%". PHPRC is used to determine the location of the php.ini file but it is not the only place where it can be set. The locations being searched for the php.ini file follows a certain order. For my purpose this setting PHPRC is sufficient. If this is not set, the default location will be used, and may result in php.ini not being loaded, which in turn results in the configuration settings being set to some unexpected values, modules not being loaded as seen in phpinfo(), etc. Some examples.

    Wrong include path
    Wrong include path
    Wrong extension directory
    Wrong extension directory

  10. Append the environment variables to the PATH environment variable.

  11. Reboot so that the PATH changes are set. If not, you'll get some error like this where the environment variable appears correctly on it's own but not in the PATH.
    Computer needs to be rebooted for PATH changes to be effected

Wednesday, November 21, 2007

Browsershots - web app to check your web page rendering

For most of us who do web pages, we don't have the luxury of a Common Operating Environment. That means, we're not in an intranet environment with standardised OS, browsers, etc. So there's the issue of making sure your webpage renders correctly, if at all, on different OSes and browsers. If resources such as hardware or software (like VMWare) are limited, a sensible solution would be to use Browsershots.

Basically it's a web app that lets you submit a website and check if it displays correctly on a variety of OSes and browsers. It will produce a bunch of screenshots which you can view and check if the rendering is correct.

test options

Hmm....this website doesn't quite pass the test.

test result

A note though. It might take some time to produce the results. If speed is an issue , you can consider getting priority processing.

Sunday, August 12, 2007

Granado Espada - Business model revealed, and bikinis too

Well, the long-awaited business model for Granado Espada has been announced, and along with it a lengthy piece on the rationale behind the decision. The goal is simply to make money, question is how to make it viable. Like, how do make sure 90% of the players don't quit once you start charging them in some form...lol. The dungeons don't seem to be congested with players today. :p

Plenty of talk about it on the forums (here, here, here, here...) and blogosphere. Don't have too much feelings about it, but generally I feel it is (might be?) a fair price to pay, provided they fix a few bugs, get rid of the botters and continue to create new content for the game. So what's the pricing gonna be like?

Granado Espada will run on a hybrid pay to play model.



Gamers will be required to invest at least SGD$9.90/P300/RM$20/USD$5.60 into the game per month via various payment methods. Minus a nominal fee, this amount will transfer into G-Points which can then be used at the cash shop for premium items. Players have the option to invest more than the minimum per month for large cash shop purchases:


Table of charges
Players will get locally priced game value cards from their local distributors. Watch your local distributor's official GE websites for more information.

Not sure if I'm understanding this correctly buy if you spend US $40, you can play for 1 year. That's around SGD $60, or 5 bucks per month. Seems affordable to me. But that's not saying I'm gonna subscribe to the game, cos there's other considerations like time.

And speaking of creating new content, look at what else has been revealed about Granado Espada recently. (First spotted in the House of Reclusion.)
Nice ....

Yeah, that's the scout and fighter with more than their armour removed. (And getting a bit too intimiate too)Summer

The gang's enjoying a bit of the sun and the breeze.

I suppose we'll soon be able to see them on our shores. It's nice to see that new content is being rolled out even as the players have to start paying for the game, hopefully it will enrich the whole experience. Customisation is a huge factor in MMORPGs. IMHO. Check out the Japanese site and the Korean site for more potential content coming our way.

Monday, August 6, 2007

Thunderbird not receiving new messages for RSS feeds

Recently a lot of my RSS feeds in Thunderbird were not updated. There seems to be some issue with receiving new messages, a lot of my feeds were affected, though not all. Here's what I did to resolve the issue.

  1. Right-click the affected feed and choose "Properties.." .

  2. Under the "General Information" tab, tick the checkbox "Check this folder for new messages".

  3. Click the "Rebuild Indexes" button.

  4. Click the "OK" button.

  5. From the toolbar, click the "Get Mail" button.


That managed to solve the problem, but you have to do steps 1 to 4 for each affected feed, before proceeding to step 5. It can be a pain if you have dozens of affected feeds, but I don't know of a better way.

Wednesday, June 6, 2007

Maven2 - installing 3rd party JARs

Have a little time these few days, trying to get familiarised with Maven2. Not for work, more for it's own sake, still stuck with a legacy app at work. Been reading about the praises for Maven over Ant but the learning curve for Maven is steeper than Ant. And I'm not sure that the Eclipse plugin is making it easier. Some accidents along the way when running "mvn clean" wiped out the entire webapps folder in Tomcat, not just the test app folder I was anticipating. Thankfully it's a fresh install of Tomcat 6, so it's just the default stuff that came along with it.

Anyway tried to manage some dependencies with Maven, wasn't as fuss-free as it's made out. Tried to compile a simple servlet under eclipse, but I couldn't add the dependency via the Eclipse plugin. Had to add it in manually in pom.xml.

Went to "C:\Documents and Settings\Administrator\.m2\repository" to take a look, looking for servlet-related strings. But not too sure about what I'm looking for so decided to install the JARs that came with Tomcat 6 in the end. Here's the commands I ran.



mvn install:install-file -DgroupId=tomcat -DartifactId=servlet-api -Dversion=6.0.13 -Dfile="C:\Program Files\Apache Software Foundation\Tomcat 6.0\lib\servlet-api.jar" -Dpackaging=jar



mvn install:install-file -DgroupId=tomcat -DartifactId=jsp-api -Dversion=6.0.13 -Dfile="C:\Program Files\Apache Software Foundation\Tomcat 6.0\lib\jsp-api.jar" -Dpackaging=jar



mvn install:install-file -DgroupId=tomcat -DartifactId=el-api -Dversion=6.0.13 -Dfile="C:\Program Files\Apache Software Foundation\Tomcat 6.0\lib\el-api.jar" -Dpackaging=jar



The Tomcat website has some instructions on using Tomcat libraries with Maven, but I can't figure out how to get Maven to download the libraries from the correct location.

Hang on, actually I do now. The following has to be added into pom.xml

[xml]

tomcat.staging.repos
http://tomcat.apache.org/dev/dist/m2-repository/org/apache


Friday, December 1, 2006

Increasing pipelines for a faster Firefox

Recently, the YUI team conducted an experiment on optimizing web page performance. Though the results are not ground-breaking, it is interesting to see the figures. Using the Pareto principle, which says 80% of the effects is achieved by 20% of the causes, the YUI team discovers where this 80% is.
Table 1 shows popular web sites spending between 5% and 38% of the time downloading the HTML document. The other 62% to 95% of the time is spent making HTTP requests to fetch all the components in that HTML document (i.e. images, scripts, and stylesheets). The impact of having many components in the page is exacerbated by the fact that browsers download only two or four components in parallel per hostname, depending on the HTTP version of the response and the user’s browser. Our experience shows that reducing the number of HTTP requests has the biggest impact on reducing response time and is often the easiest performance improvement to make.

What is network pipelining? Mozilla gives a good explanation here. One way to increase the number of pipelines for Firefox from the default of 4 is to type "about:config" in the address bar. In the filter bar, check that "network.http.pipelining" is true. Then filter for "network.http.pipelining.maxrequests" and set it to a value you desire. I entered 7 and felt Youtube loaded faster. Didn't really test the effects empirically though. It's not always the case that a higher value is better though. It's stated in mozillaZine that,
Higher values will cause a delay before the first request completes but will make the last request complete sooner. Higher values will also cause more of a delay if a connection fails.

Thursday, November 23, 2006

GIMP tutorial - Create a high-contrast grayscale image

This tutorial attempts to create a high-contrast grayscale image. Below are two methods to go about doing it, the first is quick and easy, while the second offers you more control over the distribution of gray values.

Method 1

  1. Open an existing image. On the menubar, File>>Open. I’ve chosen an image of the beautiful Kyoko Fukada.
    Step 1

  2. On the menubar, Layer>>Duplicate layer. Select the new copy of the image.Step 2

  3. On the menubar, Layer>>Colors>> Layers>>Colors>>Brightness-Contrast. Adjust brightness and contrast until you see desired results. Try and aim for an image with 3 or 4 strong colours.
    Step 3

  4. On the menubar, Layer>>Colors>> Desaturate.
    Step 4


Method 2

  1. Open an existing image. On the menubar, File>>Open. I’ve chosen an image of the beautiful Kyoko Fukada.

  2. On the menubar, Layer>>Duplicate layer. Select the new copy of the image.

  3. On the menubar, Layer>>Colors>>Levels. Extend the dynamic range of colors of the image.

  4. On the menubar, Layer>>Colors>>Curves. Once again, try and aim for an image with 3 or 4 strong colours. Experiment til you find the spread of colors you like.

  5. On the menubar, Layer>>Colors>> Desaturate.



That's the end of the tutorial.High-contrast greyscale images are useful for generating images that look like the are cel-shaded or duotone images.
Cel shaded
This is created by changing the mode of the top layer to "overlay".
Duotone
This is created using Layers>>Colors>>Color Balance and setting the Midtones and Shadows to red.Some books on GIMP.

Thursday, November 16, 2006

GIMP tutorial - Pencil Sketching II

This tutorial is based on Sweety's clean sketch tutorial for Photoshop. The steps are largely the same for GIMP. Compared to the previous tutorial, this tutorial produces a cleaner pencil sketch.

  1. Open an existing image. On the menubar, File>>Open. I’ve chosen an image of the beautiful Kyoko Fukada.
    Step 1

  2. On the menubar, Layer>>Duplicate layer. Select the new copy of the image.
    Step 2

  3. On the menubar, Layer>>Colors>> Desaturate.
    Step 3

  4. On the menubar, Layer>>Duplicate layer. Select the new copy of the image.
    Step 4

  5. On the menubar, Layer>>Colors>>Invert.
    Step 5

  6. From the layers dialog, change the mode of the inverted layer to "Dodge".
    Step 6

  7. From the menubar, Filters>>Blur>Gaussian blur. Set the blur radius to a value from 3 to 5. Apply.
    Step7


And this is the final image!
Final image

Some books on GIMP.

Sunday, November 5, 2006

GIMP tutorial - Pencil Sketching I

I've been playing around with GIMP these 2 days, and have managed to create a simple pencil sketch which I'm quite satisfied with. This tutorial serves as a reminder of the lessons I've learnt while using the software.

  1. Open an existing image. On the menubar, File>>Open. I've chosen an image of the beautiful Kyoko Fukada

    Step 1

  2. On the menubar, Layer>>Duplicate layer. Select a copy of the image.
    Step 2

  3. On the menubar, Layer>>Colors>>Desaturate
    Step 3

  4. Adjust the dynamic range of the image. On the menubar, Layer>>Colors>>Threshold
    Step 4

  5. On the menubar, Filters>>Edge detect>>Difference of Gaussians. Play around with the values until you see something you like in the preview window.
    Step 5


And that's the final image!

Some books on GIMP.