JSF 2.1 Spring Session Scope - java

I have the following confguration in my JSF Spring application:
<bean id="userSessionBean" class="com.vanilla.beans.UserSessionBean" scope="session">
<aop:scoped-proxy/>
</bean>
Then I ha have Spring bean
#Service("userService")
public class UserServiceImpl implements UserService,Serializable{
#Autowired
private UserSessionBean userSessionBean;
public String getCurrentUser(){
return this.userSessionBean.getUserName;
}
}
Now I have my managed bean:
#ManagedBean(name="userBean")
#RequestScoped
public class UserBean {
#ManagedProperty(value="#{userService}")
UserService userService;
public Sttring getUserName(){
return userService.getCurrentUser();
}
}
then I have xhtml
<h:outputText value="#{userBeanBean.userName}" />
All my flow works fine, but when my session expires I'm getting the following error and I'm clicking on refresh I have the following stacktrace:
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'scopedTarget.userSessionBean': Scope 'session' is not active for the current thread; consider defining a scoped proxy for this bean if you intend to refer to it from a singleton; nested exception is java.lang.IllegalStateException: Cannot create a session after the response has been committed
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:339)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
at org.springframework.aop.target.SimpleBeanTargetSource.getTarget(SimpleBeanTargetSource.java:33)
at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.getTarget(Cglib2AopProxy.java:653)
at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:604)
at com.vanilla.beans.UserSessionBean$$EnhancerByCGLIB$$fe05fe49.getCurrentMokdanName(<generated>)
at com.vanilla.bl.UserServiceImpl.getCurrentUser(UserServiceImpl.java:37)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:309)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
at $Proxy18.getCurrentMokedUser(Unknown Source)
at com.ewave.upromotions.beans.MokedBean.getMokedName(MokedBean.java:70)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at javax.el.BeanELResolver.getValue(BeanELResolver.java:83)
at com.sun.faces.el.DemuxCompositeELResolver._getValue(DemuxCompositeELResolver.java:176)
at com.sun.faces.el.DemuxCompositeELResolver.getValue(DemuxCompositeELResolver.java:203)
at org.apache.el.parser.AstValue.getValue(AstValue.java:123)
at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:186)
at com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:109)
... 43 more
Caused by: java.lang.IllegalStateException: Cannot create a session after the response has been committed
at org.apache.catalina.connector.Request.doGetSession(Request.java:2400)
at org.apache.catalina.connector.Request.getSession(Request.java:2120)
at org.apache.catalina.connector.RequestFacade.getSession(RequestFacade.java:833)
at org.springframework.web.context.request.ServletRequestAttributes.getSession(ServletRequestAttributes.java:79)
at org.springframework.web.context.request.ServletRequestAttributes.getSessionMutex(ServletRequestAttributes.java:211)
at org.springframework.web.context.request.SessionScope.get(SessionScope.java:90)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:325)
... 73 more
Can I solve it somehow?

Please add this:
<listener>
<listener-class>
org.springframework.web.context.request.RequestContextListener
</listener-class>
</listener>
To your web.xml
If that will not help please add more info about your web.xml and jsf config.

Related

Method of local ejb threw exception

