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

  • SEARCH
  • Home
  • 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 6754391
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T13:16:27+00:00 2026-05-26T13:16:27+00:00

I have a custom InjectionProvider which retrieves a User object from the SecurityContext and

  • 0

I have a custom InjectionProvider which retrieves a User object from the SecurityContext and makes it available. A custom ResourceFilter performs the HTTP Basic authentication, creates the SecurityContext and populates it with a Principal. This is based on this suggestion.

When I access it from a resource method, it works as expected:

@Stateless
@Path("foo")
public class FooResource {

  @GET
  @ResourceFilters(value = {UserAuthenticationFilter.class})
  public Response get(@Context User user) {
    return Response.ok().entity(user).build();
  }
}

However, when I try to inject the object as an attribute/field to the EJB, exceptions get thrown, even though I can see in the logs that the InjectionProvider gets called:

@Stateless
@Path("foo")
public class FooResource {

  @Context
  private User user;

  @GET
  @ResourceFilters(value = {UserAuthenticationFilter.class})
  public Response get() {
    return Response.ok().entity(user).build();
  }
}

The exception is strange:

[#|2011-10-31T13:35:47.691+0000|WARNING|glassfish3.1.1|javax.enterprise.system.container.web.com.sun.enterprise.web|_ThreadID=18;_ThreadName=Thread-3;|StandardWrapperValve[Gateway Servlet]: PWC1406: Servlet.service() for servlet Gateway Servlet threw exception
javax.ejb.CreateException: Could not create stateless EJB
    at com.sun.ejb.containers.StatelessSessionContainer.createStatelessEJB(StatelessSessionContainer.java:534)
    at com.sun.ejb.containers.StatelessSessionContainer.access$000(StatelessSessionContainer.java:95)
    at com.sun.ejb.containers.StatelessSessionContainer$SessionContextFactory.create(StatelessSessionContainer.java:724)
    at com.sun.ejb.containers.util.pool.NonBlockingPool.getObject(NonBlockingPool.java:247)
    at com.sun.ejb.containers.StatelessSessionContainer._getContext(StatelessSessionContainer.java:449)
    at com.sun.ejb.containers.BaseContainer.getContext(BaseContainer.java:2528)
    at com.sun.ejb.containers.BaseContainer.preInvoke(BaseContainer.java:1895)
    at com.sun.ejb.containers.EJBLocalObjectInvocationHandler.invoke(EJBLocalObjectInvocationHandler.java:212)
    at com.sun.ejb.containers.EJBLocalObjectInvocationHandlerDelegate.invoke(EJBLocalObjectInvocationHandlerDelegate.java:88)
    at $Proxy166.get(Unknown Source)
....
Caused by: com.sun.jersey.spi.inject.Errors$ErrorMessagesException
    at com.sun.jersey.spi.inject.Errors.processErrorMessages(Errors.java:170)
    at com.sun.jersey.spi.inject.Errors.postProcess(Errors.java:136)
    at com.sun.jersey.spi.inject.Errors.processWithErrors(Errors.java:199)
    at com.sun.jersey.server.impl.application.WebApplicationImpl$ComponentProcessorFactoryImpl.get(WebApplicationImpl.java:499)
    at com.sun.jersey.server.impl.ejb.EJBInjectionInterceptor.get(EJBInjectionInterceptor.java:104)
    at com.sun.jersey.server.impl.ejb.EJBInjectionInterceptor.init(EJBInjectionInterceptor.java:71)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at com.sun.ejb.containers.interceptors.SystemInterceptorProxy.doCallback(SystemInterceptorProxy.java:133)
    at com.sun.ejb.containers.interceptors.SystemInterceptorProxy.init(SystemInterceptorProxy.java:120)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at com.sun.ejb.containers.interceptors.CallbackInterceptor.intercept(InterceptorManager.java:964)
    at com.sun.ejb.containers.interceptors.CallbackChainImpl.invokeNext(CallbackChainImpl.java:65)
    at com.sun.ejb.containers.interceptors.InterceptorManager.intercept(InterceptorManager.java:393)
    at com.sun.ejb.containers.interceptors.InterceptorManager.intercept(InterceptorManager.java:376)
    at com.sun.ejb.containers.StatelessSessionContainer.createStatelessEJB(StatelessSessionContainer.java:526)
    ... 55 more

What am I doing wrong?

EDIT: I just noticed that before the exception is thrown, an error is reported in the server.log:

[#|2011-10-31T15:33:01.854+0000|SEVERE|glassfish3.1.1|com.sun.jersey.spi.inject.Errors|_ThreadID=18;_ThreadName=Thread-3;|The following errors and warnings have been detected with resource and/or provider classes:
  SEVERE: Missing dependency for field: private com.skalio.bonusapp.core.User com.skalio.bonusapp.gateway.FooResource.user|#]
  • 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-26T13:16:27+00:00Added an answer on May 26, 2026 at 1:16 pm

    This is due to a scope mismatch. You are trying to inject a request-scoped thing to a bean that is not request scoped. That won’t work.

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

Sidebar

Related Questions

I have custom view in my application which can be scrolled by the user.
I have custom drupal module. I receive result from a webservice that I need
I have custom cell which contains number of rows in it.i want to write
I have custom object MyClass and I need to create 3 instances of it.
I have custom list_row : <LinearLayout xmlns:android=http://schemas.android.com/apk/res/android android:orientation=horizontal android:layout_width=match_parent android:orientation=horizontal android:layout_width=match_parent android:layout_height=wrap_content android:baselineAligned=false> <Button
I have custom table view cell with images (loaded from app document directory), labels,
I have custom-made wizard system which so far has been quite suitable. For most
I have custom Question objects which I render into html form elements. I want
I have custom CSS for checkbox control into my web form, which is linked
I have custom object and I have stored my values in Array. but I

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.