Groovy/Grails - Unable to Resolve Class - eclipse

I am trying to build a Grails project in STS and am getting many error messages of the form: Groovy:unable to resolve class org.codehaus.groovy.grails.commons.ConfigurationHolder as well as others like Groovy:unable to resolve class org.grails.plugins.springsecurity.service.AuthenticateService
. I have Grails 1.3.7 selected in the Project Properties, but I don't see an item for 'Grails Depedencies' like I do when I create a sample project. Is this the problem? How can I add it back in?

I don't know why, but here are the steps I took to solve the problem:
Right click on the project and go to Grails Tools -> Enable Dependency Management
Grails Tools -> Refresh Dependencies. This correctly added the 'Grails Dependencies' library.
I still had plugin errors. I for some reason had to uninstall them and then reinstall them for the project to realize they were there.

For anyone who is using Grails >= 2.4
If you are using Grails 2.4 and above, use grails.util.Holders instead of org.codehaus.groovy.grails.commons.ConfigurationHolder.
Read the doc here section 'Static Holder'
Classes The following deprecated classes have been
removed from Grails 2.4.x:
org.codehaus.groovy.grails.commons.ApplicationHolder
org.codehaus.groovy.grails.commons.ConfigurationHolder
org.codehaus.groovy.grails.plugins.PluginManagerHolder
org.codehaus.groovy.grails.web.context.ServletContextHolder
org.codehaus.groovy.grails.compiler.support.GrailsResourceLoaderHolder
If you or any plugins you have installed are using these classes you
will get a compilation error. The problem can be rectified by updating
to new plugins and using grails.util.Holders instead.

If "Refresh Dependencies" has done all it can for you (as you indicate in your comment on the question), try disabling and re-enabling dependencies. You might try refreshing dependencies again afterward if the Acegi plugin still isn't recognized.

there is another way solved me this issue when i moved my workspace from Windows OS to Ubuntu , go to
yourWorkSpace -->yourGrailsProject-->setting folder --> org.grails.ide.eclipse.core.prefs,
then check all the grails paths are correct or not , because in my case all were pointing to windows paths ..
Hope this solve.

I faced a similar issue: "Unable to resolve class GrailsTestCase". I checked Grails Tools of my project and observed Dependency Management was already enabled (IDE - GGTS). I just disabled Dependency Management, refreshed and enabled it again. This solved the issue for me.

Related

Cannot connect to RemoteNG Client. Check if old version of testng.jar is being used error-Eclipse Luna