We are migrating our java applications from WAS 7 to WAS 8.5. After logging into one of our application we are calling a local ejb method from controller to get details for an id. The method gets called,it queries the data, but when returning to controller it errors out giving, Method of local EJB threw exception. Would be great if someone could shed some light on the issue. I have checked multiple forums, but couldn't get a proper explanation. Below is the stack trace.
I've mentioned some places as "package name" as it cannot be shared.
javax.ejb.TransactionRolledbackLocalException: ; nested exception is: javax.transaction.SystemException
at com.ibm.tx.jta.impl.TransactionImpl.stage3CommitProcessing(TransactionImpl.java:1251)
at com.ibm.tx.jta.impl.TransactionImpl.processCommit(TransactionImpl.java:1042)
at com.ibm.tx.jta.impl.TransactionImpl.commit(TransactionImpl.java:963)
at com.ibm.ws.tx.jta.TranManagerImpl.commit(TranManagerImpl.java:439)
at com.ibm.tx.jta.impl.TranManagerSet.commit(TranManagerSet.java:191)
at com.ibm.ejs.csi.TranStrategy.commit(TranStrategy.java:949)
at com.ibm.ejs.csi.TranStrategy.postInvoke(TranStrategy.java:262)
at com.ibm.ejs.csi.RequiresNew.postInvoke(RequiresNew.java:154)
at com.ibm.ejs.csi.TransactionControlImpl.postInvoke(TransactionControlImpl.java:567)
at com.ibm.ejs.container.EJSContainer.postInvoke(EJSContainer.java:4491)
at <package name>EJSLocalStatelessInvestigationProcessingService_8d39cc4e.epGetDetailsForInvestigationProcessing(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:95)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:56)
at java.lang.reflect.Method.invoke(Method.java:620)
at org.springframework.ejb.access.LocalSlsbInvokerInterceptor.invokeInContext(LocalSlsbInvokerInterceptor.java:70)
at org.springframework.ejb.access.AbstractSlsbInvokerInterceptor.invoke(AbstractSlsbInvokerInterceptor.java:188)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
at com.sun.proxy.$Proxy28.epGetDetailsForInvestigationProcessing(Unknown Source)
at <package name>.processGetRequest(MaintainInvestigationController.java:286)
at com.pmigroup.jpmiframework.web.mvc.controller.ApplMultiActionFormController.showForm(ApplMultiActionFormController.java:269)
at org.springframework.web.servlet.mvc.AbstractFormController.showNewForm(AbstractFormController.java:338)
at org.springframework.web.servlet.mvc.AbstractFormController.handleRequestInternal(AbstractFormController.java:278)
at org.springframework.web.servlet.mvc.AbstractController.handleRequest(AbstractController.java:153)
at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:48)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:875)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:807)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:571)
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:501)
The caused by trace is as follows.
Caused by: javax.ejb.TransactionRolledbackLocalException: ; nested exception is: javax.transaction.SystemException
at com.ibm.tx.jta.impl.TransactionImpl.stage3CommitProcessing(TransactionImpl.java:1251)
at com.ibm.tx.jta.impl.TransactionImpl.processCommit(TransactionImpl.java:1042)
at com.ibm.tx.jta.impl.TransactionImpl.commit(TransactionImpl.java:963)
at com.ibm.ws.tx.jta.TranManagerImpl.commit(TranManagerImpl.java:439)
at com.ibm.tx.jta.impl.TranManagerSet.commit(TranManagerSet.java:191)
at com.ibm.ejs.csi.TranStrategy.commit(TranStrategy.java:949)
at com.ibm.ejs.csi.TranStrategy.postInvoke(TranStrategy.java:262)
at com.ibm.ejs.csi.RequiresNew.postInvoke(RequiresNew.java:154)
at com.ibm.ejs.csi.TransactionControlImpl.postInvoke(TransactionControlImpl.java:567)
at com.ibm.ejs.container.EJSContainer.postInvoke(EJSContainer.java:4491)
at <package_name>EJSLocalStatelessInvestigationProcessingService_8d39cc4e.epGetDetailsForInvestigationProcessing(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:95)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:56)
at java.lang.reflect.Method.invoke(Method.java:620)
at org.springframework.ejb.access.LocalSlsbInvokerInterceptor.invokeInContext(LocalSlsbInvokerInterceptor.java:70)
at org.springframework.ejb.access.AbstractSlsbInvokerInterceptor.invoke(AbstractSlsbInvokerInterceptor.java:188)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
at com.sun.proxy.$Proxy28.epGetDetailsForInvestigationProcessing(Unknown Source)
at <package_name>.processGetRequest(MaintainInvestigationController.java:286)
at <package_name>.showForm(ApplMultiActionFormController.java:269)

Remove dependency on Jackson

