On the start of my application, I instantiate a new object that is stored in the application scope. This object handles encryption for the application and generates a random key when ever the application is restarted.
The start of my encryption class:
@Startup
@Name("ssoEncyription")
@Scope(ScopeType.APPLICATION)
@AutoCreate
public class Encryption {
private final String ALGORITHM = "AES";
private byte[] keyValue;
@Out
private Encryption ssoEncryption;
public Encryption(){
try {
this.generateKey();
} catch (Exception e) {
e.printStackTrace();
}
}
@Observer("org.jboss.seam.postInitialization")
public void createInstance(){
setSsoEncryption(new Encryption());
}I have a web service that is running and accepting requests.
Here is the start of that:
@WebService(serviceName = "MetawareLoginService", endpointInterface = "com.company.webservice.login.MetawareLoginServiceManager")
@Stateless
@Startup
@SOAPBinding
(
style = SOAPBinding.Style.DOCUMENT,
use = SOAPBinding.Use.LITERAL,
parameterStyle = SOAPBinding.ParameterStyle.WRAPPED
)
@Remote(MetawareLoginServiceManager.class)
public class MetawareLoginService extends Service{
private final static URL METAWARELOGINSERVICE_WSDL_LOCATION;
@In(scope=ScopeType.APPLICATION)
private Encryption ssoEncryption;but when i try to access ssoEncryption it is always null.
I've also tried:
ssoEncryption = (Encryption)Component.getInstance("ssoEncryption");but that returns with:
javax.ejb.EJBException: java.lang.IllegalStateException: No application context active
Any Ideas how to get my ssoEncryption object into my web service?
Found the solution to my problem here:
http://seamframework.org/Community/WebServiceJavalangIllegalStateExceptionNoApplicationContextActive