grails intellij ide 'run application' fails to load any controllers - grails

any number of problems tonight.
I have a grails 3.3.8 app in intellij. I have built some domain classes, and in the ide I selected the domain classes and told it to generate the controllers, which it does.
if i right click the Application project in project browser (either to run debug) the app comes up but no controllers are loaded. so i have to cease the session.
if i open gradle view and issue the bootRun command the app starts and the controllers get loaded!
however if i right click on the boot run action and select debug, if disappears off into the ether on a background thread and the IDE never fires and i dont get control of the debug session in the IDE.
This has got terribly frustrating and i've burn't alot of time tonight going round in circles
does anyone know why the right click on Application, in project explorer, fails to load the controllers, whilst bootRun does load them .
If i can fix that - then the debug from the project explorer should work. Its very odd.
i had to try and recreate the project as this evening it got lost telling me my domain classes were no domain classes and when i tried to delete and controllers/services and rebuild them it kept telling me cmdb.$xxxServices gorm data services couldn't be found and refused to build hibernate datastore
you can find the project to look at enter link description here but it needs another project (ticketAdapter to run, and a library project softwoodUtils) i've used the json end points directly on my browser for the ticketAdapter (server) project and i know thats working - its not a grails app itself)

Looks like you are trying to launch a Run/Debug Configuration of a standard Java Application with the public static void main method. For Grails 3 rather use Grails Run/Debug Configuration where specify the Grails module to load and grails command to run the app with:

You can also use gradle actions like bootRun to run your app.id youdouble click a gradle actions from the gradle panel it will automatically create and run a gradle run configuration. Then you can run or debug that configuration.

Related

Need to restart Grails after controller changes [duplicate]

It looks like IntelliJ's (Ultimate EAP 15) support for Grails 3 is in the early stages yet. If I do Run -> Debug 'Grails:My App', I'm able to launch an app from inside IntelliJ, I can set breakpoints and it works as expected.
If I make changes however, I see in the console that the file is recompiled, but when I hit reload in the browser, I don't see the changes reflected there. I have to stop and restart the app in IntelliJ before I see them. Anyone know how I can get the auto-reloading working?
After chasing this for a week, this post finally provided an explanation.
It's actually a Grails issue, not a problem with IntelliJ's Grails integration: spaces in a file's path will break automatic reloading. Renaming my project from Grails Demo to GrailsDemo got everything straighted out. (Storing a project in a folder like My Documents will also cause trouble.) The post's author indicates that this started with version 2.4.4 and it's still happening for me in 3.0.4.

Grails 2.5.6 issue

I have a weird issue with my Grails 2.5.6 application while running or debug when i change anything in the controller and press save and refresh the view page in the browser i found the below error occurs in the console and keeps occurring till i restart the application , anyone got an idea from where is this error and how to fix it as i can't develop the controller
java.sql.SQLException: The type registry TypeRegistry(id=2030320736,loader=org.codehaus.groovy.grails.cli.support.GrailsRootLoader) does not know about type id 3238
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:129)
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:97)
at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:122)
at com.mysql.cj.jdbc.ClientPreparedStatement.executeInternal(ClientPreparedStatement.java:975)
at com.mysql.cj.jdbc.ClientPreparedStatement.executeQuery(ClientPreparedStatement.java:1025)
at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.extract(ResultSetReturnImpl.java:82)
at org.hibernate.loader.Loader.getResultSet(Loader.java:2066)
at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:1863)
at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:1839)
at org.hibernate.loader.Loader.doQuery(Loader.java:910)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:355)
at org.hibernate.loader.Loader.doList(Loader.java:2554)
at org.hibernate.loader.Loader.doList(Loader.java:2540)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2370)
at org.hibernate.loader.Loader.list(Loader.java:2365)
at org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.java:126)
at org.hibernate.internal.SessionImpl.list(SessionImpl.java:1718)
at org.hibernate.internal.CriteriaImpl.list(CriteriaImpl.java:380)
at org.codehaus.groovy.grails.orm.hibernate.metaclass.AbstractFindByPersistentMethod.getResult(AbstractFindByPersistentMethod.java:105)
at org.codehaus.groovy.grails.orm.hibernate.metaclass.AbstractFindByPersistentMethod$1.doInHibernate(AbstractFindByPersistentMethod.java:67)
In IntelliJ IDEA this problem occurs. It holds the development session with its own built-in configuration. Whenever you start your app by IntelliJ it will not effect itself for changing in controller till restart. It would be better to run your app via Command Prompt then your don't need to restart your app as you change in controller.
Open Command window in your Project Folder where build.gradle file situated
Then type grails run-app & press enter
Hope it will solve your problem.

Web app reload issue in Groovy/Grails Tool Suite

