Spring Loaded , Eclipse and Tomcat integration - java

Spring loaded can dynamically reload class files in a running web application.
But it can't reload jar files.
Now, I have a project where the Web part includes many other service projects as jar files. All are eclipse based and in the same workspace.
My question is, since we cant reload jars at runtime using spring loaded, can we configure eclipse web project in such a way that
the class files from the service projects are directly copied to my WEB-INF/classes. (I dont want to have jar's of the service projects).
Also do I need to enable the "build automatically" in eclipse to get my changes reflected.
I was able to configure spring-loaded in netbeans with the compile on save option.

Related

To add External Spring jars for a spring project without Maven

I just downloaded the Spring IDE and Tool suite from Eclipse Market place.I am creating a sample Spring project using Spring core containers. I am following a tutorial video for that. I want to set build path by adding external downloaded Spring jars for that I have gone to build path of a specific project and I don't know where my downloaded external spring jars. I have searched in my local drive in java folder in programming files and also where my eclipse is saved. But I cannot find where my external spring jar files saved.
Kindly tell me the path where I can find external downloaded jars from eclipse Marketplace
Spring Suite tool is Rapid Application Development plugin, which helps to decrease spring configuration time and help you focus on core logic of your application.
Even though, As Martin Lippert Explain below, you might have to use Maven (Build Automation tool, And project dependency manager) for creating spring project.
people often use Maven for their dependency management (or Ivy or something else) and would like to use a specific version of the Spring framework (instead of the libs that are inside STS and used by STS itself). But you can define a user-defined Library that contains all the necessary Spring framework JARs and maybe others and just add that user-defined library to each project. Would make it a bit easier as adding several JARs all over again.
Maven uses a filesystem tree as a repository to store jar files with there metadata(dependency, version, etc.) which is located (by default) under your home or My Document Path within .m2 directory (folder).

How to create war file in eclipse with all the necessary dependencies without maven or ant

I saw lots of questions including this one : How to create an war file in Eclipse without ant or maven?
I have standard web project created with eclipse. In this web project like many others there isn't only jsp and web files, but java files also. I am using eclipse Luna and I am trying to export my project as war but when I use the export option and package it like war it packages only my web content. Normally after I deploy it to tomcat it fails on login in my site because there is no java files on the war. I am new to the web projects and I do not want to use maven or ant. I want to just simply make working war from eclipse and could not find normal way to do that.
Right Click on your Web project --> export --> War file --> Choose destination path and select on Export source files.
See the below screen shot:
After creating Excel2DB22.war. I have imported it again into my IDE. I can see all the files including java also in that project.
See the below SS:
I hope it will help you.

How to organize gae projects in eclipse

I try to find the way to organize a GAE with several projects within Eclipse using the Google plugin for GAE:
The Web App project (a WebApp project) containing the GAE web application.
A Java project with data access
A Java project with utility classes
My problem here is how to link things together. I want to add the two Java projects in both build and execution paths. Since a Web App project follows the JavaEE structure, only what is specified in the WEB-INF/lib directory is taken into account.
I would like to find out how to simulate a Jar file in this directory based on a Java project present in the Eclipse workspace based on what the Google Eclipse plugin for GAE provides.
I saw something that seems to be related in the WebApp project properties Google > Web Application, section "Suppress warnings about these build path entries being outside of WEB-INF/lib".
For the GAE web application to run then you'll need the classes or a jar from the projects you want to include in the WEB-INF/classes or WEB-INF/lib folders respectively.
One way would be to build your data and utility projects and put the resulting jars in the WEB-INF/lib folder. You can then then reference those jars as libraries from your web app and all should be fine. Of course that's a bit tiresome to do manually, so you should probably check out some dependency management tools. From personal experience Ivy and IvyDE were easy to get into and should cover your needs although Maven and others have their strengths.
Another way that is a easier (but less structured) is to used linked source folders in your build path (to the source folders for your data and utility projects). In such way Eclipse will build those sub projects to WEB-INF/classes and build and execution should work similarly.

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 WAR with 2 projects?

I am trying to export a WAR file from Eclipse. I have a "Dynamic Web Project". But I need classes created for two other projects, one a plain Java project, the other another web project. So in the Build Config I told it to add the other projects and on the "Order and Export" page I clicked the boxes to export the second and third projects. In runs fine within Eclipse, apparently finds the files from the other projects with no problem. But when I export, only the files from the first project are included in the WAR file.
How do I get Eclipse to include the other projects' files in the WAR? Apparently just adding them to the Build Config and marking for export isn't enough. Is there a problem because one of the other projects is also a web project? Does Eclipse balk at that?
I presume I could make this work by copying the files I need from the other projects to the first. But then any time they are updated, I would have to know that this had happened and copy the new versions. That would be a pain, and I thought that's what Eclipse projects were for, so I could share files between applications.
Edit
Let me clarify that I don't want to deploy 2 WARs. I have a web app written for one project that includes some classes that I want to re-use on another project. What I was trying to do was just pick up those couple of classes in the "real" WAR. I definately don't want to deploy 2 WARs because this might go on the same server as the original project, and I don't want to overwrite the existing WAR of the original project.
Thanks for any help!
You need to add your other project as a Java EE module to your web project. Right click on your web project -> properties -> Java EE module Dependencies. Add the 'other' project to it. Eclipse will include this project in the export.
Packing together different projects for deployment is achieved through an EAR file (enterprise archive). An EAR may combine multiple web projects (WAR), Enterprise JavaBeans projects (JAR), standard JARs, etc. and packs it into a single application.
Create a new EAR project in Eclipse, open its properties and check all dependencies on the Java EE Module Dependencies page. After that export the project as an EAR and deploy it.

Categories