How can I fix Grails error: "No domain class found for name PrivacyOptions. Please try again and enter a valid domain class name" - class

I'm just getting started with Groovy/Grails.
I added a new domain controller to my project, and generate-controller doesn't like it.
There are other indications something's wrong: If I run the app no table is actually created in the database for this.
I've reduced the DomainController to one String field and no constraints, just to make sure there wasn't something wrong with my specification. I also tried renaming it, just in case there was something about the original name (Privacy) that conflicted with something.
I'm sure I have the correct name, and that the file is called PrivacyOptions.groovy and inside the class is also called PrivacyOptions.
Here's the error:
Running script /opt/local/grails/scripts/GenerateController.groovy
Environment set to development
Domain class not found in grails-app/domain, trying hibernate mapped classes...
No domain class found for name PrivacyOptions. Please try again and enter a valid domain class name

Add the project name (aka the package name from the first line of the model file) before the model name.
grails generate-all projectname.Class
This is the one that finally worked for me, after an hour of head scratching and googling.
ref: http://grails.1312388.n4.nabble.com/Generate-Scaffold-Scripts-Don-t-Work-Getting-No-domain-class-found-Error-td2017858.html#a2017880
As of 1.2.2 Grails creates artifacts in packages that default to your
project name - see http://jira.codehaus.org/browse/GRAILS-5713
So you'd need to run grails generate-all srapp.Srmodel
- Burt

it's not projectname.Class , it must be dirname.classname .
eg: your projectname is Helloworld, the directory is "grails-app/domain/helloworld/User.groovy" . so , the command is "grails generate-all helloworld.User" ,but not "Helloworld.User"

Run:
grails clean
and then re-run the generate-all command.
ref: http://parasjain.net/2009/06/23/grails-no-domain-class-found-for-name-please-try-again-and-enter-a-valid-domain-class-name/

Great help. I faced the same problem following this tutorial that names the project as "trip-planner" and Grails generates the domain directories as '~/trip/planner/' instead of '~/trip-planner/'. Then the generate-all command for a Trip class should be 'grails generate-all trip.planner.Trip'
Just in case someone adds a '-' character to the project name.

Yep... worked for me too. I just prefixed the package name to the class I was trying to generate-all for and it worked. So ...
generate-all racetrack.User
Bit of a pants bug really since all other grails commands do not require a package name to be included :-))

I don't know how you got to this point, but maybe this will help you get over the hump.
Am I correct to assume that you used "grails create-domain-class" to create PrivacyOptions domain object, and the Groovy script showed up in your grails-app/domain directory? Did you get a PrivacyOptionsTests in test/unit? Did that pass? Did you add a package?

related issue about stack trace not being clear for missing properties:
http://jira.codehaus.org/browse/GRAILS-1607

generate-all Domainname will not work as the full package name is needed.
I tent to do add an * for the first time and then you will see what the domain class should look like for the other calls.
generate-all *
http://grails.org/doc/latest/ref/Command%20Line/generate-all.html

It must be dirname.classname.
If you have a domain class created Book, like this 'grails-app/domain/book/Book.groovy'
The it should be: grails generate-app book.Book

If you are working on Groovy/Grails Tool Suite, you can simply see the domain name by right clicking on the controller that you created, notice the exact case for domain name, then right click on views and generate views and type in domainname.viewname
Example, your controller name is RegistrationController and domain name is helloworld, you can right click on views and in generate views dialog, enter the value as helloworld.Registration

Related

New class creating

When I want to create class in default package Eclipse shows this error:
Must Declare a Named Package Because This Compilation Unit is Associated to the Named Module
Then I have to delete module.info.java from \src to solve the problem but I don't know why?
As I said I searched in internet and I've got that I should the module.info.java in \src directory must be removed.
but I don't understand the reason of mentioned problem.

The Web server is configured to not list the contents of this directory

