Setup Grails in GGTS 3.4 behind Proxy - grails

I wish to share the knowledge that how I fix the proxy problem to setup GGTS in my company's PC after I run the setup.exe of GGTS 3.4 downloaded from SpringSource (by googling for a whole day around www ;))
Problem:
When I start to build my hello world project after the IDE installation, GGTS prompts me this error message: "Error Failed to resolve dependencies". How to fix it?

I'll answer my own question:
Go to IE and find the proxy url from the specific proxy file (in Internet
Connection Settings), or just ask your firm's support guys.
Go to your grails' bin folder and run this:
grails add-proxy client "--host=your.proxy.com" "--port=xxxx" "–noproxy='localhost'"
It will give you a line of feedback like: "Added proxy client to \\path.grails\ProxySettings.groovy". Now you should open the file, check the url, port, username & password, and also make sure it contains a second line like this:
currentProxy='client'
There is an article suggesting changing a string in the first line of the ProxySettings.groovy from http.proxyUser to http.proxyUserName. In my own case the proxy doesn't require un/pw so not sure if it is vital or not (source: http://web.archive.org/web/20130910035021/http://jira.grails.org/browse/GRAILS-10097)
Now right click the project in GGTS, Grail Tools > Refresh Dependencies, or just re-create the hello world project. Huray!

ender's answer is fine when you have already run the project at least once, but recently I had a situation where I checked out my project from git on a computer behind a proxy, and I couldn't do "grails add-proxy" because I was behind a proxy and it couldn't get grails dependencies from repos :)
in that case, the solution is to do System.setProperty("http.proxyHost", yourProxy)
in BuildConfig.groovy like this:
grails.project.dependency.resolution = {
System.setProperty("http.proxyHost", yourProxy);
System.setProperty("http.proxyPort", yourProxyPort);
...
}

If you are running GGTS first time behind your company proxy you might get this Error:
Solution:
Go to C:\Users\[your username]\.grails folder, Add a folder name called ProxySettings.groovy.
Expected
Open ProxySettings.groovy file with notepad and add these Two following line:
client=['http.proxyHost':'Proxy Host Address', 'http.proxyPort':'port Number', 'http.proxyUser':'username', 'http.proxyPassword':'password']
currentProxy='client'
Note: Don't Remove single quote.
Final: For Me The content inside file look like Below:
client=['http.proxyHost':'192.150.1.1', 'http.proxyPort':'80', 'http.proxyUser':'Vineet', 'http.proxyPassword':'GoGetHigh']
currentProxy='client'

Edit File ProxySettings.groovy in windows User directory
C:\Users\YourUser
client=['http.proxyHost':'proxy host address', 'http.proxyPort':'proxy host port', 'http.proxyUser':'', 'http.proxyPassword':'']
currentProxy='client'

grails add-proxy client "--host=your.proxy.com" "--port=xxxx" "–noproxy='localhost'"
grails set-proxy client
Then replace maven with ivy in your project's BuildConfig.groovy.

Here is how I fixed the problem for myself for Grails version 2:
Go to C:\Users\\[your username]\\.grails folder, make a file called ProxySettings.groovy.
Inside that ProxySettings.groovy file, add the following two lines:
client=['http.proxyHost':'the proxy host', 'http.proxyPort':'the port number', 'http.proxyUser':'username', 'http.proxyPassword':'password']
currentProxy='client'
For example you can have something like this in the file:
client=['http.proxyHost':'1.1.1.1', 'http.proxyPort':'8080', 'http.proxyUser':'batman', 'http.proxyPassword':'superman']
currentProxy='client'
This does the trick for me and hope this will help you too.

Related

Grails - Message bundles (i18n) broken for war build only

After upgrading from 2.5.5 to 3.1.1, when I build my application as an executable war (or deploy to tomcat container), messages cannot be resolved from message.properties or any i18n properties files.
org.springframework.context.NoSuchMessageException: No message found under code 'timeZoneId' for locale 'en_US'.
When run in IntelliJ, it all works fine.
In terms of configuration, I’ve tried to make my build as close to the “out of box” Grails app as possible.
I’m wondering if anyone could provide a hint or suggestion as an avenue of investigation I could travel down as I’m just about out of ideas. Happy to add configuration detail as requested.
I'm using a multi-module build with a plugin as a dependency.
I suspect that maybe you have done some modification on your Grails project (2.5.5) that cant be support on the newest grails 3.3.0.
I would suggest you to check 3.3.0 documentation on how to customise your msg.
You can refer to https://docs.grails.org/latest/guide/validation.html. There is an example of how to modify your own label or msg.
In the case of the blank constraint this would be user.login.blank so you would need a message such as the following in your grails-app/i18n/messages.properties file:
user.login.blank=Your login name must be specified!
Hope it helps. Cheers

