Mahesh Chandran

Greenhorn
+ Follow
since Mar 23, 2011
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Mahesh Chandran

I need some pointers while using the Apache CXF WebClient JAX-RS call. I get the following error when I use the API provided WebClient:



This is strange because the output page rendered on the browser (FF21.0) shows that it is of XHTML+XML. (The server code is external and we don't seem to have access to its source code)

I understand that "ISO" is not a valid encoding type or charset whereas "ISO-8859-1" etc are. I tried using @Produces and even forcing a WebClient.accept("text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8") and such variants.

So I thought of extending AbstractClient or rather WebClient itself and implement some necessary methods and in the process see the raw message from the server as is before response handling. The approach does not properly populate objects like "cfg" etc. I don't know if WebClient is meant to be extended, as I believe, if so CXF should have provided interfaces to handle.

I am open to other ways of doing this. Currently the only requirement is to get the HTML and grab a certain segment of it. We don't have an API exposed by application to serve us that data.

NOTE: This is not a access issue, both the apps are intranet and are SSO secure. Also the URL which we are trying to access is SSL enabled, hope this should not be an issue or may be?

Regards
Mahesh

10 years ago
Hi all,

I have installed greasemonkey plug-in for Firefox (my FF version is 21.0). I wrote a userscript named mahesh.user.js



Now when I print the following



The Firebug debugger writes out the XPathResult object. But I am unable to use any of the XPathResult properties such as snapshotLength or methods such as iterateNext() or snapshotItem(). Nothing gets printed on the console if I do this.

i.e.



Nothing gets printed on the console except for the first "I am here".

Need help please. Kindly advice.

Regards Mahesh.
Hi all,

I am using Netbeans 6.9.1 and imported a "what i think is a rails project" - it has a rake file that does among other things creating gems, specs and stuff from a bunch of .rb files. But you see it is no web application, so perhaps it is just a Ruby project with rake for build. Anyways, my objective is to run a Ruby file called the_ruby.rb - code snippet as follows:



I kind of thought it's cool to run it using IRB in NB (got fed up with using Eclipse Aptana Studio's debugger, which is a different issue altogether). These were what I did to invoke the method get_somedata():

1. Read the input file for the first parameter:

file = File.open("path-to-file.xml", "rb")
contents = file.read
file.close

2. Secondly, I figured I need to add up all dependencies to the $LOAD_PATH or $:

Firstly, the following observation

>>$:

>>$:
=> ["C:/Users/mcn/myproj/workspaces/ws2/projec/lib-IC:/Users/mcn/myproj/workspaces/ws2/projec/test", "C:/Users/mcn/myproj/workspaces/ws2/projec/spec", "C:/Program Files/NetBeans 6.9.1/ruby/jruby-1.5.1/lib/ruby/site_ruby/1.8", "C:/Program Files/NetBeans 6.9.1/ruby/jruby-1.5.1/lib/ruby/site_ruby/shared", "C:/Program Files/NetBeans 6.9.1/ruby/jruby-1.5.1/lib/ruby/1.8", "."]

Attempt-1: I tried a link: http://rubynotebook.blogspot.in/2013/01/load-or-require-files-into-irb.html

Dir.glob("C:/Users/mcn/myproj/workspaces/ws2/projec/lib/*.rb")
require ("./lib/the_ruby.rb")

LoadError: no such file to load -- depend1
from ./lib/the_ruby.rb:4:in `require'
from ./lib/the_ruby.rb:4
from ./lib/the_ruby.rb:6:in `require'
from (irb):6


Do I need to do something after the Dir.glob but before the require tp make this work?

Attempt-2: Then I read up more on LOAD_PATH and got to a link: http://stackoverflow.com/questions/2587128/what-is-the-quickest-way-to-recursively-add-directories-onto-the-load-path-in-r

