JBoss buildpath, project delete external jars - java

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)

Related

what is org.eclipse.wst.common.component and how to use it for ant

I have an eclipse workspace (for work) that has an ear project that I use to "export"/deploy an ear file to a JBoss server.
However, they recently asked me to create an ant script that can build the workspace and create the ear, and I have done this successfully. The problem arises when I try to run my program with this ear that was built using the ant script; for deploying I'm simply copying the resulting ear file and pasting it into the JBoss/standalone/deployments folder and running the application.
The JBoss AS starts fine, but then I get a few exceptions that halt my application that I do not get when I do a build and deploy through eclipse. The two ear files are identical when viewing the two ear files using 7zip, however I see in the eclipse workspace, in the ear project, theres a .settings folder that has 4 files, one of them being org.eclipse.wst.common.component and I'm guessing this (if not all 4 files) is necessary when deploying somehow.
Does ecplise use this .settings folder and the files inside when deploying an ear? What happens during this process? and how can I replicate it in an ant script so that my application runs identically from either ant or eclipse builds?
EDIT
let me just add that none of the files in the .settings folder get packaged up in the ear file, so I'm guessing they're somehow used when eclipse does a build/deploy, but it doesnt get placed in the final ear product
thank you
Eclipse uses the data in org.eclipse.wst.common.component to figure out the dependencies needed for deployment. The file corresponds to the settings found in Eclipse when Right-clicking on an EAR project > Properties > Deployment Assembly.
E.g. if your EAR project has a dependency on a WAR project then Eclipse knows to include the WAR when deploying because of the Deployment Assembly settings which get stored in org.eclipse.wst.common.component
When building the EAR using Ant you need to add these dependencies manually (without relying on Eclipse metadata)

Missing spring-web.jar when deploying with WTP to Websphere

I've build a spring-based web project in Eclipse using Maven. Dependencies and class path are correct and the deployment assembly also lists spring-web*.jar correctly. However, when I deploy it using WebSphere 8 from within Eclipse the mentioned JAR file is missing from the created libs folder under .metadata.plugins\org.eclipse.wst.server.core\tmp2*\WEB-INF\lib . This JAR however is listed under the module section as a submodule for the container. I wasn't able to find out, why this JAR is listed there and why it is not copied to the LIB folder.
It works with a Tomcat server, it works when I export the WAR and deploy it manually and it also works when I manually copy the JAR to the lib folder.
Q1: Is this specific to Websphere?
Q2: Why is SPRING-WEB listed as submodule and what effect has this?
Q3: How can I automatically deploy it correctly?
This seems to be a bug in WAS as reported here
You can either copy the missing JARs manually or you can use the "Run server with resources on server" option in the "Publishing settings for WebSphere Application Server" server settings.

eclipse helios: tomcat project - jar will not be exported or published. runtime ClassNotFoundExceptions may result

