Sample: Java EE 6 + Wicket + NetBeans + GlassFish + MySQL

I worked through Jeff Schwartz's excellent "Java EE 6 & Wicket" tutorial today, which uses Java EE 6 to create a GuestBook in Wicket, via a MySQL database.

Here's the result, completely working:

Here's what the application looks like in NetBeans IDE:

I came across a few problems while working through the scenario:

  • I had to use this construction in the Application class, which is different to Jeff's tutorial and appears (after a Google search) to be a difference between Wicket 4.x and Wicket 5.x:
    @Override protected
    void init() {
        super.getComponentInstantiationListeners().add(new JavaEEComponentInjector(this));
  • I deployed without a single problem to GlassFish, after encountering and failing to solve this problem when deploying to WebLogic:
    weblogic.application.ModuleException: Exception preparing: EjbModuleExtension for Module(web)
    	at weblogic.ejb.container.deployer.EjbModuleExtension.postPrepare(
    	at weblogic.application.internal.ExtensibleModuleWrapper.prepare(
    	at weblogic.application.internal.flow.ModuleListenerInvoker.prepare(
  • Cleaning the application in the IDE resulted in this problem which could only be resolved by exiting the IDE and deleting the 'build' folder externally:
    Unable to delete file C:\Users\Geertjan\Documents\NetBeansProjects\
  • When I have the Validation Strategy in the persistence.xml set to the NetBeans IDE default, which is "Auto", I see this when I click the Submit button in the page (so I set it to "None", which seems undesirable):
    Last cause: Bean Validation constraint(s) violated while executing Automatic 
    Bean Validation on callback event:'prePersist'. Please refer to embedded 
    ConstraintViolations for details.

That's all. If anyone could help or advise on the above problems, that would be great. Other than the above, everything went fine and Jeff's sample is great as a way to learn how all these technologies fit together.


I think the problem lies with the NetBeans Entity Generator.
It puts a @NotNull constraint on the id field of your entity because most databases make the primary key not nullable by default. When persisting entities a new value will be generated AFTER the validation which is done automatically in the pre-persist event, so the validation will fail.
I just removed the @NotNull constraint from the primary key field.

Posted by Philip Markus on January 01, 2012 at 07:02 PM PST #

Post a Comment:
  • HTML Syntax: NOT allowed

Geertjan Wielenga (@geertjanw) is a Principal Product Manager in the Oracle Developer Tools group living & working in Amsterdam. He is a Java technology enthusiast, evangelist, trainer, speaker, and writer. He blogs here daily.

The focus of this blog is mostly on NetBeans (a development tool primarily for Java programmers), with an occasional reference to NetBeans, and sometimes diverging to topics relating to NetBeans. And then there are days when NetBeans is mentioned, just for a change.


« June 2016