Again, I was clueless how this is going to add files in my ./lib/*.rb files to the LOAD_PATH. As I suspected doing a $: did not show any of the .rb files.

Anyways, just being optimistic and awaiting magic, I tried to invoke a instance nmethod:



Gave the following error:

NameError: uninitialized constant MyRubyCaller
from (irb):16
>>

I am not sure what I am doing wrong, but I do suspect this has to do to the .rb files not being in LOAD_PATH. How do I run this on IRB. Please advice and help.

Regards
Mahesh
10 years ago
just changed require to require_relative - since apparently my JRuby version seems to use ruby 1.9 and I see that require_relative is the way to go. Refer to http://stackoverflow.com/questions/9750610/ruby-require-error-cannot-load-such-file. So long so good. Thanks.
10 years ago
Hi all,

I have a set of ruby code (which is actually a gem that I extracted and the lib folder contains a bunch of .rb (ruby code). I have Eclipse Aptana Studio 3 plugin setup and have JRuby

$ jruby -v
jruby 1.7.4 (1.9.3p392) 2013-05-16 2390d3b on Java HotSpot(TM) 64-Bit Server VM 1.
6.0_45-b06 [Windows 7-amd64]


I need to execute a ruby file: /lib/my_rubycaller.rb, which is like the following:



Now at the Aptana Studio 3 Terminal View, I typed the following:

$ jruby -S lib/my_rubycaller.rb
LoadError: no such file to load -- somedependency
require at org/jruby/RubyKernel.java:1054
require at c:/Users/mkorapat/MyProjects/jruby-1.7.4/lib/ruby/shared/rubygems/cor
e_ext/kernel_require.rb:51
(root) at my_rubycaller.rb:11


Inside my_rubycaller @ line# 11, I have the require statement. I don't know what I am doing wrong. I am new to Ruby development, but since I am versatile with Eclipse, just stuck to Aptana and JRuby is just because I thought perhaps I could leverage some additional benefits that it has to offer. But it might still be a matter of time for me to go with Ruby as against JRuby, but still, I wonder how it will help me in this scenario.

Thanks in advance for the help.

Regards
Mahesh


10 years ago
Hi all,

In my HTML form, the tab does not go to the buttons. Instead after, tabbing over the input HTML elements, it continues to tab to the browser address bar, tag element etc and then only goes to the two buttons in this page.

Is there anyway where I can force the tabbing to happen over these buttons instead of over the address bar etc. I dont want to be manually adding tabindex to each and every HTML element as these are rendered using some custom tags. Suggestions are welcome. Also note that the HTML elements in this page are dynamically generated, so static tabindex wont work


Regards
Mahesh
I am reading the The Definitive Guide for DOJO. I get this error when I try to execute:



This does not work on Firebug or a separate code. The example provided in http://dojotoolkit.org/reference-guide/1.6/dojo/string.html also gives the same error.

Can someone point out what I am doing wrong.

Thanks Mahesh.


Hi did some googling and study of the Xerces API and did some changes:

Changed

To


Commented out the p.parse API, as I understand this obviously may not do the validation, if setValidating(false). So replaced this with:



But on running this I get the following exception (the flow now goes inside the resolveResource overidden method):

[java] java.lang.NullPointerException
[java] at sun.misc.MetaIndex.mayContain(MetaIndex.java:225)
[java] at sun.misc.URLClassPath$JarLoader.getResource(URLClassPath.java:747)
[java] at sun.misc.URLClassPath.getResource(URLClassPath.java:169)
[java] at sun.misc.URLClassPath.getResource(URLClassPath.java:221)
[java] at java.lang.ClassLoader.getBootstrapResource(ClassLoader.java:1150)
[java] at java.lang.ClassLoader.getResource(ClassLoader.java:999)
[java] at java.lang.ClassLoader.getResource(ClassLoader.java:997)
[java] at java.lang.ClassLoader.getResourceAsStream(ClassLoader.java:1192)
[java] at java.lang.Class.getResourceAsStream(Class.java:2030)
[java] at ResourceResolver.resolveResource(Unknown Source)
[java] at org.apache.xerces.util.DOMEntityResolverWrapper.resolveEntity(Unknown Source)
[java] at org.apache.xerces.impl.XMLEntityManager.resolveEntity(Unknown Source)

This is because systemId is passed as null. I have no clue how to pass this systemId from XML. Even the publicId is null. However the nameSpaceURI shows up as:

Wonder if there is a way to make this work without using the systemId and publicId but using the nameSpaceURI, since that the only thing that gets passed to resolveResource other than the baseURI. Any help is appreciated.

Regards
Mahesh
11 years ago
Hi,

I am using Xerces-j 2.11.0 parser to validate an XML against Schema. The problem is the validating schema includes other types using xmlns: notation. These types are defined in other xsd files. When I run my validation, I get the following error:

Message: cvc-elt.1.a: Cannot find the declaration of element 'types:MyRoot'.

To fix this, I did some googling and added a ResourceResolver class as some of them suggested.



In the ResourceResolver class, I have overridden resolveResource method. I still get the same error. I dont even see that the resolveResource method is being called. I had put loggers inside the class. I thought just doing



is sufficient. Is there any wiring I am missing here. Any help or guidance in this regard will be appreciated.

NOTE: I am going for the SAX based validation because basically I need to parse the XML only once, strip off and add some stuff and validate the resultant XML. So I feel there is no need to go for DOM (using DocumentBuilderFactory stuff) for this. I might be wrong, but that's the stance I have taken. Experts, please advice.

Regards
Mahesh

11 years ago
Fixed the problem. Had to set -Djava.util.logging.config.file= "pathto\WEB-INF\classes\logging.properties in Arguments tab - Open Server->Open Launch Configuration in Eclipse
I am using slf4j over java util logging. I am trying to place logging.properties file so that it will picked up by my webapp. The following is how my logging.properties file look like:



I am NOT doing -Djava.util.logging.config.file="file_path/logging.properties. Instead I have put the logging.properties in my WEB-INF/classes and included this folder as a class folder in eclipse. I dont know if this is sufficient for things to work.

The log file myApp.log is not getting generated nor any logging happens in it. But anyways, the logging still occurs on the Eclipse console.

I suspect it is not taking this logging.properties file at all. But then I tried a suggestion from the posting - Java Logging - where is my log file? - I can see that it prints the file path with file name.

I will appreciate if some help can be provided in this regard.

NOTE: I am using slf4j over java util logging. Also I am sorry if you think I didn't do enough google search :-)

Regards Mahesh
Hi all,

I am just starting up some C++ (that is after 10 years of JAVA!). I am following examples from Stroupstrup book.


I am put together the following code segments from his book.

#include <iostream>
#include <map>
#include <string>
#include <iterator>
using namespace std;

map<string, int>histogram;
void record (const string &s)
{
histogram[s]++; //record frequency of "s"
cout<<"recorded:"<<s<<" occurence = "<<histogram[s]<<"\n";
}

void print (const pair<const string, int>& r)
{
cout<<r.first<<' '<<r.second<<'\n';
}

bool gt_42(const pair<const string, int>& r)
{
return r.second>42;
}

void f(map<string, int>& m)
{
typedef map<string, int>::const_iterator MI;
MI i = find_if(m.begin(), m.end(), gt_42);
cout<<i->first<<' '<<i->second; //this gives an error Exception: STATUS_ACCESS_VIOLATION
}

int main () {
istream_iterator<string> ii(cin);
istream_iterator<string> eos;
cout<<"input end\n";

for_each(ii, eos, record);

//typedef pair <string, int> String_Int_Pair;
//histogram.insert(String_Int_Pair("42", 1));
//histogram.insert(String_Int_Pair("44", 1));


//for_each(histogram.begin(), histogram.end(), print);
f(histogram);

}

I get an error - Exception: STATUS_ACCESS_VIOLATION, I think in the referencing i->first, i->second, I guess. Can someone help me out find out what the issue might be. Also if you can suggest some alternate C++ forums that will be helpful as well.

Regards
Mahesh


12 years ago
I am using Informix DB. This question may not be tied to one specific database. But I want to know how I can in JAVA, continuously probe into a Database and check if a certain row has been added to a table in the DB. Basically, the flow is:

(1) My JAVA application should use JDBC to check if a certain table is populated.
(2) If no, it should wait until a row has been inserted.

My question how can I have JAVA be aware of a row insertion. I am not expecting to add any triggers or anything, but in pure java be able to check that the row is added.

Some thoughts that come to my mind are continuously call DB for the row, or periodically (every half-hour or so) call DB and check if the row is available. But what I am looking for is something like a Listener which can do this.

Regards
Mahesh
Another update I have is now, I get a signal 11 segmentation fault for this thread (THREAD# 20):

f90c2160 * *java/lang/StringCoding$CharsetSD.decode([BII)[C
f910f27c * *java/lang/String.<init>([BIILjava/lang/String;)V+30 (line 405)
f9005764 * sun/font/TrueTypeFont.makeString([BSS)Ljava/lang/String;+166 (line 792)
f9005874 * sun/font/TrueTypeFont.initNames()V+174 (line 832)
f9005764 * sun/font/TrueTypeFont.init(I)V+319 (line 500)
f9005764 * sun/font/TrueTypeFont.<init>(Ljava/lang/String;Ljava/lang/Object;IZ)V+45 (line 156)
f9005764 * sun/font/FontManager.registerFontFile(Ljava/lang/String;[Ljava/lang/String;IZI)Lsun/font/PhysicalFont;+55 (line 840)
f9005874 * sun/font/FontManager.initialiseDeferredFont(Ljava/lang/String;)Lsun/font/PhysicalFont;+80 (line 792)
f9005874 * sun/font/CompositeFont.doDeferredInitialisation(I)V+70 (line 234)
f9005764 * sun/font/CompositeFont.getSlotFont(I)Lsun/font/PhysicalFont;+11 (line 305)
f9005874 * sun/font/CompositeStrike.getStrikeForSlot(I)Lsun/font/PhysicalStrike;+16 (line 59)
f9005874 * sun/font/CompositeStrike.getFontMetrics()Lsun/font/StrikeMetrics;+31 (line 75)
f9005874 * sun/font/FontDesignMetrics.initMatrixAndMetrics()V+28 (line 169)
f9005764 * sun/font/FontDesignMetrics.<init>(Ljava/awt/Font;Ljava/awt/font/FontRenderContext;)V+62 (line 160)
f9005764 * sun/java2d/SunGraphics2D.makeFontMetrics(Ljava/awt/Font;Ljava/awt/font/FontRenderContext;)Ljava/awt/FontMetrics;+123 (line 707)
f9005874 * sun/java2d/SunGraphics2D.getFontMetrics(Ljava/awt/Font;)Ljava/awt/FontMetrics;+42 (line 724)
f9005874 * java/awt/Component.getFontMetrics(Ljava/awt/Font;)Ljava/awt/FontMetrics;+103 (line 2527)
f9005874 * javax/swing/JComponent.getFontMetrics(Ljava/awt/Font;)Ljava/awt/FontMetrics;+73 (line 1583)
f9005874 * javax/swing/plaf/basic/BasicMenuItemUI.getPreferredMenuItemSize(Ljavax/swing/JComponent;Ljavax/swing/Icon;Ljavax/swing/Icon;I)Ljava/awt/Dimension;+208 (line 392)
f9005874 * javax/swing/plaf/basic/BasicMenuItemUI.getPreferredSize(Ljavax/swing/JComponent;)Ljava/awt/Dimension;+14 (line 317)
f9005874 * javax/swing/JComponent.getPreferredSize()Ljava/awt/Dimension;+26 (line 1618)
f9005874 * javax/swing/BoxLayout.checkRequests()V+111 (line 434)
f9005764 * javax/swing/BoxLayout.layoutContainer(Ljava/awt/Container;)V+127 (line 375)
f9005c2c * java/awt/Container.layout()V+11 (line 1401)
f9005764 * java/awt/Container.doLayout()V+1 (line 1390)
f9005764 * java/awt/Container.validateTree()V+30 (line 1473)
f9005764 * java/awt/Container.validate()V+61 (line 1448)
f9005764 * javax/swing/JLayeredPane.addImpl(Ljava/awt/Component;Ljava/lang/Object;I)V+59 (line 205)
f9005764 * java/awt/Container.add(Ljava/awt/Component;Ljava/lang/Object;)V+4 (line 899)
f9005764 * javax/swing/JRootPane.setMenuBar(Ljavax/swing/JMenuBar;)V+55 (line 524)
f9005764 * javax/swing/JApplet.setJMenuBar(Ljavax/swing/JMenuBar;)V+5 (line 163)
f9005764 * mypackage/****/ChartManager.setMenuBar()V+933
f9005764 * mypackage/****/PMPerfUIApplet.init()V+495
f9005764 * sun/applet/AppletPanel.run()V+197 (line 380)
f9005c2c * java/lang/Thread.run()V+11 (line 595)

Is there any documented bug in Firefox 3.0.1 running java plugin 1.5.0_23 regarding core dumped on applet load. Again I have to stress that there seems to be no issue with the user continuing with his work. But there were cases where the firefox restarts. Is this a bug in FireFox 3.0.1. Experts, any idea please.....
12 years ago
I am sure we are not using any native code. Another factor is this does not affect the functionality. The user is still able to continue working on the application and the core gets dumped silently in the background. So I assume this is not a critical issue. Another thing I want to understand is why there are references to sun motif plugin. Is there an exception from the java plugin in firefox. We are using Firefox 3.0.1 and java plugin installed is 1.5.0_23 and we are running Solaris. Any inputs...

Regards
Mahesh
12 years ago