I am getting an error like -
Cannot contact RemoteTestNG Client.Make sure you do not have older versions of testing.jar on your classpath.
Reason:Timeout while trying to contact RemoteTestNG.
I tried various solutions already present in stack overflow:
Check "Use project testng" option
Add latest testing.jar in classpath.
Check for duplicate testng jars in classpath.
Delete old testNG testsets ,clean workspace and restart workspace
But all the above solutions did not work for me and I ended up getting the same error again.
Please help me out here.
the latest release of testng eclipse 6.9.11 should fix this issue, please let me know (or fire an issue here https://github.com/cbeust/testng-eclipse/issues)
Noted: since this version, option "Use Project TestNG jar" was removed, to always respect the Project's TestNG lib.

Why do my upgraded Grails projects have red exclamation marks?

I've upgraded my Grails and on every project ( already created or new ) I have red exclamation mark. Projects are working fine.
I tried to fix it with Groovy-->Fix Compiler Mismatch Problem, with refresh dependence and Project-->Clean but without avail.
I thought that it could be problem with build path but I don't know how to fix it, so if anyone could help...
I have seen this loads of times doing this sort of stuff, the first thing to do is do a grails command wizard and clean
or grails clean
The try doing a
grails refresh dependencies
If you have actually upgraded grails over all and just copied your application folder into the new ggts (grails install) then a few things you need to do:
Create a new project under your new grails/ggts - take a look at applications.properties:
edit current applications.properties :
app.grails.version=2.3.7
Ensure the application version matches what you have in your newly created app under upgrade..
Then open grails-app/conf/BuildConfig.groovy for the new project under new upgrade and check closely the configuration. Infact copy entire BuildConfig.groovy over to your existing project and add any additional plugins you have in your project to the new BuildConfig.groovy
Then retry grails clean grails refresh depenedencies
This should fix issues.
Its most probably due to missing link to grails plugin. You can always delete those red exclamation marks by opening "Problem" view (GGTS -> Windows > Show View -> Others -> General -> Problems) and delete all errors if don't want to see them.
This is doable if you are not running your grails server from GGTS.
-SA

Eclipse bug: This project has the JPA facet, but no JPA project could be created

After restarting Eclipse, I get the following error in my project:
This project has the JPA facet, but no JPA project could be created. See the error log for more details.
Nothing I've done (clean project, maven update, etc) will get rid of the error. My JPA Content icon remains greyed out.
It looks like this was a resolved bug at Eclipse bugs...but then why am I still getting it? Should I submit a bug report to Eclipse?
This is a configuration problem of the project. To solve this problem go to the project properties, and in the node "project facets" unchecked JPA and apply the changes. Now you can checked JPA and apply again!
For me all the above didnt worked.
So I tried Project Properties>Validate. It solved my problem.
To get rid of this error in Eclipse Luna, I just did a right-click on the project and chose the "Validate" menu item.
Alt+Enter in the project
Go for Project facets
Uncheck JPA and accept
Right click in the project, go for Validate
Alt+Enter in the project
Go for Project facets
Check JPA` and accept
Although this is an old thread, will try to give info that might just help someone.
I assume you have imported a project and it is giving this error.
Step 1 : Check under project properties if jpa is configured.
Step 2 : I have used eclipseLink as the user library for jpa. If you are using eclipse as well, try installing the plugin.
Step 3 : Check the version of jpa under project properties-> project facets... check for any conflicts in version, usually seen for java version and or any supporting libs. You should be able to change the version from facets.
JPA installation and configuration JPA installation and config
Step 4 : once JPA is configured for the project, clean and check. This should work.
I had the same problem and resolved it by installing both apt and jdt connectors for m2e.
Go to Window > Preferences > Maven > Discovery > Open Catalog. Look for m2e-apt and m2e-jdt-compiler. Install and then restart eclipse.
Click right button on your project-->properties-->validation-->uncheck JPA Validation .
That works for me!
Looks like the problem is in some cases caused by a missing JPA implementation in the classpath. After I added a Maven (test scope) dependency, the Eclipse error message disappeared:
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>4.3.1.Final</version>
<scope>test</scope>
</dependency>
I this special case I had a "war" project that has a "persistence.xml" but no JPA code itself. The JPA stuff is in the referenced libraries (JARs).
For me, it was enough to clean the project.
Trying to disable JPA in the facet window caused an Exception.
Like kaushikjain said, validate your project and the error will disappear. This worked like a charm to me.
Right click in your project and Validate.
If you do not want to use JPA,
simply restart your eclipse and clean the project.
I had same problem when I copied JPA Entity to non-JPA project.
It worked for me and I hope it does so for yours :)

JFXtras and Netbeans compiler issue

Would somebody be able to walk me through the proper way of adding the latest JFXtras package to a project in Netbeans? I'm not sure what I'm doing wrong... whether it be importing incorrectly, implementing incorrectly, or just simply downloading the wrong jar files. I'm using JavaFX 1.3 and NetBeans 6.9.
I've been able to get NetBeans to recognize the components in the library (I type XCustomNode, and it prompts me to import from org.​jfxtras.​scene.) Upon trying to build/run, however, I get a compiler error such as the following:
Note: An internal error has occurred in the OpenJFX compiler. Please file a bug at the Openjfx-compiler issues home (https://openjfx-compiler.dev.java.net/Issues) after checking for duplicates. Include in your report:
- the following diagnostics
- file C:\Documents and Settings\me\Local Settings\Temp\javafx_err_4220242024568343160.txt
- and if possible, the source file which triggered this problem. Thank you. C:\Documents and Settings\me\My Documents\NetBeansProjects\project\src\input\NumberWithLabelNode.fx:24: cannot access com.sun.javafx.runtime.location.ObjectVariable class file for com.sun.javafx.runtime.location.ObjectVariable not found public class NumberWithLabelNode extends XCustomNode { 1 error
I don't think I really need to go report this to Openjfx... my gut says I'm missing a file.
Not sure what version of JFXtras you're using, but I've had much better success with version 0.7rc alongside JavaFX 1.3.
In addition to making sure Common and Controls jars in in your library, I've had to add miglayout-3.7.jar and swing-worker-1.2.jar as well, available on the project downloads page
The problem you are facing is incorrect version of library. You are trying to use JFXtras compiled with JavaFX 1.2.* and your project is using JavaFX 1.3.. As you can learn on official site, JavaFX is not backward compatible yet. Get newer library or rebuild sources with JavaFX 1.3.

Eclipse RCP: How to troubleshoot plugin dependencies & classpath problems?

I am working on an RCP project based on eclipse. It has been working fine but recently I thought I'd upgrade it to use a new eclipse version (3.2 -> 3.5).
After a bit of trouble, it was running on the new platform. Then I did something. Don't know what. The end result is that I'm now getting a classpath error when one of my plugins (A) tries to access a class in one of the dependent plugins (B) (also one of mine).
As far as I can see, Plugin A has Plugin B in its' dependency list and the compiler shows no errors. To test, I created a new Plugin C with one class and accessed the class from Plugin A. That works fine.
Does anyone have any hints for troubleshooting such issues? A checklist of settings to check? I've been struggling with this for hours and getting nowhere! Particularly frustrating as it was working until I changed something!
Thanks
Update
I should also say that the project is quite old and uses the plugin.xml and not the manifest. Could this be a problem? Is there a way to upgrade?
Some ideas:
Clean-and-build every project (maybe after a restart of Eclipse)
Check, whether the required packages are also exported
Check the Error log, maybe there is some unloadable plug-in, etc.
Check the Run configuration, whether every required plug-in is present there
If the problem does not happen in a Runtime workbench, but in an Exported RCP app, then check whether you compile the project with the same settings during export than in Eclipse
I hope, something helps about these.
You can try the following in your run configuration:
In the Main tab check Clear (workspace) under Workspace Data
In the Configuration tab check clear the configuration area before launching under Configuration Area
This helps me every time I encounter some strange ClassNotFound errors.
If I understand you correctly you have no compiler errors but when you run you get class not found exceptions? You could try PDE Tools > Update Classpath from the project's context menu to see if you declared any dependencies outside of the MANIFEST.MF file, which would result in compiling code that fails at runtime.
I developed for RCP quite a long ago, but if I'm not wrong, since 3.4 or 3.5 you have to declare in the plugin configration which packages/classes are exported for dependent plugins and which are not.
This is unlike the old convention of using 'internal' in the package to mark non-exported packages.
Since you have plugin.xml from very old version of eclipse, it might be the problem, as exported resources from one plugin to another were not enforced in Eclipse RCP 3.2.
One more complement, hope it helps.
Open plugin.xml, check "build" tab, see how "binary build" are configured. It affects which files will compiled and exported.
See binary build here : http://help.eclipse.org/indigo/index.jsp?topic=%2Forg.eclipse.pde.doc.user%2Fguide%2Ftools%2Feditors%2Fmanifest_editor%2Fbuild.htm