In Spring-MVC you have the ability to remove the Jackson library as a dependency and replace it with your own using this method:
protected void configureMessageConverters(List<HttpMessageConverter<?>> converters)
I am trying to do the same thing for Spring-Websocket so I have overridden both of these methods:
#Bean public CompositeMessageConverter brokerMessageConverter()
protected boolean configureMessageConverters(List<MessageConverter> messageConverters)
However there is still a dependency on Jackson somewhere and I can't figure out where.
EDIT
Here is a stack trace:
Caused by: java.lang.NoClassDefFoundError: com/fasterxml/jackson/databind/JsonMappingException
at org.springframework.web.socket.sockjs.transport.handler.DefaultSockJsService.getDefaultTransportHandlers(DefaultSockJsService.java:81)
at org.springframework.web.socket.sockjs.transport.handler.DefaultSockJsService.<init>(DefaultSockJsService.java:74)
at org.springframework.web.socket.config.annotation.SockJsServiceRegistration.createSockJsService(SockJsServiceRegistration.java:231)
at org.springframework.web.socket.config.annotation.SockJsServiceRegistration.getSockJsService(SockJsServiceRegistration.java:198)
at org.springframework.web.socket.config.annotation.WebMvcStompWebSocketEndpointRegistration$StompSockJsServiceRegistration.getSockJsService(WebMvcStompWebSocketEndpointRegistration.java:113)
at org.springframework.web.socket.config.annotation.WebMvcStompWebSocketEndpointRegistration.getMappings(WebMvcStompWebSocketEndpointRegistration.java:87)
at org.springframework.web.socket.config.annotation.WebMvcStompEndpointRegistry.getHandlerMapping(WebMvcStompEndpointRegistry.java:122)
at org.springframework.web.socket.config.annotation.WebSocketMessageBrokerConfigurationSupport.stompWebSocketHandlerMapping(WebSocketMessageBrokerConfigurationSupport.java:60)
at com.test.wsb.config.WebsocketConfig$$EnhancerBySpringCGLIB$$b414d315.CGLIB$stompWebSocketHandlerMapping$4(<generated>)
at com.test.wsb.config.WebsocketConfig$$EnhancerBySpringCGLIB$$b414d315$$FastClassBySpringCGLIB$$f17bc7ca.invoke(<generated>)
at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228)
at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:312)
at com.test.wsb.config.WebsocketConfig$$EnhancerBySpringCGLIB$$b414d315.stompWebSocketHandlerMapping(<generated>)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:166)
SPR-11963 has been created following this question, and is now resolved.
This has landed in Spring Framework 4.0.6.

C3P0 + Hibernate ClassNotFoundException: com.mchange.v2.log.MLog