localhost refused to connect Error in visual studio

I have copied my solution file from another system and tried to run it on my machine:
For this, I have gone to the project folder and deleted the previous solution file and copied the new one.
Now, it started giving me error. connection refused etc. So, I got one solution from here: How to solve ERR_CONNECTION_REFUSED when trying to connect to localhost running IISExpress - Error 502 (Cannot debug from Visual Studio)?
According to it, I changed the port number from 1049 to 1052. It loaded and one of the pages gets loaded.
But when I entered the desired login credentials then it redirected to the older port again, like this:
http://localhost:1049/Home/SearchFlight
and the error is:
This site can’t be reached
localhost refused to connect.
Search Google for localhost 1049 Home Search Flight
ERR_CONNECTION_REFUSED
Now, I don't know what to do from here. I have changed the port number to 1052 but still its pointing to 1049. What should i do now?
I had a similar issue. Try this and it should work
Go to your project folder and open the .vs folder (keep your check hidden item-box checked as this folder may be hidden sometimes)
In the .vs folder open the config folder
See that applicationhost.config file there? Delete that thing. (Do not worry it will regenerate automatically once you recompile the project.)
Usually on local machine we are getting errors like This site can't be reached localhost refused to connect because we have self signed certificate configuration broken for local IIS Express. Sometimes it happens when you change URLs in launchSettings.json or never configured self signed certificates on this machine at all.
To fix self-signed certificate on the local machine you need to: 
Delete .vs folder (requires to close Visual Studio 2017)
Run these commands in cmd As Administrator:
cd "C:\Program Files (x86)\IIS Express"
IisExpressAdminCmd.exe setupsslUrl -url:https://localhost:12345/ -UseSelfSigned
Make sure you run VS2017 As Administrator and check if the issue addressed
Note: https://localhost:12345/ is what is in your launchSettings.json for HTTPS
Changing port number has resolved the issue
Just Delete the (obj)Object folder in project folder then Run the application then It will work fine.
Steps:
Right Click on the project folder then select "Open folder in file Explorer".
Then Find the Obj folder and Delete that.
Run the Application.
Unfortunately, none of these answers worked for me. This answer finally did for Chrome only. Unfortunately, you have to do it each time:
Open this in your browser: chrome://net-internals/#hsts
Go to Delete domain security policies
Enter "localhost"
Restart browser
Google Chrome redirecting localhost to https
I had the same problem. Deleting .vs folder (including all contents, folder might be hidden) worked for me.
I solved a similar problem by listing bound IP addresses in a cmd window running as admin:
netsh http show iplisten
Then, one by one, blowing them all away:
netsh http delete iplisten ipaddress=127.0.0.200
netsh http delete iplisten ipaddress=127.0.0.2
...
In my case, I need to update "publishAllPorts" = false in .Net 5 MVC project's launchSettings.json.
"Docker": {
"commandName": "Docker",
"launchBrowser": true,
"launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}",
"publishAllPorts": false
}
I ran my Visual Studio as "Run as administrator" and this solved my problem.
Go to control panel > Programs and feature > IISExpress > Repair
If found it was because I had been messing about with netsh http add commands to get IIS Express visible remotely.
The symptoms were:
the site would fail to connect in a browser
the site would fail to start (right click IIS Express in the Taskbar and it was missing)
if I ran Visual Studio as admin it would start in IIS Express and be visible in the browser
The solution was to list all bound sites:
netsh http show urlacl
then delete the one I had recently added:
netsh http delete urlacl url=http://*:54321/
In addition I had removed localhost from the hidden solution folder file .vs\config\application.config for the site:
<bindings>
<binding protocol="http" bindingInformation="*:54321:" />
</bindings>
so had to put that back:
<bindings>
<binding protocol="http" bindingInformation="*:54321:localhost" />
</bindings>
This happened to me in VS2017 v 15.6.7 using .net core 2.0.
When the project first launched it created an SSL Cert for localhost and started fine. When I disabled SSL I kept getting this issue.
Apparently when you disable SSL the port numbers are changed and not all of the port numbers get changed to the new port. Make sure port numbers on Debug are all the same number.
I was having this issue and solved it by closing all open instances of Visual Studio.
Open cmd as administrator and run this command:
netsh http delete iplisten ipaddress=xxx.xxx.x.xxx
ipaddress is your private ip.
This worked for me.
I faced this annoying problem all the time in my Visual Studio MVC application especially when you start your work in the morning. Many solutions in this thread works sometimes; but there were many times none of this solves my issue.
At last I figured out only a combination of these steps works for me. Hope this helps somebody.
Close VS.
Delete .vs folder under your solution. Don't worry, it will be automatically created when you open the solution again.
Delete bin and obj folders.
Delete your cookies from the browser that you use to debug the application.
Delete the *.csproj.user file located in the project folder.
Open your startup project file (*.csproj) in Notepad++ or your favorite editor. Go towards the end of the file and delete below 3 lines that contains the local development port info. Don't worry it will be recreated on running the solution again.
<DevelopmentServerPort>0</DevelopmentServerPort>
<DevelopmentServerVPath>/</DevelopmentServerVPath>
<IISUrl>http://localhost:60573/</IISUrl>
Open your solution again, clean, build and run it. You should be good to go. If this don't work, restart your machine after step 6.
For this to work for me, all I had to do was recreate the virtual directory. I had re-installed Windows and then pulled the project back out of Git. To do this, right-click on the solution project and choose Properties, then go to the Web tab and click the Create Virtual Directory beside the Project Url.
I hope this helps someone else too!
Bud
Project properties> Web > Create Virtual Directory worked for me
Right Click on Project >> Properties >>
Select Web Tab >> Under server Select "Use Visual development server"
so indirectly it will uncheck "Local IIS Server"
Hope so it may resolve this issue.
Change the port number and remove script debugging (if enabled) to resolve in localhost.
I've tried everything but nothing worked, but this did.
If you can debug on local IIS instead of Express, change the configurations as shown in the image below. Do not forget to click on "Create virtual directory"
rebooting the machine was the only thing that worked for me
I recently ran into this exact problem and tried most of the suggestions but it turns out my problem was something different.
Our application has a section that redirects you to HTTPS if you are on HTTP (yes, I know there are better ways but this is legacy). In addition, there is special handling of localhost when you are in dev mode which redirected you back to HTTP, though I don't know why.
I have a new requirement that requires testing in HTTPS.
On a normal web page, changing http:// to https:// and calling Redirect would work fine but in IISExpress you are using custom ports. So for example, if you are on https://localhost:44300 you can't just switch to http://localhost:44300 b/c that port only serves https, not http.
So, if you are having this problem and you've cleared the config files and it didn't help, check your code for redirects. you might have something using a hardcoded or partially hardcoded url or a url from a config file that you haven't updated to https.
Update:
I also suggest clearing all .suo and .user files and someone else suggested clearing the obj/ folder. I suggest doing this with VS closed and then restarting. I had a lot of trouble with values for ports being cached when i tried to setup https:// and change ports. I also suggest trying this suggestion to check that the SSL port is within the correct range, though I don't know if that is still a requirement https://stackoverflow.com/a/24957146
In my case, Visual Studio 2017 > Tools > Options
In Debugging menu in the side list find Edit and Continue
Uncheck the Enable Edit and Continue check box
This resolves my problem.
Same problem here but I think mine was due to installing the latest version of Visual Studio and having both 2015 and 2019 versions running the solution. I deleted the whole .vs folder and restarted Visual Studio and it worked.
I think the issue is that there are multiple configurations for each version of Visual Studio in the .vs folder and it seems to screw it up.
Sometimes https and http ports can be same because if two tags are given same ports
IISExpressSSLPort and DevelopmentServerPort
Make sure these two ports have different ports
then in IISUrl use your default port either HTTP or HTTPS
https://localhost:44365
For HTTPS Use IISExpressSSLPort
For HTTP Use DevelopmentServerPort
Then you may delete hidden .vs folder in solution folder
Try deleting cookies for your localhost
My problem turned out to be a property which called itself:
Once I fixed this, the misleading connection error message disappeared.
None of these solutions worked for me. I'm not 100%, but I think my issue might have been with running the same project on the same port from multiple branches. That used to be an issue for me on Local IIS --- I'm not sure if that's also an issue on IIS Express. What worked for me was following this solution:
https://stackoverflow.com/a/27033934/2133723
Which says to go to:
File -> Open -> Web Site...
and remove the relevant projects. After this, I was able to run the project without changing the port.
Prior to doing this, I had followed the other solutions posted on this question (which didn't help me), such as deleting the .vs folder, so I'm not sure if that would be a necessary step prior to removing the website from File -> Open -> Web Site....
Like Donny V. this happened to me in VS2017 using .net core 2.0.
When the project first launched, VS displayed a dialog, offering to create an SSL Cert for localhost - but I didn't want to use SSL, so I stopped running and went into Project Properties and disabled SSL (a checkbox that can be cleared). After doing that I kept getting the issue described.
After trying many things what actually resolved the issue for me was editing the launchSettings.json file located under [ProjectName]/Properties - it's accessible from Solution Explorer.
When the editing was complete, the contents looked like this (where 12345 is a Port Number, and where MyNETCoreApp is the name of the project).
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:12345/"
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchUrl": "http://localhost:12345/",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"MyNETCoreApp": {
"commandName": "Project",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl": "http://localhost:12345/"
}
}
}
The edits I made were:
Updated the Port Numbers so they were all the same number
Removed a key:value of ssl:0 in one spot
Updated all https:// instances to be http://
I had to add https bindings in my local IIS

