Problem with running Maven GWT application in Eclipse - java

I'm trying to create a GWT project through WebAppCreator enabled Maven2.
Project creation steps:
Create project with WebAppCreator (i'm using gwt-2.3.0) ->webAppCreator -noant -maven -XnoEclipse -out MyApp com.example.MyApp
Import project as existing maven project in eclipse (helios)
Enable "Project" -> "Properties" -> "Google" -> "Google web toolkit" -> "Use google web toolkit" checkbox
Set in project properties "Google" -> "Web application" -> "This project has a WAR directory". Set WAR directory path "src/main/webapp" and uncheck "launch and deploy from this directory"
Java build path is "MyApp/target/www/WEB-INF/classes"
I did not change the settings in pom.xml
Compile project using gwt eclipse plugin (2.3.0 version). It successfully compiled.
Try to run project as Web Application. When i run application GWT plugin does not ask me about WAR folder.
I did all this, I saw in the logs:
[WARN] Server class 'com.example.server.GreetingServiceImpl' could not be found in the web app, but was found on the system classpath
[WARN] Adding classpath entry 'file:/home/redfox/workspace/java/redfox/MyApp/target/www/WEB-INF/classes/' to the web app classpath for this session
[WARN] Server class 'com.google.gwt.user.client.rpc.RemoteService' could not be found in the web app, but was found on the system classpath
[WARN] Adding classpath entry 'file:/home/redfox/.m2/repository/com/google/gwt/gwt-servlet/2.3.0/gwt-servlet-2.3.0.jar' to the web app classpath for this session
And when i try to load page from URL (http://127.0.0.1:8888/MyApp.html?gwt.codesvr=127.0.0.1:9997) i see 404 error.
In logs i don't see any errors. How can i run this default application? Also i have another question: if this problev will be solved, how can i run this application in web mode (not in development mode) for using links like "http://127.0.0.1:8888" whithout param gwt.codesvr?
P.S. Sorry for my bad English.

I understand your frustration, trust me, I recently went through exactly the same issue you having now.
As Eugene indicated, follow his instructions, but...
On the Select an Archetype choose version 2.3.0-1 (Others may work but this one works for me)
Generate your sample app using theat Archtype version. Do a mvn gwt:run, you will see this screen (If all goes well)
Click on "Launch Default Browser".
Good luck.
Cheers
PB

I know this question is two years old. But i just had the same issue and now figured out how to fix it.
When eclipse doesn't ask you at the first launch for your "WAR" directory, you can also set it manually:
In eclipse go to "Run" -> "Debug Configuration...". Select your "Web Application" -> Select the "Arguments"-Tab and add the parameter e.g. "-war C:\YourProjectPath\target\YourProject-1.0-SNAPSHOT". Provide the full path here pointing to your target, generated by maven.
Hope that helps someone solving this issue faster :)

I know this is old, but here is my latest approach (as also answered here)
I can't speak for the webAppCreator because I haven't used it, but I have had good luck creating the Maven projects in Eclipse using the gwt-maven-plugin from codehause.
Creating a Maven GWT Project Directy in Eclipse
Open the new project wizard in Eclipse and filter on Maven Project.
Select the Maven Project and click next.
Enter the project location of your preference and click next.
Enter "gwt-" into the archetype filter and select the gwt-maven-plugin from codehaus. Click Next.
Enter your maven project details and a module value, then click Finish.
This will create a maven - gwt project for you in Eclipse. This comes with a sample application that you can use to make sure you can launch the application correctly.
Running the Application Command Line
Open command line.
Navigate to your project home.
Run the command "mvn clean package".
Run the command "mvn gwt:run"
This should get you up and running. If you used the 2.7.0 gwt-maven-plugin this should run the application in super dev mode by default.
Run the application in Eclipse
As you have done, navigate to Properties > Google > Web Application and check "This project has a WAR directory". The WAR directory using this plugin should be src/main/webapp.
Navigate to Properties > Google > Web Toolkit and check "This project has a WAR directory. You may be able to specify the module here. I am actually unable to do so, it may be specific to my Google Plugin for Eclipse or something environment specific...
Run As > Web Application.
If you had issues, as I have had, in step 2 then you will get an error Missing required argument 'module[s]'. To fix this open up your run configuration (should have been auto created) and in the arguments tab add the package qualified name for your module at the end of the arguments, e.g. com.mycompany.abc.GwtSampleModule. Do not add the ".gwt.xml" prefix.
It's worth also checking that the HTML page referenced in your arguments is correct, I have also had issues with that.
The application should now be configured for Launch in Eclipse using this run configuration. My verified environment is:
Eclipse Luna (v4.4)
Google Plugin for Eclipse (v3.8)
GWT Maven Plugin (v2.7.0)

What I suggest may start slightly different than you prefer but with better results :)
Install m2eclipse plugin. This will add a lot of nice maven features to your environment.
Using new project wizard create new Maven project
Do not select "simple project" check box, instead use the one of GWT archetypes (I suggest gwt-maven-plugin)
Then appropriate project structure with all required dependencies will be created for you by maven. More info about GWT plugin can be found at http://mojo.codehaus.org/gwt-maven-plugin/user-guide/archetype.html, including on how to execute it.
P.S. Your English is fine :)

