ashish bassii

Greenhorn
+ Follow
since Sep 05, 2008
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
1
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 ashish bassii

I have a basic question about Hibernate load and get methods

I just wrote a simple Hibernate standalone application.

One table, one class, and one hbm file mapping them. Then I wrote a simple piece of Java/hibernate code to retrieve one record



What I had understood is that if we are sure that object/record is available in memory we should use the load method, or use get if one is not sure, and get will hit DB and get the record

Now since this is a standalone application, I though load would break, after all I have just started the application, memory must be empty, and load method should throw an exception, but to my surprise it worked fine, and record was retrieved, the sysout displayed the correct value. What am I missing?
Hi

If I have a connection pool, with lets say a max size of 100, and all the 100 connections are in use, what happens if there is request for another (101th) connection? Does it cause an exception
Hello

I am getting a security exception when I start my Websphere App Server. From what I understand this error indicates different classes of a package are being loaded from different jars, but this class is an IBM jar which comes with the App Server package, what could be causing this?

Caused by: java.lang.SecurityException: Signers of 'com.ibm.crypto.provider.SHA1withDSA' do not match signers of other classes in package
at java.lang.ClassLoader.checkPackageSigners(ClassLoader.java:314)
at java.lang.ClassLoader.defineClass(ClassLoader.java:256)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:151)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:703)
at java.net.URLClassLoader.findClass(URLClassLoader.java:472)
at java.lang.ClassLoader.loadClass(ClassLoader.java:650)
at java.lang.ClassLoader.loadClass(ClassLoader.java:616)
at java.lang.Class.forNameImpl(Native Method)
at java.lang.Class.forName(Class.java:130)
at com.ibm.crypto.provider.pc.newInstance(Unknown Source)
at java.security.Signature$Delegate.newInstance(Signature.java:992)
at java.security.Signature$Delegate.chooseProvider(Signature.java:1086)
at java.security.Signature$Delegate.engineInitVerify(Signature.java:1142)
at java.security.Signature.initVerify(Signature.java:476)
at com.ibm.security.x509.X509CertImpl.verify(X509CertImpl.java:536)
at com.ibm.security.x509.X509CertImpl.verify(X509CertImpl.java:474)
at javax.crypto.b.a(Unknown Source)
at javax.crypto.b.access$500(Unknown Source)
at javax.crypto.b$0.run(Unknown Source)
at java.security.AccessController.doPrivileged(AccessController.java:241)
at javax.crypto.b.<clinit>(Unknown Source)
at java.lang.J9VMInternals.initializeImpl(Native Method)
at java.lang.J9VMInternals.initialize(J9VMInternals.java:196)
at javax.crypto.d.<clinit>(Unknown Source)
at java.lang.J9VMInternals.initializeImpl(Native Method)
at java.lang.J9VMInternals.initialize(J9VMInternals.java:196)
at javax.crypto.Cipher.c(Unknown Source)
at javax.crypto.Cipher.getMaxAllowedKeyLength(Unknown Source)
at com.tibco.security.ssl.SSLFactory.<clinit>(SSLFactory.java:42)
at java.lang.J9VMInternals.initializeImpl(Native Method)
at java.lang.J9VMInternals.initialize(J9VMInternals.java:196)
at com.tibco.tibjms.TibjmsxLinkSSL._initSSL(TibjmsxLinkSSL.java:304)
at com.tibco.tibjms.TibjmsxLinkSSL.connect(TibjmsxLinkSSL.java:390)
at com.tibco.tibjms.TibjmsConnection._create(TibjmsConnection.java:1296)
at com.tibco.tibjms.TibjmsConnection.<init>(TibjmsConnection.java:4127)
at com.tibco.tibjms.TibjmsxCFImpl._createImpl(TibjmsxCFImpl.java:200)
at com.tibco.tibjms.TibjmsxCFImpl._createConnection(TibjmsxCFImpl.java:253)
at com.tibco.tibjms.TibjmsQueueConnectionFactory.createQueueConnection(TibjmsQueueConnectionFactory.java:87)
at com.tibco.tibjms.naming.TibjmsContext$Messenger.request(TibjmsContext.java:325)
at com.tibco.tibjms.naming.TibjmsContext.lookup(TibjmsContext.java:655)
at com.tibco.tibjms.naming.TibjmsContext.lookup(TibjmsContext.java:489)
at javax.naming.InitialContext.lookup(InitialContext.java:363)
9 years ago
In your servlet, you should declare and initialize qblist inside the processRequest method.

protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
///ADD THIS LINE
List qblist = new ArrayList();
response.setContentType("text/html;charset=UTF-8");
PrintWriter out = response.getWriter();
try {
con = ref.getConnection();
stmt = con.createStatement();
rs = stmt.executeQuery("select * from questions");


while (rs.next()){

Qbean qb = new Qbean();
qb.setQuestion(rs.getString("question"));
qb.setAns1(rs.getString("ans1"));
qb.setAns2(rs.getString("ans2"));
qb.setRightAns(rs.getString("rightans"));
qblist.add(qb);


}
try{

rs.close();
}catch(Exception ex){}
HttpSession session = request.getSession();
session.setAttribute("qblist", qblist);
RequestDispatcher rd = request.getRequestDispatcher("displayTest.jsp");
rd.forward(request, response);
}catch(Exception e){} finally {
out.close();
}
}
10 years ago
JSP
As per my understanding, javascript function document.getElementById works find with both ID and name attributes.

I have a HTML file, with some javascript code.

When I save this in an HTML file, on my local workstation, lets say my desktop, and open it from there, I get a Javascript error when I click the copy button which internally invokes a javascript function, which in turn invokes document.getElementById function for a name attribute.

