Grails in Eclipse - eclipse

I'm trying to follow some of the introduction to Grails tutorials and am at the point where I want to try to see if I can use a debugger in Eclipse with my Grails applications. My grails application runs fine when I use the command to execute, but when I tried to use the Eclipse run configuration, I get the following error:
Exception in thread "main" java.lang.NullPointerException
at java.io.File.<init>(File.java:194)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:494)
at org.codehaus.groovy.reflection.CachedConstructor.invoke(CachedConstructor.java:77)
at org.codehaus.groovy.runtime.callsite.ConstructorSite$ConstructorSiteNoUnwrapNoCoerce.callConstructor(ConstructorSite.java:107)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallConstructor(CallSiteArray.java:52)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:192)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:200)
at grails.util.GrailsMain.run(GrailsMain.groovy:27)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:86)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:234)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1062)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:893)
at org.codehaus.groovy.runtime.InvokerHelper.invokePogoMethod(InvokerHelper.java:744)
at org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:727)
at org.codehaus.groovy.runtime.InvokerHelper.runScript(InvokerHelper.java:383)
at org.codehaus.groovy.runtime.InvokerHelper$runScript.call(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:40)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:117)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:129)
at grails.util.GrailsMain.main(GrailsMain.groovy)
I figure it's a configuration issue (I did recently set the GRAILS_HOME environment variable and that seems to be correct) but that error message doesn't really give me much to go.
Suggestions?

Grails does work in Eclipse. Based on my observations I would actually say that it is the preferred IDE for Grails development (well the STS version).
A) You could choose to install the Eclipse groovy plug in. Can be a little fiddly http://groovy.codehaus.org/Eclipse+Plugin
B) Or you could used the Spring tool suite (STS) IDE and install Grails support from the extensions menu. http://grails.org/STS+Integration (Just works!)
STS is built on Eclipse
I personally have found STS to have better Grails support than Netbeans. Its developed by the same organisation that backs Grails

Have you installed the Groovy Eclipse Plugin?
IIRC, you need this to enable Groovy debugging --- take a look at this page for a step by step about setting up the eclipse debugger - http://www.grails.org/Eclipse+IDE+Integration
But Jared is right, Netbeans step debugger is so much nicer --- http://www.grailsblog.com/archive/show?id=13

Besides grails home, try setting JAVA_HOME environment variable.

I was never able to get grails to work properly in eclipse. You may want to try Netbeans though the 6.7 version has improved grails support.

We use Groovy/Grails Tool Suite IDE. It's similar to Spring Tool Suite (STS) in that it's based on Eclipse, but GGTS comes bundled with the Grails distribution itself and the tooling for Eclipse so that there's no extra step required to get any plugins.

Related

Apache Wicket Quick Start

I was trying to start learning about Apache Wicket (as it looked like an easy to use UI for Java) and as I like to work with Eclipse and Maven. I also like to work with Tomcat, however, Wicket seems to prefer Jetty at least in its tutorials. I do not know nothing about Jetty, however should not take ages to learn.
I tried the Wicket Quick Start and successfully imported the generated Maven project to Eclipse workspace.
But errors appear: e.g.
import org.eclipse.jetty.server.HttpConfiguration;
It seems Eclipse cannot find the jetty server classes. How to add these to the Eclipse project?
Does the creater of the Wicket Quick Start assumed that Jetty is already installed on the machine?
I installed it. However: what is the recommended way to make what jar file available to a maven project to have jetty server classes available? I would assume via the pom.xml but I doubt that is the case here - the given pom.xml would contain it.
Or is there some special plugin for Eclipse (Photon)?Run-Jetty-Run?. I wasn't brave enough to try that.
I would love to get the Wicket Quick Start running.
I also tried Eclipse + Tomcat + Apache Wicket Maven Setup with Hello World Example but it seems that it is outdated. I was not able to install qwickie to Eclipse as described.
I am using Eclipse Proton with Java 10.0.2 on Debian Stretch.
If you are using https://wicket.apache.org/start/quickstart.html then you can start the application these ways:
mvn jetty:run - this will use jetty-maven-plugin
Open in Eclipse src/test/java/com/example/Start.java and run it as a normal Java class with a main(String[]) method. This will use Jetty Maven dependencies to start an embedded Jetty server.
Wicket's Quickstart prefers Jetty because Jetty developers made it easy to use it in non production way, i.e. in development mode, for faster dev cycles. No need to build a .war file and deploy it.
On the other side Tomcat devs (disclaimer: I am a member of both Wicket and Tomcat teams) never spent time in this direction. Tomcat's Maven plugin has been abandoned long time ago. The best integration for starting embedded Tomcat is provided by Spring Boot project (I recommend it if you use Spring!).
So, just remove the Jetty related dependencies and plugin in pom.xml and the Start.java in src/test/java/.... Then you can continue developing with Eclipse and Tomcat the way you like to do it.

Use Tomcat server with Hibernate and Springsource Tool Suite?

