Setting up Jetty 7.4.x on CentOS 5.x as non-root daemon
Posted on 2:30 PM under centos daemon jetty non-root 1 comment
First, please make sure you've already installed JDK on your Centos box. There are tons of tutorials on how to do that :).
Now we will download and install Jetty, at the time of this writing, the latest version of Jetty is 7.4.5.v20110725. Every command listing below must be run as user root.
:7070/
Hope this help!
cd /opt wget http://download.eclipse.org/jetty/stable-7/dist/jetty-distribution-7.4.5.v20110725.tar.gz tar xzvf jetty-distribution-7.4.5.v20110725.tar.gz ln -s jetty-distribution-7.4.5.v20110725 jettyOK, we've just installed Jetty to /opt/jetty. Now we will setup Jetty to run on startup
cd /etc/init.d ln -s /opt/jetty/bin/jetty.sh jetty chkconfig --add jetty chkconfig --level 345 jetty onIt's a good practice to run Jetty as a non-root user, let's create a normal user called jetty
useradd -m jetty chown -R jetty:jetty /opt/jettyNow edit the startup script of Jetty located at /opt/jetty/bin/jetty.sh to include the following lines at the beginning (right after a bulk of commented lines describing various variables for Jetty)
JAVA_HOME=/opt/java JAVA=$JAVA_HOME/bin/java JAVA_OPTIONS=" -server -Xms256m -Xmx1024m -XX:+DisableExplicitGC " JETTY_HOME=/opt/jetty JETTY_USER=jetty JETTY_PORT=7070 JETTY_HOST=0.0.0.0 # If you don't set this to 0.0.0.0, jetty only listen on localhost JETTY_LOGS=/opt/jetty/logs/Now start up it:
service jetty startOpen your browser and navigate to http://
I've maintained the ibus-unikey package in Arch User Repository (AUR) for a while and suddenly my package disappeared. While I was wondering what happened to my package, I received an email from a Trusted User (TU) of Arch saying that my package had been moved to the community repo of Arch. Kudo to the ibus-unikey team for such a great piece of software which are so useful for Vietnamese Arch Users!
You are developing a Java web application, the final application will use some complex security framework (such as Spring Security, formerly Acegi, JSecurity or Shiro, etc.). But in some first milestones, the clients want you to show them the demo of the application, and they want to secure the demo site with a username/password (for things like NDA) and they don't want to wait for later milestones to have that. In this situation, you cannot integrate the above security frameworks because of time constraint, bugs or the complexity of the security frameworks.
A quick and dirty way to do this is using a built-in authentication mechanism of Tomcat (I'm using Tomcat 6.x).
First put those into your web.xml file:
If you use Spring Security, remember to remove Spring Security filter in the web.xml file. Now in your context file (the context.xml file in your META-INF of your web archive or in ther conf/Catalina/localhost/ context file), adding the following:EntireApp /* GET POST client client BASIC
Finally, edit the tomcat-users.xml (usually located at
Now, every time the clients access the demo site, the browser will pop up a dialog asking for username and password. After successfully authenticated, the clients will use the demo site as normal.
This authentication mechanism is the Basic access authentication. As the title said, this is a quick and dirty way to secure a web application on Tomcat 6.
Hope this saves you some time.
Vietnamese resource bundle for PrettyTime
Posted on 9:48 AM under 2 comments
I've just come across a Grails plugin called PrettyTime and I find it's really interesting library. Basically, it's utility library to format Date/Time value in a human-friendly form (eg: "right now", "two days ago", "3 months from now"...), it also supports localization for many languages but Vietnamese. So I decide to write a small resource bundle class for it.
Hopefully they will integrate this snippet into the next release of PrettyTime.
package com.ocpsoft.pretty.time.i18n;
import java.util.ListResourceBundle;
public class Resources_vi extends ListResourceBundle
{
private static final Object[][] OBJECTS = new Object[][] {
{ "CenturyPattern", "%n %u" },
{ "CenturyFuturePrefix", "" },
{ "CenturyFutureSuffix", " sau" },
{ "CenturyPastPrefix", "cách đây " },
{ "CenturyPastSuffix", "" },
{ "CenturyName", "thế kỷ" },
{ "CenturyPluralName", "thế kỷ" },
{ "DayPattern", "%n %u" },
{ "DayFuturePrefix", "" },
{ "DayFutureSuffix", " sau" },
{ "DayPastPrefix", "cách đây " },
{ "DayPastSuffix", "" },
{ "DayName", "ngày" },
{ "DayPluralName", "ngày" },
{ "DecadePattern", "%n %u" },
{ "DecadeFuturePrefix", "" },
{ "DecadeFutureSuffix", " sau" },
{ "DecadePastPrefix", "cách đây " },
{ "DecadePastSuffix", "" },
{ "DecadeName", "thập kỷ" },
{ "DecadePluralName", "thập kỷ" },
{ "HourPattern", "%n %u" },
{ "HourFuturePrefix", "" },
{ "HourFutureSuffix", " sau" },
{ "HourPastPrefix", "cách đây " },
{ "HourPastSuffix", "" },
{ "HourName", "giờ" },
{ "HourPluralName", "giờ" },
{ "JustNowPattern", "%u" },
{ "JustNowFuturePrefix", "" },
{ "JustNowFutureSuffix", " khắc sau" },
{ "JustNowPastPrefix", "cách đây " },
{ "JustNowPastSuffix", " khắc" },
{ "JustNowName", "" },
{ "JustNowPluralName", "" },
{ "MillenniumPattern", "%n %u" },
{ "MillenniumFuturePrefix", "" },
{ "MillenniumFutureSuffix", " sau" },
{ "MillenniumPastPrefix", "cách đây " },
{ "MillenniumPastSuffix", "" },
{ "MillenniumName", "thiên niên kỷ" },
{ "MillenniumPluralName", "thiên niên kỷ" },
{ "MillisecondPattern", "%n %u" },
{ "MillisecondFuturePrefix", "" },
{ "MillisecondFutureSuffix", " sau" },
{ "MillisecondPastPrefix", "cách đây " },
{ "MillisecondPastSuffix", "" },
{ "MillisecondName", "mili giây" },
{ "MillisecondPluralName", "mili giây" },
{ "MinutePattern", "%n %u" },
{ "MinuteFuturePrefix", "" },
{ "MinuteFutureSuffix", " sau" },
{ "MinutePastPrefix", "cách đây " },
{ "MinutePastSuffix", "" },
{ "MinuteName", "phút" },
{ "MinutePluralName", "phút" },
{ "MonthPattern", "%n %u" },
{ "MonthFuturePrefix", "" },
{ "MonthFutureSuffix", " sau" },
{ "MonthPastPrefix", "cách đây " },
{ "MonthPastSuffix", "" },
{ "MonthName", "tháng" },
{ "MonthPluralName", "tháng" },
{ "SecondPattern", "%n %u" },
{ "SecondFuturePrefix", "" },
{ "SecondFutureSuffix", " sau" },
{ "SecondPastPrefix", "cách đây " },
{ "SecondPastSuffix", "" },
{ "SecondName", "giây" },
{ "SecondPluralName", "giây" },
{ "WeekPattern", "%n %u" },
{ "WeekFuturePrefix", "" },
{ "WeekFutureSuffix", " sau" },
{ "WeekPastPrefix", "cách đây " },
{ "WeekPastSuffix", "" },
{ "WeekName", "tuần" },
{ "WeekPluralName", "tuần" },
{ "YearPattern", "%n %u" },
{ "YearFuturePrefix", "" },
{ "YearFutureSuffix", " sau" },
{ "YearPastPrefix", "cách đay " },
{ "YearPastSuffix", "" },
{ "YearName", "năm" },
{ "YearPluralName", "năm" },
{ "AbstractTimeUnitPattern", "" },
{ "AbstractTimeUnitFuturePrefix", "" },
{ "AbstractTimeUnitFutureSuffix", "" },
{ "AbstractTimeUnitPastPrefix", "" },
{ "AbstractTimeUnitPastSuffix", "" },
{ "AbstractTimeUnitName", "" },
{ "AbstractTimeUnitPluralName", "" } };
@Override
public Object[][] getContents()
{
return OBJECTS;
}
}
Hopefully they will integrate this snippet into the next release of PrettyTime.
A couple months ago, I moved my blog from Blogger to Wordpress, that's because Wordpress offers some nice themes. Recently, I've bought a new domain (my first domain actually) and I want to use that domain for my blog but it costs me 10$/year to use custom domain in Wordpress! Searching around and I found that Blogger let you use your custom domain for free with hassle-free setup. Horay!
Then I moved back to Blogger, but the problem arises, the ugly theme! I think it's the right time for me to learn CSS and start hacking Blogger API. And after 2 weeks of hard working, I've finished my custom theme for Blogger based on Natural Power theme for Wordpress.
I'm quite happy with the result I've got so far. Not too bad for a CSS newbie.
From the normal user perspective, Wordpress provides many useful functionality out of the box, but if flexibility is your top priority, Blogger is your best choice so far.
Then I moved back to Blogger, but the problem arises, the ugly theme! I think it's the right time for me to learn CSS and start hacking Blogger API. And after 2 weeks of hard working, I've finished my custom theme for Blogger based on Natural Power theme for Wordpress.
I'm quite happy with the result I've got so far. Not too bad for a CSS newbie.
From the normal user perspective, Wordpress provides many useful functionality out of the box, but if flexibility is your top priority, Blogger is your best choice so far.
I've just finished my first Grails project. To be honest, it's a quite good mind refreshment for me as a Java developer. Grails simplify alot of complex stuff of Java ecosystems like IoC(Spring), ORM(Hibernate), XML configuration with convention over configuration. It takes you less than 10 minutes to create a full working web application with Spring Security for authentication and authorization, Quartz for job scheduling and Hibernate for data persistence when you're familiar with it. Here are some Pros and Cons:
Pros:
Pros:
- Almost "zero learning effort" for Java developers (although it almost took me a week to get productive with it)
- No XML configuration
- GORM is much easier to work with comparing to Hibernate (both XML-based and annotation-based), dynamic methods for domain class is definitely a good selling point for me here. It saves me tons of DAO code.
- Lots of plugins to extend Grails functionalities
- Grails heavily uses convention-over-configuration but the documentation about conventions is not enough. Sometimes it get frustrated when you reading someone's code without knowing the convention his/her using.
- Bugs. Lots of it, just navigate to JIRA of Grails and you will know what I mean :)
- Lacking of good IDE support. First I've tried Spring STS, then NetBeans, then IntelliJ IDEA Ultimate (free trial) and finally finishing my first Grails project in Gedit!
ibus-unikey is now in the AUR
Posted on 9:48 PM under arch linux 2 comments
I've uploaded a PKGBUILD for ibus-unikey to the ArchLinux AUR. You can install it with yaourt like this:
Then add the following to your .bash_profile
PS: Ok, there is no spyware/malware/rootkit in this binary package! If you don't trust me, don't use this method and build the package yourself (this is the way I recommend)
yaourt -S ibus-unikeyIf you don't want to build from the source, you have to install all the dependencies first:
pacman -Sy gcc gconf gtk2And then download and install the binary package
Then add the following to your .bash_profile
export XMODIFIERS=@im=ibus
export GTK_IM_MODULE=ibus
export QT_IM_MODULE=ibus
PS: Ok, there is no spyware/malware/rootkit in this binary package! If you don't trust me, don't use this method and build the package yourself (this is the way I recommend)