Maven archetype for java ee 6 and eclipse - eclipse

I need to create a java ee 6 project which contains:
JSF
EJB
JPA
The Web-things should be compiled to a .war file, the ejb to the ejb-jar and overall into an ear file. The application will be deployed to a Glassfish v3.
I was looking for a maven archetype which I can use and integrate into Eclipse. However I haven't found one. Can you help me?

I consider Andy Gibson's Knappsack Archetype as a good starting point for what you are looking for. It gives you certain levels of working projects from a very basic setup to one filled with examples.
Alternatively, Adam Bien's Weblog is always a good place for finding simple solutions as for example a minimal project setup.

The Java EE MVC Security Archetype is a quickstart for websites that want user self registration and security configuration.
You can try it out on Openshift, though sometimes you have to wait a couple of minutes for openshift to load and start the application.
The archetype includes the following technologies:
Java EE MVC web application for Wildly 9 environment
JSF 2.2 and Bootstrap
JPA 2.1
H2DB (H2 Development Database)
JUnit/Arquillian/Drone/Graphene for testing
Java EE SecuritySupported by JBoss/Wildfly Database Module
Please note: This post is self-promotional.

Related

Is it possible to have Web & JPA & EJB in 1 project in Eclipse?

I just finished a tutorial which was done in NetBeans. The tutorial created only 1 project which was a Web Application Project under Java Web category. The tutorial has 1 entity using JPA annotations, 1 Stateless Session EJB using JPA annotations, 1 Servlet calling the EJB, and 1 JSP calling the Servlet. So basically this 1 project has all 3 items: Web & JPA & EJB.
How can I have such a project in Eclipse?
When I work on Eclipse I get confused about how many projects I would need for a web application which uses JPA and EJB.
Should I create 3 projects 1 each for Web & JPA & EJB? OR
Should I create 2 projects 1 each for Web & EJB and include JPA in both?
Just create the "Dynamic Web Project" right away with a minimum version of 3.0.
Since Java EE 6 ("Web Profile") you indeed don't necessarily need to create a separate project for EJBs. You can then use a subset of the EJB API in the WAR, also known as "EJB Lite". You can then easily create a single no-interface EJB class with just a state annotation (Stateless, #Stateful or #Singleton) and you're already there.
You don't need the EJB facet for a "Dynamic Web Project". EJB Lite is basically already covered by the "Dynamic Web Project". There's not much IDE magic (wizards, code generators, etc) needed for EJBs anyway. You only need to make sure that the version is set to a minimum of 3.0 (from Servlet 3.0; part of Java EE 6), and that you set the target runtime to a real Java EE application server (even if it's only "Web Profile"), such as WildFly, TomEE, GlassFish, Liberty, etc and thus not a barebones servlet container like Tomcat or Jetty. This way the EJB annotations will be readily available in the project.
You don't even necessarily need to enable the JPA facet. You'll only miss the JPA-related wizards and code-generators under the project options. But you can just write all JPA-related code all by yourself and still get it to deploy. After all, an IDE is just like notepad, but then with millions of features trying to make you more comfortable while writing code. The project facets basically enable/disable the available project options/wizards/code-generators.

Netbeans wizard for JSF pages doesn't recognize TomEE 1.6 to have Web Profile support

I am creating a Java EE 6 application with the help of Netbeans 8.0 and TomEE 1.6. I have successfully added the server to netbeans and even generated some entity classes. I am currenlty trying to generate some JSF pages using the Netbeans wizard. However I get the following message
Cannot be generated for Java EE 6 sources wihtout server with complete Java EE 6 Web profile support (at least EJB Lite support).
I am using TomEE 1.6.0.2 plus
The problem is Netbeans 8 has a bug in which it fails to find the tomee-common-[version].jar in the [TomEE]/lib directory.
The solution is to simply rename the jar file to an older version.
For example, you have [TomEE]/lib/tomee-common-1.6.0.2.jar or [TomEE]/lib/tomee-common-1.7.1.jar. Rename these files to [TomEE]/lib/tomee-common-1.6.0.jar
This should sort you out :)
you can use tomcatEE 1.7.2 with a few small changes
you find here:
http://zarnisfd.blogspot.com/
I think this also applies to TomEE 1.6
According to the following sites:
http://forums.netbeans.org/ntopic48005.html
https://netbeans.org/bugzilla/show_bug.cgi?id=210835
Tomcat does not support EJB's therefor you would need to use an enterprise server that at least supports EJB Lite. One such server would be GlassFish

difficulty in deploying struts 2 application

I am a beginner with struts2 and I have few struts2 projects downloaded from a website, but they all are created as simple java projects and not as web-projects, so I am unable to deploy them on my Tomcat or JBoss AS server through Eclipse.
How can simple java projects be deployed on a Java EE server?
Your best bet is download sample applications from Struts2 official sites and deploy them on any of the server of your choice.
Those sample application comes with all required dependencies as well will give you idea about structuring of S2 application as well flow and configurations
I created a structure similar to the one shown on website and manually added all the files required and it worked.

Is there any way to have a fully portable Java EE 6 deployment?

Is it possible to make a Java EE 6 application deployable on any Java EE 6 Container (like JBoss or GlassFish, etc) without using their modules / libraries?
If for example I want Hibernate or Weld then add these in my Maven pom.
In other words, is there any "vanilla" container or can JBoss or GlassFish be made "vanilla"?
I´m sorry... but to be honest I don´t understand your question.
Java EE applications are in most cases deployable an all containers - as long as they are not using packages or configurations which are specific to the chosen container.
Even if you add libraries in your POM and the applications are packaged as WAR or EAR this should work.
Weld is not needed because the API is part of Java EE 6. If you want to use JPA you also don´t need hibernate.

What's the ideal setup for a quick turnaround in Java EE development?

I'm currently struggling with the project setup while implementing a Java EE 6 application with Eclipse Indigo and JBoss 6. The application server and the IDE is pretty much set in the project. Maven 3 is used and was the base for the setup by using the WELD archetype and creating a WAR.
Now, the problem is, that I'm very disappointed about the development turnaround. I don't have a working automatic redeploying within eclipse and often need to restart JBoss since it gets confused with the new publishing and then is not able to redeploy correctly. This is very frustrating and time consuming. (Plus I feel the smirks behind me from the guys preferring script languages.)
From earlier projects we were using Seam 2 and the project created by seam-gen came with a somewhat decent republishing, although I still had to do a manual application restart whenever I changed Java classes. Then, from playing around with Netbeans 7 and the integrated GlassFish 3.1 I found that automatic redeployment was working ok. And since Java EE 6 is very wide spread, I assume, there must be a better setup than I have now.
So with this post I hope to get some more insight in having a good project setup for fluent development of Java EE 6 based WAR projects on JBoss and eclipse - who can share some best practices?
Thanks a lot!
You should use JBoss Tools plugins for Eclipse. JBoss Tools 3.3M2 is compatible with Indigo and JBoss AS 7 (which is 10 times faster than JBoss 6 for redeploy).
Regarding an equivalent to Seam Gen with CDI, you should really take a look to Seam Forge which is included in JBoss Tools 3.3 now.
Finally I'm using Jrebel to reload class and configuration without restarting the server. But for now it doesn't work yet with JBoss AS 7, so if you stick with JBoss AS 6 it's a goof combination.
This might not be the answer to your question, but if you want Java and fast turnaround look at http://www.playframework.org/ your script colleagues will be astounded.
For Eclipse to work well, use Eclipse Java EE edition and then add the JBoss server adapter.
The usual WTP-tooling then works for automatic deployments etc.