currently I develop my applications with eclipse and I have configured tomcat's context.xml file in tomcat/config directory and all works fine.
But when I create war with mvn clean package command, I'd like to include into META-INF folder of the project, another customized context.xml file.
How can I do this?
I tried to create 2 profiles without success.
Thanks
Tomcat's context.xml file is located under $catalina_base/conf/ and can add things to that of your web application's context file. Add your (separate) web application's context.xml in Maven project at
src
main
webapp
META-INF
context.xml
Related
I'm trying to run my camel application on external tomcat. There are 2 application.properties files present in my project, one under src/main/resources and other under src/test/resources. When I create war file using maven install command, it uses the application.properties file from src/main/resources (which is needed) but when I start the application using tomcat in eclipse, it is using application.properties file from src/test/resources. I've also removed classpath entry of src/test/resources from eclipse but no luck. I'm not really sure how is it picking the application.properties file from src/test/resources.
When I delete the application.properties file present under src/test/resources then it works fine i.e. then it picks the application.properties file present under src/main/resources.
We are using:
Oracle JDK 8
Spring 4.3.11.RELEASE
Tomcat 8.5
Camel 2.20.2
ActiveMQ 5.15.0
Maven Build Tool
Thanks in advance.
When Eclipse deploys a project to a server the important setting is the "Deployment Assembly", not the "Java Build Path". If you remove the src/test/resources folder from the deployment assembly, the files it contains will not be copied.
I have written a REST-API using JAX-RS. For that I have created a Dynamic Web Project in Eclipse, and than converted it into a Maven project.
I want my logger folder to be WEB-INF/logs/loggerFile.out.
So I created a folder in my WebContent/WEB-INF/logs.
But now when I am packaging it in a WAR, the logs folder is missing in the packages WAR as as in the target/MyProj/WEB-INF..there is no log folder there as well.
I tried creating the folder inside target/MyProj/WEB-INF manually, but still its not available in the WAR file.
(I am viewing the content inside the WAR file using 7-zip).
I am doing all this on my Windows-7.
Please help
I currently have a working servlet created in Eclipse. When running it from the Tomcat plugin, everything works, and my app shows up at localhost:8080/project_name/. However, when I package the project into a .war file and place it in the /webapps directory of Tomcat and start the server, the servlet cannot be accessed. In Terminal, I can see Tomcat loading my project, and a temporary folder of the unarchived project is also created in /webapps. However, I simply cannot access my servlet.
Note:
I'm using Tomcat 7 and I don't have a web.xml file in my project.
How are you creating the war file? Check if your war files contain jar files under WEB-INF/lib folder and if the class files are not missing. You can easily verify it under tomcat/webapps/[project name] folder.
when I run my dynamic web project from eclipse it gets deployed to wtpwebapps. However I want to deploy a war file to tomcat so when I checked here in SO this came up
How to deploy a war file in Tomcat 7
It says I have to deploy to webapps folder in tomcat.
Can anybody please explain me the details between wtpwebapps folder and webapps folder in tomcat and also if I can deploy war files to wtwebpapps folder instead of webapps folder.
wtpwebapps is an eclipse-specific folder created when you run a dynamic web project on Tomcat within eclipse.
Webapps directory is within the Tomcat home and it's where you copy over your WAR files manually.
Recently, i've struggled with webapp strange behavior while debugging in Eclipse. I've noticed that it was double deployed.
My setup was:
web module with context path that differs from document base;
enabled autoDeploy in server.xml;
and deploy was set into webapps directory.
When checking tomcat-manager i've noticed that this webapp was deployed once with its context path name and once with document base name.
Here is what the documentation states (All credits goes to octopus, Tomcat docs):
If you want to deploy a WAR file or a directory using a context path that is not related to the base file name then one of the following options must be used to prevent double-deployment:
Disable autoDeploy and deployOnStartup and define all Contexts in server.xml
Locate the WAR and/or directory outside of the Host's appBase and use a context.xml file with a docBase attribute to define it.
And, i believe it's the main reason to use wtpwebapps instead of webapps for Tomcat with Eclipse.
When selecting a new maven project from the Netbeans New Project Menu, there is the option to create a Web Application, or a Standalone Application. I'd like to create a Class Library for use with a Web Application.
How would you recommend I go about this. I see the new Servlet 3.0 Web Fragments need to be put into the META-INF folder and saved as web-fragment.xml. I'm not too sure where I'd create this directory if I'm packing a JAR and a WAR.
Some insight would be greatly appreciated.
You can create either Java application or Web Application. Just place the META-INF folder in the src/main/resources folder. and place web-fragment.xml directly under it. You can also place any images,css or javascript files in META-INF/resources folder. So when the application you are deploying this for will look in the WEB-INF/lib folder and load all the META-INF contents of the jar onto the classpath.
when generating the .war file with standard maven settings (no special config of maven-plugin-war) the web-fragment.xml should found in the /META-INF dir of the generated JAR file inside the WAR's /WEB-INF/lib dir.
in our case the web-fragment.xml was not in this dir but in the WAR's /META-INF dir, which is the wrong place