add library to seam project - java

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 :).

Related

How to use Maven to make a Java EE 6 project

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

Eclipse - How to find out which libraries your project actually uses

I installed ZK Studio plugin for eclipse and have used it to create a new ZK based webapp. However, inside my /WebContent/WEB-INF/lib folder, there are a number of .jar files that were included automatically (beloning to the zk framework). I'm assuming this was done by selecting "create a new ZK project". However, when it comes time to deploy this to the webserver, I only want to include the libraries I actually need and use. Is there a way of finding that information out so I can shrink the size of my .WAR file?
Thanks!
These are called "transitive dependencies" - libraries that required by libraries that you use. The libraries that you use can't work without their dependencies, so ultimately you need all of the jars in WEB-INF/lib.
Maven is a dependency-management tool that tells you what are the transitive dependencies, (via a dependency graph). I would recommend using maven, although it would require some effort to introduce it in the current project.
Take a look at The Content of ZK Binary Distribution
then you can remove the library you don't need :)

How do I make Eclipse automatically include jars I place in my WEB-INF/lib folder into my project?

When I was doing JSP/Servlet programming, whenever I dropped 3rd party libraries into the WEB-INF/lib folder, they were automatically included in the project classpath. In GWT, this is not the case. Anyone know why? I loved how easy this was in JSP and I'd like these jars to be included automatically the same way.
If you are using the Google Plugin for Eclipse then my understanding is that a Google Web Application Project is just not the same animal than a Dynamic Web Project and thus behave differently. So if your project depends on libraries not provided by the GWT and App Engine SDKs, you'll need to put them in war/WEB-INF/lib and to add them explicitly to your Java build path.
In Eclipse Galileo, right click the web project and select build path then select the Java EE Module Dependencies and add the jars.
There is a plug-in technique that may help you if you want a directory where new jars are automatically updated in your build path, see this other post:
Eclipse buildpath automatically taking all JARs of a internal directory
The reason it works like this for your JSP's is because that is how the Dynamic Web Project was made to behave.
"If you remove a library path entry but not the JAR file, the library entry will be re-added to the path automatically." from http://help.eclipse.org/help33/index.jsp?topic=/org.eclipse.wst.webtools.doc.user/topics/ccwebprj.html
You could adopt Maven and use the Maven Eclipse Plugin; this plugin would update your classpath whenever you add a dependency. There may be a similar plugin for Ivy.

Can OpenCms be integrated, or used, with an IDE?

I'm starting with a new project where we'll be using OpenCms. Can the workplace be integrated to an IDE, and which one is it ?
Also if you are planning to use Eclipse OpenCms module with OpenCms 8, I am afraid you have to use the WebDAV Eclipse plugin with OpenCms, the other plugin stop working.
Link to the wiki reference page.
So once you may set:
Create a blank new module on your OpenCms.
Create a standard Java project.
Change the project setup to create the class files under a folder called "classes" instead of bin.
Import the module through WebDAV into the new module.
Create an user library with all the jars placed under the lib/ folder located in the OpenCms deployed war and add it to the buildpath.
Now you are ready to go.
If you're just going to develop on your local machine, I'd recommend the OpenCms Module Developer for Eclipse. The only thing you have to be aware of, is setting the encoding of the files to the same (by default Eclipse has some ISO-9... for editors which can be changed in the preferences).
Otherwise you could utilize the webdav-access to the VFS to edit with your favorite Editor.
The OpenCms Wiki might help as well in general.
This should help if you use Maven (which you can use with Eclipse):
Fully automated builds with the OpenCms-Maven-Plugin:
OpenCms-Maven is an open source
project ... to ease the build and
versioning process of OpenCms
projects. The core of the project is a
Maven plugin that enables full
automated OpenCms builds and provides
functionality to synchronize virtual
file system resources of OpenCms with
a real file system.
here is the link on the wiki that works...
http://www.opencms-wiki.org/wiki/Main_Page

How to get Netbeans 6.5 shareable libraries working

I created a Web application in Netbeans 6.5. Now I want to use the Joda Time library. I want to share this library via subversion, because I don't want my team mates to be dependend on some Netbeans configuration.
Just to get the project working, I first added the library to the Netbeans library (Tools->Library). This worked OK. The JAR is added to the classpath, and is also deployed.
But when I create a shared library (via Project Properties->Libraries->Browse/New Libraries Folder), the JAR is not in the classpath. I get the error message package org.joda.time does not exist on the code import org.joda.time.*.
Any ideas?
What is the scope of this library? Is this library used for just this particular web-application?
If so, can we put the library in the WEB-INF/lib directory and check that into subversion as well?
Libraries in the WEB-INF/lib directory should be automatically added to the classpath of the project.
Here is what I did:
Tools -> Library -> New Library...
called the library joda-time
add added the joda-time-1.6.jar file to it
Project -> Properties -> Libraries
under the compile tab
Add library...
selected joda-time
(Edit, think I see the issue now - but perhaps not).
You need to add the library to the compile libraries AND add it to the distribution libraries. Or am I misunderstanding the question?
when creating a 'new project', there is an option to enable 'dedicated folder for libraries'. That way, the libraries will also be committed to the repository and your peer developer can checkout your project with all the libraries, your project has dependencies upon, thereby eliminating netbeans configuration bound.
In scenario where a project depends on JARs which can be placed in different locations for different users, a named IDE variable can be used.
http://wiki.netbeans.org/NewAndNoteWorthyNB65#section-NewAndNoteWorthyNB65-VariableBasedPathsInJ2SEJ2EEProjects
Another option would be to use the Maven plugin which already works quite well in NetBeans 6.5. A Intranet repository for the Artifact Jar files could be placed on a file server, or managed through a Maven Proxy like Nexus.
This blog entry describes a hack that worked in NetBeans 5. I don't know if it will work in NetBeans 6.5. I also don't know if this will work if you are building files nightly on a server.
http://blogs.oracle.com/gjmurphy/entry/using_netbeans_free-form_projects_as
I remember setting up shared libraries like this 8 years ago in JBuilder. I wish Netbeans had it by now.

Categories