Sencha engineers created an Eclipse plugin, with context sensitive help that doesn’t put Eclipse into this indexing mode. They solved this problem by creating a special type library file (ext.ser) supporting code assistance in Eclipse. This solution will work until some of the Ext JS API changes, after that Sencha should update the type library file.
After that, Sencha marketing people put it in a gift box titled “Sencha Compete” with a little price tag that read $900. To be fair, this box has other stuff too, but you can’t just purchase Sencha Eclipse plugin, say for $50. Spending your own $50 may not be the option in large corporations that are limiting what you can install on the company computer.
In any event, I’ll share with you how Ext JS developers of Farata Systems deal with this situation when they have to work in Eclipse IDE with Ext JS. Our developers usually need to program the server side in Java hence they need to deploy the code under one of the Java servers, e.g. Apache Tomcat. They use different setups and I’ll show you a couple of them. you’ll see how to to configure Tomcat inside the IDE and then add Ext JS to your Web applications.
Installing Eclipse for Java EE Developers
We’ll use the “Eclipse IDE for Java EE developers” version of this most popular IDE among Java developers. It’s available free of charge at Eclipse Downloads site. The installation comes down to unzipping of the downloaded archive. Then double-click on the Eclipse executable, and it’ll start.
http://tomcat.apache.org%5BApache Tomcat is probably the most popular free and open source server used by Java developers for deploying Web applications. Besides being a Web Server, Tomcat also contains Java Servlet container.
Get the latest version of Apache Tomcat from the Download section at http://tomcat.apache.org. At the time of this writing Tomcat 7.0.39 is the latest build, so download the zip file with the Tomcat’s Binary Distributions (Core). Unzip the file in the directory of your choice.
Even though you can start Tomcat from a separate command window, the more productive way is to configure Tomcat right in the Eclipse IDE. This will allow to deploy your applications, and start/stop Tomcat without the need to leave Eclipse.
To add a server to Eclipse, open Eclipse Java EE perspective (menu Window | Open Perspective ), select the menu File | New | Other | Server |Server | Apache | Tomcat v7.0 Server, select your Tomcat installation directory and press Finish. If you don’t see Tomcat 7 in the list of Apache servers, click on “Download additional server adapters”.
You’ll see the Tomcat entry in the Eclipse Project Explorer. Go to Eclipse menu Windows | Show View and open the Servers view. Start Tomcat using the right-click menu.
By default, Eclipse IDE keeps all the required server configuration and deployment files in its own hidden directory. To see where exactly they are located in your computer, just double-click on the name of Tomcat in the Server view. The server path field contains the path. Keep in mind that while Tomcat documentation defines webapps as a default deployment directory, Eclipse uses wtpwebapps directory instead. If you prefer to deploy your Eclipse projects under your original Tomcat installation path, select the option Use Tomcat Installation.
In the next section you’ll learn how to create Dynamic Web Projects in Eclipse, where you’ll need to specify the Target Runtime for deployment of your Web applications. This newly installed and configured Tomcat server will serve as a deployment target for our sample projects.
Dynamic Web Projects and Ext JS
Eclipse for Java EE developers comes with http://www.eclipse.org/webtools/%5BWeb Tools Platform] that simplifies development of Web applications by allowing you to create so-called Dynamic Web Project, which will be specifically created for deployment under a particular Java server – Apache Tomcat in our case.
To create such a project select Eclipse menu File | New | Other | Web | Dynamic Web Project. It’ll pop up a window similar to shown below. Note that the Target Runtime is Apache Tomcat v7.0 that we’ve configured in the previous section.
Upon creation, this project will include several directories, and one of them will be called WebContent. This directory it serves as a document root of the Web server in Eclipse Dymamic Web Projects . This is the place to put your index.html and one of possible places to keep the Ext JS framework.Create a subdirectory ext under WebContent and copy there all files from the Ext JS distribution. The app directory should also go under WebContent.
If you don’t have Sencha Eclipse plugin, there is a couple of solutions to this problem (we’ll use the first one).
1. Exclude from Eclipse build the following Ext JS directories: ext, build, and packages.
2. Don’t copy the Ext JS framework into your Eclipse project. Keep it in the place known for Tomcat, and configure as a loadable module.
For the second solution, In this case you’ll need to add your Ext JS folder as a static Tomcat module. Double-click at the Tomcat name in the Servers view and then click on the bottom tab Modules. Then click on Add External Web Module. In the popup window find the folder where your Ext JS is (in my computer it’s inside the Library folder as in below screensot) and give it a name (e.g. /static/extjs-4.2).
Now Tomcat will know that on each start it has to load year another static Web module known as /static/extjs-4.2. If you’re interested in details of such deployment, open up the file server.xml located in your Eclipse workspace in the directory .metadata/.plugins/org.eclipse.wst.server.core/tmp0/conf.
To ensure that you did everything right, just enter in your browser the URL http://localhost:8080/static/extjs-4.2, and you should see the Ext JS Welcome screen.
In both of these solutions you’ll lose the Ext JS context sensitive help, but at least you will eliminate the long pauses caused by Eclipse internal indexing processes. Again, developing ExtJS code in Web Storm IDE or IntelliJ IDEA IDEs would spare you from all these issues. To see how to configure IntelliJ Idea with Ext JS, see this video in our Youtube Channel.
P.S. If you know of other and better ways of working with Ext JS inside Eclipse IDE, please share it with everyone by leaving a comment at this blog.
6 thoughts on “Configuring Eclipse with Apache Tomcat and Ext JS”
You can also try MyEclipse – it can give you almost all that out of the box. And if your employer refuses to pay $50/year for it, I would find a better one. 😉
On parallel topic: have you tried FlexJS? See: http://www.linkedin.com/groups/FlexJS-AS3-HTML-JS-Web-4296888.S.235751280?view=&srchtype=discussedNews&gid=4296888&item=235751280&type=member&trk=eml-anet_dig-b_mc-ttl-cn&ut=11hdtw1eVYJlI1
I hope it will get fully implemented and popular.
If Adobe would allow Alex Harui to work on the FlexJS project 2 days a week,it’d give Flex framework a second life. Alex is probably the only Flex guru still employed by Adobe. But at this point he works on it in his spare time AFAIK.
Eclipse plugin was showing “500 internal server” errors after activating it in my java hosting server. I changed the ownership of the “conf” directories and its working fine now.
bt it still shows ext is not defined
Are you including extjs in your includes. That would be the only reason
i have used 2nd solution to configure ext js in eclipse when i access the localhost with my path extjs welcome screen appears bt when i try to run it show ext is not defined in the browsers console