I have a web application. I have created a war file out of the "export" option from Eclipse. However, the war file only contains the META-INF and the WEB-INF folders. There are no .java or .class files at all.
I also tried another method using the Maven "clean install" goals. This one also gives me the exact problem as above. Where am I going wrong? Can someone help me out?
Thanks.
Please chcek if you have your code in default src path for maven (src\main\java)
If your project is an Eclipse project you need to make sure you created it as a 'Dynamic Web Project' so Eclipse attaches the right Facets so it knows how to build the .war.
If it's a maven project, you at least include
<packaging>war</packaging>
so Maven knows how to package your app.
If you run 'mvn package', assuming your pom.xml is configured correctly, you should get a .war file created in the target dir.
Sounds like something is not configured right - can you share more info about your source project structure and how it is configured?
Related
My company is attempting to make a transition from Eclipse to Intellij Idea and I have a (might be silly) question regarding the paths.
I have a library in the root of the eclipse project and a spring configuration file which simply points to it by "folderName/file.txt". It works fine in Eclipse since it recognizes the folder. In IntelliJ however it seems to not pick the folder at all.
I've tried to mark the folder as a resource/test resource folder but it seems to simply take the contents of the folder and dump it directly into the target folder without the folder itself, just the contents.
Is there a way to configure IntelliJ to work with the folder just like in Eclipse? This is important because some are still using Eclipse, some IntelliJ, so we need a solution that will work for both.
I am guessing your are using maven since you mention the "target folder"
What happens is that since your imported the project from the maven pom.xml intellij build it by following maven.
In maven the default project structure is
this
This in maven everything you copy in the resources folder, will be copied to your root classpath. so if you make for
resources/myFolder/my.txt then in the build you will have copied to your classpath myFolder/my.txt
Anyway if you are not using maven all you have to do is go to
Project structure (ctrl+alt+shift+s) - Modules - go to your module - mark the folder that your want to add as resource
I have downloaded a project from git. Its a web project using maven. I have eclipse in my machine and also maven is there. Now I want to create a war file from this project for deploying in Tomcat.
Any idea how I can do it. Command line will be a prefer option. I searched in Google but in most of the places it is asking to create a new Maven project or I am missing something.
Thank you
Just add <packaging>war</packaging> to your pom.xml, and run mvn package from the root of your project (i.e. where the pom.xml resides). If everything will be successful, you'll get a war file in the target directory. See: http://maven.apache.org/pom.html#Maven_Coordinates
I have a java web application name webapp,when I export it to a war,the source codes will be compiled to the WEB-INF/classes.
Now I want these classed be compressed to a jar,and put into the WEB-INF/lib.
I have tried this:
create a new java project named webapp_jar.
Copy all the source codes under the webapp/src to the webapp_jar/src,configurate the build path to make the project work.
Add the webapp_jar reference to webapp project.
However ,when I run the webapp,it seems that the classes defined at webapp_jar can not be found.
Is this possible?
BTW,I use the eclipse ee ide.
have you try ant https://ant.apache.org/ ?
you could make a jar and copy it to folder you want and build the war after.
But , if I anderstand, you would package all the app to a jar ?
I think your webapp can't work without a servlet or two ...
This is really easy to do with maven by creating two subject projects, one to build the war, and the other as a jar project and then use the jar project as a dependency on your war project which would put the jar inside the lib directory when packaging the war.
No I use the Web Deployment Assembly settings in eclipse. I worked.
You can find details here.
When I was working with java spring hibernate struts2 eclipse project. I used buildpath-> addjar option to add jars from a folder inside the workspace. Even if the class is available it shows class not found exception.
If i put those jar files in web-inf/lib folder everything works.. Should i keep those files in the lib itself? Can i just include those jars in a seperate folder and add jar using eclipse configure build path??
what is the problem ? please help me... thanks in advance...
If you're using a standard Eclipse Dynamic web project, best way to go is to put all your Jars in the WEB-INF\lib folder. This will automatically add them to your build path and also include them in your WAR when you export it.
If you still want to use the Build Path > Add Jar option on the project, and want your Jars to also be included in your WAR, you have to go to the Project Properties > Deployment Assembly configuration and include them there. Of course this is double the work for every Jar.
This is probably a basic question for you here but here goes:
I'm building a java project using Maven in eclipse at the moment. I have a pom.xml file which is working fine, but I need to be able to organise my source files into 'src/main/java' and resources into 'src/main/resources' etc. Any other maven projects I've looked at are structured like this and the build goes to success without picking up any source files, since it "skips non existent resourceDirectory src/main/resources" and the others.
I currently have a source folder 'src', and eclipse won't let me add more source folders with 'src' in the name.
Any guidance whatsoever would be greatly appreciated.
Try right-clicking on the project and selecting Maven->Update Project Configuration from the context menu. Then refresh the project. If your pom is close to right, that should represent your project in eclipse the way you want.
Why don't you just open your pom.xml file in eclipse? It can recognize it and will built its project files correspondingly
In eclipse right click over the project / Build Path / Configure Build Path / Source (tab)/ Add folder and select the source folder you want. If the folder you need doesn't exist under /src/main create it following the maven conventions.
after that I would recommend:
mvn eclipse:clean eclipse:eclipse