Saturday, October 11, 2014

EXP 11: replace String in postgresql

Problem
Replace String "EJB" by "Bean" in postgresql

Solution
Using function regexp_replace(input_string, original_expression, new_expresstion)

Sample
UPDATE tbfunction
SET functionresource = regexp_replace(functionresource, 'EJB', 'Bean')

Wednesday, October 8, 2014

EXP 10: Cannot import javax.enterprise.context.SessionScoped

Problem
Cannot import javax.enterprise.context.SessionScoped
Webserver: Glassfish 4.1
IDE: Eclipse Luna

Cause
default Eclipse Luna dont add cdi-api.jar package into build path. So, you cannot import javax.enterprise.context.SessionScoped  class.

Solution
Add cdi-api.jar to build path. You can find it in <glassfins-install-dir>/glassfish/modules

EXP 9: org.jboss.weld.exceptions.DefinitionException: WELD-000075: Normal scoped managed bean implementation class has a public field: [EnhancedAnnotatedFieldImpl]

Problem
When using @Named annotation, console output error:
org.jboss.weld.exceptions.DefinitionException: WELD-000075: Normal scoped managed bean implementation class has a public field:  [EnhancedAnnotatedFieldImpl]

Cause
The field in @Named injection  is must declared not public visibility

Solution
Change public access to private or protected

Monday, September 8, 2014

EXP 8: Software Life Cycle Processes from IEEE Std 12208-2008

This image is extracted from IEEE Std 12208-2008  document. Hope it help you recognize about process standards and give you more perspectives about your project.



You can download full this ISO document at here

Friday, September 5, 2014

EXP 7: java.io.NotSerializableException: com.sun.faces.context.FacesContextImpl

Problem
Get exception java.io.NotSerializableException: com.sun.faces.context.FacesContextImpl when deploy application in cluster

Cause
FacesContext implement should be use as FacesContext.getCurretntInstance() for all case. Dont use any variable e.g:

ExternalContext ec = FacesContext.getCurrentInstance().getExternalContext();
ec.redirect(url);

Solution
Check all FacesContext implementations, using FacesContext.getCurrentInstance() instead.

Wrong way:
ExternalContext ec = FacesContext.getCurrentInstance().getExternalContext();
ec.redirect(url);

Right way:
FacesContext.getCurrentInstance().getExternalContext().redirect(url);

Wednesday, September 3, 2014

EXP 6: java.lang.IllegalArgumentException: setAttribute: Non-serializable attribute with name

Prolem
Server log show error:
java.lang.IllegalArgumentException: setAttribute: Non-serializable attribute with name sessionBean

Cause
The instance "sessionBean" of SessionBean class is non--serializable when enable distribute feature on web.xml

Solution
Implement Serializable to SessionBean class  or super of SessionBean class

EXP 5: Connect remote EJBs on clustered environment

Problem
Cannot connect remote EJBs on clustered enviroment (Glassfish 4 app server)

Cause
in clustered environment, Glassfish use different JNDI compare single server.

Solution
Correct JNDI as described as below:

java:globbal/<earname>/<ejbprojectname>/

You can find exactly JNDI on server.log file of Glassfish Server when it startup.

Example

java:global/gbear/gbeejb/

If EJB which you need to connect named TestEJB, the full JNDI is:

java:global/gbear/gbeejb/TestEJB

Quotes from server.log

[2014-09-03T12:48:21.608+0700] [glassfish 4.1] [INFO] [AS-EJB-00054] [javax.enterprise.ejb.container] [tid: _ThreadID=14 _ThreadName=RunLevelControllerThread-1409723271247] [timeMillis: 1409723301608] [levelValue: 800] [[
  Portable JNDI names for EJB TestEJB: [java:global/gbear/gbeejb/TestEJB, java:global/gbear/gbeejb/TestEJB!com.gbsofts.gbe.module.system.service.TestService]]]

[2014-09-03T12:48:21.608+0700] [glassfish 4.1] [INFO] [AS-EJB-00055] [javax.enterprise.ejb.container] [tid: _ThreadID=14 _ThreadName=RunLevelControllerThread-1409723271247] [timeMillis: 1409723301608] [levelValue: 800] [[
  Glassfish-specific (Non-portable) JNDI names for EJB TestEJB: [ejb/TestEJB#com.gbsofts.gbe.module.system.service.TestService, ejb/TestEJB]]]