I am new to Karaf and I am trying to get the default servlet to stop listening:
I managed to stop all the other things which I do not need by stopping their respective bundles, but for the default servlet I am unable to figure out how to stop it.
Currently it replys:
No services have been found.
Question: where can I disable the default servlet for the root dir?
Edit: We would like to have whiteboard serve an angular site and its ressources dirctly from /. Currenlty ResourceServlet default tries to find javascript files in its bundle ressoures (not a chance...). How do we get the default Servlet to stop bothering us? :)
It is not possible to disable the default servlet. Instead a new Servlet has to be registered under the / path. This servlet will have precedence.
Related
I am following headfirst JSP and Servlets book these days and it says that ServletConfig object is only created once during the life cycle of a servlet before being passed down to the init method of the servlet.
I was testing out some examples given in the book to just print out the init-params and context-params defined in the DD of my webapp using the out.println method of HttpServletResponse.
What I am seeing this is if I make any change in the DD (adding or changing param names, values) and reload the URL in my chrome browser pointing to that particular servlet inside the webapp it gets updated with the newly added params. This should not be the case. I am not redeploying the servlet (by stopping and re-running the tomcat service again) which will cause the ServletConfig object to be recreated. What is happening here?
I am running this on tomcat9 over windows 8 while the book refers to tomcat5. Has there been changes since to dynamically update the ServletConfig and Context init params? I couldn't see anything indicating this on the internet.
Look at the Tomcat logs and you 'll see the app being re-deployed.
By default changes to web.xml will trigger an application redeployment. The check for modifications happens every 10-15 seconds (I forget exactly how often).
This is the default behavior where tomcat automatically re-deploys the application
when /WEB-INF/web.xml file is updated.
As per the documentation at
http://tomcat.apache.org/tomcat-9.0-doc/deployer-howto.html#Deploying_on_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:
Re-loading of a web application if the /WEB-INF/web.xml file (or any other resource defined as a WatchedResource) is updated."
To bypass the default behavior set autoDeploy to false and restart the tomcat.
You can update the server.xml to set autoDeploy to false value.The file located at
$CATALINA_BASE/conf. Tag name is Host as given below
<Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true">
I can only update the "server.xml" file, although the documentation says : In earlier versions of Tomcat the content of a Context Descriptor configuration was often stored within Tomcat's primary configuration file server.xml but this is now discouraged (although it currently still works).
So in answer to your query , no there has been no change with respect to setting autoDeploy to true or false as per the documentations of tomcat 5.x.x and tomcat 9.x.x. I am also running tomcat 9.x.x as I verify this default behavior by setting autoDeploy to false .
I am using React single page app for my application. I have hosted solution on IBM Bluemix using cloud foundry. I want 2 help.
How to override existing nginx configuration with new one to support URL rewrite for my react routes?
What are the url rewrites configuration for nginx server? (I am using nginx for the firs time)
Here is my manifest.yml which I have used to host on cloud foundry. I am using staticfile-buildpack for node.js.
applications:
- buildpack: https://github.com/cloudfoundry/staticfile-buildpack.git
name: xyz
memory: 128M
stack: cflinuxfs2
path: build/
routes:
- route: xyz.eu-gb.mybluemix.net/
- route: xyz.eu-gb.mybluemix.net/store
- route: xyz.eu-gb.mybluemix.net/checkout
Here xyz is my app domain. I am able to load my app and pass through click action to other routes but when I hard refresh or change url from browser address bar it shows me 404 error.
Can someone please guide me here to resolve above issue.
Thanks.
How to override existing nginx configuration with new one to support URL rewrite for my react routes?
You can override the nginx.conf, but it's not recommended with the staticfile buildpack. Instead, try to use the configuration options provided by the buildpack to achieve your goal. The buildpack has a lot of common options, so you don't need to drop down to the level of configuring Nginx yourself.
https://docs.cloudfoundry.org/buildpacks/staticfile/index.html#config-options
Here xyz is my app domain. I am able to load my app and pass through click action to other routes but when I hard refresh or change url from browser address bar it shows me 404 error.
It sounds like you need to enable pushstate support. Adding pushstate: enabled to your Staticfile I think that should fix your issue.
What are the url rewrites configuration for nginx server? (I am using nginx for the firs time)
You can look at the Nginx configuration that's generated for your app. Once your push your app and it starts, run cf ssh <app-name> -c "cat app/nginx/conf/nginx.conf". That should dump the nginx config to your screen.
buildpack: https://github.com/cloudfoundry/staticfile-buildpack.git
Don't point to the master branch of any buildpack. It's a moving target. Commit to commit can change or even break.
You should generally use the buildpack that's provided by your operator. If you run cf buildpacks you can see the list there. If that's not new enough or your provider doesn't include a buildpack you need, you can use the git repo syntax to link to a repo online, however make sure you include the #<branch|tag> in your URL.
Ex: https://github.com/cloudfoundry/staticfile-buildpack.git#v1.4.29
This locks in the buildpack to a tagged release which prevents it from changing out from under you.
We have multiple applications pointing to the same physical directory. On one of the sites, I would like to configure custom error redirects for http error code 403. when I make a change in the web.config file, the changes are all applied to all the applications. Is there a way to limit the change to just one application. I know about location Element by specifying the path but not entirely sure on how to use it. Can someone tell me if this is the correct approach or if there is an approach other than using location element in the web.config
You can create separate web.config file for each application and than
add settings as you want this will not effect other applications.You can override configurations and add new for a specific application.
I want to know the root of the application both system eg. /var/www/app/ or /app/ for the purposes of file uploads. When I upload, I believe I need the "system" directory name, for use to links in web front end, I need the "relative" path. How do I get this information?
In a previous project, I defined constants in the app*.php files (front controller)
define('APP_ROOT', __DIR__);
Wonder if theres a better way?
In any ContainerAware class you can get location of web directory by,
$this->container->get('kernel')->getRootdir().'/../web';
If the container is not available, you can use dependency injection: set %kernel.root_dir% as an argument to your class in the service configuration.
This may seem simple, but not yet found a solution.
How to map to my applications www.mysite.com.br/MyController instead of www.mysite.com.br/servlet-name/MyController.
Thanks
Given that you're using Tomcat, you probably need to set your context root to be the default for your server.
If your application is configured in server.xml then this means you set the path attribute on <Context> to an empty string, ie "".
<Context docBase="webapps/MyWAR" path=""></Context>
See http://tomcat.apache.org/tomcat-6.0-doc/config/context.html
There are other ways of setting the path attribute if you're running Tomcat in an IDE, for example directly from Eclipse. In Eclipse you set the path attribute in the Modules tab on the server window.