Showing posts with label eclipse. Show all posts
Showing posts with label eclipse. Show all posts

Friday, January 23, 2015

Eclipse hangs on start up after proxy configuration change

The problem appeared after I had changed the proxy settigns of IDE in Preferences/General/Network Connections. After that eclipse started sticking on loading workbench. The following solution solved the problem:

  1. Go to your eclipse installation folder
  2. Switch to configuration/.settings
  3. Open file org.eclipse.core.net.prefs
  4. Set all the boolean properties related to proxy to false
  5. Save the changes
  6. Start Eclipse again
This solution has worked for me. Hope it will work for you as well.

Eclipse xpath parser fails to search elements by the tag names

For those who encountered the same issue (when you try to access the element using xpath by the node name in Eclipse built-in parser) I would recommend either to remove namespace definition from the document at all or remove the default namespace.
Example:

<apprepo xmlns="asdasd">
<app name="good-app">
<appinfo>
<author name="John Smith"/>
<stores>
<store name="goo" price="1"/>
<store name="app" price="1.5"/>
</stores>
</appinfo>
</app>
<app name="another-good-app">
<appinfo>
<author name="James Smith"/>
<stores>
<store name="goo" price="2"/>
</stores>
</appinfo>
</app>
</apprepo>

Query: //appinfo returns "no matches"

Let's now change the namespace so that it is bound to some prefix (let's even not use that prefix in our document)

<apprepo xmlns:pref="asdasd">
<app name="good-app">
<appinfo>
<author name="John Smith"/>
<stores>
<store name="goo" price="1"/>
<store name="app" price="1.5"/>
</stores>
</appinfo>
</app>
<app name="another-good-app">
<appinfo>
<author name="James Smith"/>
<stores>
<store name="goo" price="2"/>
</stores>
</appinfo>
</app>
</apprepo>

Result: query returns all the appinfo nodes found

P.S. - the proper parsing happens even if you completely get rid of the namespace attribute. So Eclipse xpath parser is not working with the documents having the default namespace set.

Tuesday, November 20, 2012

How to prepare your Eclipse IDE for web development

Objective

Once you're going to start developing some java-based web-applications or just static web-sites you need to perform some simple steps to configure your development environment. Basically you need three things to start developing:
  1. Eclise IDE (J2EE edition)
  2. Tomcat server (Servlet container and servlet specification implementation)
  3. JDK to support basic java features along with runtime environment
Lets go step-by-step here. At the moment of this post publishing the latest version of Eclipse IDE was Juno release.  Download it from here so that you've got the version suitable for your operating system. I'm using Windows 7 64bit so all further statements will be related to it. 
That will be great to create some sandbox so that you can use it as isolated disk space to have some practice. After you're pretty much familiar with the configuration you can repeat the steps with your own paths. Say, create the following folder where all the magic is going to happen: c:/sandbox. Create Projects subfolder to keep Eclipse project there.

Configure your Eclipse and Tomcat instances

Extract the eclipse archive to c:/sandbox. So you now have your IDE under c:/sandbox/Eclipse. Start it up (lets not talk about performance tuning of your IDE - this is not our topic here). Set up the workspace to Now you have IDE working. Unfortunately that's not enough to start coding. Close welcome screen.
You won't be able to code a piece of java code until you have JDK installed. Follow this link to download J2SE 6 for your operating system (make sure you're registered as oracle user as you will have to input your oracle credentials).

Install the distribution to C:\sandbox\JDK_SE6. Switch to Eclipse.
  • Go to Window\Preferences
  • In the preferences tree go to Java\Installed JREs
  • Click [Add] button. Choose Standard VM in new dialog and click Next
  • Specify folder C:\sandbox\JDK_SE6 for JRE home. Once you do that all other fields are pre-filled automatically
  • Now you may remove all other VMs from the list if they are.
  • Click OK to close preferences dialog
You now can write and execute Java code. However we're going to create web application, aren't we? Hence we need to install servlet implementation. That's also good to have a web server. Fortunately all those stuff is combined under Apache Tomcat server. Lets use the latest version at the moment. You may take it from here. Unpack the content of the archive to our sandbox so that we have Apache Tomcat server under C:\sandbox\apache-tomcat-7.0.32.

Lets bind eclipse to that apache instance.
  • Go to Window\Preferences again. In preferences tree go to Server\Runtime Environments.
  • Click [Add...] button
  • In "New Server Runtime Environment" dialog choose Apache Tomcat v7.0. Check "Create a new local server" cehck-box. Click Next
  • Click [Browse...] button and choose the folder C:\sandbox\apache-tomcat-7.0.32
  • Under JRE you may choose either default JRE of workbench or JDK_SE6. They are all the same. However lets choose the second option to be more defined.
  • Click Finish and then OK to close preferences window.

Creating a template project.

Lets now create some project to get aware how to create the project each time you want to start trying new create something new.
  • In Eclipse press Ctrl+N so that "New" dialog is opened. 
  • Choose "Dynamic Web Project" and click Next
  • There type some project name (note that the project path is attached automatically to our sandbox)
  • Choose Apache Tomcat v7.0 as target runtime
  • Set dynamic web module version to 3.0
  • Click Next until it gets disabled :)
  • There check the check-box "Generate web.xml deployment descriptor"
  • Finally click [Finish]
