Does someone knows how this exception can be fixed?
I want to use mybatis under Liferay 7.4 and i am getting this exception which i dont understand how to fix this or what is the main problem.
I would really appreciate any help.
I use Liferay 7.4, Java Server Faces 2.2, Mybatis 3.5.11, Mysql Conector 8.0.30 and Tomcat 9.0.56
This is the code being used:
private void ermittleTabellePersonsMitMybatisMitJNDI() {
Thread thread = Thread.currentThread();
// Get the thread's class loader. You'll reinstate it after using
// the data source you look up using JNDI
ClassLoader origLoader = thread.getContextClassLoader();
// get the shielded class loader
ClassLoader shieldedClassLoader = PortalClassLoaderUtil.getClassLoader();
// get the webapp class loader from it
ClassLoader webappClassLoader = shieldedClassLoader.getClass().getClassLoader();
// Set webapp class loader on the thread
thread.setContextClassLoader(webappClassLoader);
DataSource datasource = null;
InitialContext ctx = null;
try {
// Look up the data source and connect to it
ctx = new InitialContext();
datasource = (DataSource) ctx.lookup("java:comp/env/jdbc/testdatabase");
} catch (NamingException ne) {
ne.printStackTrace();
}
Properties props = new Properties();
// props.put("data_source", datasource);
props.put("initial_context", ctx);
SqlSessionFactory sqlSessionFactory = null;
try {
Reader reader = Resources.getResourceAsReader("mybatis/config/SqlMapConfig.xml");
// sqlSessionFactory = new SqlSessionFactoryBuilder().build(reader);
sqlSessionFactory = new SqlSessionFactoryBuilder().build(reader, props);
} catch (Exception e) {
throw new RuntimeException("Fatal Error. Cause: " + e, e);
}
abfrageStellen(sqlSessionFactory);
thread.setContextClassLoader(origLoader);
}
Here is the stacktrace:
java.lang.IllegalStateException: Keine Factory als Backup für javax.faces.lifecycle.LifecycleFactory gefunden.
at javax.faces.FactoryFinderInstance.getFactory(FactoryFinderInstance.java:555)
at javax.faces.FactoryFinder.getFactory(FactoryFinder.java:283)
at com.sun.faces.lifecycle.ELResolverInitPhaseListener.afterPhase(ELResolverInitPhaseListener.java:99)
at com.sun.faces.lifecycle.Phase.handleAfterPhase(Phase.java:189)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:107)
at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:219)
at com.liferay.faces.bridge.internal.BridgePhaseHeaderRenderCommon.executeRender(BridgePhaseHeaderRenderCommon.java:253)
at com.liferay.faces.bridge.internal.BridgePhaseRenderCompatImpl.execute(BridgePhaseRenderCompatImpl.java:57)
at com.liferay.faces.bridge.internal.BridgePhaseRenderImpl.execute(BridgePhaseRenderImpl.java:57)
at com.liferay.faces.bridge.internal.BridgeImpl.doFacesRequest(BridgeImpl.java:157)
at javax.portlet.faces.GenericFacesPortlet.doView(GenericFacesPortlet.java:802)
at javax.portlet.GenericPortlet.doDispatch(GenericPortlet.java:397)
at javax.portlet.faces.GenericFacesPortlet.doDispatch(GenericFacesPortlet.java:718)
at javax.portlet.GenericPortlet.render(GenericPortlet.java:291)
at org.jboss.weldx.portlet.faces.GenericFacesPortlet$Proxy$_$$_WeldClientProxy.render(Unknown Source)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at com.liferay.bean.portlet.cdi.extension.internal.CDIBeanPortletMethod.invoke(CDIBeanPortletMethod.java:58)
at com.liferay.bean.portlet.cdi.extension.internal.CDIBeanPortletExtension._invokeBeanPortletMethod(CDIBeanPortletExtension.java:542)
at com.liferay.bean.portlet.cdi.extension.internal.CDIBeanPortletExtension.access$000(CDIBeanPortletExtension.java:113)
at com.liferay.bean.portlet.cdi.extension.internal.CDIBeanPortletExtension$3._invokePortletBeanMethods(CDIBeanPortletExtension.java:370)
at com.liferay.bean.portlet.cdi.extension.internal.CDIBeanPortletExtension$3.lambda$invokeWithActiveScopes$1(CDIBeanPortletExtension.java:355)
at com.liferay.bean.portlet.cdi.extension.internal.scope.ScopedBeanManagerThreadLocal.invokeWithScopedBeanManager(ScopedBeanManagerThreadLocal.java:78)
at com.liferay.bean.portlet.cdi.extension.internal.CDIBeanPortletExtension$3.invokeWithActiveScopes(CDIBeanPortletExtension.java:352)
at com.liferay.bean.portlet.registration.internal.BeanPortletInvokerPortlet._invokeMethodWithActiveScopes(BeanPortletInvokerPortlet.java:256)
at com.liferay.bean.portlet.registration.internal.BeanPortletInvokerPortlet.render(BeanPortletInvokerPortlet.java:193)
at com.liferay.portlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:127)
at com.liferay.portlet.ScriptDataPortletFilter.doFilter(ScriptDataPortletFilter.java:58)
at com.liferay.portlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:124)
at com.liferay.portal.kernel.portlet.PortletFilterUtil.doFilter(PortletFilterUtil.java:71)
at com.liferay.portal.kernel.servlet.PortletServlet.service(PortletServlet.java:113)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:764)