Mandy Singh

Greenhorn
+ Follow
since May 30, 2011
Mandy likes ...
Eclipse IDE Java Opera
New Delhi, India
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
4
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Mandy Singh

Hi...

I know this question was asked almost 5 years back, but for the benefit of those reading this post.... the solution (restarting the system) really works !

I did not have a JSP page or something as mentioned in the question... but I simply added a server (Tomcat 7.0) configuration to my eclipse workspace. The problem was that the server would not start and would throw:

SEVERE: Begin event threw

error java.lang.ClassFormatError: Illegal constant pool index 0 for method name in class file org/apache/catalina/util/Lifecycle Support


After searching for a solution to this problem, I came across this post and restarted my PC.

It indeed worked fine! By the way, am using jre7
4 years ago
JSP

Well, if I put the values I want to pass into a byte[], it works. But its working because a long[] cannot refer to a byte[]. So the ambiguity is resolved.

But that is not the question. My question is, why passing a 'byte' causes ambiguity (even when byte is more specific than long) ?

Tony Docherty wrote:The reason passing a byte value doesn't work (whereas passing a long does work) was explained by Campbell earlier.



Not sure which post by Campbell you are referring to. In fact in this post...

Campbell Ritchie wrote:Passing a long[] to a byte[] is impossible, so that sorts out the ambiguity; bytes being smaller than longs are more specific, but only a byte can fit into a byte[], so the ambiguity can be sorted out.

...it is said that bytes being smaller than long are more specific so the ambiguity can be sorted out.

But the fact is that the ambiguity doesn't get sorted out !

I know this is going on and on. Thanks for bearing with me.
5 years ago
Hi, sorry for the semicolons at the end of the methods I wrote above. They were not abstract methods. I just placed the semicolon by mistake while reproducing the code here.

Tony Docherty wrote: When I added empty method bodies it compiled on my system - what version of Java are you using and can you show the whole compiler error message.



Sure... the code that I am trying to compile is...


The compiler error that I get is...

D:\java_practice>javac Test.java
Test.java:13: reference to go is ambiguous, both method go(byte...) in Test and
method go(long...) in Test match
go(b);
^
1 error


I am using Java 6

Campbell Ritchie wrote:Don’t know any more. Sorry. Have you tried casting a byte[] to a long[]? Does that compile at all?


I tried doing that, but it didn't compile. It says... "Illegal start of type".
5 years ago

Winston Gutkowski wrote: Now, most of the guys (and gals) here are good, but we do make mistakes from time to time...

Winston



No worries
5 years ago
Ohh... I clicked on "resolved" pretty soon it seems...

In fact, that's exactly what my question was... that ambiguity can be sorted out since byte is more specific than long but the compiler says the calls are ambiguous.





These parameters make the method call ambiguous again even though the one with 'byte... x' is more specific.



We agreed that 'Number' was more specific than 'Object', hence there was no ambiguity.
Similarly, we agree that 'byte' is more specific than 'long' so there should be no ambiguity...

Campbell Ritchie wrote:bytes being smaller than longs are more specific, but only a byte can fit into a byte[], so the ambiguity can be sorted out.



So that's what... if the ambiguity can be sorted out (in case of 'byte...' and 'long...' ), why does the compiler give an error ?

I think I need to spend some time away from my computer.
5 years ago
Right. I somehow overlooked the fact that the var-args would be translated into an array. Thanks !

As for the misconception... well..

use ctrl-F-“overload”

I read it in a way which made me feel you were suggesting that I could just look up the answer in the JLS instead of asking. My Bad !

Anyway, good that we talked about it

Thanks a lot, mate. Cheers !!
5 years ago

There are about 7 hits if you open the Java Language Specification and use ctrl-F-“overload”

I hope that wasn't a taunt

Thanks for your reply, though.

Number is chosen because its the most specific in this case but then why does the same not happen when the parameters in both the methods are primitives. for eg:



These parameters make the method call ambiguous again even though the one with 'byte... x' is more specific.
5 years ago
Hi all,

I have 2 overloaded methods, both using var-args.

