Friday, 29 July 2011

GWT code generator - For the following type(s), generated source was never committed (did you forget to call commit()?)

For the following type(s), generated source was never committed (did you forget to call commit()?)


When you encounter this issue while implementing a code generator in GWT using ClassSourceFileComposerFactory, ensure you are calling writer.commit(logger). If this is not you are missing, make sure you are passing context to composer.createSourceWriter(context, printWriter);

There are lot of examples out there on code generators that doesn't show context being passed. Without context, your writer doesn't commit your source generation changes.

Friday, 15 July 2011

Shared connection pool between multiple webapps of tomcat

For configuring a container managed connection pool you define a resource in context.xml as

<ResourceLink
name="jdbc/myoracle"
global="shared/jdbc/myoracle"
type="javax.sql.DataSource"
factory="org.apache.naming.factory.DataSourceLinkFactory"
username="username"
password="password" />

and do a JNDI lookup to access the resource and get a db connection. Even though the connection pool is maintained by the container, it creates a pool for every webapp on tomcat and doesn't really share the pool between webapps. This usually causes your environments use up too many connections and result in session unavailable exceptions.

To make your webapps use a truely sharable connection pool across all webapps on the container, use the following configuration

1. Remove any definition you have from context.xml (These configuration files are usually found on tomcat_home/conf)
2. Move this definition to server.xml and copy under as

<GlobalNamingResources>
<Resource auth="Container" driverClassName="oracle.jdbc.OracleDriver"
maxActive="2" maxIdle="1" maxWait="-1"
name="shared/jdbc/myoracle" password="password"
type="javax.sql.DataSource" url="jdbc:oracle:thin:@server:1521:XE" username="username"/>
</GlobalNamingResources>

3. Link this resource to your webapplication context by copying the below xml under element

<ResourceLink
name="jdbc/myoracle"
global="shared/jdbc/myoracle"
type="javax.sql.DataSource"
factory="org.apache.naming.factory.DataSourceLinkFactory"
username="username"
password="password" />
4. Restart tomcat
5. Look into your database administration console to verify the connections you are holding.

Now, all your web application contexts link to just a global truely shared connection pool and use less connections.

Tuesday, 12 July 2011

What are the default or test credentials for jasig CAS (Central Authentication Service)

CAS uses SimpleTestUsernamePasswordAuthenticationHandler by default. The only rule for a successful authentication is username and password should match. (eg., tiger/tiger)

Monday, 11 July 2011

GWT ClassFormatError

Ensure your accessor methods (getters) are all final in the corresponding class. This occurred to me when one of my getter methods was non-final