bhushan shelke

Greenhorn
+ Follow
since Feb 04, 2001
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 bhushan shelke

Environment - /Tomcat6/bin/version.sh

Using CATALINA_BASE: /Tomcat6
Using CATALINA_HOME: /Tomcat6
Using CATALINA_TMPDIR: /Tomcat6/temp
Using JRE_HOME: /usr/java/jdk1.6.0_23
Using CLASSPATH: /Tomcat6/bin/bootstrap.jar
Server version: Apache Tomcat/6.0.29
Server built: July 19 2010 1458
Server number: 6.0.0.29
OS Name: Linux
OS Version: 2.6.18-164.el5
Architecture: i386
JVM Version: 1.6.0_23-b05
JVM Vendor: Sun Microsystems Inc.

Its a spring based web application few important 3rd party tools to mention are Castor 1.2, logback 1.6.4 tomcat jdbc connection pool.

We are seeing lot of threads locked on org.apache.catalina.loader.WebappClassLoader.loadClass -


Thread 1981: (state = BLOCKED)
- org.apache.catalina.loader.WebappClassLoader.loadClass(java.lang.String, boolean) @bci=0, line=1524 (Compiled frame)
- org.apache.catalina.loader.WebappClassLoader.loadClass(java.lang.String) @bci=3, line=1491 (Compiled frame)
- javax.xml.parsers.FactoryFinder.getProviderClass(java.lang.String, java.lang.ClassLoader, boolean) @bci=25, line=111 (Interpreted frame)
- javax.xml.parsers.FactoryFinder.newInstance(java.lang.String, java.lang.ClassLoader, boolean) @bci=3, line=146 (Interpreted frame)
- javax.xml.parsers.FactoryFinder.find(java.lang.String, java.lang.String) @bci=345, line=233 (Interpreted frame)
- javax.xml.parsers.SAXParserFactory.newInstance() @bci=4, line=128 (Interpreted frame)
- org.exolab.castor.xml.util.XMLParserUtils.getSAXParser(boolean, boolean) @bci=2, line=118 (Interpreted frame)
- org.castor.xml.AbstractInternalContext.getXMLReader(java.lang.String) @bci=56, line=262 (Interpreted frame)
- org.castor.xml.AbstractInternalContext.getXMLReader() @bci=2, line=248 (Interpreted frame)
- org.exolab.castor.xml.Unmarshaller.unmarshal(org.xml.sax.InputSource) @bci=8, line=692 (Interpreted frame)
- org.springframework.oxm.castor.CastorMarshaller.unmarshalInputStream(java.io.InputStream) @bci=12, line=386 (Interpreted frame)
- org.springframework.oxm.support.AbstractMarshaller.unmarshalStreamSource(javax.xml.transform.stream.StreamSource) @bci=12, line=368 (Interpreted frame)
- org.springframework.oxm.support.AbstractMarshaller.unmarshal(javax.xml.transform.Source) @bci=57, line=134 (Interpreted frame)