Grails application that copies and unzippes files from remote server to another remote server using SSH

I'm new in JAVA\Grails\Groovy. Just began to create simple apps.
I've got a task to create grails app that:
1) shows a list of source zip files on a remote server, that is available by FTP and SSH
2) shows a list of destination remote servers with predefined target folders, that are available only by SSH
3) after choosing source zip and dest server it copies zip to target server\folder and unzippes. Progress bar must be shown.
4) performs some additional commands, such as ls or something like that
All configurations must by either in config files or in the database.
No information should be hardcoded in app.
Please help me to choose approach, plugin or framework.
Any help would be appreciated
I've used JSch a lot for SCP file transfer and remote exec using SSH and works very well. You could use it directly like you would in a Java app, by adding a dependency for the jar in BuildConfig.groovy
compile 'com.jcraft:jsch:0.1.51'
but the most trivial Google search I could manage that included "Grails" and "SSH" tells me that there's this plugin which looks great, and this plugin which also looks great, and this blog post which looks great, and also this plugin which uses a different library but also looks great.
Those options cover the ssh and scp/sftp parts, and you can use the JDK support for Zip files, e.g. java.util.zip.ZipFile and the other related classes in that package, to unzip the files. The rest is pretty straightforward, but if you need more help ask more questions (one question per question).

