• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

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

Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 java.io.IOException;
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;

Posts: 10780
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.



Posts: 1166
Netbeans IDE Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
    Bookmark Topic Watch Topic
  • New Topic