Related

Spring Boot project in IntelliJ community edition

I am new to IntelliJ Community edition. Can anyone help me with creating spring boot project in intelliJ Community edition. For ultimate edition there is spring-boot initializer but I cannot find anything for community edition. I followed this links but cannot find any solutions
"Create Spring Boot Project with IntelliJ Community (FREE) Edition in 5 mins"
"Getting Started with SpringBoot in Intellij IDEA Community Edition"
You can install a plugin called Spring Assistant:
Now you can use the initializer as:
Personally, however, I use Spring initializer at start.spring.io
EDIT: Adding run configuration
Select Edit Configuration from the Run menu
Now in the dialog box, lick on the + button and select Application.
Now you just need to provide the name of the main class. You could click on the browse button(...) to get a list of files having main(...).
If you have done your spring project with SPRING IO
Then You can import it as maven project and follow this steps to import spring project
Open IntelliJ IDEA
You can see Welcome screen, click Import Project.
The Select File
Navigate to your Maven project and select
Click OK.
Pretty simple, as both link you attached say you created your project with Spring Initializr, and if it is a maven project, then follow these steps mentioned below:
click on File option
click Open option
navigate to your project and choose pom.xml file [it not a maven project, choose your configuration.xml file, if something else, just select the project folder]
press Ok. And you are done
now, open idea terminal and run mvn clean install(I assume you have installed maven) or, just select project->right click->choose maven-> click on Reimport maven option. Now run mvn clean build All are set now.
You can follow these steps.
Click on Add / Edit configuration
Then select configuration type as application.
Fill in appropriate details.
Note: In place of <no module> add directory / module in which the entry class is present.
Save the configuration and click on Run / Debug symbol shown in first screenshot.
Extending #Prashant's answer
If you are not able to find Spring Assistant plugin within IntelliJ Community Edition, Go to Plugin's website and then click on GET button, Choose Compatibility with IntelliJ IDEA Community and then click Download.
The rest of the procedure remains the same as described by #Prashant.
Also if you want to change your Port, then select Modify Options and select Add VM Options, and paste
-Dserver.port=8090
in that VM Options textbox and then run the application.
Just go to the below mentioned:
https://start.spring.io/
Fill the information regarding Project(Maven, Java, spring-version(Select version only
have digits(for eg:2.6.2))). Don't select "snapshot" version.
Fill project Metadata information and click on Generate file. It will create jar file. Unzip it and open your IntelliJ and select "Open->select this Unzip folder and select "pom.xml" file inside this package and open as project.
Apart from the spring initialiser, in my experience no where else do you need an ultimate edition to work with spring boot, you can use Spring Intialiser
But there is a plugin as rightly mentioned by other Spring assistant which you can download from the plugin section which you can access from setting inside intellJ Idea.
For configuration instead of actually going in the edit configuration option of intellJ Idea you can just run the application and that would automatically have your configuration loaded and there onwards you can always use it.

STS, running any of the Guide projects