12650 - org.apache.catalina.loader.WebappClassLoader.loadClass(java.lang.String, boolean) @bci=0, line=1524 (Compiled frame)
12651 - org.apache.catalina.loader.WebappClassLoader.loadClass(java.lang.String) @bci=3, line=1491 (Compiled frame)
12652 - ch.qos.logback.classic.spi.PackagingDataCalculator.loadClass(java.lang.ClassLoader, java.lang.String) @bci=8, line=199 (Compiled frame)
12653 - ch.qos.logback.classic.spi.PackagingDataCalculator.bestEffortLoadClass(java.lang.ClassLoader, java.lang.String) @bci=3, line=218 (Compiled frame)
12654 - ch.qos.logback.classic.spi.PackagingDataCalculator.computeBySTEP(ch.qos.logback.classic.spi.StackTraceElementProxy, java.lang.ClassLoader) @bci=32 , line=133 (Compiled frame)
12655 - ch.qos.logback.classic.spi.PackagingDataCalculator.populateUncommonFrames(int, ch.qos.logback.classic.spi.StackTraceElementProxy[], java.lang.Clas sLoader) @bci=26, line=108 (Compiled frame)
12656 - ch.qos.logback.classic.spi.PackagingDataCalculator.populateFrames(ch.qos.logback.classic.spi.StackTraceElementProxy[]) @bci=182, line=100 (Compile d frame)
12657 - ch.qos.logback.classic.spi.PackagingDataCalculator.calculate(ch.qos.logback.classic.spi.IThrowableProxy) @bci=11, line=58 (Compiled frame)
12658 - ch.qos.logback.classic.spi.ThrowableProxy.calculatePackagingData() @bci=24, line=100 (Compiled frame)
12659 - ch.qos.logback.classic.spi.LoggingEvent.<init>(java.lang.String, ch.qos.logback.classic.Logger, ch.qos.logback.classic.Level, java.lang.String, ja va.lang.Throwable, java.lang.Object[]) @bci=131, line=128 (Compiled frame)
12660 - ch.qos.logback.classic.Logger.buildLoggingEventAndAppend(java.lang.String, org.slf4j.Marker, ch.qos.logback.classic.Level, java.lang.String, java. lang.Object[], java.lang.Throwable) @bci=13, line=468 (Compiled frame)
12661 - ch.qos.logback.classic.Logger.filterAndLog_0_Or3Plus(java.lang.String, org.slf4j.Marker, ch.qos.logback.classic.Level, java.lang.String, java.lang .Object[], java.lang.Throwable) @bci=57, line=424 (Compiled frame)
12662 - ch.qos.logback.classic.Logger.error(java.lang.String, java.lang.Throwable) @bci=11, line=587 (Interpreted frame)



Thread 1939: (state = BLOCKED)
- java.lang.ClassLoader.findLoadedClass0(java.lang.String) @bci=0 (Compiled frame; information may be imprecise)
- java.lang.ClassLoader.findLoadedClass(java.lang.String) @bci=12, line=950 (Compiled frame)
- org.apache.catalina.loader.WebappClassLoader.loadClass(java.lang.String, boolean) @bci=134, line=1548 (Compiled frame)
- org.apache.catalina.loader.WebappClassLoader.loadClass(java.lang.String) @bci=3, line=1491 (Compiled frame)
- javax.xml.parsers.FactoryFinder.getProviderClass(java.lang.String, java.lang.ClassLoader, boolean) @bci=25, line=111 (Interpreted frame)
- javax.xml.parsers.FactoryFinder.newInstance(java.lang.String, java.lang.ClassLoader, boolean) @bci=3, line=146 (Interpreted frame)
- javax.xml.parsers.FactoryFinder.find(java.lang.String, java.lang.String) @bci=345, line=233 (Interpreted frame)
- javax.xml.parsers.SAXParserFactory.newInstance() @bci=4, line=128 (Interpreted frame)
- org.exolab.castor.xml.util.XMLParserUtils.getSAXParser(boolean, boolean) @bci=2, line=118 (Interpreted frame)
- org.castor.xml.AbstractInternalContext.getXMLReader(java.lang.String) @bci=56, line=262 (Interpreted frame)
- org.castor.xml.AbstractInternalContext.getXMLReader() @bci=2, line=248 (Interpreted frame)
- org.exolab.castor.xml.Unmarshaller.unmarshal(org.xml.sax.InputSource) @bci=8, line=692 (Interpreted frame)
- org.springframework.oxm.castor.CastorMarshaller.unmarshalInputStream(java.io.InputStream) @bci=12, line=386 (Interpreted frame)
- org.springframework.oxm.support.AbstractMarshaller.unmarshalStreamSource(javax.xml.transform.stream.StreamSource) @bci=12, line=368 (Interpreted frame)
- org.springframework.oxm.support.AbstractMarshaller.unmarshal(javax.xml.transform.Source) @bci=57, line=134 (Interpreted frame)



