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.
23 October 2011
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>
Injection of EntityManager or CDI Bean in FacesConverter
Seam3 Persistence Module along with Faces Module helps in enabling CDI injection in FacesConverter belonging to JSF. Example below.
The Java class which produces the EntityManager is as below.
The related jars should be added to your web application. If you use Maven use the dependencies below.
Example Usage - xhtml file
<h:panelGrid columns="2">
<p:selectOneMenu value="#{searchMultipleChoiceQuestionAction.questionDataModel.selTag}" converter="questionTagConverter">
<f:selectItems value="#{searchMultipleChoiceQuestionAction.tags}" var="qt" itemLabel="#{qt.qtag}" itemValue="#{qt}"/>
</p:selectOneMenu>
<p:commandButton update="searchresult" action="#{searchMultipleChoiceQuestionAction.search()}" value="Search"/>
</h:panelGrid>
@FacesConverter(value = "questionTagConverter", forClass = QuestionTag.class)
public class QuestionTagConverter implements Converter{
@Inject
EntityManager entityManager;
@Override
public Object getAsObject(FacesContext fc, UIComponent uic, String string) {
return entityManager.find(QuestionTag.class, Integer.parseInt(string));
}
@Override
public String getAsString(FacesContext fc, UIComponent uic, Object o) {
return ((QuestionTag)o).getId().toString();
}
}
The Java class which produces the EntityManager is as below.
import javax.enterprise.context.ConversationScoped;
import javax.enterprise.inject.Produces;
import javax.persistence.EntityManagerFactory;
import javax.persistence.PersistenceUnit;
import org.jboss.seam.solder.core.ExtensionManaged;
public class EntityMgrProducer {
@ExtensionManaged
@Produces
@PersistenceUnit(name = "PU_NAMEHERE")
@ConversationScoped
EntityManagerFactory entityManager;
}
The related jars should be added to your web application. If you use Maven use the dependencies below.
<dependency>
<groupId>org.jboss.seam.faces</groupId>
<artifactId>seam-faces</artifactId>
<version>3.0.2.Final</version>
</dependency>
<dependency>
<groupId>org.jboss.seam.persistence</groupId>
<artifactId>seam-persistence</artifactId>
<version>3.0.0.Final</version>
</dependency>
Example Usage - xhtml file
<h:panelGrid columns="2">
<p:selectOneMenu value="#{searchMultipleChoiceQuestionAction.questionDataModel.selTag}" converter="questionTagConverter">
<f:selectItems value="#{searchMultipleChoiceQuestionAction.tags}" var="qt" itemLabel="#{qt.qtag}" itemValue="#{qt}"/>
</p:selectOneMenu>
<p:commandButton update="searchresult" action="#{searchMultipleChoiceQuestionAction.search()}" value="Search"/>
</h:panelGrid>
05 October 2011
Signing a jar file
As I had to sign the jar file (to provide it permissions), used the following command to sign the jar file.
Note: The srack.keys was generated earlier using a command like (as I was lazy specified 10 years validity :))
keytool -genkey -keystore srack.keys -alias https://www.skillrack.com/ -validity 3650
jarsigner -keystore PATHTO\srack.keys -storepass password PATHTOYOURJAR\audiorecording-1.0.jar https://www.skillrack.com/
Note: The srack.keys was generated earlier using a command like (as I was lazy specified 10 years validity :))
keytool -genkey -keystore srack.keys -alias https://www.skillrack.com/ -validity 3650
03 October 2011
GlassFish Error - javax.ejb.AccessLocalException: Client not authorized for this invocation
If you are using GlassFish (along with NetBeans and facing this error when invoking an EJB from a Servlet or any web layer class using @EJB inject, clear the generated policy files and redeploy the application.
Ensure a line for the (newly added or renamed) method being accessed is present in the policy file. An example is provided below.
permission javax.security.jacc.EJBMethodPermission "ExamManagementEJB", "getQuestionTags,Local,com.packagename.entity.SomeEntity";
Ensure a line for the (newly added or renamed) method being accessed is present in the policy file. An example is provided below.
permission javax.security.jacc.EJBMethodPermission "ExamManagementEJB", "getQuestionTags,Local,com.packagename.entity.SomeEntity";
Configuring Hibernate as JPA implementation provider in GlassFish
This post helps to configure Hibernate as JPA implementation provider replacing the bundled EclipseLink.
I am using Maven and mine is an EAR containing a WAR and an EJB module. Hence in the pom.xml of the EAR module, the following dependency is mentioned.
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>3.6.7.Final</version>
</dependency>
As this jar has to go into the lib folder directly under EAR ROOT, specify the value for defaultLibBundleDir (in pom.xml)
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ear-plugin</artifactId>
<version>2.4.2</version>
<configuration>
<version>6</version>
<defaultLibBundleDir>lib</defaultLibBundleDir>
Finally your persistence unit in persistence.xml
<persistence-unit name="yourPU" transaction-type="JTA">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>jdbc/yourDataSourceName</jta-data-source>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect" />
<property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.SunONETransactionManagerLookup" />
</properties>
</persistence-unit>
I am using Maven and mine is an EAR containing a WAR and an EJB module. Hence in the pom.xml of the EAR module, the following dependency is mentioned.
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>3.6.7.Final</version>
</dependency>
As this jar has to go into the lib folder directly under EAR ROOT, specify the value for defaultLibBundleDir (in pom.xml)
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ear-plugin</artifactId>
<version>2.4.2</version>
<configuration>
<version>6</version>
<defaultLibBundleDir>lib</defaultLibBundleDir>
Finally your persistence unit in persistence.xml
<persistence-unit name="yourPU" transaction-type="JTA">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>jdbc/yourDataSourceName</jta-data-source>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect" />
<property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.SunONETransactionManagerLookup" />
</properties>
</persistence-unit>
Subscribe to:
Posts (Atom)