I set up a Java EE DAL as a jar library. I used JPA + Hibernate + C3P0 for the connection pool management. The EntityManager class is produced by the following bean
package my.dal;
import javax.enterprise.inject.Alternative;
import javax.enterprise.inject.Default;
import javax.enterprise.inject.Produces;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
import javax.persistence.PersistenceContext;
#Alternative
#Default
public class EntityManagerProvider {
private EntityManager entityManager;
#Default
#Produces
#PersistenceContext
public EntityManager getEntityManager() {
if(entityManager == null) {
EntityManagerFactory emf = Persistence.createEntityManagerFactory("DALPersistenceUnit");
entityManager = emf.createEntityManager();
}
return entityManager;
}
}
A DAO class, then, injects the EntityManager and uses it
package my.dal.dao;
#Default
public class UserDAO {
#Inject private EntityManager entityManager;
public User find(String username)
{
...
}
...
}
These are the C3P0 dependencies set in the pom.xml
<dependency>
<groupId>com.mchange</groupId>
<artifactId>c3p0</artifactId>
<version>0.9.2.1</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-c3p0</artifactId>
<version>4.3.5.Final</version>
</dependency>
<dependency>
<groupId>com.mchange</groupId>
<artifactId>mchange-commons-java</artifactId>
<version>0.2.3.4</version>
</dependency>
I wrote a test class (named DALUserTest) which injects the DAO class and uses it to persist data on a DB. The problem is that whenever I try to run the test, the application stops at the injection step throwing the following exception stack
javax.enterprise.inject.CreationException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at java.lang.Class.newInstance(Unknown Source)
at org.jboss.weld.security.NewInstanceAction.run(NewInstanceAction.java:33)
at java.security.AccessController.doPrivileged(Native Method)
at org.jboss.weld.injection.Exceptions.rethrowException(Exceptions.java:40)
at org.jboss.weld.injection.Exceptions.rethrowException(Exceptions.java:78)
at org.jboss.weld.injection.MethodInjectionPoint.invokeOnInstanceWithSpecialValue(MethodInjectionPoint.java:101)
at org.jboss.weld.injection.MethodInjectionPoint.invokeOnInstance(MethodInjectionPoint.java:86)
at org.jboss.weld.injection.producer.ProducerMethodProducer.produce(ProducerMethodProducer.java:96)
at org.jboss.weld.injection.producer.AbstractMemberProducer.produce(AbstractMemberProducer.java:151)
at org.jboss.weld.bean.AbstractProducerBean.create(AbstractProducerBean.java:183)
at org.jboss.weld.context.unbound.DependentContextImpl.get(DependentContextImpl.java:69)
at org.jboss.weld.manager.BeanManagerImpl.getReference(BeanManagerImpl.java:733)
at org.jboss.weld.manager.BeanManagerImpl.getReference(BeanManagerImpl.java:789)
at org.jboss.weld.injection.FieldInjectionPoint.inject(FieldInjectionPoint.java:92)
at org.jboss.weld.util.Beans.injectBoundFields(Beans.java:358)
at org.jboss.weld.util.Beans.injectFieldsAndInitializers(Beans.java:369)
at org.jboss.weld.injection.producer.DefaultInjector.inject(DefaultInjector.java:72)
at org.jboss.weld.injection.producer.ResourceInjector.inject(ResourceInjector.java:60)
at org.jboss.weld.injection.producer.DefaultInjector$1.proceed(DefaultInjector.java:66)
at org.jboss.weld.injection.InjectionContextImpl.run(InjectionContextImpl.java:48)
at org.jboss.weld.injection.producer.DefaultInjector.inject(DefaultInjector.java:64)
at org.jboss.weld.injection.producer.BasicInjectionTarget.inject(BasicInjectionTarget.java:90)
at org.jboss.weld.bean.ManagedBean.create(ManagedBean.java:150)
at org.jboss.weld.context.unbound.DependentContextImpl.get(DependentContextImpl.java:69)
at org.jboss.weld.manager.BeanManagerImpl.getReference(BeanManagerImpl.java:733)
at org.jboss.weld.manager.BeanManagerImpl.getReference(BeanManagerImpl.java:789)
at org.jboss.weld.injection.FieldInjectionPoint.inject(FieldInjectionPoint.java:92)
at org.jboss.weld.util.Beans.injectBoundFields(Beans.java:358)
at org.jboss.weld.util.Beans.injectFieldsAndInitializers(Beans.java:369)
at org.jboss.weld.injection.producer.DefaultInjector.inject(DefaultInjector.java:72)
at org.jboss.weld.injection.producer.ResourceInjector.inject(ResourceInjector.java:60)
at org.jboss.weld.injection.producer.DefaultInjector$1.proceed(DefaultInjector.java:66)
at org.jboss.weld.injection.InjectionContextImpl.run(InjectionContextImpl.java:48)
at org.jboss.weld.injection.producer.DefaultInjector.inject(DefaultInjector.java:64)
at org.jboss.weld.injection.producer.BasicInjectionTarget.inject(BasicInjectionTarget.java:90)
at org.jboss.weld.bean.ManagedBean.create(ManagedBean.java:150)
at org.jboss.weld.context.AbstractContext.get(AbstractContext.java:96)
at org.jboss.weld.bean.proxy.ContextBeanInstance.getInstance(ContextBeanInstance.java:98)
at org.jboss.weld.bean.proxy.ProxyMethodHandler.invoke(ProxyMethodHandler.java:78)
at my.dal.test.DALUserTest$Proxy$_$$_WeldClientProxy.testInsert(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.jglue.cdiunit.CdiRunner$2.evaluate(CdiRunner.java:139)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: java.lang.NoClassDefFoundError: com/mchange/v2/log/MLog
at com.mchange.v2.c3p0.DataSources.<clinit>(DataSources.java:72)
at org.hibernate.c3p0.internal.C3P0ConnectionProvider.configure(C3P0ConnectionProvider.java:203)
at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:89)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:206)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:178)
at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.buildJdbcConnectionAccess(JdbcServicesImpl.java:260)
at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:94)
at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:89)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:206)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:178)
at org.hibernate.cfg.Configuration.buildTypeRegistrations(Configuration.java:1885)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1843)
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl$4.perform(EntityManagerFactoryBuilderImpl.java:850)
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl$4.perform(EntityManagerFactoryBuilderImpl.java:843)
at org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl.withTccl(ClassLoaderServiceImpl.java:399)
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:842)
at org.hibernate.jpa.HibernatePersistenceProvider.createEntityManagerFactory(HibernatePersistenceProvider.java:75)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:79)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:54)
at my.dal.EntityManagerProvider.getEntityManager(EntityManagerProvider.java:22)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.jboss.weld.injection.MethodInjectionPoint.invokeOnInstanceWithSpecialValue(MethodInjectionPoint.java:93)
... 58 more
Caused by: java.lang.ClassNotFoundException: com.mchange.v2.log.MLog
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 83 more
I googled a lot but nothing helped me solving this issue.
What do you think the problem could be?
Thank you
Download mchange-commons-java-0.2.16.jar to resolve the error java.lang.NoClassDefFoundError: com/mchange/v2/log/MLog