Bower install without ssl

I have trouble connecting to sites with ssl, i.e. https. It can successfully download artifacts from the internet if the url begins with http.
bower install will download dependencies via https. Is there anyway make it download via http?
I had troubles with this too, and I couldn't find an elegant way to fix it. My workaround was:
Go to your global npm folder and find the "bower" folder (on Windows 7 that is "C:\Users\\AppData\Roaming\npm\node_modules").
In that folder, search the default.js file placed in node_modules\bower-config\lib\util\default.js
Inside that file you will find a "var defaults". Replace the "registry" url property from "https" to "http".
Yes, I know. This shouldn't be done like this, but at least help me to bypass the connection error.
Hope that helps!
You can change the registry used by Bower in the .bowerrc file. The default registry is: https://bower.herokuapp.com and is defined in node_modules/bower-config/lib/util/default.js (as described by Jean Manuel Arias in his answer).
To override for your project, add a value for the registry setting in .bowerrc. An example file might be:
{
"directory": "<YOUR LIBRARY INSTALL DIRECTORY>",
"registry":"http://bower.herokuapp.com"
}
In the above example, the default https registry is being overridden with the http version. A full list of the available .bowerrc settings can be found at: Bower Spec.
You can do a global override for the current user by creating a %USERPROFILE%\.bowerrc file (for windows, in Linux it is: ~/.bowerrc). Bower follows a similar search path when applying settings to NPM (see npmrc settings). This is probably a better route as it avoids cluttering your project with local settings.

Cannot run Grails from command prompt

I’ve added a GRAILS_HOME environment variable, which points to the folder in which I extracted the Grails distribution zip, and I’ve added %GRAILS_HOME%\bin to my path. Yet after I open a new command prompt, the “grails” command is still not found. Does anyone have any clue as to why this is happening?
I’m running Grails 2.2 on Windows 7.
I have the same problem on Windows 7 64 bit and Grails version 2.*
By removing local neither maven repository nor installed plugins repository doesn't help.
I found - just set properties of %GRAILS_HOME%/bin/grails.bat and startGrails.bat as Run in compatibility mode: Windows XP (Service Pack 3).
To do that You need to have local PC Administrators rights.
/igors
have you create JAVA_HOME in there?
Maybe you are experiencing [STS-2530] Problem deploying Grails App if workspace path has a space. Jira shows the issue as resolved but it would not hurt to check that you do not have a space in your workspace path as it my trip up grails.
Do the following.
Go to your command prompt, execute the Path command. If everything has been set right your paths should show up as complete paths starting with C:... If the paths show up with the % sign that means your paths need to be set correctly. I did noticed that in your example you have used the forward slash - I am assuming that is a typo, because that will be a problem.
Another way to trouble shoot the issue is CD to the location C:\Grails\bin, execute the command grails.bat, if it executes you are in a good place that means you have to tweak your paths - following this path might give you a clue about other issues....
You might want to check the bin folder of your grails installation. The grails.bat file could be missing. I had this problem today and solved it by downloading the zip file again.

Resources