Thread 1899: (state = BLOCKED)
- org.apache.catalina.loader.WebappClassLoader.loadClass(java.lang.String, boolean) @bci=0, line=1524 (Compiled frame)
- org.apache.catalina.loader.WebappClassLoader.loadClass(java.lang.String) @bci=3, line=1491 (Compiled frame)
- com.sun.org.apache.xerces.internal.parsers.ObjectFactory.findProviderClass(java.lang.String, java.lang.ClassLoader, boolean) @bci=55, line=393 (Interpreted frame)
- com.sun.org.apache.xerces.internal.parsers.ObjectFactory.newInstance(java.lang.String, java.lang.ClassLoader, boolean) @bci=3, line=348 (Interpreted frame)
- com.sun.org.apache.xerces.internal.parsers.ObjectFactory.createObject(java.lang.String, java.lang.String, java.lang.String) @bci=76, line=154 (Interpreted frame)
- com.sun.org.apache.xerces.internal.parsers.ObjectFactory.createObject(java.lang.String, java.lang.String) @bci=3, line=97 (Interpreted frame)
- com.sun.org.apache.xerces.internal.parsers.SAXParser.<init>(com.sun.org.apache.xerces.internal.util.SymbolTable, com.sun.org.apache.xerces.internal.xni.grammars.XMLGrammarPool) @bci=5, line=102 (Interpreted frame)
- com.sun.org.apache.xerces.internal.parsers.SAXParser.<init>() @bci=3, line=87 (Interpreted frame)
- com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.<init>(com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl) @bci=1, line=332 (Interpreted frame)
- com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl.<init>(com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl, java.util.Hashtable, boolean) @bci=15, line=122 (Interpreted frame)
- com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl.newSAXParser() @bci=13, line=76 (Interpreted frame)
- org.exolab.castor.xml.util.XMLParserUtils.getSAXParser(boolean, boolean) @bci=17, line=122 (Interpreted frame)
- org.castor.xml.AbstractInternalContext.getXMLReader(java.lang.String) @bci=56, line=262 (Interpreted frame)
- org.castor.xml.AbstractInternalContext.getXMLReader() @bci=2, line=248 (Interpreted frame)
- org.exolab.castor.xml.Unmarshaller.unmarshal(org.xml.sax.InputSource) @bci=8, line=692 (Interpreted frame)
- org.springframework.oxm.castor.CastorMarshaller.unmarshalInputStream(java.io.InputStream) @bci=12, line=386 (Interpreted frame)
- org.springframework.oxm.support.AbstractMarshaller.unmarshalStreamSource(javax.xml.transform.stream.StreamSource) @bci=12, line=368 (Interpreted frame)
- org.springframework.oxm.support.AbstractMarshaller.unmarshal(javax.xml.transform.Source) @bci=57, line=134 (Interpreted frame)


