问题
Where do I set the user context Websphere uses when it calls a @Startup EJB?
I have a Java EE application with a startup EJB, and I know that it sets a user when calling the EJB, since the call fails due to missing roles. However, I couldn't find where to set the user.
回答1:
The EJB spec states that session bean @PostConstruct
methods are called in an unspecified security context, and WebSphere does not document a specific security context or allow it to be configured. In practice, singleton session bean @PostConstruct
will typically be called with an unauthorized user as the security context. If setting a specific security context is important, then you could open a WebSphere RFE, but I would recommend finding another solution to avoid a vendor-specific solution.
来源:https://stackoverflow.com/questions/33103036/user-context-for-startup-ejb-on-websphere