RPC is not working

i am new to gwt and trying to implement RPC .
on button click on HomePage
public void onClick(ClickEvent event) {
/* 1.*/ cService.getRepositories(repocallback);
// 2. fService.getRepositories(repocallback);
}
});
1st one is working fine.
(HomePage.java:195) 2012-03-01 14:29:45,988 [FATAL] Uncaught Exception:
com.google.gwt.event.shared.UmbrellaException: One or more exceptions caught, see full set in UmbrellaException#getCauses
at com.google.gwt.event.shared.HandlerManager.fireEvent(HandlerManager.java:129)
at com.google.gwt.user.client.ui.Widget.fireEvent(Widget.java:129)
at com.google.gwt.event.dom.client.DomEvent.fireNativeEvent(DomEvent.java:116)
at com.google.gwt.user.client.ui.Widget.onBrowserEvent(Widget.java:177)
at com.google.gwt.user.client.DOM.dispatchEventImpl(DOM.java:1351)
at com.google.gwt.user.client.DOM.dispatchEvent(DOM.java:1307)
at sun.reflect.GeneratedMethodAccessor49.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)
at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessagesWhileWaitingForReturn(BrowserChannelServer.java:337)
at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:218)
at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:136)
at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:561)
at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:269)
at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:91)
at com.google.gwt.core.client.impl.Impl.apply(Impl.java)
at com.google.gwt.core.client.impl.Impl.entry0(Impl.java:213)
at sun.reflect.GeneratedMethodAccessor31.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)
at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessages(BrowserChannelServer.java:292)
at com.google.gwt.dev.shell.BrowserChannelServer.processConnection (BrowserChannelServer.java:546)
at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:363)
at java.lang.Thread.run(Thread.java:662)
Caused by: java.lang.NullPointerException
at com.client.GUI.HomePage$7.onClick(HomePage.java:195)
at com.google.gwt.event.dom.client.ClickEvent.dispatch(ClickEvent.java:54)
at com.google.gwt.event.dom.client.ClickEvent.dispatch(ClickEvent.java:1)
at com.google.gwt.event.shared.GwtEvent.dispatch(GwtEvent.java:1)
at com.google.web.bindery.event.shared.EventBus.dispatchEvent(EventBus.java:40)
at com.google.web.bindery.event.shared.SimpleEventBus.doFire(SimpleEventBus.java:193)
at com.google.web.bindery.event.shared.SimpleEventBus.fireEvent(SimpleEventBus.java:88)
at com.google.gwt.event.shared.HandlerManager.fireEvent(HandlerManager.java:127)
at com.google.gwt.user.client.ui.Widget.fireEvent(Widget.java:129)
at com.google.gwt.event.dom.client.DomEvent.fireNativeEvent(DomEvent.java:116)
at com.google.gwt.user.client.ui.Widget.onBrowserEvent(Widget.java:177)
at com.google.gwt.user.client.DOM.dispatchEventImpl(DOM.java:1351)
at com.google.gwt.user.client.DOM.dispatchEvent(DOM.java:1307)
at sun.reflect.GeneratedMethodAccessor49.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)
at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessagesWhileWaitingForReturn(BrowserChannelServer.java:337)
at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:218)
at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:136)
at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:561)
at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:269)
at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:91)
at com.google.gwt.core.client.impl.Impl.apply(Impl.java)
at com.google.gwt.core.client.impl.Impl.entry0(Impl.java:213)
at sun.reflect.GeneratedMethodAccessor31.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)
at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessages(BrowserChannelServer.java:292)
at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:546)
at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:363)
at java.lang.Thread.run(Thread.java:662)
When i comment 1st and try to use 2nd its give s me error.
Initially i wrote all the methods in one class on the server side.. now i am making diffrent class and adding their methods which should related to them.
on server side
1st class is for connection : which is working fine
2 class is for Folders with delete update add methods.
both the class extends RemoteServiceServlet.
i dont know whether i have to add something on web.xml , if there are two classes with "extends RemoteServiceServlet",
help me to solve my problem.
If neone need more details plz tell me , i will edit it.
edited___
public class FService implements FInterfaceAsync {
FInterfaceAsync service =(FInterfaceAsync)GWT.create(FInterface.class);
ServiceDefTarget endpoint = (ServiceDefTarget) service;
public FService(){
endpoint.setServiceEntryPoint(GWT.getModuleBaseURL() + "folderService");
}
public void getRepositories(
AsyncCallback<FCollection> repositoryCallback) {
// TODO Auto-generated method stub
service.getRepositories(repositoryCallback);
}
}
XML FIle
my WEB.xml is
<servlet>
<servlet-name>CServlet</servlet-name>
<servlet-class>com.server.CServiceImpl</servlet-class>
</servlet>
<servlet>
<servlet-name>FServlet</servlet-name>
<servlet-class>com.server.FServiceImpl</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>CServlet</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>FServlet</servlet-name>
<url-pattern>/FServiceImpl</url-pattern>
</servlet-mapping>
CServlet is working fine
Wild guess here, but it seems your fService might be null. How are you creating it? Are you using GWT.create(FService.class);?
By the way, yes, all your servlets (including the RPC ones) must be declared in web.xml.
Your remote service interface must also be annotated with #RemoteServiceRelativePath("path").
EDIT: it seems <url-pattern>/FilenetFolderServiceImpl</url-pattern> in your web.xml should also be /{moduleBaseURL}/folderService, where {moduleBaseURL} is usually the name of your project (or similar).
Finally i solved it was mistake in my coding.
I didnt initailize the FService with new FService();
private static FService fService = new FService();

