aspose file tools
The moose likes Java in General and the fly likes Inner class is not getting instantiated in java 5 and the same works fine in java 6 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of The Software Craftsman this week in the Agile forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Inner class is not getting instantiated in java 5 and the same works fine in java 6" Watch "Inner class is not getting instantiated in java 5 and the same works fine in java 6" New topic

Inner class is not getting instantiated in java 5 and the same works fine in java 6

Nagaraj Shivaklara
Ranch Hand

Joined: Dec 16, 2008
Posts: 78
Hi All,

I am trying to instantiate inner class in java 5.0.11, but getting the below exception:

java.lang.NoClassDefFoundError: com/test/security/websso/sp/MobileRequestWrapper$MobileWrapperHttpServletRequest

The same works fine in Java 6.

Here is my code:

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpServletRequestWrapper;
import org.apache.commons.lang.StringUtils;

public class MobileRequestWrapper implements Filter {

/** {@inheritDoc} */
public void init(FilterConfig filterConfig) throws ServletException {


/** {@inheritDoc} */
public void doFilter(ServletRequest servletRequest,
ServletResponse servletResponse, FilterChain filterChain)
throws IOException, ServletException {
String output = com.thl.gsk.DeviceDetectionUtil.processRequest((HttpServletRequest)servletRequest,(HttpServletResponse)servletResponse);
if(StringUtils.isNotBlank(output) && "mobile".equalsIgnoreCase(output))
System.out.println("----------------> in do filter of new class start");
HttpServletRequest wrappedRequest = new MobileWrapperHttpServletRequest(
(HttpServletRequest) servletRequest);
filterChain.doFilter(wrappedRequest, servletResponse);
filterChain.doFilter(servletRequest, servletResponse);


public void destroy() {

private static class MobileWrapperHttpServletRequest extends
HttpServletRequestWrapper {

public MobileWrapperHttpServletRequest(HttpServletRequest request) {

public String getParameter(String name) {

System.out.println("----------------> in do filter of new class get parameter");
String originalValue = super.getParameter("cmd");
if (originalValue == null) {
return null;
} else {
String newVal = fixup(originalValue);
System.out.println("newVal in the brand new servlet ------------------------>"+newVal);
return fixup(originalValue);
private String fixup(String value) {
String newValue = null;
newValue = "MProductsByName";
return newValue;


Thanks n Regards,
Nagaraj S K
Winston Gutkowski

Joined: Mar 17, 2011
Posts: 8626

Nagaraj Shivaklara wrote:Here is my code:...


Please UseCodeTags (←click) when posting code; you'll get a lot more response. I'm surprised you haven't worked this out after 70 posts.

And BEFORE you post again, I'd suggest you also read the DontWriteLongLines page and break up some of those enormous lines, because many of them are far too long.



Isn't it funny how there's always time and money enough to do it WRONG?
Articles by Winston can be found here
Richard Tookey

Joined: Aug 27, 2012
Posts: 1129

If this bug exists in JDK 5 then it is fairly fundamental and I would have expected developers the world over to have been yelling at Sun ( I don't think Oracle were on the scene for Java 5 ). I use inner classes though all my code and it all works well in Java 5 , 6 and 7.

It sounds to me like you have a bug in your build system. You could check the 'classes' directory ( or whatever you have called it ) after the compile step to see whether or not the class file has been created. If it has been created then you can check the jar file to see whether or not it contains the class file. In other words - check the build at each stage to make sure it is correct.
subject: Inner class is not getting instantiated in java 5 and the same works fine in java 6