However, if I copy the same file on some other machine, lets say another system's shared folder, and try to open this file from there, i get no Javascript error?

My question is how come the same function works fine from a remote location, but gives Javascript error when opened locally.

Just to add, I did not face this problem with IE7, I am facing this problem only with IE8


Even I thought the use of name attribute instead of id might be causing the problem. While I will change this and hopefully this will work, still wondering how can this be, there must be some reasoning behind why a Javascript function works on IE8 in some machines, but not on others. Could there be some IE settings which could be different?
Its a legacy code, wish I knew the answer

I noticed a few things while debugging this:

1) The document.getElementById function is being used for the name attribute of the textarea, instead of the id attribute. But, it has been working till now
2) Also, I just checked, its not that it doesnt work at all. It works in some systems, and doesnt work in others. All the systems are from same vendor, not much difference in system/ie settings, all are Windows 7 and IE8. Just flabbergasted as to why one simple piece of code should work fine in some systems and not in others with the same settings
I am facing an issue where an application which has been in production for years now, suddenly started giving a java script error when we upgraded to Window 7 and IE8 (Earlier it was XP and IE 7).

Below is the relevant section of the source. This appears in a Webpage dialog as a popup when a button on the main screen is clicked.

Functionality expected is that when the Copy button is clicked, it should copy the text displayed in text area in the clipboard. As I mentioned, this used to work fine, but once we moved to Win7-IE8, I get a javascript error

"An Error has occurred in the script on this page”
"Error “null” is null or not an object

This appears to be at the below line of code

cp = doc.createTextRange();

because variable named doc was null. I dont understand why a simple doc.getElementById should fail in IE8.



Thanks Henry, Piet,Jayesh

I updated the code to test for equality as well




Highlighted the modified part in bold, Now it seems fine and works for TreeSet, here is the output


[Canada, USA, Belgium, Afgahnistan, India, Denmark, Russia, Hungary, USA, USA, Canada, Canada, USA, usa]
[usa, USA, USA, USA, USA, Canada, Canada, Canada, Afgahnistan, Belgium, Denmark, Hungary, India, Russia]
En nu de treeset:
[usa, USA, Canada, Afgahnistan, Belgium, Denmark, Hungary, India, Russia]
treeset contains USA

10 years ago
Thanks Piet..You are right, when the number of exceptions is just 1 or 2, then the code I wrote seems to be fine.

For a more generic version, one can use the approach you mentioned
10 years ago
The code mentioned in finally block will execute even if the exception thrown is not handled by any of the exception blocks, so if you have try block, a catch block for ArithmeticException, and a finally block.. but the exception you actually got in try block is IOExcepton, the finally block will still execute, but the code after catch block wont
10 years ago
I am trying to sort a List of country names alphabetically, with the exception being that USA and Canada should be the first 2 countries, and the remaining countries should follow alphabetically. I have written a piece of code which is working, just wanted to know if someone can advice a better, more efficient way

10 years ago
I created a simple JAVA program to send email, below is the code. It accepts 3 paramters, the ToEmail Id, Subject, and DataHandler object which contains a file which needs to be attached in the mail



When I test this Java program as a simple Java application, it works. I get the email with attachment. However if I convert it into a Web Service, It doesnt work.. I'm testing the Web Service using the below Client code.




I have verified that the Web service is configured correctly. If I add sysouts in Web service method, and invoke the client, i do see the sysouts on server console. So the request is reaching the webservice. But the exception is coming at the following line of web service method



Below mentioned stack trace appears on client console (No exception on server console)

-------------java.lang.reflect.InvocationTargetException
AxisFault
faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
faultSubcode:
faultString: java.lang.reflect.InvocationTargetException
faultActor:
faultNode:
faultDetail:
{http://xml.apache.org/axis/}hostname:WSUSOH30V1998X

java.lang.reflect.InvocationTargetException
at org.apache.axis.message.SOAPFaultBuilder.createFault(SOAPFaultBuilder.java:222)
at org.apache.axis.message.SOAPFaultBuilder.endElement(SOAPFaultBuilder.java:129)
at org.apache.axis.encoding.DeserializationContext.endElement(DeserializationContext.java:1087)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endElement(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanEndElement(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
at javax.xml.parsers.SAXParser.parse(Unknown Source)
at org.apache.axis.encoding.DeserializationContext.parse(DeserializationContext.java:227)
at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:696)
at org.apache.axis.Message.getSOAPEnvelope(Message.java:435)
at org.apache.axis.handlers.soap.MustUnderstandChecker.invoke(MustUnderstandChecker.java:62)
at org.apache.axis.client.AxisClient.invoke(AxisClient.java:206)
at org.apache.axis.client.Call.invokeEngine(Call.java:2784)
at org.apache.axis.client.Call.invoke(Call.java:2767)
at org.apache.axis.client.Call.invoke(Call.java:2443)
at org.apache.axis.client.Call.invoke(Call.java:2366)
at org.apache.axis.client.Call.invoke(Call.java:1812)
at send.mail.WebServiceCalling.main(WebServiceCalling.java:26)
12 years ago
I have a struts application, which runs in http mode in some environments, and in https mode in others.

Weather app is running in http or https mode is mentioned in one of the properties files

Im using that property so that while making AJAX calls, i need to know the current protocol, which i need to mention in the URL of the struts action im invoking. For example,

URL url = new URL("http://localhost:9080/myproject/myAction.do?method=get");
or
URL url = new URL("https://localhost:9080/myproject/myAction.do?method=get");

Now since the action is in the same WAS context, is there a way i can mention simply the relative URL (myAction.do?method=get) and not bother about weather its http or https?

when i try to use

URL url = new URL("/myAction.do?method=get");
i get MalformedURLException
15 years ago