Add the following to CATALINA_OPTS
-verbose:gc -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -Xloggc:/home/PATH_TO_LOG/gc.log
07 February 2014
06 February 2014
Command to remove files older than N days
The below command removes files older than 2 days in the current directory
sudo find . -mtime +2 -exec rm {} \;
sudo find . -mtime +2 -exec rm {} \;
07 January 2014
Monitoring open connections in MySQL
Use the following commands
show status like '%onn%';
show processlist
show status like '%onn%';
show processlist
03 August 2013
Renew SSL certificates - courier and imap server in Ubuntu
Remove the expired .pem file
rm /etc/courier/imapd.pem
Just open and check if the entries are recent (like contact email etc). This is NOT a mandatory step.
nano /etc/courier/imapd.cnf
Issue the following command to create new .pem file
mkimapdcert
Restart imap SSL service
/etc/init.d/courier-imap-ssl restart
rm /etc/courier/imapd.pem
Just open and check if the entries are recent (like contact email etc). This is NOT a mandatory step.
nano /etc/courier/imapd.cnf
Issue the following command to create new .pem file
mkimapdcert
Restart imap SSL service
/etc/init.d/courier-imap-ssl restart
20 June 2013
Configuration parameter to make git ignore carriage return difference
Configuration parameter to make git ignore carriage return difference
in Unix/Linux and Windows
git config core.autocrlf false
29 May 2013
11 April 2013
09 April 2013
04 June 2012
Ubuntu 12.04 and mysql does not start
Once you upgrade to Ubuntu 12.04 and if you had configured mysql to use UTF character set, the mysql server may not start.
This is due to the following deprecated parameters.
default-character-set=utf8
default-collation=utf8_unicode_ci
Replace the above parameters (they are normally in /etc/mysql/my.cnf)
character-set-server = utf8
collation-server = utf8_unicode_ci
Now restart mysql server using the command
This is due to the following deprecated parameters.
default-character-set=utf8
default-collation=utf8_unicode_ci
Replace the above parameters (they are normally in /etc/mysql/my.cnf)
character-set-server = utf8
collation-server = utf8_unicode_ci
Now restart mysql server using the command
sudo service mysql start
06 April 2012
03 March 2012
ProGuard - A case to disable shrink
Assume you are obfuscating a jar in a web application (say you deploy it on machines where you want to protect from decompile+disassembling).
If you come across the error message "The output jar is empty. Did you specify the proper '-keep' options?" , disable shrinking (as you may not have a valid main method entry point in a web application.
If you come across the error message "The output jar is empty. Did you specify the proper '-keep' options?" , disable shrinking (as you may not have a valid main method entry point in a web application.
13 November 2011
How to find if Apache is running prefork or worker MPM
Use the command
apache2 -l
It should list modules like
Compiled in modules:
core.c
mod_log_config.c
mod_logio.c
worker.c
http_core.c
mod_so.c
As worker.c is displayed then it uses worker MPM.
23 October 2011
Shortcut to show desktop in Ubuntu 11.10
Upgraded to Ubuntu 11.10 today.
The default short cut to show desktop minimizing all windows is Alt+Ctrl+D
Install tint2 (sudo apt-get install tint2) for the taskbar to switch between applications. Also add it to startup so that it appears after logging in.
The default short cut to show desktop minimizing all windows is Alt+Ctrl+D
Install tint2 (sudo apt-get install tint2) for the taskbar to switch between applications. Also add it to startup so that it appears after logging in.
21 October 2011
PrimeFaces Themes Dependencies
<dependency>
<groupId>org.primefaces.themes</groupId>
<artifactId>aristo</artifactId>
<version>${theme.version}</version>
</dependency>
<dependency>
<groupId>org.primefaces.themes</groupId>
<artifactId>black-tie</artifactId>
<version>${theme.version}</version>
</dependency>
<dependency>
<groupId>org.primefaces.themes</groupId>
<artifactId>blitzer</artifactId>
<version>${theme.version}</version>
</dependency>
<dependency>
<groupId>org.primefaces.themes</groupId>
<artifactId>bluesky</artifactId>
<version>${theme.version}</version>
</dependency>
<dependency>
<groupId>org.primefaces.themes</groupId>
<artifactId>casablanca</artifactId>
<version>${theme.version}</version>
</dependency>
<dependency>
<groupId>org.primefaces.themes</groupId>
<artifactId>cupertino</artifactId>
<version>${theme.version}</version>
</dependency>
<dependency>
<groupId>org.primefaces.themes</groupId>
<artifactId>dark-hive</artifactId>
<version>${theme.version}</version>
</dependency>
<dependency>
<groupId>org.primefaces.themes</groupId>
<artifactId>dot-luv</artifactId>
<version>${theme.version}</version>
</dependency>
<dependency>
<groupId>org.primefaces.themes</groupId>
<artifactId>eggplant</artifactId>
<version>${theme.version}</version>
</dependency>
<dependency>
<groupId>org.primefaces.themes</groupId>
<artifactId>excite-bike</artifactId>
<version>${theme.version}</version>
</dependency>
<dependency>
<groupId>org.primefaces.themes</groupId>
<artifactId>flick</artifactId>
<version>${theme.version}</version>
</dependency>
<dependency>
<groupId>org.primefaces.themes</groupId>
<artifactId>glass-x</artifactId>
<version>${theme.version}</version>
</dependency>
<dependency>
<groupId>org.primefaces.themes</groupId>
<artifactId>hot-sneaks</artifactId>
<version>${theme.version}</version>
</dependency>
<dependency>
<groupId>org.primefaces.themes</groupId>
<artifactId>humanity</artifactId>
<version>${theme.version}</version>
</dependency>
<dependency>
<groupId>org.primefaces.themes</groupId>
<artifactId>le-frog</artifactId>
<version>${theme.version}</version>
</dependency>
<dependency>
<groupId>org.primefaces.themes</groupId>
<artifactId>midnight</artifactId>
<version>${theme.version}</version>
</dependency>
<dependency>
<groupId>org.primefaces.themes</groupId>
<artifactId>mint-choc</artifactId>
<version>${theme.version}</version>
</dependency>
<dependency>
<groupId>org.primefaces.themes</groupId>
<artifactId>overcast</artifactId>
<version>${theme.version}</version>
</dependency>
<dependency>
<groupId>org.primefaces.themes</groupId>
<artifactId>pepper-grinder</artifactId>
<version>${theme.version}</version>
</dependency>
<dependency>
<groupId>org.primefaces.themes</groupId>
<artifactId>redmond</artifactId>
<version>${theme.version}</version>
</dependency>
<dependency>
<groupId>org.primefaces.themes</groupId>
<artifactId>rocket</artifactId>
<version>${theme.version}</version>
</dependency>
<dependency>
<groupId>org.primefaces.themes</groupId>
<artifactId>sam</artifactId>
<version>${theme.version}</version>
</dependency>
<dependency>
<groupId>org.primefaces.themes</groupId>
<artifactId>smoothness</artifactId>
<version>${theme.version}</version>
</dependency>
<dependency>
<groupId>org.primefaces.themes</groupId>
<artifactId>south-street</artifactId>
<version>${theme.version}</version>
</dependency>
<dependency>
<groupId>org.primefaces.themes</groupId>
<artifactId>start</artifactId>
<version>${theme.version}</version>
</dependency>
<dependency>
<groupId>org.primefaces.themes</groupId>
<artifactId>sunny</artifactId>
<version>${theme.version}</version>
</dependency>
<dependency>
<groupId>org.primefaces.themes</groupId>
<artifactId>swanky-purse</artifactId>
<version>${theme.version}</version>
</dependency>
<dependency>
<groupId>org.primefaces.themes</groupId>
<artifactId>trontastic</artifactId>
<version>${theme.version}</version>
</dependency>
<dependency>
<groupId>org.primefaces.themes</groupId>
<artifactId>ui-darkness</artifactId>
<version>${theme.version}</version>
</dependency>
<dependency>
<groupId>org.primefaces.themes</groupId>
<artifactId>ui-lightness</artifactId>
<version>${theme.version}</version>
</dependency>
<dependency>
<groupId>org.primefaces.themes</groupId>
<artifactId>vader</artifactId>
<version>${theme.version}</version>
</dependency>
<groupId>org.primefaces.themes</groupId>
<artifactId>aristo</artifactId>
<version>${theme.version}</version>
</dependency>
<dependency>
<groupId>org.primefaces.themes</groupId>
<artifactId>black-tie</artifactId>
<version>${theme.version}</version>
</dependency>
<dependency>
<groupId>org.primefaces.themes</groupId>
<artifactId>blitzer</artifactId>
<version>${theme.version}</version>
</dependency>
<dependency>
<groupId>org.primefaces.themes</groupId>
<artifactId>bluesky</artifactId>
<version>${theme.version}</version>
</dependency>
<dependency>
<groupId>org.primefaces.themes</groupId>
<artifactId>casablanca</artifactId>
<version>${theme.version}</version>
</dependency>
<dependency>
<groupId>org.primefaces.themes</groupId>
<artifactId>cupertino</artifactId>
<version>${theme.version}</version>
</dependency>
<dependency>
<groupId>org.primefaces.themes</groupId>
<artifactId>dark-hive</artifactId>
<version>${theme.version}</version>
</dependency>
<dependency>
<groupId>org.primefaces.themes</groupId>
<artifactId>dot-luv</artifactId>
<version>${theme.version}</version>
</dependency>
<dependency>
<groupId>org.primefaces.themes</groupId>
<artifactId>eggplant</artifactId>
<version>${theme.version}</version>
</dependency>
<dependency>
<groupId>org.primefaces.themes</groupId>
<artifactId>excite-bike</artifactId>
<version>${theme.version}</version>
</dependency>
<dependency>
<groupId>org.primefaces.themes</groupId>
<artifactId>flick</artifactId>
<version>${theme.version}</version>
</dependency>
<dependency>
<groupId>org.primefaces.themes</groupId>
<artifactId>glass-x</artifactId>
<version>${theme.version}</version>
</dependency>
<dependency>
<groupId>org.primefaces.themes</groupId>
<artifactId>hot-sneaks</artifactId>
<version>${theme.version}</version>
</dependency>
<dependency>
<groupId>org.primefaces.themes</groupId>
<artifactId>humanity</artifactId>
<version>${theme.version}</version>
</dependency>
<dependency>
<groupId>org.primefaces.themes</groupId>
<artifactId>le-frog</artifactId>
<version>${theme.version}</version>
</dependency>
<dependency>
<groupId>org.primefaces.themes</groupId>
<artifactId>midnight</artifactId>
<version>${theme.version}</version>
</dependency>
<dependency>
<groupId>org.primefaces.themes</groupId>
<artifactId>mint-choc</artifactId>
<version>${theme.version}</version>
</dependency>
<dependency>
<groupId>org.primefaces.themes</groupId>
<artifactId>overcast</artifactId>
<version>${theme.version}</version>
</dependency>
<dependency>
<groupId>org.primefaces.themes</groupId>
<artifactId>pepper-grinder</artifactId>
<version>${theme.version}</version>
</dependency>
<dependency>
<groupId>org.primefaces.themes</groupId>
<artifactId>redmond</artifactId>
<version>${theme.version}</version>
</dependency>
<dependency>
<groupId>org.primefaces.themes</groupId>
<artifactId>rocket</artifactId>
<version>${theme.version}</version>
</dependency>
<dependency>
<groupId>org.primefaces.themes</groupId>
<artifactId>sam</artifactId>
<version>${theme.version}</version>
</dependency>
<dependency>
<groupId>org.primefaces.themes</groupId>
<artifactId>smoothness</artifactId>
<version>${theme.version}</version>
</dependency>
<dependency>
<groupId>org.primefaces.themes</groupId>
<artifactId>south-street</artifactId>
<version>${theme.version}</version>
</dependency>
<dependency>
<groupId>org.primefaces.themes</groupId>
<artifactId>start</artifactId>
<version>${theme.version}</version>
</dependency>
<dependency>
<groupId>org.primefaces.themes</groupId>
<artifactId>sunny</artifactId>
<version>${theme.version}</version>
</dependency>
<dependency>
<groupId>org.primefaces.themes</groupId>
<artifactId>swanky-purse</artifactId>
<version>${theme.version}</version>
</dependency>
<dependency>
<groupId>org.primefaces.themes</groupId>
<artifactId>trontastic</artifactId>
<version>${theme.version}</version>
</dependency>
<dependency>
<groupId>org.primefaces.themes</groupId>
<artifactId>ui-darkness</artifactId>
<version>${theme.version}</version>
</dependency>
<dependency>
<groupId>org.primefaces.themes</groupId>
<artifactId>ui-lightness</artifactId>
<version>${theme.version}</version>
</dependency>
<dependency>
<groupId>org.primefaces.themes</groupId>
<artifactId>vader</artifactId>
<version>${theme.version}</version>
</dependency>
16 October 2011
GlassFish 3.1 - Enabling mod_jk
- Ensure GlassFish server is up and running. (or use asadmin start-domain domain1 command)
- Execute asadmin create-http-listener --listenerport 8009 --listeneraddress 0.0.0.0 --defaultvs server jk-connector
- Execute asadmin set configs.config.server-config.network-config.network-listeners.network-listener.jk-connector.jk-enabled=true
- Final step is to restart GlassFish server. Thats it enjoy.
15 October 2011
Configuring JDBC Realm in GlassFish 3.1
Use the following sample in domain.xml (under config folder) in GlassFish. Change the digest-algorithm and encoding accordingly.
<security-service>
<auth-realm classname="com.sun.enterprise.security.auth.realm.jdbc.JDBCRealm" name="jdbcRealm">
<property name="jaas-context" value="jdbcRealm"></property>
<property name="datasource-jndi" value="jdbc/srack"></property>
<property name="user-table" value="users"></property>
<property name="user-name-column" value="username"></property>
<property name="password-column" value="password"></property>
<property name="group-table" value="groups"></property>
<property name="group-name-column" value="groupname"></property>
<property name="digest-algorithm" value="MD5"></property>
<property name="encoding" value="Base64"></property>
<property name="assign-groups" value=""></property>
</auth-realm>
............
More config here
.............
<security-service>
<auth-realm classname="com.sun.enterprise.security.auth.realm.jdbc.JDBCRealm" name="jdbcRealm">
<property name="jaas-context" value="jdbcRealm"></property>
<property name="datasource-jndi" value="jdbc/srack"></property>
<property name="user-table" value="users"></property>
<property name="user-name-column" value="username"></property>
<property name="password-column" value="password"></property>
<property name="group-table" value="groups"></property>
<property name="group-name-column" value="groupname"></property>
<property name="digest-algorithm" value="MD5"></property>
<property name="encoding" value="Base64"></property>
<property name="assign-groups" value=""></property>
</auth-realm>
............
More config here
.............
14 October 2011
SEVERE: Exception while loading the app GlassFish error CDI JPA
Verify if one of your @Named annotated backing bean which is ViewScoped or ConversationScoped is Serializable if you receive the error SEVERE: Exception while loading the app without any stacktrace in GlassFish 3.1
DataExporter dependent jars - iText and Apache POI version
If you are using PrimeFaces 3.x and wish to use dataExporter for producing pdf and xls files, iText
and Apache POI jars are required. If you are using Maven please include the following
dependencies.
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>3.7</version>
</dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>3.7</version>
</dependency>
<dependency>
<groupId>com.lowagie</groupId>
<artifactId>itext</artifactId>
<version>2.1.7</version>
</dependency>
<groupId>com.lowagie</groupId>
<artifactId>itext</artifactId>
<version>2.1.7</version>
</dependency>
13 October 2011
Listing long running conversations in CDI based web application
I am not sure if CDI provides APIs to list all long running conversations. So I came up with the below class.
Note: Time-out and eviction of conversations by the container when not in use for a long time to save resoruces is NOT considered in the code below.
- addConversation method when you begin a conversation like
- removeConversation when we end a conversation like
You can check of a long running conversation for a desired use case is already active like
Note: Time-out and eviction of conversations by the container when not in use for a long time to save resoruces is NOT considered in the code below.
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import javax.enterprise.context.SessionScoped;
import javax.inject.Named;
import java.util.ArrayList;
import java.util.List;
import javax.enterprise.context.SessionScoped;
import javax.inject.Named;
@NamedInject conversation and the above session scoped bean and invoke
@SessionScoped
public class SRackWorkSpace implements Serializable{
private List<String> cids=new ArrayList<String>();
public void addConversation(String cid){
cids.add(cid);
}
public void removeConversation(String cid){
cids.remove(cid);
}
public boolean isConversationActive(String cid){
return cids.contains(cid);
}
}
- addConversation method when you begin a conversation like
conversation.begin("deliverexam");
sRackWorkSpace.addConversation("deliverexam");
sRackWorkSpace.addConversation("deliverexam");
- removeConversation when we end a conversation like
sRackWorkSpace.removeConversation(conversation.getId());
conversation.end();.
conversation.end();.
You can check of a long running conversation for a desired use case is already active like
if (sRackWorkSpace.isConversationActive("deliverexam")) {
return "/YOUR_PATH_TO_XHTML_VIEW?cid=deliverexam&faces-redirect=true";
}
11 October 2011
Validating email field programmatically - Hibernate Validator
First the Email.java class
Let us say you have to validate a Collection of email values,public class Email {
@org.hibernate.validator.constraints.Email(message = "Email is not valid")
private String email;
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
}
import javax.validation.ConstraintViolation;
import javax.validation.Validation;
import javax.validation.Validator;
import javax.validation.ValidatorFactory;//More code here
Email emailClass = new Email();
ValidatorFactory factory = Validation.buildDefaultValidatorFactory();
Validator validator = factory.getValidator();
for (String e : emails) {
emailClass.setEmail(e.trim());
Set<ConstraintViolation<Email>> constraintViolations =validator.validate(emailClass);
if (!constraintViolations.isEmpty()) {
//Email is not valid. Perform the logic
}
}
I use Hibernate Validator implementation. Since I use Maven for build, the dependency is as below.
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>4.2.0.Final</version>
</dependency>
Subscribe to:
Posts (Atom)