Issue on removing jar from deployment assembly in eclipse - java

hi guy iam facing a problem in my Liferay Eclipse project. I have included in it some required jar files using Right_click_on_project -> Properties -> Deployment Assembly.
when i try to remove them using the same procedure an clicking on Apply button they are removed. but when i come back again the deleted jar figure again. doing and doing again the result is always the same: the jar are not removed!
how to delete those jar as they are not needed anymore in my project? i tryed to manually delete them. but their entries always figure in the Deployment Assembly with yellow mark.
Ian using eclipse Luna with liferay plugin 6.1 and Ivy.

i figured how to get rid of those jar file.
i went to the directory liferay_sdk -> portlet -> eclipse_plugin_project_name -> .settings
and then i deleted entries relative to those included jar file in file org.eclipse.wst.common.component.

Related

Eclipse loses classpath src entries after Gradle IDE `refresh all`

I have an existing Spring web-app that I wish to convert to a gradle project. I downloaded the Gradle IDE plugin and converted to Gradle project. This reset my .classpath and .project files and got rid of my src entries that are neccesarry for my application to run. So no big deal I thought, I would just go in and add them back, which I did. The problem is that when I right click on my project and choose Gradle STS -> refresh all, it resets my .classpath and .project back to how they were without my src entries. How can I prevent this from happening?

Update External Jar in Android Project

All, I have an external JAR that I'm adding to my Android project. However, as my jar is consistently updating and changing. When I update my JAR, I get the dalvik VM magic number error.
I don't understand how I'm supposed to fix this?
Here's the steps I've followed.
Adding The Jar Initially
Copy JAR to libs folder in my project
Run project
My JAR is picked up, installed everyone is happy.
Updating the Jar
In Eclipse, go to the jar in libs and right click -> delete.
Copy my new jar (same name) into the libs folder.
Receive bad class file magic error.
My Troubleshooting So Far
In eclipse, Project -> Clean...
Select my project, clean it.
Run it. Same error... magic number
Project Properties -> Java Build Path -> Remove Android Private Libraries
Now the private libraries aren't being re-added. (Which equates to missing imports in my Java project) Why is this a nightmare? Any suggestions?
Turns out that my issue was caused by the multiple JDK's I had. Android was defaulting to use JDK 1.7 while my console jar was using JDK 1.8

java.lang.NoClassDefFoundError: org/hibernate/cfg/Configuration

I'm trying to do an initial setup with Hibernate in Eclipse, while deploying with Tomcat.
I encountered the following problem:
java.lang.ClassNotFoundException: org.hibernate.cfg.Configuration
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1701)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1546)
db.HibernateUtil.buildSessionFactory(HibernateUtil.java:13)
db.HibernateUtil.<clinit>(HibernateUtil.java:8)
I've goggled my problem online and I understand that it has something to to with the project class path.
I've added a user library to my project containing all the jars under the "required" directory in the hibernate download, but that doesn't seem to work.
Please find a screen shot of my project here:
You're getting the error because the hibernate libraries are not available to Tomcat. In your picture, below the hibernate library set there is an empty set called 'Web App Libraries' - this is the set your hibernate libraries need to be in.
Right click your project -> Build Path -> Configure Build Path, and remove the hibernate set from the build path. Now import the jars into the WEB-INF/lib folder. Refresh your project and now you should see them listed in the 'Web App Libraries' set (i appreciate this is somewhat annoying that you have to import them into your code base - someone else might know a better way to do this that doesn't involve copying the jars in)
This error can happen when your jar files has not been exported with your web archive. You can do what #Chris White has said or you can follow below steps if you are using Eclipse.
Right click the project -> Build Path -> Configure Build Path
In the list at left side click on Deployment Assembly. Click "Add" button. Select "Java Build Path Entries" and click next. Now select your hibernate jar files or library. Click finish. Then click Ok.
Restart the server if necessary.
Simpler way than Chris White's way.
You're getting the error because the hibernate libraries are not available to Tomcat. Right click your project -> Build Path -> Configure Build Path, and remove the hibernate set from the build path.
Do the same stuff, but instead of importing the jars everytime for a new project, **copy the required hibernate jars in lib folder of Apache Tomcat **(or whatever the server u are using).
You don't have the hibernate jar present in your library folder
Visit the below link for the possible solution, http://www.smashplus.info/2012/11/javalangnoclassdeffounderror.html
To achieve the same with IntelliJ :
File -> Project Structure
Project Settings -> Artifacts
Select your .war artifact
expand Available Elements
right click the Hibernate lib -> Put into /WEB-INF/lib
Done.

Adding 3rd party jars to WEB-INF/lib automatically using Eclipse/Tomcat

I have a dynamic-web project set up on Eclipse and I'm using Tomcat 7 as my web server. It doesn't seem to be automatically putting 3rd party JARs I add to my library on my build path into the WEB-INF/lib folder. Is there a way I can do this automatically? Every time I search for an answer to this, I find something like this.
So how do I do that automatically? Is there a way to configure my build path to do this?
Here are the instructions for Helios. For earlier releases, see SeanA's answer.
Project Properties -> Deployment Assembly
Add -> Java Build Path Entries
You should now see the list of libraries on your build path that you can specify for inclusion into your finished WAR.
Select the ones you want and hit Finish.
You can use "Ant" to copy files to WEB-INF/lib when you deploy files. Using Ant you will be able to copy only those files which have changed.
http://ant.apache.org/manual/Tasks/copy.html
http://help.eclipse.org/helios/index.jsp?topic=/org.eclipse.platform.doc.user/gettingStarted/qs-81_basics.htm
I haven't tried this personally, but what I believe it does is what I think you are looking for:
Right-click project -> Properties
Go to Java EE Module Dependencies
Check the boxes for the JARs that you want to export with your Web Application
Let me know if this automatically puts them in your exported WAR. I always just add mine to WEB-INF/lib :)
Instructios for Eclipse Indigo (version 3.7.2)
Project Properties -> Deployment Assembly
Add -> Archives From File System -> Next -> Add
(The file dialog of your system opens up.)
Navigate to the archive you want to include in your WEB-INF/lib, select it and hit OK.
Hit Finish.
Hit OK.

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.

Categories