Grails Package name wont change - spring

I have started learning Grails and now familiarizing with configurations.
To change the default package name for my grails project i entered the following in
config.groovy
grails.project.groupId = com.grailspractice.nick
Then ,
grails create-controller testc
But the files are not being created in the package domain structure.
I get the following structure instead
Created file grails-app/controllers/testapp/TestcController.groovy
Created file grails-app/views/testc
Created file test/unit/testapp/TestcControllerSpec.groovy
Please tell me if i am missing anything else.
Also If I run my app using
grails run-app
Then the application runs fine, but if in a separate command window if i create a controller while the application is running i get the following error on my prompt where the app was running
grails error cannot get property on cache operation source null object
Is it an installation problem? Or have i messed up any configuration?

Related

Web application throws NoClassDefFoundError in Unix server whereas locally in Eclipse it works properly

I'm newbee in web application deployment and stuff related to this. I have simple maven web application which works cool locally in my Eclipse & Tomcat9 server. Application has jsp file and main class, both try to call log4j2 classes like Logger or LogManager:
<% Logger.getLogger("bla").toString()%>
or in main:
private statis final Logger logger = LogManager.getLogger("blablabla");
Just in addition I call getPath() method on those classes and they show me my local maven repository.
After I deployed it on Unix server I get NoClassDefFoundError: Could not initialize class org.apache.logging.log4j.status.StatusLogger in browser and if I try to call it again I always get a bit different: NoClassDefFoundError: Could not initialize class org.apache.log4j.LogManager
Trying to execute main class through the PuTTY I get the same however after setting up a export CLASSPATH=$CLASSPATH:./WEB-INF/lib/* to the path with the libraries the program exetutes in console showing me enviroment CLASSPATH exactly as i've set before but continuing to not to work as web application through the browser.
I've tried to set CLASSPATH through the command above (startup.sh\setenv.sh etc...) but nothing. The command ...catalina.sh version shows me a CLASSPATH but app still doesn't work. I can only run a main class in PuTTY after manual setting up the CLASSPATH as I said above.
I've run out of ideas, probably you guys can give me some tips & hints about it? Maybe there is some script to set it each time starting the app. Unfortunatelly I'am not able to attache some code stuff.
The problem was related to the SecurityManager which was turned off on my local whereas it was turned on on a server. First I had simulated problem on my local, then I found out what permissions are missed debagging SecurityManager. I then added an VM argument -Djava.security.debug=access,failure to a run conf. Be carefull because of huge amount of output in console and better to log it in external txt file. After that I ran through the log.txt serching a word like "denied\failed\fail" and added necessary permission to a catalina.policy file.
Hope that will be helpfull for somebody.

On running spring boot war from cmd getting error resolving template exception in thymeleaf

On running the spring boot war file from the command line why I am getting the below error in thymeleaf :
Error resolving template, template might not exist or might not be accessible by any of the configured Template Resolvers.
I have changed the default thymeleaf template folder location using spring.thymeleaf.prefix property in application properties file. However, when I run the same code using IDEs it works perfectly fine.
Oh ok I got the issue, it was with the html file name which i was returning from my controller. I was using / with the file name (e.g. /index) because of which it was failing. But i am amazed that the IDEs are smart enough to detect that issue and somehow internally auto corrected it while running. That's why it was running via IDEs but failing while running the war from command line.

Can't access static file from Spring Boot application running in Tomcat servlet

All I want to do is access a specific file in a Java class. I am using Spring Boot 2.0.0.M7. When I run from my development machine using mvn spring-boot:run then everything works well. In that case I am using:
File jFile = new File("src/main/resources/static/folder/fileName.txt");
When I deploy this to a Tomcat server (8.5) as a war, the file is put into:
WEB-INF/classes/static/folder/fileName.txt
I've tried everything I could find or think of, but always get an error of some sort, usually a file not found exception.
My most recent attempt was:
URL url = this.getClass().getClassLoader().getResource("fileName.txt");
File jFile = new File(url.getPath());
That produces a null pointer exception with url.getPath().
I have read about needing to access the servlet config, but couldn't ever understand that well enough to get it to work. Does anyone have a clear example so that I can access the file both from the development context and the production context? Thanks!

Spring 4, STS 3.7 tc server 3.1.1. how to enable insights for my existing web application?

I am new to Spring framework even though i have been a java dev for quite some time. I am impressed by the spring insight application demos in you tube and want to use it in my application. How ever, when i try to create a new tc server using the instructions provided, for windows 8.1 64 bit
tcruntime-instance.bat create --template bio --template insight -i C:\workspaces\eclipses\sts\sts-bundle\pivotal-tc-server-developer-3.1.1.RELEASE\insight-instance http-insight-server-stsdeployed
When i try to add the folder created as the location of the new tc server with insight configured, using STS-> server view-> right click-> new-> server-> selected v3.0-3.1- && server-runtime env->add->browse="newly created server instance directory" it shows me below error.
The Tomcat installation directory is not valid. It is missing expected file or folder tcruntime-ctl.sh.
any idea how to add a new server and run my application on it? or add spring insights to existing spring boot or spring web application thru maven or spring configuration?
Note: Even though im using STS, i would like to know how to use these instances with Eclipse or IntelliJ idea. Im on a windows 8.1 64 bit machine.
When you click "add" from your instructions, you are browsing to a new tc Server installation directory (the binaries you want to run) not the instance directory. Once you select the installation directory of the version you wish to use, you will select next in the configuration and it will give you the option to "Create instance" or use an existing instance. You will then select use an existing instance and point to your newly created instance directory.

Setting up home page in spring

I am new to spring environment. I have created small test spring project through STS.
Project name: SPTest
base package name: uk.co.ifTest
When I run and open this project browser through Eclipse. It work fine, but url, it put in the browser is xx.xx.xx.xx:8080/ifTest/, instead of //xx.xx.xx.xx:8080/SPTest/.
I guess, it is adding base package name.
Is there any way I can open project with http://xx.xx.xx.xx:8080/SPTest/.
Thanks
ish
You need to change your context path for the server to point from ifTest to SPTest.
This answer will help you identify how to do it:
Changing Tomcat context path of web project in Eclipse

Resources