IntelliJ and Tomcat….changed files are not automatically recognized by Tomcat

This cannot be done if you deploy a war with IntelliJ IDEA. However, it can be if you deploy an exploded war. In IDEA: open your Tomcat Run/Debug configuration (Run > Edit Configurations) Go to the “Deployment” tab In the “Deploy at Server Startup” section, remove (if present) the artifact my-webapp-name:war Click the add icon, … Read more

Maven WAR dependency

There’s another option since maven-war-plugin 2.1-alpha-2. In your WAR project: <plugin> <artifactId>maven-war-plugin</artifactId> <version>2.1.1</version> <configuration> <attachClasses>true</attachClasses> </configuration> </plugin> This creates a classes artifact which you can use in the acceptance tests project with: <dependency> <groupId>your-group-id</groupId> <artifactId>your-artifact-id</artifactId> <version>your-version</version> <classifier>classes</classifier> </dependency>

How do I run a class in a WAR from the command line?

Similar to what Richard Detsch but with a bit easier to follow (works with packages as well) Step 1: Unwrap the War file. jar -xvf MyWar.war Step 2: move into the directory cd WEB-INF Step 3: Run your main with all dependendecies java -classpath “lib/*:classes/.” my.packages.destination.FileToRun

Oracle JDBC ojdbc6 Jar as a Maven Dependency

It is better to add new Maven repository (preferably using your own artifactory) to your project instead of installing it to your local repository. Maven syntax: <dependency> <groupId>com.oracle</groupId> <artifactId>ojdbc6</artifactId> <version>11.2.0.3</version> </dependency> … <repositories> <repository> <id>codelds</id> <url>https://code.lds.org/nexus/content/groups/main-repo</url> </repository> </repositories> Grails example: mavenRepo “https://code.lds.org/nexus/content/groups/main-repo” build ‘com.oracle:ojdbc6:11.2.0.3’

How to create war files

You can use Ant to set up, compile, WAR, and deploy your solution. <target name=”default” depends=”setup,compile,buildwar,deploy”></target> You can then execute one click in Eclipse to run that Ant target. Here are examples of each of the steps: Preconditions We’ll assume that you have your code organized like: ${basedir}/src: Java files, properties, XML config files ${basedir}/web: … Read more

Difference between jar and war in Java

From Java Tips: Difference between ear jar and war files: These files are simply zipped files using the java jar tool. These files are created for different purposes. Here is the description of these files: .jar files: The .jar files contain libraries, resources and accessories files like property files. .war files: The war file contains … Read more

Appending files to a zip file with Java

In Java 7 we got Zip File System that allows adding and changing files in zip (jar, war) without manual repackaging. We can directly write to files inside zip files as in the following example. Map<String, String> env = new HashMap<>(); env.put(“create”, “true”); Path path = Paths.get(“test.zip”); URI uri = URI.create(“jar:” + path.toUri()); try (FileSystem … Read more

How to deploy a war file in Tomcat 7

You can access your application from: http://localhost:8080/sample Deploying or redeploying of war files is automatic by default – after copying/overwriting the file sample.war, check your webapps folder for an extracted folder sample. If it doesn’t open properly, check the log files (e.g. tomcat/logs/catalina.out) for problems with deployment.

What is WEB-INF used for in a Java EE web application?

The Servlet 2.4 specification says this about WEB-INF (page 70): A special directory exists within the application hierarchy named WEB-INF. This directory contains all things related to the application that aren’t in the document root of the application. The WEB-INF node is not part of the public document tree of the application. No file contained … Read more