I suppose same problem as described in question MSAL for Java quickstart sample app throws exception. When using IDE and deploying to embedded tomcat, app works. After spending one day, I figured out what is the problem.
Application AuthPageController specifies #RequestMapping("/msal4jsample/secure/aad"). This works with embedded tomcat. When deployed to tomcat server, tomcat removes application name from path since it is deployment information and exploded folder name depends on war file name. Same application can be deployed multiple times to different folders. Tomcat maps url as /secure/aad and request in this case is never handled. To fix problem, I created array of request mappings #RequestMapping(value = {"/msal4jsample/secure/aad", "/secure/aad"}).
I forked MS Azure repository and made changes. Please take a look at zdenko-s/ms-identity-java-webapp
There are other fixes too.
War file name is specified in pom.xml, no need to rename it. Removed rename step from documentation also
.gitignore wrongly specifies exclude target. Should be */target
Sharing info. Fix in my forked branch
Related
Ideally what I want to be able to do is load in a fresh copy of the config if a change is detected so that if it is updated in the DB, it gets fetched and updated in the application without a restart.
I tried to add autodeploy = true inside host, server.xml and reloadable = true inside context.xml.But none of this worked.
Is there any other solution for this. Iam using eclipse IDE and my sever is Tomcat.
I read adding inside context will help for this.
<Context reloadable="true">
<!-- Default set of monitored resources -->
<WatchedResource>Config/Design/configs/globalconfig</WatchedResource>
But this one still din't help me.Am I giving the path in wrong way or something?I got this from the following link https://www.mulesoft.com/tcat/tomcat-reload
Edited Besides I tried with the auto reload on module, disabled and enabled as well. And also noting one more thing here I don't want to use JRebel.
If I go by the heading of the question
change in configuration/setting without restarting Tomcat
I would agree with Jomcy Johny, that the design approach perhaps need to be reviewed. In continuation to the above comment, perhaps you should consider keeping the configuration outside of the container. There are many way of achieving the same, one possible direction is with Apache Zookeeper.
On the side note, the path mentioned in the Mule document is generally of form 'WEB-INF/x/yz' or '/Dir0/config.file'.
It is possible to deploy web applications to a running Tomcat server.
If the Host autoDeploy attribute is "true", the Host will attempt to deploy and update web applications dynamically, as needed, for example if a new .WAR is dropped into the appBase. For this to work, the Host needs to have background processing enabled which is the default configuration.
autoDeploy set to "true" and a running Tomcat allows for:
Deployment of .WAR files copied into the Host appBase.
Deployment of exploded web applications which are copied into the
Host appBase.
Re-deployment of a web application which has already been deployed
from a .WAR when the new .WAR is provided. In this case the exploded
web application is removed, and the .WAR is expanded again. Note that
the explosion will not occur if the Host is configured so that .WARs
are not exploded with a unpackWARs attribute set to "false", in which
case the web application will be simply redeployed as a compressed
archive.
Re-deployment of a web application if the /WEB-INF/web.xml file (or
any other resource defined as a WatchedResource) is updated.
Re-deployment of a web application if the Context Descriptor file
from which the web application has been deployed is updated.
Re-deployment of a web application if a Context Descriptor file (with
a filename corresponding to the Context path of the previously
deployed web application) is added to the
$CATALINA_HOME/conf/[enginename]/[hostname]/ directory.
Undeployment of a web application if its document base (docBase) is
deleted. Note that on Windows, this assumes that anti-locking
features (see Context configuration) are enabled, otherwise it is not
possible to delete the resources of a running web application
Above is a snippet from Apache tomcat And also most of the general idea about hot deployment I gained from hot deploy
Reloading Context elements when they are within the server.xml is not likely to work as "...server.xml file cannot be reloaded without restarting Tomcat"[1].
What you can try, is creating a file at "/META-INF/context.xml"[1], and adding the context in there.
Then you can replace the war file if with the new context files without a server restart.
Or you program a server restart in if needed. See [2]
source:
[1] https://tomcat.apache.org/tomcat-8.5-doc/config/context#Defining_a_context
[2] Java - Tomcat: Reload context.xml without restarting server
You can write a script and run it as a service outside your application to keep a track of your config file's last modified time, in case of a change you switch to your Tomcat container and run the following command (considering OS is Linux):
source ~/.bashrc
(In case of windows, its done as soon as you change environment variables and save.)
Hope that this helps.
My question may sound obvious but i'm quite new working with Wildfly 9 !
I deployed my EAR in server via admin console. My Wildfly is in standalone mode. I couldn't where the ear was deployed ! Is there any specific folder for deployed applications in wildfly ?
Thanks!
[EDIT]
I want to know about deployed location because of class loading in wildfly. I attempted to load a resource which is a .exe from classpasth but it render a wierd path:
Event.class.getResource("/Decorder/Decoder.exe")
I get the following out put in wildfly logs :
C:\apps\wildfly-9.0.2.Final\bin\content\SYSE.ear\SYSE-components-3.0.jar\Decoder\Decoder.exe
I don't know from were the resource path above is coming from !
You have deployed your ear throught the webconsole or cli, it is a managed content and as such is managed through the ContentRepoistory in WildFly. It should be under standalone/data/content + hash part.
This looks quite weird to me : C:\apps\wildfly-9.0.2.Final\bin\content\SYSE.ear
[UPDATED to new question]
This all comes down to how you packaged and configured your deployment.
/Decorder/Decoder.exe might be a valid path if you provided the file in /resources/Decorder/Decoder.exe. This is due to the fact that the classloader will provide all of your resources relative to your root, which in most cases is the jar component.
Note: maybe it is already resolved by removing the typo in your path: /Decorder/Decoder.exe -> /Decoder/Decoder.exe
I am using Jenkins (v1.4.87) and have the deploy plugin (v1.10) to create a job that deploys a built war file into tomcat 6.
The deployment is running successfully, the war is being deployed ok.
Here is the plugin configuration part of the job:
(I have not included the real server details for obvious reasons)
The problem is that somewhere along the way, the application context file is renamed to appname.xml.bak and left in that state. Therefore the application fails to start because tomcat cannot find the context file it expects for the application any longer.
To remedy this I have to log into the server where the context file is located and rename the backup back to its original file name appname.xml.
It feels like the deploy plugin may be getting to a point where it should handle this. I would expect it to either make a copy of the context file called appname.xml.bak or rename the backup back to the correct file name.
I cannot find any documentation that lists out the phases that the plugin goes through so I cannot confirm if this behavior is expected or not. I am left with the only option to download the plugin code from Github and figure it out myself.
Have I missed something obvious maybe?
UPDATED:
I have since updated to Jenkins v2.32.3 and I have the same issue with the deploy plugin. Any help would be great thanks.
There's alot of questions on different forums [1] [2] [3] about this topic but none seem to provide a definitive answer. I've tried different combinations suggested in the various posts but I have yet to succeed.
My goal is to make compiled source code in a standalone tomcat (8) reloadable - just like the embedded tomcat reloads newly complied sources in e.g. spring-boot or Grails. There are a few constraints that I need to comply with:
No Grails or Spring-boot is available
No Maven or Gradle is available
The tomcat should read the exploded war file from an external location
To keep things simple I use a very simple JEE app with Spring MVC as POC for this before I move on to the real deal. The setup is as follows (for now):
Exploded war builds into directory target/exploded
Tomcat is setup with default settings except from Context.xmlwhere the two lines regarding WatchedResource are removed. Context is not set to reloadable="true".
The Tomcat server is run from within IntelliJ Idea (2016.3) like this:
where the "exploded" folder points to the target described above. And the "Server" tab like this:
The server starts up and the app is running fine. I then try to change some code, save it, and build a new exploded war file. I can see the class files change - but nothing is reloaded in tomcat.
Can anybody please elaborate? Is this approach even possible - in contrary to what many posts suggest? How is it possible in the embedded tomcat in e.g. Grails?
I am curious about following error :
Publishing to JBoss 7.1 runtime server - MyEAP has encountered problem
Error renaming C:\(some path) to (MyEAR proj path)\(my war file)\META-INF\MANIFEST.MF
you can change these settings in server etc...
I have created a simple EAR project along with a dynamic web project with stuts2. I am deploying EAR file and everything is working fine but whenever I make changes to any file and save I get this error message. What is the exact meaning of this message?
Thanks
Maybe the problem to be that it is necessary to configure a scanner for external deployments.
See: 'Publishing to JBoss 7.1 Runtime Server...' has encountered a problem
In previous versions of JBossAS, there was an exposed JMX server with
an option to mark a folder as one that the deployment scanner should
look at. This option still exists in AS7, but, we haven't integrated
with the management ability yet. THis means we can't do it on the fly,
currently, in the current toolset is a bit hurt by this missing
feature.
It is still possible in the raw configuration of the server, howerver.
This means you can mark your server directly to scan some external folder by modifying
your configuration and adding a deployment scanner. The instructions for it are over here:
https://community.jboss.org/wiki/DeployingAnApplicationFromAnExternalDeploymentLocation
To make use of this, double-click your jboss-7 server inside eclipse
to open the server editor. You can then switch over to the second
page, "Deployments", where you can change the deployment method to
"custom" and set any folder that's on the same filesystem as your
eclipse installation. Once this is done, you can add that folder to
your server's deployment scanner lists as per the wiki above.