I have used Eclipse to make a EJB project, Dynamic Web project and then I have combined these to in a EAR project. Now I am learning Maven and I wonder how you manage how you do this?
If I use an archetype that generates a javaee6-webapp then after what I understand you get a WAR archive....but that can only use the subset of the JavaEE6 specifiaction. I want to use the whole. So do I need to use one archetype for javaee6-ejb and one for javaee6-webapp, and then combine these in some way?
If this is the case or there are other better approaces I would be happy to learn about it.
Or are the EJBs in a webapp project generated by an archetype compiled and packed as a library and added to the WEB-INF/lib folder? If so, does it have access to the full JavaEE6 API if deployed in a full profile app server?
This article by Adam Bien might be interesting for you.
Also, if I understand it correctly, you can use all the goods of Java EE 6 specification using WAR deployment. You can use timers, remote interfaces, asynchronous invocation etc. in your WAR.
It just depends if you use Full vs Web Profile.
There are few differences between EAR and WAR packaging but, in my opinion, the biggest added value of EAR is the separation of concerns and modules (business logic from web).
To start quickly you can also use a maven archetype like this http://seam-archetype.sourceforge.net/jbosscc-seam-archetype/1.4/javaee.html
You have the right idea.
Create all of your maven projects such as ejb-javaee6, webapp-javaee6, etc.
Then IF you want, create an maven ear-javaee6 project to bundle them all together. This EAR would reference your ejb and webapp.
Updated link:
Eclipse has a plugin for maven that makes your life easier
Related
Whenever I create a maven J2EE archetype in my eclipse IDE, I get the following weird project structure in my work-space where it treats each folder as it own independent folder.
Is the project structure suppose to turn out like that?
Inside the project folder, it looks more like how I expected it to look.
This is normal and is the way that Eclipse copes with nested projects.
There was a time when it could not do this at all and you had to structure your project with the parent pom in a directory adjacent to the others especially for Eclipse.
You will occasionally encounter old projects structured like this for that very reason.
I never tried J2EE archetype but consider J2EE is very old term (now J2EE term was replaced with Java EE, for your information J2EE was used until version 4 and Java EE start from version 5).
In J2EE is common practice to separate each project, you will have many jar for your EJB and war for your Web project and then you will need EAR to bundle all of your module project.
But now with Java EE you just need war for everything. It's more simple rather than using EAR. So, if you want to build Java EE project I suggest you to see this minimalist Java EE maven archetype
I'm switching from Eclipse to IntelliJ Idea and had some, homemade i guess, problems while deploying.
In Eclipse usually my (main-) project contains 4 subprojects:
EAR
EJB
Shared (with JPA Entities, JPA Facet and so on...)
WEB (JSF, REST)
I know that JetBrains way of organizing is another. So i create a new Project and check all desired technologies i need (EJB, Web, CDI for example). When i try to deploy the project there is as cdi ambigious error, because the class is in the EJB artifact and also in the Web artifact. So my stupid way of thinking was, to delete the compile output from the web artifact, but now the files are not accessible in the Web-Project anymore (CNFE while calling).
So please, what is the correct doing if i'm trying to develop a project with EJBs, JPA, Web (JSF, REST). That could not be so hard and i'm going insane ;). Thank you!
Guten Abend,
I think you should allow to build your project from the command line. I use IntelliJ for large projects and I always make sure that I can build the thing from the commandline with a mvn clean install since it is sometimes needed and good not to depend on an IDE. I recommend that you divide your projects into the subprojects that you mention and make a pom.xml for each project and put the source into source control e.g. subversion. Then you will be able to checkout the project from subversion and it will load up neatly in IntelliJ iff you got it all configured right.
So if you haven't already, consider using Maven and Subversion (or some other VCS) for your projects and it will simplify your work.
If you provide more details about specific files and specific error messages we can help you more to move forward, and these were my general recommendations.
My setup in IntelliJ that builds a large project from several subprojects looks like the following.
When done this way, I can rebuild individual subproject without being forced to rebuild the entire thing just because of one small change. And I also can build everything from the commandline using the maven command mvn clean install
I can easily create a Maven project for programming portlets (for example using archetype). But in order to deploy this project to Liferay, I have to run:
mvn package liferay:deploy
Even if I change just a simple JSP file, I have to redeploy the whole portlet application. Is there a way to speed up this development process?
I don't want to use Ant, because then I would have to deal with dependencies and other stuff. I would really like to use Maven to develop Liferay portlet applications.
I tried JRebel, but because of the packaging to WAR file it's magic doesn't work :(
To re-create this situation:
Create project from maven archetype with artifactId: liferay-portlet-archetype
Add properties to pom.xml: liferay.version, liferay.auto.deploy.dir
Start Liferay
mvn package liferay:deploy -> this will create a WAR file and deploy it to liferay auto deploy directory.
Each time you want to change something, you must do mvn package liferay:deploy
This is time consuming on something bigger than just hello world.
As far as I know this is supposed to be the best practice. But Liferay documentation is sparse on this subject. Is there another way?
Problem solved using combination of STS (SpringSource Tool Suite) and Liferay IDE. With this combination it's not necessary to use Liferay Maven plugin at all. Just simply add Liferay server, deploy Maven app on this server and it all works.
Using this combination with JRebel is IMHO the most effective solution.
Your application can be packaged in WAR for JRebel to work, no problem there. Did you put rebel.xml configuration file into the WAR?
Environment
IDE: Netbeans 6.9
App Server: Glassfish 3
Frameworks: Spring, Hibernate, Struts 2
Problem
I have 2 web applications. I want to share resources between them both - i.e. authentication form jsp and other assets (js - yui,jquery/images/css). I will be adding more web applications that will also require access to these common components.
As a last resort I will create another web project with just the common assets - including them via http://common.mydomain.
How has anyone else achieved this? Can I create a web resource jar/war and include this in both applications?
I am experimenting so will update question with any progress.
Many thanks.
Place these 'common' components in a separate module (or in several separate modules) and make a dependency to this module from other parts of your app. (I'm not sure how is it called in NetBeans, in IntelliJ IDEA it's called module, in Eclipse - it's a separate project in the same workspace).
In eclipse you must create an utility project and an ear project containing the utility project and your current web applications. You can then move common code to the utility project, and deploy the ear to glassfish.
Common resources must be located through the classpath. This is rather easy with JSF 2
Netbeans has a feature to do this. Create a new project just for your shared components. List the project as a dependency of the projects that need it and make sure both projects are open in the IDE during the build process.
The IDE agnostic way(which I'm using in my own projects.)
would be to:
use maven to manage your projects
build your shared components into their own .jar
setup a local repository server(nexus, artifactory) server to host the shared .jar
(if you're the only dev, you might be able to get around this with mvn install)
list your new jar as a dependency on the projects(wars) that need it.
How can I add an library to a seam project?
Do I need to copy them manually somewhere or edit the build.xml to do it for me?
Or is there an automatic way provided by seam to add new libraries?
BR,
Cleber
Do I need to copy them manually somewhere or edit the build.xml to do it for me?
If you project was generated by seam-gen simply add library to lib subfolder.
Or is there an automatic way provided by seam to add new libraries?
You can use maven to manage dependencies. Seam projects aren't mavenized by default, but there are community templates of seam maven projects. Fortunately maven will officially supported in Seam 3.
I did find a way to get it done, the 'ear' task in build.xml has a
<includesfile name="deployed-jars-ear.list"/>
If I edit this file (found next to build.xml) and add the names of my libraries to the end of it, they get copied to the lib folder inside my EAR file which is what I need, since I want then to be loaded by the EAR classloader.
It is worth noting for people new to JBoss like me that JBoss ships with a few libraries already deployed under jboss-5.1.0.GA\lib\endorsed that might conflict with yours if you don't watch out.
I recommend using JBoss Tools Eclipse plugin to develop, build and launch Seam applications. I tried both JBoss Tools approach and Seamgen/Ant approach and found myself more productive using the former (much fewer headaches). There are quite a few tutorials explaining how to use Seam with JBoss Tools (e.g. a dedicated chapter in official documentation ).
To the point: while using JBoss Tools all I have to do to add a library to a project is to copy it to WebContent/WEB-INF/lib directory :).