I'm using Eclipse Helios and I was wondering how can I add a library project to my folder that will be copied to the build directory where my compiled project resides.
currently I did the following:
created a lib directory in the root of my project
copied the relevant jars to that dir
My Project -> properties -> Java Build Path -> add jars and I added all the jars from that directory.
after adding all the jars i got the following warning regarding each of the jar file:
jar will not be exported or published. runtime ClassNotFoundExceptions may result
first of all how can I add the directory of the jars instead of individual jars?
and the 2nd question is how can I do that the libraries will be deployed properly when compiling my application ?!
In eclipse Junu:
in a web project, after adding jar to build path,
one must add it to
Deployment Assembly
(in project properties)
when adding that jar to "Deployment Assembly" press the add button and select
Java Build Path Entry
(and not other workspace or file system option)
It can be about:
a simple refresh issue:
Can you switch to the navigator view, right-click refresh the project, make sure it's not in the LIB dir,
Then try and drag and drop the JAR into the lib dir and see if it shows up.
a process issue (from this cached blog entry, the original one being unavailable):
When you have total control of you web container/app server, deploying jar files is as easy as dropping the folder in your common lib folder.
If you don't package your web apps as a war file then it's even easier because you only have to drop the jars in the WEB-INF/lib folder of your webapp.
But if you don't have total control of your web server or application server, your only choice is to package the jars you've used with your war file.
While developing a web project using my recently developed utility(a jar file), I encountered a NoClassDefFound error. Of course, it's pretty obvious that the jar file I've made and using on my web project could not be found (not visible in the CLASSPATH).
Adding the jar to the build path only eliminated the compilation problem. Dragging the jar file into the lib folder of my Eclipse workspace isn't a very good idea.
It took me a couple of hours before I figured out the solution:
Right Click on your web project
Click Properties
Select J2EE Module Dependencies
Click the Web Libraries Tab
Add external jars (if the jar is outside of your project). An entry will be added under Jar/Module, make sure you click on the checkbox (checked).
And everything should be fine. I tried exporting to a war file and then checked the content and my jar files are indeed deployed with the war.
a project configuration issue
The OP ufk mentions in the comment:
I resolved the issue by:
adding a "Web App Libraries" library in "java build path" and
adding all the relevant jars into WebContent/WEB-INF/lib
I was facing the same problem, like whenever I export my web app as a war file, the external added jar files didn't get included in app/lib directory, causing exceptions during deployment.
you Have to switch the navigator view, right-click refresh the project, make sure it's not in the LIB dir (but in the project folder)
then try and drag and drop the JAR into the lib dir and see if it shows up.

Error ClassNotFoundException accessing jar in web project

Summary
Classes from 3rd party jar files are accessible when added to build path while running a standalone JUnit test, but "ClassNotFoundException" when accessed through plain old java objects from within a dynamic web project.
IDE used: Eclipse
Web Server: Apache 7
Details
My project required a lot of 3rd party jars, namely sqlite, eclipse jdt & jsoup. I had created this project as a standalone project and all the classes from the jars were accessible fine.
But now I have copied the entire "src" folder into a "dynamic web project". I have created a folder "jars" which contains all these 3rd party jars and ensure that all of these are added to the build path by following these steps:
Project properties --> Java Build Path --> Libraries --> Add jars --> Select all the jar files from jars folder.
These jars are accessible fine when I run a standalone JUnit test inside the web project. Note that this junit test does not require a server by any means.
But when I try to "Run on Server.." , I keep on getting ClassNotFoundException like these for all the 3rd party classes:
java.lang.ClassNotFoundException: org.sqlite.JDBC
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1672)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1517)
I'm sure this has got to do something with my lack of knowledge of how applications are deployed on the web.
The runtime classpath can be different from the build classpath. Create an explicit launch configuration. The default will start with the build classpath but you may have to manually tweak it to include those 3rd party jars.
I've run into this problem before with Eclipse and the Web Server Tools project. Check your .settings files and other files for configuring the plugins that you're using with your project. You may have to remove some filters in the Eclipse view. WST constructs its build path differently, so it may not be using the jars that you've included in your project.
I figured it out. I just had to put all the jars in the WEB-INF/lib directory. I assumed that Eclipse would do all the required settings for me when I asked it to use the mentioned jars. But I guess there are somethings that are not automated very well.

Eclipse and SubClipse: How to deploy my own package with svn to a TomCat server?

I'm using SubClipse for Eclipse for my project.
And in this project I've added my own package "com.mytestpkg.www"
I then use TortoiseSVN to deploy my project on the TomCat server where the project is running, because i the easily can update the site with "SVN Update".
But using this method I always have to manually update my package by copying it from my Eclipse workspace build path to the WEB-INF folder classes/com/mytestpkg/www.
Is there a way to make Subclipse/SVN update this file directly with the other files?
Why don't you do this a more conventional way; e.g.
get Eclipse to create and deploy a WAR file
use Ant or Maven to build the WAR file and deploy it by hand. (The Maven way of building WAR files is really slick!)
Doing a checkout into a Tomcat server's webapps directory is ... weird. And you've got the problem of stopping the world seeing the .svn directories.

Categories