Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6160737
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T21:21:21+00:00 2026-05-23T21:21:21+00:00

I am having a strange problem with ModelAttribute in Spring MVC 3.0. When I

  • 0

I am having a strange problem with ModelAttribute in Spring MVC 3.0. When I deploy the app at localhost, it works fine. But when I deploy the app on a remote server, it fails everytime user access a specific action, with the errors:

ERROR: my.package.application.web.filter.ExceptionFilter - long.<init>()
java.lang.NoSuchMethodException: long.<init>()
        at java.lang.Class.getConstructor0(Class.java:2706)
        at java.lang.Class.getDeclaredConstructor(Class.java:1985)
        at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:104)
        at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.resolveModelAttribute(HandlerMethodInvoker.java:762)
        at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.resolveHandlerArguments(HandlerMethodInvoker.java:356)
        at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:153)
        at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:426)
        at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:414)
        at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:790)
        at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719)
        at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644)
        at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:549)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

The code that I user to init the ModelAttribute in that controller is:

    @ModelAttribute("id")
    public long getUserId(HttpSession session) {
        UserInfoHolder userHolder = (UserInfoHolder) session
                .getAttribute("userHolder");
        long userId = userHolder.getUserId();
        return userId;
    }

As far as I can tell, the bug can’t be reproduced at my local workstation. And it happens before the action get called.

Looking in HandlerMethodInvoker.java (line 762), we see this line:

bindObject = BeanUtils.instantiateClass(paramType);

An experienced peer of mine believes that this line causes problem, because that a primitive-type ModelAttribute(long) doesn’t have a constructor. I think that reason maybe right, but how can it explain that the web application works fine on my local server?

I tried to search to know if ModelAttribute support primitive data type, but with no good results. Does anyone have experience about this issue?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T21:21:21+00:00Added an answer on May 23, 2026 at 9:21 pm

    I’m just throwing in some thoughts, hoping it might help a bit.

    The stack trace shows that it is indeed trying to call the constructor method for long:

    java.lang.NoSuchMethodException: long.<init>()
    

    Does it work if you change the used type from long to Long?

    As for things working locally but not on the client. Is the Java version the same?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having a strange problem comparing strings. I send a string to my server
I'm having a strange problem. I want to put border around the image, but
I'm having a strange problem connecting via remote to MySQL. This is an internal
I'm having a strange problem with the following code works. Map<String, Object> map =
I'm having a strange problem with my app - A have a Fragment Activity
i am having strange problem, when i change the default app pool to use
I'm having a strange problem. I have to use GetPostBackEventRefence to force a Postback,
I'm having a strange problem in Visual Studio 2008 where my Pending Checkins window
I'm having a strange problem here... I have an ASP.NET 3.5 application that has
i am having a strange problem, i have a static class like this public

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.