Thread 1702: (state = BLOCKED)
- org.apache.catalina.loader.WebappClassLoader.loadClass(java.lang.String, boolean) @bci=0, line=1524 (Compiled frame)
- org.apache.catalina.loader.WebappClassLoader.loadClass(java.lang.String) @bci=3, line=1491 (Compiled frame)
- com.sun.org.apache.xerces.internal.impl.dv.ObjectFactory.findProviderClass(java.lang.String, java.lang.ClassLoader, boolean) @bci=55, line=395 (Interpreted frame)
- com.sun.org.apache.xerces.internal.impl.dv.ObjectFactory.newInstance(java.lang.String, java.lang.ClassLoader, boolean) @bci=3, line=350 (Interpreted frame)
- com.sun.org.apache.xerces.internal.impl.dv.DTDDVFactory.getInstance(java.lang.String) @bci=5, line=59 (Interpreted frame)
- com.sun.org.apache.xerces.internal.impl.dv.DTDDVFactory.getInstance() @bci=2, line=44 (Interpreted frame)
- com.sun.org.apache.xerces.internal.parsers.XML11Configuration.<init>(com.sun.org.apache.xerces.internal.util.SymbolTable, com.sun.org.apache.xerces.internal.xni.grammars.XMLGrammarPool, com.sun.org.apache.xerces.internal.xni.parser.XMLComponentManager) @bci=815, line=538 (Interpreted frame)
- com.sun.org.apache.xerces.internal.parsers.XIncludeAwareParserConfiguration.<init>(com.sun.org.apache.xerces.internal.util.SymbolTable, com.sun.org.apache.xerces.internal.xni.grammars.XMLGrammarPool, com.sun.org.apache.xerces.internal.xni.parser.XMLComponentManager) @bci=4, line=125 (Interpreted frame)
- com.sun.org.apache.xerces.internal.parsers.XIncludeAwareParserConfiguration.<init>() @bci=4, line=86 (Interpreted frame)
- sun.reflect.GeneratedConstructorAccessor6.newInstance(java.lang.Object[]) @bci=24 (Interpreted frame)
- sun.reflect.DelegatingConstructorAccessorImpl.newInstance(java.lang.Object[]) @bci=5, line=27 (Compiled frame)
- java.lang.reflect.Constructor.newInstance(java.lang.Object[]) @bci=92, line=513 (Compiled frame)
- java.lang.Class.newInstance0() @bci=118, line=355 (Interpreted frame)
- java.lang.Class.newInstance() @bci=15, line=308 (Interpreted frame)
- com.sun.org.apache.xerces.internal.parsers.ObjectFactory.newInstance(java.lang.String, java.lang.ClassLoader, boolean) @bci=8, line=349 (Interpreted frame)
- com.sun.org.apache.xerces.internal.parsers.ObjectFactory.createObject(java.lang.String, java.lang.String, java.lang.String) @bci=76, line=154 (Interpreted frame)
- com.sun.org.apache.xerces.internal.parsers.ObjectFactory.createObject(java.lang.String, java.lang.String) @bci=3, line=97 (Interpreted frame)
- com.sun.org.apache.xerces.internal.parsers.SAXParser.<init>(com.sun.org.apache.xerces.internal.util.SymbolTable, com.sun.org.apache.xerces.internal.xni.grammars.XMLGrammarPool) @bci=5, line=102 (Interpreted frame)
- com.sun.org.apache.xerces.internal.parsers.SAXParser.<init>() @bci=3, line=87 (Interpreted frame)
- com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.<init>(com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl) @bci=1, line=332 (Interpreted frame)
- com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl.<init>(com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl, java.util.Hashtable, boolean) @bci=15, line=122 (Interpreted frame)
- com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl.newSAXParser() @bci=13, line=76 (Interpreted frame)
- org.exolab.castor.xml.util.XMLParserUtils.getSAXParser(boolean, boolean) @bci=17, line=122 (Interpreted frame)

- org.castor.xml.AbstractInternalContext.getXMLReader(java.lang.String) @bci=56, line=262 (Interpreted frame)
- org.castor.xml.AbstractInternalContext.getXMLReader() @bci=2, line=248 (Interpreted frame)
- org.exolab.castor.xml.Unmarshaller.unmarshal(org.xml.sax.InputSource) @bci=8, line=692 (Interpreted frame)
- org.springframework.oxm.castor.CastorMarshaller.unmarshalInputStream(java.io.InputStream) @bci=12, line=386 (Interpreted frame)
- org.springframework.oxm.support.AbstractMarshaller.unmarshalStreamSource(javax.xml.transform.stream.StreamSource) @bci=12, line=368 (Interpreted frame)
- org.springframework.oxm.support.AbstractMarshaller.unmarshal(javax.xml.transform.Source) @bci=57, line=134 (Interpreted frame)
- com.cms.common.concurrent.ResponseDataProcessingThread.run() @bci=44, line=139 (Interpreted frame)
- java.lang.Thread.run() @bci=11, line=662 (Interpreted frame)

Locked ownable synchronizers:
- None

