Grails 3.3.10 and strange behavior in the URLs - grails

I'm developing an application using Grails 3.3.10 using Spring security plugin but I'm getting very weird behavior, when I run the application using -https for instance I finished editing the Profile in the edit.gsp here its URL https://localhost:8443/profile/edit/1 and I press Update so it will suppose to take me to the index.gsp but the URL I get is http://localhost:8080//profile/index as you can see the URL isn't https and there is extra / by the way this is happing in a lot of the views.
What is the reason for this behavior

I figured out what is the cause for this weird behavior i found in config file application.yml, the property grails.serverURL was configured twice ,so i commented them and everything worked fine

Related

Grails application doesn't automatically start in browser with grails run-app

For some reason my grails application no longer starts a browser with the webpage displayed when doing a grails run-app. It always did before. There is no errors or anything, it just no longer auto-starts the application. I haven't changed any code unless git corrupted something. Anyone know what could cause this?
Grails does not start a browser - usually your IDE takes care of this.
On IntelliJ you can enable this behaviour (Launch Browser) under your Run Configuration.
Click on Edit Configurations… here
Enable Launch Browser

MVC Bundling with HTTPS IE7

I have successfully implemented MVC bundling for my MVC application. There is one problem with the run time which runs under HTTPS.
I am sure there is a problem because when I switch the debug field to false the user gets the warning message "This page contains secure and nonsecure items. Do you wish to proceed?
I know that I can turn this prompt off using the security setting in IE. I would like to know if there is something I can do to the application so that bundled scripts and styles come through the secure pipe.
If you use the Scripts.Render helper to include the bundle it will use the same HTTP scheme as the one used to request the main page. So if the main request was done over HTTPS then this helper will generate a <script> element using HTTPS. You could use the Net tab of FireBug to see which resources are served through HTTP and HTTPS and be able to isolate the problem.
Thank you for this suggestion. I figured out that the problem was coming from modernizr-1.7.js
The strange thing was that this problem only occurs when modernizr is bundled. I removed modernizr because we don't really need it.

Grails 2.0 Redirect Include App Context Even Though I Have It Set To "/"

Using Grails 2.0.1 (upgraded from 1.3.7). In application.properties I have app.context = "/" and all is generally working well. However, my redirects now attempt to include an app context.
redirect action: "edit", id:genAttribute.id
So instead of
http://localhost:8080/genAttribute/edit/55
I end up with
http://localhost:8080/bh/genAttribute/edit/55
which of course doesn't work. Another interesting piece of this is that the g:link tag works fine. It just seems to be the redirect calls from my controllers.
I just stumbled across this so the solution is to remove the grails.serverURL from Config.groovy.
The problem is an invalid grails.serverURL config property, it's explained here in the "Redirects" section, quoting:
As a side-effect, the redirect() is now dependent on the
grails.serverURL configuration setting. If this doesn't match the URL
of your application, redirects will stop working.
The simplest way to avoid this problem is to remove the setting unless
you need it. If you need it (usually for production deployments) then
the value should already match the URL of your application. This
mostly impacts development where old projects often have a legacy
value that doesn't work.

Grails - Plugin view pages issue

I have a plugin with domain, controller and view pages. (Using grails 1.3.6)
I run the plugin as standalone, the views work fine. URL: http://localhost:8080/sample-plugin/gp/list. I am able to view the list page.
I installed the plugin into a main application i.e. plugin-test. Start as run-app within STS and browse to http://localhost:8080/plugin-test/gp/list. I am able to view the list page.
I bundle the application as war i.e. plugin-test.war and deploy to tomcat. When I browse to http://localhost:8181/plugin-test/gp/list I get a 404 error! I am not sure what I am doing wrong.
I have been trying to resolve it for quite sometime now and still no luck. The same main application works fine in STS but not in tomcat.
HTTP Status 404 - /plugin-test/WEB-INF/grails-app/views/gp/list.jsp
type Status report
message /plugin-test/WEB-INF/grails-app/views/gp/list.jsp
description The requested resource (/plugin-test/WEB-INF/grails-app/views/gp/list.jsp) is not available.
Please help.
Thank you.
Jay Chandran.
This sounds worryingly familiar, as I spent a while figuring out this (or a very similar) issue. I ended up raising this Grails bug report:
Plugin layout not found in war when installed from BuildConfig.groovy
Have you installed the plugin as using the new BuidConfig dependency technique? The JIRA documents my workaround.
Sharing some of my lessons learned after experiencing the same exact issue (1.3.7):
Double check your HTML source to make sure that your template really isn't being included. Mine was being included, but my CSS/image URLs were wrong (only while running as a war)...so I wrongly assumed that my template wasn't there.
Don't use the ui performance tags for referencing your static content...doesn't appear to work, even if the plugin attribute is specified.
Don't name your layout main.gsp. You're guaranteed to have conflicts.
Don't use absolute=true on your g:resource tags. This doesn't appear to append the pluginContextPath to the absolute url, even if you specify dir="${pluginContextPath}"
Don't use pluginContextPath, as it's no longer required: http://grails.org/doc/latest/guide/single.html#6.3%20Tag%20Libraries (search "Plugin Paths")
In your g:resource tags in your plugin layout, make sure you specify the plugin attribute. Set it to the name of your plugin.
Move your static images/css from your plugin to a web server. If each application using your plugin has its own copy, your users aren't going to benefit from caching when bouncing between apps.
Note that all of the above applies to the layout gsp in your plugin project, not your consuming application.

ASP.NET MVC Deployment Issues

HI am new to ASP.NET MVC and I am running into some issues trying to deploy a very simple site! I took the MVC Storefront (Kona), made some basic changes and now I would like to deploy it to a webserver! For testing, I just turned on IIS7 on my windows 7 desktop! I change the web projects settings to use local IIS and run it!
The first issue I get is the "Request is not available in this context"... To fix this I had to remove the HttpContext.Current.GetSiteUrl() in the global.asx.cs file! If I now run the app it works but I have no css? If I switch back to VS development server everything works great?
I can also swithc from integrated mode on IIS to classic which makes the css work but then I have no routing?
On IIS 7, HttpContext.Current is null in Application_Start because it isn't triggered by the first request anymore.
You can work around that issue by moving the code from Application_Start to Application_BeginRequest and add a flag to indicate if the application is already initialized (member of the Global class). When false, execute the code that uses HttpContext.Current and set the flag to true so subsequent requests don't execute that piece of code.
Doing what is said above fixed the css for me but adding this to
http://blogs.msdn.com/mikeormond/archive/2008/11/06/and-getting-asp-net-routing-up-and-running-in-web-applications-and-on-iis7.aspx
Fixed the routing for me.
Good luck took me long enough!

Resources