I understand that the following does not compile because of an ambiguous invocation ...



But what about the following code. Why is the method call not ambiguous ?


5 years ago
So what should I do now? How to access the logs containing the details of the exception ?
6 years ago
The puppy's sad. There is no "catalina.out" in tomcat dir or in the workspace. What should I do and where is this file normally located ? There are some localhost_access_log files in my workspace, but again as I said, they don't contain enough details.
6 years ago
Hello Everyone,

I encountered a problem while running a small test application on Tomcat. The server gives an HTTP Status 500 error along with an exception.

The actual error that I get is...





There is a note at the end which states : "The full stack trace of the root cause is available in the Apache Tomcat/7.0.8 logs."

Where are these logs located ?

The only logs that I can see being updated are the ones located in my workspace:

"C:\J2EE workspace\StrutsPractice\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\logs"

Catalina Base is set as (In eclipse, VM arguments for Server Configuration)...

catalina.base="C:\J2EE workspace\StrutsPractice\.metadata\.plugins\org.eclipse.wst.server.core\tmp0

and the "logging.properties" file in Tomcat/conf folder specifies juli.FileHandler.directory as :
FileHandler.directory = ${catalina.base}/logs

for these handlers...
1. catalina.org.apache.juli.FileHandler,
2. localhost.org.apache.juli.FileHandler,
3. manager.org.apache.juli.FileHandler,
4. host-manager.org.apache.juli.FileHandler

So I assumed that I was looking at the correct location (my workspace, as specified above) for the logs. Please correct me if I a wrong.

The logs at this location aren't really helpful, with output similar to this...
0:0:0:0:0:0:0:1 - - [03/May/2012:15:19:16 +0530] "GET /KurniawanChap02Struts/ HTTP/1.1" 500 1789

So my questions are...

1. Am I looking at the correct location for my logs ?
2. How do I get more detailed logs or how should I access the "full stack trace of the root cause" as stated in line 23 of the Server's error report ?
6 years ago
Jeff, thats exactly what I was asking. Thanks for the explanation, precise and crisp
6 years ago
Hi Guys,

Well... my question is a bit different. I very clearly understand that static methods cannot be "overridden" and I also understand very clearly that variables (whether they are instance variables or static variables) cannot be overridden.

I dont want to override any of those.

All i am asking is, why is there a "discrepancy" when it comes to "hiding" methods and variables using static and non-static contexts together in the code. I am able to hide a static variable using an instance variable, but I am not able to hide a static method using an instance method ( and vice-versa).

Why ?

@Gursewak... Bro, we can hide static methods of a superclass using a static method of the same signature, compatible return types and throws clause in a subclass. It works fine. My question is ...
Why can't we do the same "hiding" using instance methods in the subclass. I do understand that static methods have got nothing to do with an instance of the class, but I don't know how valid an explanation it would be in this case. I am able to hide static variables of a super class using instance variables in a subclass. Why can't i do so (hiding static methods of a superclass ) using instance methods in a subclass ?

@Seetha... I dont want to. I just wanted to "hide" static vars using instance vars, and I am able to do so. But not in the case of methods (using static/non-static contexts together). Why ?

@Campbell ... was just trying to find out the technical feasibility and answers to the "hows" and "whys" in this case. I surely will get hold of the book - Java Puzzlers, though.

Thank you all for your posts !! Cheers :-)
6 years ago
Hello ,

Why is it allowed to "hide" static variables using instance variables in a sub class when we are not able to do the same in case of methods.

The following compile time errors are encountered:

1. "This instance method cannot override the static method from A". - Generated when I try to redefine a static method of class A using an instance method in class B having the same signature.
2. "This static method cannot hide the instance method from A". - Generated when I try to override an instance method of class A using a static method in class B having the same signature.

In the above case, if I use instance and static variables to hide each other, it works like charm
Why doesn't it work in the case of methods ???

I have searched it in other forums/web sites but haven't yet seen a convincing answer (or maybe I wasn't able to understand).

Can anybody please explain? Thanks
6 years ago