Tomcat has become unresponsive, while application is yet to reach level of stability, but these issues doesn't look like are caused by application.

Has anyone faced/seen similar issues?

--Bhushan
12 years ago
I've a C function which takes char** as a argument. C program treats this char** argument as two dimentional array. So this is what it does -

void getStringArray(char** myString){

myString[0] = (char*) malloc (sizeof(char)*20)
strcpy(myString[0], somestring1)
myString[1] = (char*) malloc (sizeof(char)*20)
strcpy(myString[0], somestring2)
myString[2] = (char*) malloc (sizeof(char)*20)
strcpy(myString[0], somestring3)

}

Java

public void getData(){
PointerByReference pRef = new PointerByReference();
JNAINSTANCE.getStringArray((pRef);

Pointer p = pRef.getValue();
byte buffer[] = p.getByteArray(0,10) //these offsets are indicative, I pass actual value by calculating them in C
sysout(new String(buffer));

byte buffer[] = p.getByteArray(11,20)
sysout(new String(buffer));

buffer[] = p.getByteArray(21,30)
sysout(new String(buffer));
}

After invoking program I get correct value for first String only other two contain some random values.
am I missing something? or Is there any other way to achieve this?

Thanks
Bhushan
13 years ago
Hello All,

I'm working with embeded system, which has standard command set.

I need to store some of those commands in some kind of script file and then parse them sequentially(thr' java) and pass those commands to embeded system (thr' java).
Everything looks simple so far, but real challenge is handling conditional statements for e.g script/command file could be something like -

SET X
MOVETO 1000
X =GETPOSITION
IF(X<1000)
MOVETO (1000-X)

CAPTURE
....

This looks pretty much same as parsing grammar, how can this be achieved in java? Especially conditional parsing and then choosing appropriate path in script.

Thnx in advance.
13 years ago
Sure

Kannan Mani wrote:hi,
I am trying to use JNA , to call secur32.dll funtions but is not working for me .Can you help me

Regards
Kannan

14 years ago
Hey thanks Buddy, it did help me. Actually I was was assigning memory.gePointer to a Pointer, did not realize that Memory extends Pointer and just assigning memory reference would be sufficient. After that everything worked.
Now, I have another question which related to correct usages of jna, for instance I am using things like

1) Structure.ByReference
2) Memory
Who is responsible for freeing up the memory after program is over especially when I use something like -
(Memory buf = new Memory(size)), which will allocate memory on native heap, will JVM GC collect such memory?

If not, how do I free up the memory, I saw there is free() method in Memory class but is not a public method.
One way I can imagine how this may work is after all reference to Memory object become void and when finalize method is invoked by GC on memory object
it will free the memory on native heap as well, is it how it works? (I hope, I don't sound too imaginative :-))
14 years ago
I am trying to implement something similar to single signon thr' Java using Microsoft SSPI.
I need to invoke following two windows APIs in secur32.dll to accomplish it

1) AcquireCredentialsHandle
2) InitializeSecurityContext

Out of that first one (AcquireCredentialsHandle) seems to work fine, but the second one returns me some negative number during first run, which indicates it is an error. But that negative no can't be mapped to any of the error codes mentioned by Microsoft on msdn (http://msdn.microsoft.com/en-us/library/aa375512(VS.85).aspx).
The negative value returned is (-2146893052). I know there must be something wrong with my code but this error code is not helping me to find it out.

Following is the signature of InitializeSecurityContext -

SECURITY_STATUS SEC_Entry InitializeSecurityContext(
__in_opt PCredHandle phCredential,
__in_opt PCtxtHandle phContext,
__in SEC_CHAR *pszTargetName,
__in ULONG fContextReq,
__in ULONG Reserved1,
__in ULONG TargetDataRep,
__in_opt PSecBufferDesc pInput,
__in ULONG Reserved2,
__inout_opt PCtxtHandle phNewContext,
__inout_opt PSecBufferDesc pOutput,
__out PULONG pfContextAttr,
__out_opt PTimeStamp ptsExpiry
);

