Issue:
In my project, I was getting maven to download two dependencies:
1.
< dependency >
< groupId >org.mortbay.jetty< /groupId >
< artifactId >jetty-embedded< /artifactId >
< version >6.1.9< /version >
< /dependency >
2. < dependency >
< groupId >org.openqa.selenium.client-drivers< /groupId >
< artifactId >selenium-java-client-driver< /artifactId >
< version >0.9.2< /version >
< /dependency >
Looking at the dependency tree for the selenium codebase, I found that the org.mortbay.jetty version number used in Selenium 0.9.2 was 5.1.0. Hence, Eclipse defaults to using Jetty API 5.1.0 for rather than 6.1.9 - causing my code (which needs Jetty 6.* to be marked as an error in Eclipse).
How to Resolve It?
-------------------------
Use Selenium 1.0.1:
< dependency >
< groupId >org.seleniumhq.selenium.client-drivers< /groupId >
< artifactId >selenium-java-client-driver< /artifactId >
< version >1.0.1< /version >
< /dependency >
This Selenium version uses Jetty 6.1.6. Hence, your project code (that needs Jetty 6.*) will be resolved correctly by Eclipse.
Friday, January 29, 2010
Tuesday, December 15, 2009
How to increase the heap size available to a JUnit Test Class in Eclipse?
If your running a JUnit Test on Eclipse, do the following to increase the heap size available for it:
1. Click on 'Run' and 'Open Debug Dialog'
2. Click on 'JUnit' on the left pane of the window
3. Enter a name for the JUnit test
4. Fill up all the relevant details in the 'Test' tab
5. Click on the 'Arguments' tab
6. In 'VM arguments', type the following:
-Xmx1024M
1. Click on 'Run' and 'Open Debug Dialog'
2. Click on 'JUnit' on the left pane of the window
3. Enter a name for the JUnit test
4. Fill up all the relevant details in the 'Test' tab
5. Click on the 'Arguments' tab
6. In 'VM arguments', type the following:
-Xmx1024M
Monday, November 2, 2009
Getting the attributes of an OpenLayer.Feature.Point that has been clustered in a OpenLayers.Layer.Vector layer
I encountered this problem and spent a day trying to understand how it worked. I have figured it out and am sharing my understanding with everyone.
Issue
------------
I had a GeoJSON parser that parsed the following geojson file:
{
"type": "FeatureCollection",
"features": [
{"type":"Feature", "id":"computer1", "properties":{"trial":"test"}, "geometry":{"type":"Point", "coordinates":[143, -35.91]}},
{"type":"Feature", "id":"computer2", "properties":{"trial":"test"}, "geometry":{"type":"Point", "coordinates":[144, -37.81667]}}
]
}
Once the GeoJSON parser parsed the file and created 2 OpenLayer.Feature.Points, these points were parsed to the OpenLayers.Layer.Vector object that implemented the clustering strategy.
Now, since the two points were within a close distance (specified by me), they were clustered and only one top level feature point was displayed on the map.
I wanted to get the 'id' and 'properties' (as in the GeoJSON file above) of each of the two points (when I zoomed into the map). However, I could not get it. It seemed to me, back then, that the GeoJSON parser had somehow overriden the properties I added into the "properties":{} field (in the above geojson file) with the 'count' property of the clustering Vector layer.
Hence, the question was, how do I get the attributes and ID of each point in the map (as in the geojson file).
Fix
----
feature.cluster solved the problem.
For other users who come across this problem, try to get the attributes of a point (specified in the geojson file in the 'properties' list) by using
feature.cluster[0].attributes.
Basically, this is what happens when the geojson fileabove is parsed by OpenLayers.Format.GeoJSON parser and added as OpenLayers.Vector.Feature objects into a OpenLayers Vector layer (that performs the clustering strategy):
1. GeoJSON file is read by the GeoJSON parser.
2. Parser creates OpenLayers.Vector.Feature objects for each string.
3. These OpenLayers.Vector.Feature objects are then added to the OpenLayers Vector layer
4. OpenLayers Vector layer performs clustering strategy
5. Each feature point that appears on the map is the top-level feature point (for a group of clusters). The attributes for this feature point is:
undefinedlayer value :[object Object]
lonlat value :null
data value :[object Object]
id value :OpenLayers.Feature.Vector_201
geometry value :POINT(15918687.18122222 -4288244.5663272375)
state value :null
attributes value :[object Object]
style value :null
cluster value :[object Object],[object Object],[object Object] //this indicates that this cluster point has three feature objects underneath it
renderIntent value :select
marker value :null
6. As it can be seen above, there is a 'cluster' property that holds 3 objects (being the three points). Hence, if you drill down to the 'cluster' property (i.e. feature.cluster[0]), it will give you the attributes of the first object in the cluster (being the point):
undefined0 value :[object Object]
layer value :null
lonlat value :null
data value :[object Object]
id value :OpenLayers.Feature.Vector_197
geometry value :POINT(8218510.393273033 -2699238.272071229)
state value :null
attributes value :[object Object]
style value :null
fid value :computer14
marker value :null
7. From the above, it can be seen that the 'id' property from the geojson file has been mapped to the 'fid' key of the feature point object. You can also see that the 'attributes' key holds an [object Object]. If you do feature.cluster[0].attributes.trial , it will display the 'trial' property and value that you specified in the geojson file (i.e. 'test').
Hence, adding as many property-value pairs in the GeoJSON file is easy as the GeoJSON parser just parsers the property-value pairs and enters the data into feature point object attributes that are beneath the top-level cluster point (it does not override the properties as I initially thought).
Issue
------------
I had a GeoJSON parser that parsed the following geojson file:
{
"type": "FeatureCollection",
"features": [
{"type":"Feature", "id":"computer1", "properties":{"trial":"test"}, "geometry":{"type":"Point", "coordinates":[143, -35.91]}},
{"type":"Feature", "id":"computer2", "properties":{"trial":"test"}, "geometry":{"type":"Point", "coordinates":[144, -37.81667]}}
]
}
Once the GeoJSON parser parsed the file and created 2 OpenLayer.Feature.Points, these points were parsed to the OpenLayers.Layer.Vector object that implemented the clustering strategy.
Now, since the two points were within a close distance (specified by me), they were clustered and only one top level feature point was displayed on the map.
I wanted to get the 'id' and 'properties' (as in the GeoJSON file above) of each of the two points (when I zoomed into the map). However, I could not get it. It seemed to me, back then, that the GeoJSON parser had somehow overriden the properties I added into the "properties":{} field (in the above geojson file) with the 'count' property of the clustering Vector layer.
Hence, the question was, how do I get the attributes and ID of each point in the map (as in the geojson file).
Fix
----
feature.cluster solved the problem.
For other users who come across this problem, try to get the attributes of a point (specified in the geojson file in the 'properties' list) by using
feature.cluster[0].attributes.
Basically, this is what happens when the geojson fileabove is parsed by OpenLayers.Format.GeoJSON parser and added as OpenLayers.Vector.Feature objects into a OpenLayers Vector layer (that performs the clustering strategy):
1. GeoJSON file is read by the GeoJSON parser.
2. Parser creates OpenLayers.Vector.Feature objects for each string.
3. These OpenLayers.Vector.Feature objects are then added to the OpenLayers Vector layer
4. OpenLayers Vector layer performs clustering strategy
5. Each feature point that appears on the map is the top-level feature point (for a group of clusters). The attributes for this feature point is:
undefinedlayer value :[object Object]
lonlat value :null
data value :[object Object]
id value :OpenLayers.Feature.Vector_201
geometry value :POINT(15918687.18122222 -4288244.5663272375)
state value :null
attributes value :[object Object]
style value :null
cluster value :[object Object],[object Object],[object Object] //this indicates that this cluster point has three feature objects underneath it
renderIntent value :select
marker value :null
6. As it can be seen above, there is a 'cluster' property that holds 3 objects (being the three points). Hence, if you drill down to the 'cluster' property (i.e. feature.cluster[0]), it will give you the attributes of the first object in the cluster (being the point):
undefined0 value :[object Object]
layer value :null
lonlat value :null
data value :[object Object]
id value :OpenLayers.Feature.Vector_197
geometry value :POINT(8218510.393273033 -2699238.272071229)
state value :null
attributes value :[object Object]
style value :null
fid value :computer14
marker value :null
7. From the above, it can be seen that the 'id' property from the geojson file has been mapped to the 'fid' key of the feature point object. You can also see that the 'attributes' key holds an [object Object]. If you do feature.cluster[0].attributes.trial , it will display the 'trial' property and value that you specified in the geojson file (i.e. 'test').
Hence, adding as many property-value pairs in the GeoJSON file is easy as the GeoJSON parser just parsers the property-value pairs and enters the data into feature point object attributes that are beneath the top-level cluster point (it does not override the properties as I initially thought).
Friday, October 30, 2009
Printing Javascript object properties
If you would like to print out all the properties of an Javascript object and their associated values, do this:
Note: Replace < objName > below with the name of your instantiated object.
var str;
for(prop in < objName >)
{
str += prop + ' value :' + < objName >[prop]+ '\n ';
}
alert(str); //Show all properties and its value
Note: Replace < objName > below with the name of your instantiated object.
var str;
for(prop in < objName >)
{
str += prop + ' value :' + < objName >[prop]+ '\n ';
}
alert(str); //Show all properties and its value
Friday, October 16, 2009
Resolving the Exception in thread "main" java.lang.UnsupportedClassVersionError: com/google/gwt/dev/GWTCompiler(Unsupported major.minor version 48.0)
When I tried compiling my GWT project using TestProject-compile.cmd, I got the following exception:
Exception in thread "main" java.lang.UnsupportedClassVersionError:
com/google/gwt/dev/GWTCompiler (Unsupported major.minor version 48.0)
at java.lang.ClassLoader.defineClass0(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
How To Resolve This?
Ensure that your JRE version in your environment variable in anything from Version 1.4 and above.
To check your Java version, pull up comman prompt and type in the following on the command line to check your JRE version:
java -version
Since I had Oracle installed, my "Path" environment variable was referencing 2 Oracle JVM's that were versions 1.1.3 and 1.1.8. I deleted these two paths and ensured that JVM path in the environment variable was pointing to the folder where I had installed Java 1.6.
This worked and did not cause the UnsupportedClassVersionError exception to be thrown anymore.
Exception in thread "main" java.lang.UnsupportedClassVersionError:
com/google/gwt/dev/GWTCompiler (Unsupported major.minor version 48.0)
at java.lang.ClassLoader.defineClass0(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
How To Resolve This?
Ensure that your JRE version in your environment variable in anything from Version 1.4 and above.
To check your Java version, pull up comman prompt and type in the following on the command line to check your JRE version:
java -version
Since I had Oracle installed, my "Path" environment variable was referencing 2 Oracle JVM's that were versions 1.1.3 and 1.1.8. I deleted these two paths and ensured that JVM path in the environment variable was pointing to the folder where I had installed Java 1.6.
This worked and did not cause the UnsupportedClassVersionError exception to be thrown anymore.
Tuesday, October 13, 2009
How to print output on the same line on the console in Java?
Trying to continuously print output onto the same line in a console using Java?
Try this:
System.out.print("TEST TEXT\r");
The "\r" (carriage return) character returns the cursor to the beginning of the output line.
Just remember that if you do System.out.print("TESTTEXT\r"); and then System.out.print("BLAH\r");, your final output will be
BLAHTEXT
This is because the remaining characters from the longest string are not deleted after the shorter string overwrites it. Hence try to do something like this to delete of all characters from the longest string:
System.out.print("TESTTEXT\r"); //write text and go back to beginning of line
System.out.print(" \r"); //have many empty spaces to overwrite the chars from the longest string and then go back to the beginning of the line
System.out.print("BLAH\r"); //write text and go back to the beginning of the line
This will output:
BLAH
Try this:
System.out.print("TEST TEXT\r");
The "\r" (carriage return) character returns the cursor to the beginning of the output line.
Just remember that if you do System.out.print("TESTTEXT\r"); and then System.out.print("BLAH\r");, your final output will be
BLAHTEXT
This is because the remaining characters from the longest string are not deleted after the shorter string overwrites it. Hence try to do something like this to delete of all characters from the longest string:
System.out.print("TESTTEXT\r"); //write text and go back to beginning of line
System.out.print(" \r"); //have many empty spaces to overwrite the chars from the longest string and then go back to the beginning of the line
System.out.print("BLAH\r"); //write text and go back to the beginning of the line
This will output:
BLAH
Monday, October 12, 2009
Internet Information Services - Setting Up Access Permissions for Specific Windows Users to Access Specific FTP Virtual Directories
To set up the Windows IIS FTP Server to allow certains Windows users to access certain virtual directories, ensure that you have done the following:
1. Install an IIS FTP Server
2. Ensure that you have a Windows User account set up for the user you want to log on as, onto your FTP Server.
3. In the 'Default FTP Site Properties', uncheck the 'Allow Anonymous Connections' checkbox which can be found under the 'Security Accounts' tab. This will allow specific users that have the right username and password of one of the Windows user accounts on the FTP Server machine to access the FTP Virtual Directories.
Once Step 1 and 2 above is set up, permissions to specific FTP Virtual Directories can be set up as follows:
3. Right click on the virtual directory you have created (eg. CHITRATEST). Below this Local Path textbox, there are three checkboxes (Read, Write and Log Visits). You can uncheck/check these boxes. Think of these boxes as three different pipes. Clogging a pipe (i.e. unchecking a say, 'Write' checkbox) will cause all Windows users who log on to the FTP Server to not have Write permissions to CHITRATEST, regardless of whether the folder on the local path of the virtual directory (e.g. c:\TEST) has 'Write' permission enabled for the currently logged in Windows Users.
4. Once the FTP Server evaluates the super access priviledges it can give to a currently logged Windows user (by evaluating the checkboxes in Step 3 above), it will then evaluate the next level folder properties of the virtual directory. If say, C:\TEST is mapped to a virtual directory called CHITRATEST, the Security permissions set on C:\TEST and C:\Inetpub\ftproot\CHITRATEST will both be evaluated to give the currently logged Windows user specific permissions. Both C:\TEST and C:\Inetpub\ftproot\CHITRATEST must have the exact permissions set/unset for folder level permissions to be evaluated by the FTP Server.
Summary
-------
To allow users with the username and password of a specific Window User account to access the FTP server, follow Steps 1 and 2.
To allow specific logged on Windows users (with a corresponding Windows User account) to gain access permissions to specific virtual directories, follow Step 3.
To allow a lower level folder access permission for logged on Windows users, follow Step 4.
1. Install an IIS FTP Server
2. Ensure that you have a Windows User account set up for the user you want to log on as, onto your FTP Server.
3. In the 'Default FTP Site Properties', uncheck the 'Allow Anonymous Connections' checkbox which can be found under the 'Security Accounts' tab. This will allow specific users that have the right username and password of one of the Windows user accounts on the FTP Server machine to access the FTP Virtual Directories.
Once Step 1 and 2 above is set up, permissions to specific FTP Virtual Directories can be set up as follows:
3. Right click on the virtual directory you have created (eg. CHITRATEST). Below this Local Path textbox, there are three checkboxes (Read, Write and Log Visits). You can uncheck/check these boxes. Think of these boxes as three different pipes. Clogging a pipe (i.e. unchecking a say, 'Write' checkbox) will cause all Windows users who log on to the FTP Server to not have Write permissions to CHITRATEST, regardless of whether the folder on the local path of the virtual directory (e.g. c:\TEST) has 'Write' permission enabled for the currently logged in Windows Users.
4. Once the FTP Server evaluates the super access priviledges it can give to a currently logged Windows user (by evaluating the checkboxes in Step 3 above), it will then evaluate the next level folder properties of the virtual directory. If say, C:\TEST is mapped to a virtual directory called CHITRATEST, the Security permissions set on C:\TEST and C:\Inetpub\ftproot\CHITRATEST will both be evaluated to give the currently logged Windows user specific permissions. Both C:\TEST and C:\Inetpub\ftproot\CHITRATEST must have the exact permissions set/unset for folder level permissions to be evaluated by the FTP Server.
Summary
-------
To allow users with the username and password of a specific Window User account to access the FTP server, follow Steps 1 and 2.
To allow specific logged on Windows users (with a corresponding Windows User account) to gain access permissions to specific virtual directories, follow Step 3.
To allow a lower level folder access permission for logged on Windows users, follow Step 4.
Subscribe to:
Posts (Atom)