Wednesday, October 13, 2010

Fixing org.apache.jasper.JasperException: PWC6180: Unable to initialize TldScanner Error on GlassFish 3.0.1

If you get the following error when running a Java EE 6 / JSF 2.0 web application in GlassFish 3.0.1 :

Oct 14, 2010 1:05:26 AM org.apache.catalina.core.StandardContext callServletContainerInitializers
SEVERE: PWC1420: Error invoking ServletContainerInitializer org.apache.jasper.runtime.TldScanner
org.apache.jasper.JasperException: PWC6180: Unable to initialize TldScanner
at org.apache.jasper.runtime.TldScanner.scanTlds(TldScanner.java:287)
at org.apache.jasper.runtime.TldScanner.onStartup(TldScanner.java:228)
at org.apache.catalina.core.StandardContext.callServletContainerInitializers(StandardContext.java:5352)
at com.sun.enterprise.web.WebModule.callServletContainerInitializers(WebModule.java:550)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:5263)
at com.sun.enterprise.web.WebModule.start(WebModule.java:499)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:928)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:912)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:694)
at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:1947)
at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:1619)
at com.sun.enterprise.web.WebApplication.start(WebApplication.java:90)
at org.glassfish.internal.data.EngineRef.start(EngineRef.java:126)
at org.glassfish.internal.data.ModuleInfo.start(ModuleInfo.java:241)
at org.glassfish.internal.data.ApplicationInfo.start(ApplicationInfo.java:236)
at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:339)
at org.glassfish.kernel.embedded.EmbeddedDeployerImpl.deploy(EmbeddedDeployerImpl.java:214)
at org.glassfish.kernel.embedded.EmbeddedDeployerImpl.deploy(EmbeddedDeployerImpl.java:144)
at org.glassfish.maven.RunMojo.execute(RunMojo.java:98)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:107)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:195)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:148)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:140)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:314)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:151)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:445)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:168)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:132)
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.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
Caused by: java.lang.IllegalArgumentException: javax.servlet.ServletException: com.sun.enterprise.container.common.spi.util.InjectionException: Error creating managed object for class com.sun.appserv.web.taglibs.cache.CacheContextListener
at org.apache.catalina.core.StandardContext.addListener(StandardContext.java:2659)
at org.apache.catalina.core.StandardContext.addListener(StandardContext.java:2642)
at org.apache.catalina.core.ApplicationContext.addListener(ApplicationContext.java:1270)
at org.apache.catalina.core.ApplicationContextFacade.addListener(ApplicationContextFacade.java:665)
at org.apache.jasper.runtime.TldScanner.addListener(TldScanner.java:435)
at org.apache.jasper.runtime.TldScanner.scanJar(TldScanner.java:420)
at org.apache.jasper.runtime.TldScanner.scanJars(TldScanner.java:633)
at org.apache.jasper.runtime.TldScanner.scanTlds(TldScanner.java:282)
... 39 more

The solution is to update the jsp-impl.jar library file since GlassFish 3.0.1 used an older and buggy one.

Download the newest jsp-impl.jar from http://download.java.net/maven/2/org/glassfish/web/jsp-impl/
(currently the newest version is 2.2.2-b03)

Overwrite the file in ${GLASSFISH_HOME}/glassfish/modules/jsp-impl.jar with the new jsp-impl.jar (rename the file to omit the version number).

Now your Java EE applications should run just fine. I also run a mixed Java EE/Scala web application and it runs fine with the new jsp-impl.jar.

Sunday, October 10, 2010

Installing M2Eclipse from "hidden" Archived Update Site

The latest M2Eclipse Maven Plugin for Eclipse IDE versions actually has archived update site files for offline installation.

However it is currently not mentioned in M2Eclipse Installation page.

You can download the recent archived update sites here:
http://repository.sonatype.org/content/repositories/eclipse/org/maven/ide/eclipse/org.maven.ide.eclipse.site

For example, this is the latest update site as of this writing:
http://repository.sonatype.org/content/repositories/eclipse/org/maven/ide/eclipse/org.maven.ide.eclipse.site/0.10.2.20100623-1649/org.maven.ide.eclipse.site-0.10.2.20100623-1649-site.zip