I just installed Springsource Tool Suite as a plugin to eclipse kepler. I need to develop database-driven-web applications with it. I have thought I could do that using hibernate, but the eclipse STS plugin that I found for hibernate seems to only work with jboss server. I want to work with tomcat 7 server. Can someone suggest a good way to use hibernate with STS eclipse and tomcat? Or is there a better way besides eclipse to do database integration with STS eclipse and tomcat? Links to download tools, and to modern tutorials with the current versions of each tool, would be greatly appreciated. I just created a new Spring MVC project using the template in STS eclipse kepler. It would be nice to have tutorials and tools that work with that toolset. Even a fully working database-driven web application sample code to study.
Your requirements as listed below:
Spring Tools Suite : http://www.springsource.org/downloads/sts-ggts (Choose the appropriate version)
For Tomcat 7 to be used on STS , you will need to download it from this link: http://tomcat.apache.org/download-70.cgi
Update to JDK 7. Link: http://www.oracle.com/technetwork/java/javase/downloads/index.html
To setup tomcat 7 in Spring Tools Suite (essentially Eclipse configured for Spring) use this link : http://www.coreservlets.com/Apache-Tomcat-Tutorial/tomcat-7-with-eclipse.html (Follow the same procedure for STS)
You will also need to install a DBMS. Try using MySQL . Download it from : http://dev.mysql.com/downloads/mysql/
Also if you decide to use Eclipse for Spring (I do.. :P ), use this : http://www.eclipse.org/downloads/packages/eclipse-ide-java-ee-developers/keplerr
If you decide to use Kepler, you will need to install STS plugin for Kepler. Try: http://marketplace.eclipse.org/content/spring-tool-suite-sts-eclipse-kepler-43#.UhwuRNJkOSo
Try the following link for your first project: http://www.mkyong.com/spring/maven-spring-hibernate-mysql-example/
EDIT: As a developer it is very essential to know what is the standard way of implementing a Spring+ORM application. It's practice to to include Maven as a dependency management tool. Follow the links:
Download Maven: http://maven.apache.org/download.cgi
Setup maven in Eclipse : Setting up new Maven In eclipse
Link to website using maven : Just Google.. :P
As for the no Maven part, try understanding why actually is maven used. Follow the link: http://www.tutorialspoint.com/spring/spring_environment_setup.htm , to setup a spring envirnoment without maven. When you use Hibernate, just add the necessary jars to WEB-INF/lib folder. As simple as that.
Hope it helps. :)

Eclipse configuration to support dual Equinox/Felix environments

What are some configuration changes to make Eclipse PDE best support working with both Equinox and Felix?
Here's an example problem I'm currently having. I can run my application ok via the Eclipse OSGi Framework launcher. Similarly, there are no compilation problems in PDE. However, when running in Felix I will get NoClassDefFoundErrors:
java.lang.NoClassDefFoundError: org/w3c/dom/DOMException
My understanding is it's my Eclipse setup that is at fault here; org.w3c.dom is not a 'default' OSGi package and shouldn't be loaded when I run it in Eclipse. Similarly, the import in my code for org.w3c.dom.DOMException should be an error.
I know how to fix this for Felix: declare an Import-Package. But that's not my question. My question is how to force Eclipse PDE to take on a closer configuration to Felix... basically to make it stricter in loading packages?
I think Equinox does behave like Felix, if you run it stand alone. It's more of an Eclipse legacy thing than an Equinox thing, as stated on osgi.org.
As far as I know, there isn't any way to override the boot delegation from Eclipse, but I'd love to be proven wrong, as I've faced this problem often.
If you are developing a server application I recommend to not use the PDE at all. I am using maven and the maven bundle plugin to develop my bundles. Then I deploy on Apache karaf. Debugging also is quite simple by using the karaf dev:watch command and remote debugging. I never really missed the PDE features and they never worked well with my maven build.
This sounds like that launcher is setting bootdelegation to legacy mode. See the following page on the OSGi Wiki: http://wiki.osgi.org/wiki/Why_does_Eclipse_find_javax.swing_but_not_Felix%3F

I want to use javax jms

I want to use javax.jms in netbeans project , but netbeans tell my that there is no package like this , what should I do ?
this error occurs when I try from terminal
Exception in thread "main" java.lang.NoClassDefFoundError: javax/jms/MessageListener
You have to have the jms-api.jar in your classpath. I got mine from HornetQ.
Edit
I just saw that you said you were using NetBeans. In that case, you need to have downloaded the version of NetBeans that includes Java EE. Go here and download that. This site seems to have a nice tutorial on how to set it up from there.

slight url mismatch while publishing java 6 maven webapp to tomcat from netbeans

Honestly I've started this small maven webapp using eclipse 3.6 (STS) and i found it so complicated that i had to switch to netbeans.I really wanted to use eclipse but these are reality on the ground.So at the end of everything I'll like to have an eclipse version of the same project. thanks
I set up the maven webapp using the embedded archetype, and use cargo plugin to take care of the deployment.basically there is only hello world index.jsp in the project.after picking pom configuration here and there my pom finally is like this .
while it started publishing after i restart the IDE, it's publishing to http://localhost:8080/ but for me I'm expecting it at http://localhost:8080/mvnTestWebap
so here are my questions
Question 1 : How can i correct that?
Question 2 : I believe my pom is tied to netbeans too much, how can i achieve the publishing to tomcat result but having a portable pom?Can anyone suggest a rewrite that can run on eclipse?
Question 3 : what correspond to netbeans "run" in eclipse?
probably by some deployment descriptor editing.
don't really understand the point. by default netbeans uses it's own embedded IDE way of deployment. That's not creating a pom tied to netbeans in any way. You can use that in eclipse or IDE or command line to build the project. The deployment part of the web app is specific to the server being used and the IDE being used.
You can also tell netbeans to execute your cargo plugin on executing the Run/Debug/Profile action (bypassing the netbeans default behaviour)
run basically performs a redeploy of the app on the server of choice. There has to be an equivalent on eclipse.