I´m using Vaadin 7.5.8 on Wildfly 9.0.2. In our application we need Push support, so I´ve added the maven dependency
<groupId>com.vaadin</groupId>
<artifactId>vaadin-push</artifactId>
and added PushMode Parameter to servlet initialization.
#WebServlet(value = {"/ui/*", "/VAADIN/*"}, asyncSupported = true, initParams = {
#WebInitParam(name = "UIProvider", value = "com.vaadin.cdi.CDIUIProvider"),
#WebInitParam(name = "pushmode", value = "automatic")})
On application start i will see the login page of our application. From this point each action that causes a server communication end with this error:
Caused by: javax.enterprise.context.ContextNotActiveException: WebBeans context with scope type annotation #SessionScoped does not exist within current thread
at org.apache.webbeans.container.BeanManagerImpl.getContext(BeanManagerImpl.java:330) ~[openwebbeans-impl-1.2.7.jar:1.2.7]
at org.apache.webbeans.intercept.NormalScopedBeanInterceptorHandler.getContextualInstance(NormalScopedBeanInterceptorHandler.java:88) ~[openwebbeans-impl-1.2.7.jar:1.2.7]
at org.apache.webbeans.intercept.NormalScopedBeanInterceptorHandler.get(NormalScopedBeanInterceptorHandler.java:70) ~[openwebbeans-impl-1.2.7.jar:1.2.7]
at com.vaadin.cdi.internal.BeanStoreContainer$$OwbNormalScopeProxy0.getUIBeanStore(com/vaadin/cdi/internal/BeanStoreContainer.java) ~[na:1.0.3]
at com.vaadin.cdi.internal.UIScopedContext.get(UIScopedContext.java:97) ~[vaadin-cdi-1.0.0.alpha2.jar:1.0.3]
at org.apache.webbeans.container.BeanManagerImpl.getReference(BeanManagerImpl.java:754) ~[openwebbeans-impl-1.2.7.jar:1.2.7]
at org.apache.webbeans.inject.instance.InstanceImpl.get(InstanceImpl.java:139) ~[openwebbeans-impl-1.2.7.jar:1.2.7]
Everything works fine, when i remove the push parameter from the servlet configuration. Is there something wrong with my push configuration?
your problem is likely caused by the VaadinUI attempting an asynchronous push to the client while the session context is not active. Try switching to async-supported false to use polling rather than true async push.
This is a limitation of the Vaadin CDI plugin unfortunately, the async push wasn't designed with scope implementations in mind.
-Juuso
Related
I am trying to have a grails service method which does database commits while running instead of commiting everything at the end.
serviceMethode(){
status = 0
doFirst
status = 1
doSecond
status = 2
doThird
status = 3
}
I am experiencing that 1, and 2 are never persistend to the database, even though I am doing DomainObject.save(flush:true). My guess is that this is due to transaction handling. How can i persist values while the service-method is running rather than at the end of the method.
Annotate your service method with #NotTransactional
We're currently using Grails 2.3.4 with ActiveMQ 5.7.0 and JMS Plugin 1.2, to successfully receive message maps by queues.
Now we want to switch to a "virtual topic" based scenario - and fail miserably, when it comes to receiving by Grails...
Standard Camel tests work, so the sending side seems ok.
Addendum: we use "selector-aware" configuration.
E. g. for a "queue-like" access to the "virtual topics" we need to set the "static messageSelector", but accessing the ActiveMQ by JMX never shows any value for the selector.
Has anyone had any experience using the ActiveMQ "virtual topic" with Grails!?
In addition, just recently I found that "grails-jms /src/groovy/grails/plugin/jms/listener/ListenerConfig.groovy" shows some strange code (see below).
Is there some Groovy woodoo at work or is it just an error?
def registerListenerContainer(beanBuilder) {
beanBuilder.with {
"${listenerContainerBeanName}"() {
it.parent = ref(containerParent + JmsListenerContainerAbstractBeanDefinitionBuilder.nameSuffix)
it.'abstract' = false
it.destroyMethod = "destroy"
destinationName = this.destinationName
pubSubDomain = topic
// (( ????????????
if (messageSelector) {
messageSelector = messageSelector
}
// )) ????????????
messageListener = ref(listenerAdapterBeanName)
}
}
}
Thanks for any help, comment, thought, whatsoever...
When I try run this script to secure my web services on Grails / CXF client I get
"Cannot invoke method getInInterceptors() on null object" on secureServiceFactory
Does secureServiceFactory need to be set somewhere else?
Any ideas:
Code :
class BootStrap {
def secureServiceFactory
def init = { servletContext ->
Map<String, Object> inProps = [:]
inProps.put(WSHandlerConstants.ACTION, WSHandlerConstants.USERNAME_TOKEN);
inProps.put(WSHandlerConstants.PASSWORD_TYPE, WSConstants.PW_TEXT);
Map<QName, Validator> validatorMap = new HashMap<QName, Validator>();
validatorMap.put(WSSecurityEngine.USERNAME_TOKEN, new UsernameTokenValidator() {
#Override
protected void verifyPlaintextPassword(org.apache.ws.security.message.token.UsernameToken usernameToken, org.apache.ws.security.handler.RequestData data)
throws org.apache.ws.security.WSSecurityException {
if(data.username == "wsuser" && usernameToken.password == "secret") {
println "username and password are correct!"
} else {
println "username and password are NOT correct..."
throw new WSSecurityException("user and/or password mismatch")
}
}
});
inProps.put(WSS4JInInterceptor.VALIDATOR_MAP, validatorMap);
secureServiceFactory.getInInterceptors().add(new WSS4JInInterceptor(inProps))
}
Not sure this is a total answer, but, I receive the same errors and I understand that the cxf plugin is meant to wire up service factories that will match the name of your exposed service. I have verified that out of the box, running the grails-cxf plugin using grails run-app the application works. however, by executing grails war on the project creates a war that when deployed to tc server [vfabric-tc-server-developer-2.9.4.RELEASE] tomcat 7 [tomcat-7.0.47.A.RELEASE], this error occurs.
It is also useful to note that out of the box, as the plugin author has noted in other references [http://www.christianoestreich.com/2012/04/grails-cxf-interceptor-injection/] the generated war won't work unless you change test('org.apache.ws.security:wss4j:1.6.7') to compile('org.apache.ws.security:wss4j:1.6.7') and I note that I was unable to make that work, I had to use compile('org.apache.ws.security:wss4j:1.6.9')
Unfortunately, after surpassing this, I run into a third error when deploying the war that doesn't occur in grails run-app:
22-Aug-2014 11:46:05.062 SEVERE [tomcat-http--1] org.apache.catalina.core.StandardWrapperValve.invoke Allocate exception for servlet CxfServlet
org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'cxf' is defined
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanDefinition(DefaultListableBeanFactory.java:641)
at org.springframework.beans.factory.support.AbstractBeanFactory.getMergedLocalBeanDefinition(AbstractBeanFactory.java:1159)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:282)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:273)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200)
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:979)
at org.apache.cxf.transport.servlet.CXFServlet.loadBus(CXFServlet.java:75)
I'll continue looking at it, but perhaps this war isn't meant to really deploy, but is more meant just for development of the plugin itself. however, if that is the case, it would still be better to work in TC because then we can leverage the code in our own projects with confidence.
We have a server that processes portfolio and securities (inside it) in different actors. For portfolio with smaller number of securities (<20) this works fine. When i increase the number of security count to 1000, encountered following issues:
akka.dispatch.FutureTimeoutException: Futures timed out after [5000] milliseconds
I could bypass this error by increasing timeout inside akka config, is that the right thing to do? In akka versions earlier than 1.2 i could set self.timeout inside the actor but that is deprecated.
The other issue I faced (intermittently) is that the entire server hangs while joining in futures.map code inside my portfolio actor:
//fork out for each security
val listOfFutures = new ListBuffer[Future[Security]]()
for (security <- portfolio.getSecurities.toList) {
val securityProcessor = actorOf[SecurityProcessor].start()
listOfFutures += (securityProcessor ? security) map {
_.asInstanceOf[Security]
}
}
EventHandler.info(this,"joining results from security processors")
//join for each security
val futures = Future.sequence(listOfFutures.toList)
futures.map {
listOfSecurities =>
portfolioResponse = MergeHelper.merge(portfolio, listOfSecurities)
}.get
You do not state which version of Akka you're on, and given my limited time with the crystal ball I'll assume that you're on 1.2.
You can specify a Timeout when you call ask/?
(Also, your code is a bit convoluted, but that I have already solved in your other question.)
Cheers,
√
We have a custom data source that extends BasicDataSource. We have overridden the getConnection method which does a couple things inside of it. When we run the webapp outside of testing, when we call a service from a controller it will grab a new connection and use that connection until the service is done. All is well. However, inside an integration test, the connection appears to be grabbed before the test even calls the controller. Flow below
Regular Run:
call controller -> controller calls service method -> connection is grabbed -> service method is run and returns to controller
Integration Test:
connection is grabbed -> call controller from test -> controller calls service method -> service method is run and returns to controller
Needless to say, this is giving us problems as having the correct connection is very important for our app. Thoughts?
Edit: Still getting significant issues with this. We've reached a point where we have to avoid creating integration tests, or do some manual connection switching (which defeats half the point of the tests)
DataSource.groovy
dataSource {
pooled = true
dialect="org.hibernate.dialect.OracleDialect"
properties {
maxActive = 50
maxIdle = 10
initialSize = 10
minEvictableIdleTimeMillis = 1800000
timeBetweenEvictionRunsMillis = 1800000
maxWait = 10000
testWhileIdle = true
numTestsPerEvictionRun = 3
testOnBorrow = true
}
}
hibernate {
cache.use_second_level_cache = true
cache.use_query_cache = true
cache.provider_class = 'net.sf.ehcache.hibernate.EhCacheProvider'
}
This is not a final Answer, however I believe this is an explanation of what is going on:
Running as Web app: your Service class has a transactionManager which has a sessionFactory, which gets the connection! So in this case, assuming that you Service is 'transactional=true' all methods that you call in your services will have a 'Session.beginTransaction()' in the beginning of the method(there is a Grails`s Proxy to do that, when you set 'transactional=true'), which will call all that stack until getConnection().
Running as Integration Test: as Grails doesnt commit your DB changes, it always rollback them! I believe that when you are starting your Integration test, grails is creating a transaction right away! so it will be able to rollback it afterwards!(which make totally sense right!), you can confirm that taking a look at the class org.codehaus.groovy.grails.test.support.GrailsTestInterceptor. The method init() is called before your services in your integration test. So that`s why getConnection() is being called before everything!
Suggestion:
You can try setting your integration test class as 'transaction=false' and see if getConnection() doesn't get call in the beginning!
Go to Transactions section in here to see more!
Just dont forget that in your test you will have to rollback your transaction! if your set transaction=false.