Using Visual Studio 2012:
I created an "ASP.NET Empty Web Application" (using C#).
I used NuGet to install the FubuMVC package.
When I run the application (using IIS Express), I get the "Welcome to FubuMVC!" page which tells me to delete the FubuMVC.GettingStarted.dll file and to set the home page.
So I do both of those things, implementing a HomeController that simply returns "Hello World" from Index.
Rather than the expected "Hello World", I get an IIS error: The Web server is configured to not list the contents of this directory.
What have I done wrong?
try this
cmd => don't forget to run as administrator
%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_regiis.exe -ir
Just tried reproducing your problem with a brand new project; it turns out that problem is that the instructions in the example haven't kept up with the changes in FubuMVC.
The instructions tell you to create a class called 'MyHomeController' and add the Index() method to it. This used to work, because one of the default rules for routes was to use any class with a name that ends in 'Controller'.
But the default has been changed in more recent versions, and the rule now looks for classes ending in 'EndPoint'.
So if you change the name of the class from 'MyHomeController' to 'MyHomeEndpoint', it should work.
Also, remember that the application pool needs to restart for the new configuration to take effect, so you might have to touch your web.config (or force IISExpress to restart).
Did you activate FubuMVC in your Global.asax? I usually see that error when there is no FubuMVC application.
So in Application_Start() (or whatever it's really called), you'll need something like:
FubuApplication.DefaultPolicies().StructureMap(new Container()).Bootstrap();
Where you're telling it:
1.) What are the policies/conventions to use
2.) What's your IoC container
Usually if I run into this it's because I've got a conflict with a route and a folder in the project. For example, I might have a folder called 'Unit' and inside it I have a class called 'UnitEndpoint' with a method 'get_unit' (which should map to '/unit' as a route, assuming I'm using the FubuMVC defaults).
In that case, browsing to '/unit' will result in this error because IIS thinks I'm trying to list the contents of the 'Unit' folder. Renaming the endpoint or the folder to remove the conflict will fix it (e.g., renaming the 'Unit' folder to 'Units').
I suggest that you recompile your application or at least touch your global.asax -- looks like you need to rerun the App_Start method.

Three20.h file not found when building with xcodebuild

I build my project(include subproject Three20) successfully using xcode GUI,but when I use xcodebuild,it failed with this below:
/Users/***/MyProject/Classes/ComposeSMSViewController.h:14:9: fatal error: 'Three20/Three20.h' file not found [1] #import <Three20/Three20.h> 1 error generated.
my Header Search Paths are $(BUILT_PRODUCTS_DIR)/../three20 and $(BUILT_PRODUCTS_DIR)/../../three20 and Classes/Three20/Build/Products/three20
That works on GUI building but failed on xcodebuild.
How can I solve this? Thanks
I think you should restart three20's install , it need several steps and make sure it's without mistake. Best regards. It may help you: http://three20.info/article/2011-03-10-Xcode4-Support
If it still doesn´t work (and an error like "Three20.h file not found" is shown), try setting "Skip Install" to "Yes" for all of the Three20 dependencies and projects in your app (except your main project): graphically . This onle creates an .ipa for your project, but not for your three20 projects.
I resolved this issue today by accident. I tried all the solutions I found online and it didn't work. I was pretty confident that the problem was within xcode because the app built fine on my boss's machine. Turns out my scheme name didn't match my target name. This was a result of duplicating a target, which automatically named my scheme to "myapp copy". When I matched the scheme name to the target name, everything worked fine and the three20.h file was found. Hope this helps anyone with similar circumstances.
Product-> Manage Schemes... and rename the file

Workspace is closed error

I have created a EMF model and generated a model code for that. I have created one plugin project and i have created one class named as 'CommandTest' which is having "public static void main()" method which reads mymodel resource file.
Its working fine in eclipse 3.5.2. There is no issues am able to read the contents.
But same thing am running through command prompt, am getting error "Workspace is closed". I have included my plugin folder in my classpath.
I have used one statement resource.load(null). In this line am getting "IllegalStateException: Workspace is closed".
I want to run my project in commandline not in eclipse environment. I have searched this problem in internet, i can able to find some solutions but its all related to eclipse environment.
If anything am doing wrong in this following statement
====Code Snippet======
file = "C:\temp\mytemp.xml";
// Creating resource
XMLResource resource = (XMLResource) new MyModelResourceFactoryImpl().createResource(
URI.createURI(file.toURI().toString(), true));
resource.load(null);
=======================
Is it possible to run plugin project in commandline? if it is possible could any one guide me how to achieve this to avoid "workspace is closed" error?
Did you try to specify a workspace with the -data <workspace-path> command line switch? You could try as well to call Plugin.getStateLocation().

Problems with zend-tool reporting that providers are not valid

I have recently setup XAMPP 1.7.3 and ZendFramework 1.10.4 on a new computer and many of the commands that I normally use now fail.
Here are the steps I used to setup and test ZF.
First I added the ZF library folder (C:\xampp\php\ZendFramework-1.10.4\library) to the include path in php.ini.
Then I added the ZF bin folder (C:\xampp\php\ZendFramework-1.10.4\bin) to my Path system variable.
To test that everything is configured correctly I ran the command "zf show version" from the command line. The result is "Zend Framework Version: 1.9.6".
Immediately something appears to be wrong. The file that is downloaded is "ZendFramework-1.10.4.zip" and the reported version is 1.9.6. I have re-downloaded the latest version (1.10.4) and removed old copy. Still the incorrect version number problem persisted.
Having done some research there is a bug in the ZF knowledgebase that version 1.10.3 reports a wrong version number. So that may explain the version number problem.
Moving forward I tried to run some zf-tool commands and certain commands reports that the action or provider is not valid.
Example:
C:\xampp\htdocs>zf create project test
Creating project at C:/xampp/htdocs/test
C:\xampp\htdocs>cd test
C:\xampp\htdocs\test>zf create controller Test
Creating a controller at C:\xampp\htdocs\test/application/controllers/TestController.php
...
Updating project profile 'C:\xampp\htdocs\test/.zfproject.xml'
C:\xampp\htdocs\test>zf create action test Test
Creating an action named test inside controller at C:\xampp\htdocs\test/application/controllers/TestController.php
...
Updating project profile 'C:\xampp\htdocs\test/.zfproject.xml'
C:\xampp\htdocs\test>zf enable layout
An Error Has Occurred
Action 'enable' is not a valid action.
...
C:\xampp\htdocs\test>zf create form Test
An Error Has Occurred
Provider 'form' is not a valid provider.
...
Can any one provide insight into these errors and how to correct them?
I had a similar issue, it turned out that I needed to manually update the zf.bat and zf.php files that came included with xampp after updating to the latest zend framework.
I got them from the zend svn here: http://framework.zend.com/svn/framework/standard/trunk/bin/
the simple way if you are using xampp, just go to the path "xampp\php\PEAR" an replace the older Zend directory with all included files by a new one zend 1.10... dir and your porblems are lost :)
i think your problem is, that Zend Tool is shipped with xampp since some versions.
Try to find zf.bat in your Xampp directory and remove it ;)
ZF friends have written the worst kind of docs. For XAMPP user, it is more difficult. I have learning ZF and posting error getting on the path. I am also using XAMPP.
Your error list is very big. I hope I can help you.
Solution for error "An Error Has Occurred
Action 'enable' is not a valid action." is XAMPP's Zend Tool installation. Delete that.
Check here for more details about the solution and other possible errors: http://www.satya-weblog.com/2010/11/zend-framework-creating-layout.html.