So.. Congratulations! You've now got web project configured. To make sure it's working lets do the following.
  • In your Project Explorer expand WebContent folder
  • Right-click the folder and choose New->Html file
  • Name it index.html and click okay
  • Within <body>...</body> enclosure  add piece of html-code like <h1>It really works!</h1>. Save the changes
  • Right click the project root in project explorer. Select "Run as -> Run on Server"
  • You should now see your html page which was deployed to the web-server and now loaded from it
That's all

Thursday, May 10, 2012

Connect Eclipse IDE to Oracle DB using TNS configuration file

Check new series of the articles. Review and user experience on test management systems. Functionality and usability.
-------------------

If you work with Oracle RDBMS you probably use the SQL IDE like Oracle SQL Developer however some may want to use old and reliable Eclipse IDE. Lets look how to configure it to access oracle DB. We'll do that using the configs from so called TNSNames.ora file.

So open that file. You should find your database description there. It should look like this:
oracle TNSNames.ora example


You need the information highlighted with yellow.
Now open Eclipse IDE and enable 'Data Source Explorer' view. In that view right click on 'Database Connections' and choose 'New...'
Eclipse Data Source Explorer view

Choose Oracle from the vendor list, specify name and description and proceed with Next button
Eclipse New Connection Profile settings (Oracle TNS)
Set up your driver so that it is Oracle Thin Driver. Specify corresponding JDBC jar file for that.
Set up the server name, port number and SID. Also specify your credentials so that DB server can authenticate you. Your connection URL should now look like this
jdbc:oracle:thin:@1.2.3.4:1521:SAMPLE
Okay. Once your connection test is passed you may finish configuring and use it from corresponding view.
Eclipse IDE Oracle connection established TNS

Tuesday, June 07, 2011

Ant custom task in application to the real purpose. Part Two.

Hi!

Here here I started the set of posts about how to apply the customized tasks in Ant to address some real requirement.

So there is a lot of information about how to create custom task in ant. But we're talking about some production requirements. As you may discover in previous post we're trying to create the framework allowing to roll back the changes which have been made anywhere in the ant script, and it doesn't matter whether they were made within one target or the changes were distributed among the several ones. So, to achieve that I decided to extend the native ant tasks performing file operations and I started from Replace task. However I still needed the infrastructure to support this functionality. So the whole workflow looks now like the following:

- We take care of reseting the storage holding the information about which file is mapped to which backup.
- Then we perform safe operations with our files
- Finally we take care of cleaning up the backups being sure all has finished successfully

The particular ANT script will look like this
<project name="Safe replace" default="do-all" basedir=".">

 <taskdef name="safereplace" classname="com.enkata.ant.tasks.SafeReplaceTask">
  <classpath>
   <pathelement path="C:/temp/safereplace.jar" />
  </classpath>
 </taskdef>

 <taskdef name="initstorage" classname="com.enkata.ant.tasks.InitializeStorageTask">  <classpath>
   <pathelement path="C:/temp/safereplace.jar" />
  </classpath>
 </taskdef>

 <taskdef name="cleartemporary" classname="com.enkata.ant.tasks.ClearTempFilesTask">  <classpath>
   <pathelement path="C:/temp/safereplace.jar" />
  </classpath>
 </taskdef>

 <target name="do-all">
  <initstorage/>
  <antcall target="valid"/>
  <antcall target="notvalid"/>
  <cleartemporary/>
 </target>

 <target name="valid">
  <safereplace dir="c:/test_safereplace" token="The" value="HRENAR">
   <include name="**/*.txt" />
  </safereplace>
 </target>

 <target name="notvalid">
  <safereplace file="abc" token="0" value="0">
  </safereplace>
 </target>

</project>

So here are several important points we should pay attention for. First of all it is seen that we use three custom tasks here. Each task has the path to the jar it is represented in. Also we have the general target where we take care of the items I have specified above and call the some valid target (not producing any errors) and some not valid one (that should always fail)

As most of us already know to create the custom task we have to extend ANT native class Task or any class that is the extension of it. The simple custom task that I use is the following:

public class InitializeStorageTask extends Task {

 @Override
 public void execute() throws BuildException {
  File storage = new File (SafeTasksUtils.BACKUP_STORAGE_FILE_NAME);
  if (storage.exists()){
   FileUtils.delete(storage);
  }
 }

}

I'm not including the default overridden methods not to waste the space. Anyway the IDE will remind you. So we should to implement our own execute() method to make it work.

In the third part I will describe the core of the example means how the extended Replace task works and then in the fourth part the step-by-step implementation workflow will be described using Eclipse IDE.

Thank you!

Monday, February 21, 2011

Eclipse. Perfoce. Error in change specification. Can't include file(s) not already opened. Error in change specification. Can't include file(s) not already opened.

Recently I faced the problem using P4-Eclipse integration. The message said like the one specified in this post's subject. So, googling gave nothing but only the that lot of people face the same kind of problem but actually of different reasons. Now after the short investigation I can share my one.
It seems eclipse gets mad if the current client spec is set up with some client view different from looking straight into the storage root. You should either to remap client view or to use another client spec.