To maintainers of M2Eclipse, *PLEASE* update this Installation page:
http://m2eclipse.sonatype.org/installing-m2eclipse.html

and mention the existence of the archives of update site at the following URL:
http://repository.sonatype.org/content/repositories/eclipse/org/maven/ide/eclipse/org.maven.ide.eclipse.site

I found the archived update site location by following MNGECLIPSE-858 issue history here plus some common sense. ;-)

Friday, October 8, 2010

Apache Maven 3.0 Released [New Version Announcement]

The Maven team is pleased to announce the release of Apache Maven 3.0.

Maven is a project comprehension and build tool, designed to simplify
the process of maintaining a healthy development lifecycle for your
project. You can read more here:

http://maven.apache.org/

Downloads of source and binary distributions are listed in our download
section:

http://maven.apache.org/download.html

A major goal of Maven 3.0 is to be compatible, to the extent possible,
with existing plugins and projects designed for Maven 2.x. Users
interested in upgrading to this new major release should have a glance
at the compatibility notes for known differences between Maven 3.0 and
Maven 2.x:

http://cwiki.apache.org/MAVEN/maven-3x-compatibility-notes.html

If you encounter unexpected problems while using Maven 3.0, please feel
free to contact us via the Maven developer list:

http://maven.apache.org/mail-lists.html

Last but not least, the Maven team would like to thank all the users
that tested the various alphas/betas/RCs and provided valuable feedback
that helped us to eventually release a solid Maven 3.0!

Release Notes - Maven 2 & 3 - Version 3.0 (since 3.0-beta-3 only)

** Bug
* [MNG-4592] - Snapshot artifacts that could not be downloaded due
to communication problems are "blacklisted" for a day by default.
* [MNG-4751] - Snapshot version not resolved for version range
* [MNG-4785] - NPE in dependency resolution code for TC plugin
* [MNG-4786] - [regression] Ant-based mojo using
maven-script-ant:2.1.0+ cause NPE
* [MNG-4788] - [regression] Appassembler Maven Plugin doesn't work
like as it should
* [MNG-4789] - [regression] Difference in compile scope dependency
resolution
* [MNG-4791] - [regression] POM artifacts passed into
MavenProjectBuilder.buildFromRepository() are no longer resolved
* [MNG-4793] - Unable to obtain archiver for extension 'zip'
* [MNG-4794] -
'org.apache.maven.plugins:maven-install-plugin:2.3.1'. A required class
is missing: org.codehaus.plexus.digest.Digester
* [MNG-4795] - [regression] Dependencies in forked reactor projects
are not resolved when aggregator bound to lifecycle forks
* [MNG-4800] - Conflict resolution does not pick sub tree of
nearest dependency if farther conflicting dependency has wider scope
* [MNG-4810] - Maven cannot build if loaded in a classloader that
is not backed by a real JAR file / classpath
* [MNG-4811] - Custom Maven Plugin regression in Maven 3.x, custom
ComponentConfigurator causes infinite loop
* [MNG-4814] - Eary dependency resolution attempts for reactor
projects prevent their later resolution from the reactor
* [MNG-4818] - NPE in legacy.DefaultWagonManager.getArtifact
* [MNG-4829] - [regression] Checksum failures aren't logged
* [MNG-4832] - Maven 3 Regression: Missing constructor of
org.codehaus.plexus.component.configurator.converters.special.ClassRealmConverter
* [MNG-4834] - [regression] MavenProject.getParent() ignores
configured repositories
* [MNG-4836] - Incorrect recursive expression cycle errors (update
plexus-interpolation)
* [MNG-4837] - Interpolation error due to cyclic expression for one
of the POM coordinates gets needlessly repeated
* [MNG-4842] - [regression] Repositories discovered in dependency
POMs override repositories configured for original resolution request of POM
* [MNG-4845] - [regression] MavenProject.getDependencyArtifact()
returns artifacts without version for dependency with version range

