I am new to programming web applications, and so far I am working with a eclipse/maven-setup with a Jetty server, to develop java web-apps.
One thing I do not understand however, is the dynamics of including external jars. Many tutorials, and Q&A's here on SO claims that it is enough to add the jar to WEB-INF/lib. other explain how I need to add them as dependencies in pom.xml. I have found that some times the first solution works, while some times I also need to add the dependency. I am not sure why it is this way. In addition, when adding dependencies, I have manually copied the external .jars to folders matching the already excisting repository resources. I can't believe that this is the right way to do it, but it has been working out for me.
So my questions are:
- Am I correct that the jars need to be double referenced, or am I making a work around for a possible other problem?
- What is the difference between the two methods of import/referral?
Bonus Question: Why are the errors below showing up in eclipse? These refers to all of the jars I have tagged as dependencies in pom.xml. The web-app runs as it should, although with seemingly random different runtime errors after a period of time. Restart of the server fixes it at the moment.
Description Resource Path Location Type
Missing artifact standard:standard:jar:1.1.2 pom.xml /WebApp line 1 Maven Dependency Problem
Missing artifact jstl:jstl:jar:1.2 pom.xml /WebApp line 1 Maven Dependency Problem
Missing artifact junit:junit:jar:4.8.2 pom.xml /WebApp line 1 Maven Dependency Problem
ArtifactDescriptorException: Failed to read artifact descriptor for javax.servlet:javaee-web-api:jar:6.0: ArtifactResolutionException: Failure to transfer javax.servlet:javaee-web-api:pom:6.0 from http://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced. Original error: Could not transfer artifact javax.servlet:javaee-web-api:pom:6.0 from/to central (http://repo.maven.apache.org/maven2): connection timed out to http://repo.maven.apache.org/maven2/javax/servlet/javaee-web-api/6.0/javaee-web-api-6.0.pom pom.xml /WebApp line 1 Maven Dependency Problem
Missing artifact com4j:com4j:jar:1.0 pom.xml /WebApp line 1 Maven Dependency Problem
WebApp Unknown Validation Message
WebApp Unknown Validation Message
WebApp Unknown Validation Message
(Yes there is a total of 8 errors, whereof 3 is completely empty in eclipse.