Sunday, August 21, 2011

Install and remove APK Files on Android Device Emulator (Windows)

Install APK

1. Download android SDK.
2. Go to $SDK_ROOT/tools or $SDK_ROOT/platform-tools directory and execute the file ‘emulator.exe’. You might need to also include android virtual device (AVD) to command line execution for example,

./emulator -avd TestDevice
3. Save/copy the APK file directly in the $SDK_ROOT/tools or $SDK_ROOT/platform-tools directory.
4. Goto Shell/Terminal/CommandPrompt, adb install fileName.apk (You will need to shell/terminal/cmd sessions live)

or ./adb install fileName.apk
5.If there is ‘Path not found’ error then you need to add $SDK_ROOT/tools directory to your system PATH settings correctly.

Remove APK

1.Click on menu and then select settings icon >> Click on applications tab>>Go to Manage applications
2. Find the application which you want to remove and uninstall.

Friday, August 19, 2011

Some exceptions we will get and how to resolve when we upgrade the application from java 1.4 to 1.6

This file will be keep on updating.

1.java.lang.IllegalAccessError: class javax.activation.SecuritySupport12 cannot access its superclass javax.activation.SecuritySupport

This issue will happen when we are using the old activation.jar with mail.jar. solution is delete the activation.jar. Sometimes if we are using weblogic.jar, there is a subdirectory javax.activation also need to be deleted.

Thursday, August 11, 2011

Run RichFace 4.0 on GlassFish 3.1 get warning This page calls for XML namespace http://richfaces.org/a4j declared with prefix a4j but no taglibrary exists for that namespace

If you get "This page calls for XML namespace http://richfaces.org/a4j declared with prefix a4j but no taglibrary exists for that namespace" error when running RichFace 4.0 on GlassFish 3.1 with Eclipse, it is always because you didn't deploy the RichFace jar lib to GlassFish path. Try to export below jar files with deploy package

cssparser-0.9.5.jar,
guava-r08.jar,
richfaces-components-api-4.0.0.Final.jar,
richfaces-components-api-4.0.0.Final.jar,
richfaces-components-ui-4.0.0.Final.jar,
richfaces-core-api-4.0.0.Final.jar,
richfaces-core-impl-4.0.0.Final.jar,
sac-1.3.jar

1. Goto project properties
2. Click Deployment Assembly
3. Add above jar files

Done.

Tuesday, August 9, 2011

Upgrade web from struts 1.3 to jsf 2.0

1. Change the tile of web.xml from

<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>

to:
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">

2. Add <jsp-config> before <taglib> to match the new structure of 2.5

<jsp-config>
<taglib>
<taglib-uri>/WEB-INF/struts-bean.tld</taglib-uri>
<taglib-location>/WEB-INF/tld/struts/struts-bean.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/WEB-INF/struts-html.tld</taglib-uri>
<taglib-location>/WEB-INF/tld/struts/struts-html.tld</taglib-location>
</taglib>
</jsp-config>

3. Add context-param

<context-param>
<description>
Tell the runtime where we are in the project development
lifecycle. Valid values are:
Development, UnitTest, SystemTest, or Production.
The runtime will display helpful hints to correct common mistakes
when the value is Development.
</description>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Development</param-value>
</context-param>

4. Add Faces Servlet

<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>/faces/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>

5. Add a blank faces-config.xml in WEB-INF

<?xml version="1.0" encoding='UTF-8'?>
<faces-config xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd"
version="2.0">
</faces-config>

6. Add new jar lib of jstl 1.2 and jsf 2.0.x

jstl-api-1.2.jar
jsf-api.jar
jsf-impl.jar

Problem
In JSF 2.0 web application, during server initialization, it hits following warning message
WARNING: JSF1063: WARNING! Setting non-serializable attribute value into HttpSession (key: userBean, value class: com.jsfcompref.model.UserBean).

UserBean
package com.mkyong;

@ManagedBean(name="user")
@SessionScoped
public class UserBean{

//...
}

The “UserBean” is not serializable, Simply make this bean implement java.io.Serializable interface.

package com.mkyong;

import java.io.Serializable;

@ManagedBean(name="user")
@SessionScoped
public class UserBean implements Serializable{

//...
}

JSF 2 getting issue in Tomcat 7

There is an JSF 2.1 bug which cause Tomcat 7 problem. You will get below error if you are using JSF 2.1 under Tocmcat 7.

java.lang.InstantiationException: com.sun.faces.application.ServletContextSensitiveSingletonStore at java.lang.Class.newInstance0(Class.java:340) at java.lang.Class.newInstance(Class.java:308) at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:118) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4268) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:4771) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:138) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:785) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:763) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:558) at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:674) at org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:599) at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:538) at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1390) at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:355) at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119) at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:89) at org.apache.catalina.util.LifecycleBase.setState(LifecycleBase.java:312) at org.apache.catalina.util.LifecycleBase.setState(LifecycleBase.java:292) at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:998) at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:772) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:138) at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:990) at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:275) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:138) at org.apache.catalina.core.StandardService.startInternal(StandardService.java:424) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:138) at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:648) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:138) at org.apache.catalina.startup.Catalina.start(Catalina.java:576) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:415)

To fix this you must switch back to JSF 2.0.X stable version.