Is there a way to make JBoss load .jar files that are placed within sub-folders of a specific lib folder?
We unfortunately can't use a dependency management tool such as Maven in our environment and packaging jars into folders would help for manual management.
Related
I have one parent project which has WAR and JAR project. Currently the .xml and .properties files are packaged with jar. My requirement is that I want the resources folder of jar project which as .xml and .properties files to be available in WEB-INF folder of the war when the war project is build.
So that I can edit the files when the war is deployed on server.
There are a few ways to share resources across multiple projects or modules:
Cut and paste them.
Use Assembly and Dependency plugins
Use the maven-remote-resources-plugin
the second approach is described here
the third approach is described here
I'm developing a web application in JBoss in Eclipse Luna using external jars. I have imported the jars clicking on Project => Properties => Build Path => Add External Jars. Because the web application will need to use those jars, i have placed them in the MyApp.war/WEB-INF/lib folder, so, when the webapp will be finished, i'm sure i can just export the .war folder and deploy it on another server.
1) The problem is that everytime i turn on my pc in the morning, the deployment process gives me a ClassNotFoundException. I see that the external jars are no longer in their place. As far as i know, i'm not using any plugin to manage dependencies (i'm a newbie on webapps)
EDIT:
2) what i do is unpack my zip containing the jars again in the lib folder. Strangely, if i unpack them in a subfolder (for example, i place the jars in lib/httpcomponents/lib) JBoss cannot find the jars. What's the reason?
Try to inserting the external jar files in to jboss server lib directory (jboss\server\default\lib)
I am building a library which wraps some code around spymemcached client. This is called CacheClient. This is s simple Java project. I put the spymemcached.jar into its lib folder.
Here is how it looks like, also you can see the build path settings:
Library: CacheClient Project: cacheclient.jar
lib
spymemcached.jar
Java Build Path / Libraries Tab:
spymemcached.jar - CacheClient/lib/spymemcached.jar
What I am doing is I am building a simple java web project which is using this library.
WebApp: ServiceWebApp Project: servicewebapp.war
WebContent
WEB-INF
lib
EMPTY
Java Build Path / Projects Tab: CacheClient
So, my Webapp's build path is set to using the CacheClient project. I copied the cacheclient.jar into tomcat's lib directory and deployed the ServiceWebApp.
When I run the web app, it fails as it says my CacheClient code is looking for the spymemcached classes (ClassNotFoundException).
I could solve this by putting spymemcached.jar into tomcat's lib directory but it would be great if there will be an other solution.
Any suggestion appreciated.
Thanks,
The simplest way of making the lib available in your web app would be to put the lib's jar to your WEB-INF/lib directory.
If you don't want to do it manually, check this link about how this can be automated: Adding 3rd party jars to WEB-INF/lib automatically using Eclipse/Tomcat
In your case cacheclient.jar has a dependency on spymemcached.jar. But when your cacheclient.jar is built it's not packaged with spymemcached.jar. So just copying cacheclient.jar in tomcat/lib folder is not enough. In first place it's not a good practice to copy jar files in tomcat lib folder.
What you can do is copy both your jars in
servicewebapp.war > WenContent>WEB-INF>lib that should work.
Are .classpath and .project files as created by Eclipse, only used by Eclipse internally? Are these files being used by JDK? How do Java EE application servers find classes and path?
In between, when I create the ear, war using ant, I will use ant options to look out for the libraries for the project compilation.
Then does the application server use .classpath for compilation?
Java EE application servers don't need the classpath which we set in Eclipse for the war (web project) to run because while packaging the war, we stuff all the required jar's in the lib folder of the war file. When the application server starts , it loads all the jars from the lib folder without the need for any classpath declaration.
Also, in case any external dependencies are needed, most Java EE servers provide facility to define external jar dependencies.
And yes, .project, .settings folder etc. are all needed by Eclipse to handle the classpath and other settings of your workspace.
if we put it simply
.classpath and .project are eclipse metadata files and are used by eclipse only. They are meaning less for other applications.
I am trying to build java client for rabbitmq.
I have my source folder as A.mq.client.
Also I have a libs folder where I have my rabbitmq jar files. These jars have been added to build path. Everything works OK in Eclipse.
Then I export the entire project in eclipse as jar. jar contents are .classpath, libs folder and my package folder + rest of stuffs.
Now I am getting exception :
java.lang.ClassNotFoundException: com.rabbitmq.client.Consumer
com.rabbitmq.client.Consumer is in lib jars.
I am running jar using java -cp rabbit.jar A.mq.client.Worker where I want to invoke main method of worker class in my package and Worker is accessing jar packages.
As far as I know, you can't generally package jar files inside of another jar file. Typically, you would have to expand all the various dependent jars prior to packaging up your final jar. If you've ever used Maven, this is what the maven-shade-plugin helps to automate.
See the answer in this question for more information.
The CLASSPATH lists places, where the classes are found - either in a directory or in a jar, but not
directories of directories
directories of jars
jars of directories
jars of jars