I have ggts-bundle bundle 3.6.1 64 bit with JDK 7 (jdk1.7.0_67) on Win7 64bit.
I have grails home setup as GRAILS_HOME and grails version grails-2.4.3.
When i create a new action/method in the controller class in the tool suite and hit save and refresh the browser, it doesn't reload the changes in the application.
I even modified BuildConfig.groovy and added the following
grails.reload.enabled = true
I also tried with grails -reloading run-app
Nothing seem to reload the changes, I have to stop the server and restart it and then
it reflects the changes.
I am sure there's something i can do to have it reload the app.
I read online and tried other suggestion in questions on stackoverflow before i posted this.
Any suggestions.
Did you end up getting a solution to this?
I've just tried this out in GGTS and it looks like there is no problem.
Version: 3.6.3.RELEASE
Build Id: 201411281415
Platform: Eclipse Luna SR1 (4.4.1)
OS: Win7 64bit
I'm working on a plain vanilla (unmodified) install with default settings.
Using a simple Grails project, with a simple HelloController.groovy and a couple of GSPs... corresponding to two methods inside the controller. Launch the server...
Tried out two scenarios to see what happened, back in the IDE...
modify some simple output text in one of the GSPs, save, refresh the browser... yep, no problem, the change shows up
modify the HelloController.groovy to tell one of the methods to use a different GSP, save, refresh the browser... again, no problems, the change is reflected.
Note. I did have to wait a few seconds in scenario 2 for the IDE to notice the change and to recompile
Perhaps try updating your instance of GGTS to the latest release to see if that makes a difference?
Hope this helps.

Running grails test-app command from grails web console plugin

I have installed the grails web plugin. I can now browse to :
localhost:8080/myappname/console
And I can see the console displayed over there. I have bunch of test-cases written for application. I wish I can test my app from this web console.
Is it possible to do so? I'm very new to grails.
Thanks in advance.
Short answer no. The grails console is meant to write groovy code that interacts with your running application. Your running application does not include your test cases or the grails command line by default.
Long answer sort of. Provided you have all of your projects source code available somewhere in the file system where your application is running, you could call an external process to run test-app and return the result to the user. Here are some docs on running external processes in groovy: http://groovy.codehaus.org/Executing+External+Processes+From+Groovy. I suppose you could also package you application somehow to make this work, but I think doing that would be fairly complex.
I am not sure this is a good use case for the console plugin over all. Hope this helps

Rename Web Role in VS 2010 Cloud Service Project

I just started using VS 2010 to create a Cloud Service (HealthTracker), and I attached a MVC2 web project to it. When I hit Debug, the dev fabric was started and I was able to navigate my web app on my machine as expected.
I decided MVCWebRole2 was a bad name for my web app, so I renamed it to HealthTrackerMVC. I used Refactor --> Rename to change MVCWebRole2 to HealthTrackerMVC. I Built clean and now when I hit debug the dev fabric starts, and the web app never starts and eventually it exits debug mode without me doing anything.
How do I fix this? I'd rather not start over with everything...
UPDATE
I have checked the ServiceConfiguration.cscfg, the ServiceDefinition.csdef and the solution file. All the names match, and all the GUIDs match. I even renamed the folder that housed HealthTrackerMVC (formerly named MVCWebRole2) and edited the solution file to point to the new project. Everything loads and builds correctly. The Development Fabric shows HealthTrackerMVC starting, says it's busy, then shuts it down, rather quickly. See the attached screenshot:
So I know my web role is being started... why is it shutting down so quickly?
Check the Azure configuration files, as both reference the role name and I don't belive VS's refactor command hits. If your project is building and the role simply isn't launching, its most likely as a result of the role not knowing what to start.
In ServiceDefinition.csdef
<?xml version="1.0" encoding="utf-8"?>
<ServiceDefinition name="YourAzureService" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition">
<WebRole name="HealthTrackerMVC" vmsize="Small" enableNativeCodeExecution="true">
...
In ServiceConfiguration.cscfg
<?xml version="1.0"?>
<ServiceConfiguration serviceName="YourAzureService" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceConfiguration">
<Role name="HealthTrackerMVC">
...
If that doesn't work, right click on "Roles" under the Cloud Service Project in Solution Explorer. The ADD menu should have an option for "Web Role Project in Solution". Select that and link up your new role. Delete the old role as well at this point
If that still doesn't work, go to the file system where the project is stored and open the .ccproj file (Cloud Service Project) in a text editor.
Look for the reference to the previous role (ccproj are in MSBUILD format). It will be something like:
<ItemGroup>
<ProjectReference Include="Folder\MVCWebRole2.csproj">
<Name>YourAzureService</Name>
<Project>{26f72b59-1423-4175-b401-9c8f5f45db2a}</Project>
<Private>True</Private>
<RoleType>Web</RoleType>
<RoleName>MVCWebRole2</RoleName>
</ProjectReference>
</ItemGroup>
Change references to the new HealthTrackerMVC project (name and .csproj ref) and you should be good to go. Most likely the project GUID hasn't changed, but if somehow it did, just open up the SLN file to get that number.
Once you change on this VS should prompt to reload the Solution/Projects. If not, you should reload anyways.
I recommend to check Web.config and the actual start-up logic (i.e. Azure fabric is known to silently kill web projects with invalid web config without raising any errors; that's something that just made my life exciting a few times).
Just some ideas. For example you can try by starting web project alone (just like a usual project). If it works - drop an existing web role and add a new one to the solution (referencing this web project) and try running it in the dev fabric. If it does not, but web project runs alone - export it to a fresh solution and add to a new web role there.
This is a bit of a long shot, but if you have overwritten the RoleEntryPoint and overwritten the Run method, it should contain something like
public override void Run()
{
while (true)
{
Thread.Sleep(8000);
}
}
If this method ever returns, your application will stop.

Resources