Monday, July 30, 2012

BroadLEARN Early Learning Credits

BroadLEARN™ Early Learning is a multi-award winning early childhood literacy and numeracy program which features over 300 interactive learning and assessment activities

BroadLEARN™ Early Learning encourages exploration play for your child while developing speaking, listening, reading, writing and computer skills.

My Credit:

How to obtain JTA Transaction / User Transaction from JSF Context

There are 3 ways UserTransaction can be obtained from JSF Context, ie. InitialContext object.
1. Using SessionContext or EJBContext from within your EJB implementation class. Only Bean-Managed transaction beans can have access
@Resources EJBContext context;
UserTransaction utx = (UserTransaction) context.getUserTransaction();
2. Using InitialContext from your JSF controller class or utility class using the EJB
UserTransaction utx; 
try {
    InitialContext context = new InitialContext();
    utx = (UserTransaction) context.lookup("java:comp/UserTransaction");
} catch(Exception e){} 
3. Using InitialContext from your JSF controller class or utility class using the EJB
UserTransaction utx; 
try {
    InitialContext context = new InitialContext();
    utx = (UserTransaction) context.lookup("java.transaction.UserTransaction");
} catch(Exception e){} 

Wednesday, July 25, 2012

Embedded Glassfish 3.1.2 - Arquillian compile error

If you get :
Absent Code attribute in method that is not native or abstract in class file javax/validation/constraints/Pattern$Flag
Solution: remove this dependency (if you have it)
<dependency>
    <groupId>javax</groupId>
    <artifactId>javaee-web-api</artifactId>
    <version>6.0</version>
    <scope>provided</scope>
</dependency>

Another one:
ArquillianServletRunner not found. Could not determine ContextRoot from ProtocolMetadata, please contact DeployableContainer developer.
which is caused by
Error invoking ServletContainerInitializer org.apache.jasper.runtime.TldScanner
java.lang.NoSuchMethodError: javax.servlet.ServletContext.getServletRegistration(Ljava/lang/String;)Ljavax/servlet/ServletRegistration;
 at org.apache.jasper.runtime.TldScanner.onStartup(TldScanner.java:231)
Solution is to modify your pom.xml. Tell maven-surefire-plugin to ignore servlet-api 2.3
<plugin>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>2.12</version>   
    <configuration>
       <forkMode>always</forkMode>
       <classpathDependencyExcludes>
           <classpathDependencyExcludes>               
               javax.servlet:servlet-api
           </classpathDependencyExcludes>
           <classpathDependencyExcludes>
               org.apache.felix:javax.servlet
           </classpathDependencyExcludes>
      <classpathDependencyExcludes>
    </configuration>
</plugin>
Taken from this site: http://java.net/jira/browse/GLASSFISH-17445