1
votes

This is probably a very basic question but managing dependencies in java is a nightmare for me. I have a Liferay portelt (Liferay 6.05 deployed on JBoss AS 6) and I am trying to use batik in it. When I reference batik.jar (and possibly some other jars from the distribution) in Eclipse (properties -> build path -> add external jars), IDE says that everything is fine and shows no error.

However, when I deploy my portlet to the server, I get ClassNotFoundException - the portlet doesnt find the jars I referenced earlier. I feel that the problem is that I am only referencing those jars on my local machine and they are not present on the server (they dont get deployed in the WEB-INF/lib directory of the portlet either).

Should I copy those jars somewhere else? Perhpas somewhere in the liferay directory? Or to the directory where JBOSS AS is unpacked?

Thanks for any tips. I will try to make myself clearer if this sounds too confusing...

1

1 Answers

4
votes

For a custom portlet to work correctly the dependency jars should be present in the WEB-INF/lib of the portlet or at the global classpath of the server something like /liferay-portal-6.0/jboss/server/default/lib or .../lib/ext.

So if you are developing many portlets using the same dependency jars you can keep them at the global classpath of the Server, this would require server restart if any of the jars need to change. This way all the portlets and even liferay portlets (if you think of using the batik classes in a hook or something) will have access to batik jars.

Or else if you are using a build-tool like ANT or MAVEN, then you can have a script which will be executed while creating the WAR file and that would automatically copy the required jars to your portlet's WEB-INF/lib in the WAR.

Or else you can have them already copied to your WEB-INF/lib of every portlet you develop manually :-)