Following is how I have mapped all the attributes in Java
__in_opt PCredHandle phCredential - passed as Structure.ByReference (refer to SECURITY_HANDLE.java in attached file)
__in_opt PCtxtHandle phContext, - passed as null during first call
__in SEC_CHAR *pszTargetName - passed a Java String
__in ULONG fContextReq - ISC_REQ_CONFIDENTIALITY | ISC_REQ_REPLAY_DETECT | ISC_REQ_SEQUENCE_DETECT| ISC_REQ_CONNECTION
__in ULONG Reserved1 - 0
__in ULONG TargetDataRep - 0x10
__in_opt PSecBufferDesc pInput - null for first time
__in ULONG Reserved2 - 0
__inout_opt PCtxtHandle phNewContext - passed as Structure.ByReference (refer to SECURITY_HANDLE.java in attached file)
__inout_opt PSecBufferDesc pOutput - passed as Structure.ByReference ( refer to SecBufferDesc.java and SecBuffer.java), I think I am making some mistake in this mapping
__out PULONG pfContextAttr - LongByReference
__out_opt PTimeStamp ptsExpiry - passed as Structure.ByReference (refer to SECURITY_INTEGER.java in attached file).

Somebody has already done same thing using JInvoke, but I need to do it using jna, but I have used almost same code base with relevant changes.

Important URLs from microsft are -
1) http://msdn.microsoft.com/en-us/library/aa375512(VS.85).aspx
2)http://msdn.microsoft.com/en-us/library/aa379814(VS.85).aspx
3)http://msdn.microsoft.com/en-us/library/aa379815(VS.85).aspx

I can share the code, but it probably need to be on one to one basis as site doesn;t allow me to upload the code zip
Thanks,
Bhushan
14 years ago
i am writing java mail code thr' java program . i have set all the classpatahs.it gives send failed exception giving errors
which indicates that it is not identifying smtp host.
my o.s. is win98.
I am sending this mail to yahoo account thr' my program.
pls tell me to what i should set "from" address.
is it necessary that i must have installed smtp host on my machine?
i am also attching code i am using pls help mei am new to java mail .my o.s. is win98
i have set all slasspaths appropriately. the code i have return gives errors
which indicates that it is not identifying smtp host.
I am sending this mail to yahoo account thr' my program.
pls tell me to what i should set "from" address.
i am also attching code i am using pls help me
import javax.mail.*;
import javax.mail.internet.*;
import java.util.Properties;
import java.util.Vector;
import java.io.*;
import javax.activation.FileDataSource;
import javax.activation.DataHandler;
public class Mailer {
protected static Message prepareHeader(String smtp_host, String from,
String to, String subject)
throws IOException, AddressException,
MessagingException {
Properties props = new Properties();
props.put("smtp.host", smtp_host);
Session session = Session.getDefaultInstance(props, null);
Message msg = new MimeMessage(session);
InternetAddress addr = new InternetAddress(to);
msg.addRecipients(Message.RecipientType.TO,
new InternetAddress[] {addr });
InternetAddress from_addr = new InternetAddress(from);
msg.setFrom(from_addr);
msg.setSubject(subject);
return msg;
}
public static void sendMail(String smtp_host, String from,String to, String subject, String message)throws IOException, AddressException,MessagingException
{
Message msg = prepareHeader(smtp_host, from, to, subject);
msg.setContent(message, "text/plain");
Transport.send(msg);
}
public static void main(String args[])
{
try
{
Mailer m = new Mailer();
m.sendMail("mail.yahoo.com","bhushan_shelke@yahoo.com","vivekma_2000@yahoo.co m","mail","this is second mail");
}
catch(AddressException ade)
{
System.out.println(ade.getMessage());
}
catch(MessagingException mes)
{
System.out.println(mes.getMessage());
}
catch(IOException ioe)
{
System.out.println(ioe.getMessage());
}
}
}

------------------
23 years ago