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.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(EjbModuleExtension.java:106)
    	at weblogic.application.internal.ExtensibleModuleWrapper.prepare(ExtensibleModuleWrapper.java:89)
    	at weblogic.application.internal.flow.ModuleListenerInvoker.prepare(ModuleListenerInvoker.java:100)
  • 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\
    GuestBook\build\web\WEB-INF\lib\cglib-nodep-2.1_3.jar
  • 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.

Comments:

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
About

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.

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
12
13
14
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today