** Improvement
* [MNG-4452] - Metadata for snapshots should include classifier
* [MNG-4787] - Allow class realm manager delegates to alter public
part of Maven core realm
* [MNG-4815] - (3.0-RC1) Maven Java API does not give nice error
messages when improperly configured
* [MNG-4824] - multiple failures need additional whitespace
* [MNG-4825] - Relative path errors could be more explicit

** New Feature
* [MNG-4484] - Create a Maven API for component configuration

** Task
* [MNG-4805] - Update default plugin versions used for built-in
lifecycle mappings
* [MNG-4807] - Extend core artifact filter to exclude relocated
Guice-based Plexus shim

** Wish
* [MNG-4796] - add a warning when profiles.xml is used (Maven 2) or
detected (Maven 3)

Enjoy,


-The Maven team

Relational DBMS vs Object-oriented DBMS vs Document-oriented databases issue is moot when you're already using multiple data stores!

The issue of:

1. Relational databases (RDBMS) e.g. MySQL, PostgreSQL, SQLite, JavaDB, HSQLDB... versus
2. Object-Oriented databases (OODBMS) e.g. db4o... versus
3. Document-oriented databases e.g. MongoDB, Apache CouchDB...

...is probably because many developers (including me! :) are not aware that the application is already using multiple data stores at once.

Note: Practically all data stores, except OODBMS, will require some form of roundtrip serialization, object-mapping and code generation to be conveniently usable inside an application, accessible not only via framework/library API but also via domain model objects and classes.

By the way even if you use an OODBMS, if you use features that require specific language support (e.g. Weaving traits and behaviors, like soft deletes, timestampable, nested sets) and the language (e.g. PHP, Java) doesn't support it, you'll still need to do either code generation, manual coding, or be content with dynamic proxying (say goodbye to IDE code hints!)

Why pick just one data store and debate?

A few I have in mind right now is:

1. Key-value stores.
The application INI configuration file.
Cache storage, be it file-backed, memcached-backed, or even RDBMS-backed! (you're just abstracting/implementing a key-value store on top of a relational schema).
Translation/localization data is sometimes also stored using this store.
Web application Session data also uses key-value (though it does automatic de/serialization).

2. Hierarchical data store / Object store.
XML file.
A hierarchy of folders, subfolders, and files.
In the case of Zend Frameworks's Zend_Config, also INI files.
JSON file.
YAML file.
CSS file (surprising, eh? Though it's only two levels deep.)
I think there's no such thing as an "object store". What exists is a data store that acts like an object repository, that does automatic de/serialization of objects, that stores its data in a hierarchical store or content/document store or hybrid.
How an object is serialized/its serialization representation (i.e. "should a GeoPoint instance be embedded or linked?") should be specifiable through some form of metadata/configuration/annotations.
The object graph, by itself, does not contain sufficient information to be managed as a data store.

3. Content/Document store.
A content store doesn't always restrict a type to a schema. It allows arbitrary properties to be attached to a content node.
Some content stores also allow nesting (hierarchical content stores).
The filesystem (fixed standard schema), but some filesystems support additional metadata.
The node API in Drupal (implemented on top of RDBMS).
The EAV tables in Magento (implemented on top of RDBMS).
Natively: the JCR (Java Content Repository) in Alfresco & Jackrabbit (Java), MongoDB, Apache CouchDB, Persevere.

4. Binary/BLOB store.
It's basically a key-value store with support for huge values and block/partial access.
The filesystem.
S3.

5. Structured markup.
HTML. Wiki format. Markdown. Textile.
All fits in one string.

6. Full text index store.
Apache Lucene.
Zend_Lucene.

7. Search store.
Apache Solr.
The search/faceted navigation index in Magento (built on top of RDBMS).

Did I miss something?

Friday, July 2, 2010

Tomcat java.lang.OutOfMemoryError: PermGen space


The "OutOfMemoryError: PermGen space" Java error will appear after Tomcat has exhausted all of its memory. This is typically caused by using the "Update" or "Reload" function on a webapp too many times. Currently, Tomcat and/or the JVM isn't releasing all of the memory when a webapp is destroyed/recreated. After several reloads Tomcat is out of its allotted memory and will hang or freeze.

It is a common error, many people have encountered this problem before you (I guess that's a sad fact). ;-)

The "OutOfMemoryError: PermGen space" message is normally encountered during development activites where a long-running JVM is asked to load/unload builds (i.e. reload/redeploy WARs under Apache Tomcat). However it can also be encountered in a recently spawned JVM under the "right" set of conditions.

The message is a symptom of an incomplete garbage collection sweep where resources are not properly released upon unload/restart.

Solutions

  • Developers: Restart Tomcat after several updates/reloads
  • Developers and Implementers: Allow Tomcat to use more memory. This will not stop the error, just prolong times between tomcat restarts. Follow the 'Java Heap Size' solution instructions.
  • Implementers: Tell Tomcat to not leak memory 
How to Increase Tomcat's Allowed Memory
Start Tomcat with the parameters:
-Xmx512m -Xms512m -XX:PermSize=256m -XX:MaxPermSize=256m -XX:NewSize=128m

Tomcat 6 Developer's GuideInside Eclipse IDE:
  1. Click on Tomcat start up
  2. Click on Java tab in Tomcat startup
  3. Use the parameters above.
To be an expert of Apache Tomcat, I suggest you to read the book Tomcat 6 Developer's Guide.

References:

Monday, June 28, 2010

NetBeans IDE 6.9 Released


NetBeans IDE 6.9 newest version has been released by Oracle. NetBeans is a powerful open source IDE supporting Java, C/C++, Ruby on Rails, Python, PHP, Groovy/Grails, and other programming languages.

Download NetBeans 6.9 here.

The Definitive Guide to NetBeans™ PlatformLearn more about NetBeans by reading The Definitive Guide to NetBeans Platform.

NetBeans 6.9 Highlights


NetBeans IDE 6.9 introduces the JavaFX Composer, a visual layout tool for building JavaFX GUI applications, similar to the Swing GUI builder for Java SE applications. With the JavaFX Composer, developers can quickly build, visually edit, and debug Rich Internet Applications (RIA) and bind components to various data sources, including Web services.

The NetBeans 6.9 release also features OSGi interoperability for NetBeans Platform applications and support for developing OSGi bundles with Maven. With support for OSGi and Swing standards, the NetBeans Platform now supports the standard UI toolkit and the standard module system, providing a unique combination of standards for modular, rich-client development.

Additional noteworthy features in this release include support for JavaFX SDK 1.3, PHP Zend framework, Ruby on Rails 3.0, and GlassFish v3.0.1; as well as enhanced Java EE 6 support, improvements to the Java Editor, Java Debugger, issue tracking, and more.

More info available at NetBeans 6.9 release announcement.

NetBeans 6.9 New Features

OSGi
  • Develop OSGi bundles with Maven
  • Bundled Felix container
  • Use OSGi bundles in a NetBeans RCP application

NetBeans Platform
  • OSGi interoperability (developing and consuming OSGi bundles in Platform-based applications)
  • Felix 2.0.3 OSGi support, experimental Equinox support
  • Convert NetBeans modules into OSGi bundles and run them in an unmodified OSGi container
  • Branding Editor for both Ant and Maven Platform-based projects
  • NetBeans Platform-based applications generate installers for most common operating systems
  • Enhanced support for consuming web services and connecting to databases


JavaFX
  • JavaFX Composer for form-like UI components with states and access to various data sources
  • Added and improved editor hints and refactoring
  • Enhanced Palettes for JavaFX Shapes, Colors, Effects, and Charts
  • Improved code formatting
Java EE
  • Support for Contexts and Dependency Injection (CDI) (JSR-299)
  • Spring Framework 3.0 support
  • Bundled GlassFish Server Open Source Edition 3.0.1
  • Easy regeneration of JPA entities after database change
  • REST web services support for RCP applications
Java
  • Java Debugger breakpoint grouping, debugger attach parameter history
  • Support for annotation processors in the editor, configurable in the Project Properties
  • New Applet and Web Start (JNLP) support
  • Improved navigation in Stack Trace Analyzer and URLs, Go To Overridden/Implemented Method action

Web Languages: HTML, CSS, JavaScript
  • Refactoring and find usages for CSS and HTML-like languages
  • Code completion and hyperlinking for id and class selector attributes
  • Refactoring inline CSS styles


Java Card
  • Support for creating Java Card Connected 3 servlets, classic and extended applets
  • Backward compatibility with Java Card 2.2.x and Java Card Classic
  • Debugging, and multiple Java Card Platform/Device creation
  • Alignment with Java Card Reference Implementation
PHP
  • PHP Zend Framework support
  • "Overrides/Implements" and "Is Overridden/Implemented" annotations
  • New formatter with many formatting rules

Ruby
  • Ruby on Rails 3.0 support
C/C++
  • Unit test integration with C/C++ projects
  • Enhanced remote development including remote file download and browsing
  • Improved support of makefile targets and Fortran
  • Improved hyperlink navigation between overridden methods and classes
General
  • Many more editor hints for Java and Ruby
  • Spell checker support in the Editor
  • Help menu item for reporting bugs and slowness against NetBeans IDE
  • Support for multiple Kenai-based team servers (e.g. kenai.com and netbeans.org).
The Definitive Guide to NetBeans™ PlatformLearn more about NetBeans by reading The Definitive Guide to NetBeans Platform.

Eclipse Java IDE 3.6 Helios Released

 
Eclipse IDE, the most popular open source Java IDE, has released version 3.6 codenamed Helios.

Download Eclipse 3.6 here.

New features in Eclipse IDE 3.6 include:
  • A new Linux IDE package makes it easier for Linux developers to use an integrated tool chain for building C/C++ applications for the Linux operating system. This package includes the new Linux Tools project which includes Eclipse integrations of popular Linux utilities such as GNU Autotools, Valgrind, OProfile, RPM, SystemTap, GCov, GProf, and LTTng. A recent Eclipse Community Survey has shown increased use of Linux by developers. It is expected this package will help further accelerate Eclipse adoption in the Linux community.
  • Eclipse Marketplace Client provides developers an 'app-store' experience to easily discover and install new Eclipse plug-ins. Eclipse Marketplace is a catalog of Eclipse based solutions. Over 100 of these will be available from the new Marketplace Client, making it significantly easier to find and install Eclipse solutions.
  • Support for Git, a popular distributed version control (DVCS), is provided by the new Eclipse EGit and JGit projects. The new EGit 0.8 release includes a new Git repositories view and support for fast forward merging and tagging. JGit 0.8 - which EGit uses under the covers to talk to Git repositories - benefited from performance enhancements of up to 50% when working with large repositories.
  • The Web Tools Platform project has introduced support for creating, running, and debugging applications written for the latest Java EE Specifications (Java EE 6) including, Servlet 3.0, JPA 2.0, JSF 2.0, and EJB 3.1.
  • Improved support in the JavaScript Development Tools project (JSDT) for JavaScript developers, including a JavaScript debug framework that allows for integration of JavaScript debuggers, such as Rhino and Firebug. A new JavaScript IDE package has also been created to make it easier for JavaScript developers to find, install and use an Eclipse-based IDE.
  • Eclipse Xtext 1.0, a popular framework for creating domain specific languages (DSL), introduces 80 new features, including improved performance and scalability by up to 30 times previous versions. A new in-memory indexing feature makes it possible to develop more sophisticated DSL's in Xtext.
  • A new release of Acceleo 3.0 implements the OMG Model-to-text (MTL) specification and provides the features required for a code generator IDE. This release also provides unique tools around example-base design of code generators.
For more information check out Eclipse 3.6 release announcement.

To learn more about Eclipse platform programming, I highly recommend Eclipse Rich Client Platform (vogella series) by Lars Vogel. It's really good for learning Eclipse RCP/RAP development, most of the things that apply to RCP also applies to RAP. In fact, you can single-source an application to two target platforms (RCP for desktop, RAP for web) simultaneously. :-)