I've built a basic Java Web Project using Netbeaans, which uses Maven.
The issue is, in my 'dependencies' I see 'javaee-web-api-6.0.jar'. However, when I build the project, in the .war file I don't see this .jar file included anywhere.
Am I missing something, or is there any extra step that I need to take to have all the dependencies be included in the .jar?
Servlet API dependencies should never be in the resulting war file. It is a dependency that is provided by your container. Having it in the war file would only result in a bunch of classloader issues. Most containers would ignore the jar file anyway, if it was present inside the war.
Check the scope of javaee-web-api-6.0.jar dependency. If its provided then it will not be bundled into the resultant war.
javaee-api-6.0.jar and servlet-api-3.jar These jars are already provided by Tomcat(assuming using tomact). To verify this look in <TOMCAT_HOME>\lib to see that these jars are already there.
Related
I have a question about using Apache Maven: I built a very simple Maven-based project. This works fine so far.
Now I want to make an executable JAR file from my target file. The problem here seems to be that the dependencies (external libraries) are not packaged together with my app.
I've already googled and found the maven-assembly-plugin. That actually does exactly what I want, but seems to be somewhat inflexible, since the dependencies are not automatically resolved and I can not specify file filters, etc. (or only with much effort over assembly.xml).
What I really like is the solution of spring-boot-maven-plugin, so automatically determine all linked JAR files and put in a lib folder. Now my little project is not a Spring application, so Spring Boot might not be suitable for me, right?
So what would interest me: Is there a way to get a similarly structured and executable JAR archive as spring-boot-maven-plugin builds?
Just use Maven Shade Plugin. It packages your dependencies inside your jar and you can specify the Java packages to exclude
I'm using Eclipse 3.7 (STS) with Tomcat 7 running inside the IDE. I've created a new Dynamic Web project and added a single JSP file to the web content root folder. I can run Tomcat and access the JSP from within Eclipse with no problems.
I've added a few 3rd party JAR's to the project from User Libraries (I'm not using maven or auto dependecies managment). In the JSP I reference a class from the project's JAR file, I can compile this with no problem, but when I deploy on Tomcat the JSP throws ClassNotFoundException. Clearly, Tomcat can't find the JAR's from my library settings. I tried creating a Run As configuration for Tomcat Server and I set the classpath to match the classpath settings of the project, but I still get the same classnotfound problem.
I could get around the issue by manually copying all project JARs to the WEB-INF/lib directory so the webapp can find all dependencies, but that's absurd and I don't expect that to be the solution since it's a maintenance nightmare.
Am I missing something?
In project's properties, go to Deployment Assembly. Add there the buildpath entries as well which you've manually added as user libraries. It'll end up in /WEB-INF/lib of the deployed WAR.
You'll need to copy the jar files to the WEB-INF/lib folder: that is where they are supposed to be.
Eclipse should offer you the option of generating a WAR file that includes all the dependencies: I haven't used Web Tools for a good while but one way or another all dependencies have to be in WEB-INF/lib or the class loader won't be able to find them.
Where should I be putting the plugin dependencies in neo4j 3 (not the actual plugin jars).
In neo4j 2 there was a lib folder where the system would load the jars from but this no longer exists.
I've tried putting them in the plugin folder but then it requires me to add every dependency of the jars which becomes unmanageable and it also seems weird to have them there.
I've tried putting them in the neo4j bin directory but they aren't detected.
I've tried adding a command line argument to the vmoptions file with a wildcard pointing to a lib folder I created and this didn't work either.
Use maven shade plugin to package all the dependencies (except that one with scope test or provided) in the jar.
I think the documentation has just been updated (although I may have missed it). It says
Having built your code, the resulting jar file (and any custom dependencies) should be placed in the $NEO4J_SERVER_HOME/plugins directory. We also need to tell Neo4j where to look for the extension by adding some configuration in neo4j.conf:
So it turns out they should go in the plugins folder or you do as Daniela said and build a fat jar.
EDIT: I eventually came to the conclusion for several reasons including this one to use the server edition which has the same directory structure as the version 2.x.
I built my netbeans project and it created a .war file including all the .jar libraries. I need to remove my all libraries from .war file. I tried to untick them from library folder but then the project does not deployed. How can I remove my libraries from the .war file and if I remove them where should I put them correctly. In jboss also there is a folder called lib in standalone folder.Should I put them there? If so how to do it. I am not using maven.
If you are using Maven set the dependency scope to the libraries you would like omitted to have scope provided. You can add the dependencies of your WAR to the MANIFEST.MF file or the jboss-deployment-structure.xml file using Maven. If the lirbaries are not JBoss modules by default, eg Orcale JDBC driver, then you will need to create these modules yourself. See the JBoss AS 7 documentation on how to do this.
You can try following approach. I haven't worked on Jboss so don't have detail idea about it.
Deploy each logical library (like "OpenJPA" or "Log4J") as a module, including its api and impl jars and any dependency JARs that aren't already provided by other AS7 modules. If there's already a module add a dependency on it rather than adding a JAR to your module. If several different libraries share some common dependencies, split them out into modules and add them as module dependencies in module.xml.
Use jboss-deployment-structure.xml to have your deployment .war / .ear / whatever declare a dependency on the module if it isn't autodetected and autoloaded.
Courtesy #Craig Ringer.
For complete thread go here
I'm completely new in Spring and followed this tutorial http://tutorialspoint.com/spring
and this video too http://www.youtube.com/watch?v=ZwMwfGNrRtE
And according to this i downloaded spring-framework-4.0.6.RELEASE-dist.zip from here
I did extracted those zip files,
Now i'm unable to locate jars files into folder, But www.tutorialspoint.com/spring says It contains this pic.
But into my folder(which i downloaded spring framework), I can't locate these library please help!!
I did search all jar files in that folder but i could find only this pic
and not being able to find these jar files:
antlr-runtime-3.0.1
org.springframework.aop-3.1.0.M2
org.springframework.asm-3.1.0.M2
org.springframework.aspects-3.1.0.M2
org.springframework.beans-3.1.0.M2
org.springframework.context.support-3.1.0.M2
org.springframework.context-3.1.0.M2
org.springframework.core-3.1.0.M2
org.springframework.expression-3.1.0.M2
commons-logging-1.1.1
Well surprisingly, the dist for release 4.0.6 does not contain the jars for 3.1.0.M2 ! More seriously, under lib dir on related zip file, you will find all the jars for spring 4.0.6.
But you must have a minimal knowledge on your build environment be it maven, eclipse, Netbeans + ant, Netbeans + maven, ...
And do not forget the documentation for spring that explains what external jars are required for some operations. Notably commons-logging-1.1.1 even if the manual explains how to use other loggin utilities.
You may want to consider using Maven, as opposed to manually downloading jar files and referring to them explicitly.
With Maven, you'd declare a dependency on the spring framework (including specific version) and you'd have all of the dependencies downloaded to a local repository, including transitory dependencies (you'd only need to specify the framework itself, for example, although in your case you'd probably need to include security and/or mvc.)