I install Spring Toolsuite.
I go to New -> Import Getting Started project.
I choose the 'Building a RESTful Web Service' one. Download only the 'complete' project, select maven and not to open the site.
Now what on earth to I have to do to launch it? Right-click on the project, run as, run on server, shows 'The selection cannot be run on any server'.
I have gone through loads of posts trying to find out what else I can do, done maven clean, maven install, changed the JRE Environment, nothing works.
Running a maven clean or maven install will only update the dependencies of the project (for instance, bring in Spring and its child dependencies, loggers, etc. specified in the pom.xml file).
To run the project right click on the class with the #SpringBootApplication
annotation (it will likely be the one with a main method in it, that's the one you want!). Then select 'Run as->Java Application'.
First a disclaimer. This answer applies to most of the guides. But there may be some to which it doesn't apply, because there's such a diversity of guides available.
Assuming you are trying a 'typical' guide which does something in the context of a web-app... then read on.
The reason that you can not run a guide with "Run On Server" is because of spring-boot adheres to the slogan of "Make Jar not War". The guide sample code are not things you deploy on a server (i.e war) but are standalone Java apps (i.e. jar) which contain their own embedded servlet container (if they need one). That means running them is really quite simple. Just find the 'main' method/class in the guide and use Eclipse "Run As >> Java Application".
There's also a convenient alias in STS called "Run As >> Spring Boot App" which does pretty much the same thing but gives you a few extra bells and whistles in the launch configuration editor.
Also... you don't really have to go look for the main method yourself because the "Run As >> Spring Boot App" knows how to find it in most cases. So clicking project and "Run As >> Spring Boot App" should do the trick.

Eclipse configuration to launch a Maven project with Google Web Toolkit

I'm starting a GWT project with web creator as following:
C:\>webAppCreator -noant -maven -overwrite -out MavenTest com.raphiki.MavenTest
It generates a Maven project's structure with an GWT Hello world project, I import this project in Eclipse as a Maven project with existing sources.
Then I enable Google Web Toolkit in my project, and I need to give a WAR path. I try with the /src/main/webapp which contains the entry point, but when I launch the app I get a ClassNotFoundException on Hello world's class's package.
See the following image which is the structure the WebAppCreator built:
Did I miss any configuration to do?
See http://web.archive.org/web/20130619170526/https://developers.google.com/eclipse/docs/faq#gwt_with_maven
TL;DR: run mvn package (or mvn war:exploded), then run DevMode, choose target/myapp-1.0-SNAPSHOT/ as webapp directory.
I can't speak for the webAppCreator because I haven't used it, but I have had good luck creating the Maven projects in Eclipse using the gwt-maven-plugin from codehause.
Creating a Maven GWT Project Directy in Eclipse
Open the new project wizard in Eclipse and filter on Maven Project.
Select the Maven Project and click next.
Enter the project location of your preference and click next.
Enter "gwt-" into the archetype filter and select the gwt-maven-plugin from codehaus. Click Next.
Enter your maven project details and a module value, then click Finish.
This will create a maven - gwt project for you in Eclipse. This comes with a sample application that you can use to make sure you can launch the application correctly.
Running the Application Command Line
Open command line.
Navigate to your project home.
Run the command "mvn clean package".
Run the command "mvn gwt:run"
This should get you up and running. If you used the 2.7.0 gwt-maven-plugin this should run the application in super dev mode by default.
Run the application in Eclipse
As you have done, navigate to Properties > Google > Web Application and check "This project has a WAR directory". The WAR directory using this plugin should be src/main/webapp.
Navigate to Properties > Google > Web Toolkit and check "This project has a WAR directory. You may be able to specify the module here. I am actually unable to do so, it may be specific to my Google Plugin for Eclipse or something environment specific...
Run As > Web Application.
If you had issues, as I have had, in step 2 then you will get an error Missing required argument 'module[s]'. To fix this open up your run configuration (should have been auto created) and in the arguments tab add the package qualified name for your module at the end of the arguments, e.g. com.mycompany.abc.GwtSampleModule. Do not add the ".gwt.xml" prefix.
It's worth also checking that the HTML page referenced in your arguments is correct, I have also had issues with that.
The application should now be configured for Launch in Eclipse using this run configuration. My verified environment is:
Eclipse Luna (v4.4)
Google Plugin for Eclipse (v3.8)
GWT Maven Plugin (v2.7.0)

Java EE deployment in Intellij IDEA

I have a fairly complex Java EE project which can be built fine from Maven. After importing it to IDEA, I had set up a working deployment of the frontend WAR and the backend EAR to a local Weblogic 12c server. The project also have several 'common' artifacts packaged as jars and used by both the frontend and backend artifacts. For deployment, I used the exploded artifacts to save some time on packaging/unpacking, everything works fine till that point.
During development, I edit some Java sources and try to redeploy the updated artifacts to the running Weblogic. I press Shift+F10, choose Redeploy artifacts, I see IDEA building the project, the project redeploys on the server, and more often than not, I do not see any of the recent changes. Even if I choose Rebuild project explicitly and then try to redeploy artifacts after, no changes can be seen on the server. The only safe way to make my changes appear in the deployed artifacts is to invoke maven from the command line calling the package goal, and then redeploying from IDEA. (No JRebel is installed, is being used either in the IDE or on Weblogic, and I'd like to stay that way).
Is that expected behaviour from IDEA? Could this be something specific to our project or something global? Should IDEA be able to discover which projects needs rebuilt and repackaged and then redeploy the EAR/WAR artifacts properly to the server? Does it need any help from my side achieving that goal?
Whats your run/debug configurations? Check this, if not already sois not.
in the quick menu, edit configurations > Run/debug configurations window:
Server tab:
On 'update' action: restart server
Before launch: set 'run maven clean' and 'run maven install'
Deplowment tab
inserts your ear's here.
don't sure this specific answer your question but what I can suggest you is to try configure
weblogic maven plugin
then you can execute deployment from command line / or from IDEA with maven support.
http://docs.oracle.com/cd/E21764_01/web.1111/e13702/maven_deployer.htm
http://www.youtube.com/watch?v=hagaMr6UL6U
Evenif your final goal is to do the whole built process done by IntelliJ build and deployment options I will first try the following:
If your project was set up properly in maven you should be able to load you maven pom.xml within you IntelliJ. All the maven build commands and deployment setting you were doing through mvn command line will show up in your IntelliJ's maven panel in a nice three structure.
If this works out then clearly one of the libraries that are built through your IntelliJ build are not being deployed properly into the right location. You need to narrow down which one of the jars, the ear, or the war has to be affected by a single change you make and then check whether the date of the file is updated in the location it is to be deployed or not.
To wrap up, my humble sugestion though is to use either maven or gradle intelliJ panels for your J2EE projects. As you do achieve the defined goal of having your project built completely through the IntelliJ idea. Also whatever plugin you add to your maven shows up in you idea's maven/gradle panel. It is a fairly straight forward approach and you achieve a powerfull and flexible deployment and build tools within IntelliJ like your wanted.

Tomcat throws ClassNotFound exceptions for classes in other open eclipse projects

I have an eclipse project structure that looks something like this:
eclipse
project a
project b
All of these projects are Maven projects. Project B is an Eclipse WTP project and contains Project A as a dependency. I'm using the m2eclipse plugin.
When I deploy Project B to Tomcat (all from within Eclipse) it always throws errors saying that it can't find classes from Project A. The only way I can resolve this is to close Project A in Eclipse and do a mvn install command, so at this point Project A is treated like any other dependency.
I would like to not have to keep reopening and then closing Project A every time I make changes to it (which is pretty frequently at this stage).
I have tried adding Project A to Project B's Build Path, however that doesn't seem to do the trick. Again, it only works if I close the project in eclipse so it's treated like a normal maven dependency.
FYI I'm using the Helios version of Eclipse. Project B is a Spring project, so naturally Tomcat falls over when it imports all the beans etc.
Does anyone have any suggestions? Thanks a lot.
What you need to do is this:
In Eclipse go to Window > Show View > Servers > and open tab called Servers
In Servers, double click the server you want
This action should open a window entitled Overview, with your selected Server in the TAB
In this window select: Open launch configuration, and click the link.
In the Edit Configuration window, select the tab called Classpath
In the ClassPath textbox, select the line: User Entries
Now push the button on the right entitled: Add Projects
In the resulting Project Selection window select the external project you want the server to find via click.
Close these windows by clicking Apply then OK as appropriate as you work up the stack
Restart your server in the Overview window
You should be ready to go. It's actually only a 2 minute exercise. Good luck
If you go to the project properties, pick the item "Deployment Assembly", click "Add..." and choose "Project", you can add the dependent project and the issue should be solved.
The reason that tomcat cannot find your classes is that the project dependency in eclipse is not seen by tomcat. To resolve the issue you can add the bin folder of project a to the tomcat classpath of the app running from project b.
Right click on the web project which is added to container server and select Maven and then select Disable Workspace Resolution. Then your dependency project will start appearing as a jar like any other dependencies.
Right Click on the WebProject --> Maven --> Disable Workspace Resolution.
Have you installed the m2eclipse extension that know about WTP? Without it m2e will not work correctly for WTP projects. See this:
https://docs.sonatype.org/display/M2ECLIPSE/WTP+mini+howto
Simple way :
Run -> Run Configurations... -> Classpath

Categories

Resources