Has anyone successfully deployed Sonar on Jetty 7?

I am trying to deploy Sonar (automatic code monitoring tool) on a Jetty 7 servlet container.
I would like to use the default config first (embedded Derby DB) as a POC and transition to a production grade DB later.
So far I have tried various ways to make this work (todo: document failed attempts) without any luck...
Did anyone managed to pull this off?
This is the exception I get by deploying in jetty/webapps and launching with
java -DOPTIONS=Server,deploy,jsp -jar start.jar etc/jetty.xml
org.picocontainer.PicoLifecycleException: PicoLifecycleException: method 'public void org.sonar.core.database.JndiDatabaseConnector.start()', instance 'org.sonar.core.database.JndiDatabaseConnector#1f1a3a8, java.lang.RuntimeException: wrapper
at org.picocontainer.monitors.NullComponentMonitor.lifecycleInvocationFailed(NullComponentMonitor.java:76)
at org.picocontainer.lifecycle.ReflectionLifecycleStrategy.monitorAndThrowReflectionLifecycleException(ReflectionLifecycleStrategy.java:129)
at org.picocontainer.lifecycle.ReflectionLifecycleStrategy.invokeMethod(ReflectionLifecycleStrategy.java:115)
at org.picocontainer.lifecycle.ReflectionLifecycleStrategy.start(ReflectionLifecycleStrategy.java:89)
at org.picocontainer.injectors.AbstractInjector.start(AbstractInjector.java:131)
at org.picocontainer.behaviors.AbstractBehavior.start(AbstractBehavior.java:173)
at org.picocontainer.behaviors.Stored$RealComponentLifecycle.start(Stored.java:134)
at org.picocontainer.behaviors.Stored.start(Stored.java:111)
at org.picocontainer.DefaultPicoContainer.startAdapters(DefaultPicoContainer.java:882)
at org.picocontainer.DefaultPicoContainer.start(DefaultPicoContainer.java:630)
at org.sonar.core.Application.start(Application.java:57)
at org.sonar.web.listeners.ApplicationListener.contextInitialized(ApplicationListener.java:42)
at org.eclipse.jetty.server.handler.ContextHandler.startContext(ContextHandler.java:627)
at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:189)
at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1200)
at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:585)
at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:334)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:55)
at org.eclipse.jetty.server.handler.HandlerCollection.doStart(HandlerCollection.java:164)
at org.eclipse.jetty.server.handler.ContextHandlerCollection.doStart(ContextHandlerCollection.java:161)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:55)
at org.eclipse.jetty.server.handler.HandlerCollection.doStart(HandlerCollection.java:164)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:55)
at org.eclipse.jetty.server.handler.HandlerWrapper.doStart(HandlerWrapper.java:92)
at org.eclipse.jetty.server.Server.doStart(Server.java:221)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:55)
at org.eclipse.jetty.xml.XmlConfiguration.main(XmlConfiguration.java:979)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.jetty.start.Main.invokeMain(Main.java:248)
at org.eclipse.jetty.start.Main.start(Main.java:637)
at org.eclipse.jetty.start.Main.main(Main.java:138)
Caused by: java.lang.RuntimeException: wrapper
at org.picocontainer.lifecycle.ReflectionLifecycleStrategy.monitorAndThrowReflectionLifecycleException(ReflectionLifecycleStrategy.java:127)
... 32 more
Caused by: org.sonar.commons.database.JndiException: Can not bind JDBC datasource to JNDI
at org.sonar.core.database.JndiDatabaseConnector.createAndBindDatasource(JndiDatabaseConnector.java:124)
at org.sonar.core.database.JndiDatabaseConnector.start(JndiDatabaseConnector.java:69)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.picocontainer.lifecycle.ReflectionLifecycleStrategy.invokeMethod(ReflectionLifecycleStrategy.java:110)
... 31 more
Caused by: javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
at javax.naming.InitialContext.getURLOrDefaultInitCtx(Unknown Source)
at javax.naming.InitialContext.lookup(Unknown Source)
at org.sonar.core.database.JndiDatabaseConnector.createJNDISubContexts(JndiDatabaseConnector.java:177)
at org.sonar.core.database.JndiDatabaseConnector.createAndBindDatasource(JndiDatabaseConnector.java:118)
... 37 more
And this is what I get by deploying in webappls-plus and launching with:
java -DOPTIONS=Server,deploy,jsp -jar start.jar etc/jetty.xml etc/jetty-plus.xml
java.lang.ClassNotFoundException: org.eclipse.jetty.plus.webapp.EnvConfiguration
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at org.eclipse.jetty.util.Loader.loadClass(Loader.java:90)
at org.eclipse.jetty.util.Loader.loadClass(Loader.java:70)
at org.eclipse.jetty.webapp.WebAppContext.loadConfigurations(WebAppContext.java:796)
at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:297)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:55)
at org.eclipse.jetty.server.handler.HandlerCollection.doStart(HandlerCollection.java:164)
at org.eclipse.jetty.server.handler.ContextHandlerCollection.doStart(ContextHandlerCollection.java:161)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:55)
at org.eclipse.jetty.server.handler.HandlerCollection.doStart(HandlerCollection.java:164)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:55)
at org.eclipse.jetty.server.handler.HandlerWrapper.doStart(HandlerWrapper.java:92)
at org.eclipse.jetty.server.Server.doStart(Server.java:221)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:55)
at org.eclipse.jetty.xml.XmlConfiguration.main(XmlConfiguration.java:979)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.jetty.start.Main.invokeMain(Main.java:248)
at org.eclipse.jetty.start.Main.start(Main.java:637)
at org.eclipse.jetty.start.Main.main(Main.java:138)
Sonar tries to bind its JDBC datasource to JNDI. But it seems that Jetty 7 needs some extra-configuration to allow this. See this thread for more details.
I hope it helps.

Categories

Resources