Exception instantiating SqlSessionFactory

classic Classic list List threaded Threaded
12 messages Options
Reply | Threaded
Open this post in threaded view
|

Exception instantiating SqlSessionFactory

shorkun
I'm getting exception instantiating SqlSessionFactory inside
CustomServletContextListener

My environment :

1. IDE Netbeans
2. Project type Web Project Rest service singleton
3. Latest mybatis,
4. Database MySQL
5. Web Server Glasfish 3 which comes with netbeans

What I'm trying to do : is to instantiate SqlSessionFactory and attach
it to the Application Context variable, so i can get connection inside
of each REST Service I'm implementing vs instantiating SessionFactory
each time.

For this I have created CustomContext listener :

public class CustomServletContextListener implements
ServletContextListener {

    @Override
    public void contextInitialized(ServletContextEvent event) {


        try {

              ServletContext ctx = event.getServletContext();
              Reader reader = Resources.getResourceAsReader("usample/
mybatis/config/SqlMapConfig.xml");
-->> Exception here              SqlSessionFactory sqlSessionFactory =
new SqlSessionFactoryBuilder().build(reader,
"Production_Environment");

....... ETC.


And I'm getting exception below when I'm deploying project using
netbeans to glasfish.

Can anyone help me out with this ?
1. Is it a right way to instantiate a global session factory inside
java web project ?
2. If it is, then why am I getting this exception ? Cause this code
works in the console app

Thanks,
Shorkun



EXCEPTION :


INFO: Registering the Jersey servlet application, named
org.netbeans.rest.application.config.ApplicationConfig, at the servlet
mapping, /resources/*, with the Application class of the same name
SEVERE: PWC1306: Startup of context /usServiceServer failed due to
previous errors
SEVERE: PWC1305: Exception during cleanup after start failed
org.apache.catalina.LifecycleException: PWC2769: Manager has not yet
been started
        at
org.apache.catalina.session.StandardManager.stop(StandardManager.java:
892)
        at
org.apache.catalina.core.StandardContext.stop(StandardContext.java:
5456)
        at com.sun.enterprise.web.WebModule.stop(WebModule.java:530)
        at
org.apache.catalina.core.StandardContext.start(StandardContext.java:
5284)
        at com.sun.enterprise.web.WebModule.start(WebModule.java:499)
        at
org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:
928)
        at
org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:
912)
        at
org.apache.catalina.core.StandardHost.addChild(StandardHost.java:694)
        at
com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:
1947)
        at
com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:
1619)
        at
com.sun.enterprise.web.WebApplication.start(WebApplication.java:90)
        at org.glassfish.internal.data.EngineRef.start(EngineRef.java:
126)
        at
org.glassfish.internal.data.ModuleInfo.start(ModuleInfo.java:241)
        at
org.glassfish.internal.data.ApplicationInfo.start(ApplicationInfo.java:
236)
        at
com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:
339)
        at
com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:
183)
        at
org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:
272)
        at com.sun.enterprise.v3.admin.CommandRunnerImpl
$1.execute(CommandRunnerImpl.java:310)
        at
com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:
320)
        at
com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:
1121)
        at com.sun.enterprise.v3.admin.CommandRunnerImpl.access
$900(CommandRunnerImpl.java:83)
        at com.sun.enterprise.v3.admin.CommandRunnerImpl
$ExecutionContext.execute(CommandRunnerImpl.java:1235)
        at com.sun.enterprise.v3.admin.CommandRunnerImpl
$ExecutionContext.execute(CommandRunnerImpl.java:1224)
        at
org.glassfish.deployment.admin.ReDeployCommand.execute(ReDeployCommand.java:
96)
        at com.sun.enterprise.v3.admin.CommandRunnerImpl
$1.execute(CommandRunnerImpl.java:305)
        at
com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:
320)
        at
com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:
1176)
        at com.sun.enterprise.v3.admin.CommandRunnerImpl.access
$900(CommandRunnerImpl.java:83)
        at com.sun.enterprise.v3.admin.CommandRunnerImpl
$ExecutionContext.execute(CommandRunnerImpl.java:1235)
        at com.sun.enterprise.v3.admin.CommandRunnerImpl
$ExecutionContext.execute(CommandRunnerImpl.java:1224)
        at
com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:
365)
        at
com.sun.enterprise.v3.admin.AdminAdapter.service(AdminAdapter.java:
204)
        at
com.sun.grizzly.tcp.http11.GrizzlyAdapter.service(GrizzlyAdapter.java:
166)
        at
com.sun.enterprise.v3.server.HK2Dispatcher.dispath(HK2Dispatcher.java:
100)
        at
com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:
245)
        at
com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:
791)
        at
com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:693)
        at
com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:954)
        at
com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:
170)
        at
com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:
135)
        at
com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:
102)
        at
com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:
88)
        at
com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:
76)
        at
com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:
53)
        at
com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:
57)
        at com.sun.grizzly.ContextTask.run(ContextTask.java:69)
        at com.sun.grizzly.util.AbstractThreadPool
$Worker.doWork(AbstractThreadPool.java:330)
        at com.sun.grizzly.util.AbstractThreadPool
$Worker.run(AbstractThreadPool.java:309)
        at java.lang.Thread.run(Thread.java:619)

SEVERE: ContainerBase.addChild: start:
org.apache.catalina.LifecycleException:
java.lang.ExceptionInInitializerError
        at
org.apache.catalina.core.StandardContext.start(StandardContext.java:
5289)
        at com.sun.enterprise.web.WebModule.start(WebModule.java:499)
        at
org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:
928)
        at
org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:
912)
        at
org.apache.catalina.core.StandardHost.addChild(StandardHost.java:694)
        at
com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:
1947)
        at
com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:
1619)
        at
com.sun.enterprise.web.WebApplication.start(WebApplication.java:90)
        at org.glassfish.internal.data.EngineRef.start(EngineRef.java:
126)
        at
org.glassfish.internal.data.ModuleInfo.start(ModuleInfo.java:241)
        at
org.glassfish.internal.data.ApplicationInfo.start(ApplicationInfo.java:
236)
        at
com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:
339)
        at
com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:
183)
        at
org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:
272)
        at com.sun.enterprise.v3.admin.CommandRunnerImpl
$1.execute(CommandRunnerImpl.java:310)
        at
com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:
320)
        at
com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:
1121)
        at com.sun.enterprise.v3.admin.CommandRunnerImpl.access
$900(CommandRunnerImpl.java:83)
        at com.sun.enterprise.v3.admin.CommandRunnerImpl
$ExecutionContext.execute(CommandRunnerImpl.java:1235)
        at com.sun.enterprise.v3.admin.CommandRunnerImpl
$ExecutionContext.execute(CommandRunnerImpl.java:1224)
        at
org.glassfish.deployment.admin.ReDeployCommand.execute(ReDeployCommand.java:
96)
        at com.sun.enterprise.v3.admin.CommandRunnerImpl
$1.execute(CommandRunnerImpl.java:305)
        at
com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:
320)
        at
com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:
1176)
        at com.sun.enterprise.v3.admin.CommandRunnerImpl.access
$900(CommandRunnerImpl.java:83)
        at com.sun.enterprise.v3.admin.CommandRunnerImpl
$ExecutionContext.execute(CommandRunnerImpl.java:1235)
        at com.sun.enterprise.v3.admin.CommandRunnerImpl
$ExecutionContext.execute(CommandRunnerImpl.java:1224)
        at
com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:
365)
        at
com.sun.enterprise.v3.admin.AdminAdapter.service(AdminAdapter.java:
204)
        at
com.sun.grizzly.tcp.http11.GrizzlyAdapter.service(GrizzlyAdapter.java:
166)
        at
com.sun.enterprise.v3.server.HK2Dispatcher.dispath(HK2Dispatcher.java:
100)
        at
com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:
245)
        at
com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:
791)
        at
com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:693)
        at
com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:954)
        at
com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:
170)
        at
com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:
135)
        at
com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:
102)
        at
com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:
88)
        at
com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:
76)
        at
com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:
53)
        at
com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:
57)
        at com.sun.grizzly.ContextTask.run(ContextTask.java:69)
        at com.sun.grizzly.util.AbstractThreadPool
$Worker.doWork(AbstractThreadPool.java:330)
        at com.sun.grizzly.util.AbstractThreadPool
$Worker.run(AbstractThreadPool.java:309)
        at java.lang.Thread.run(Thread.java:619)
Caused by: java.lang.ExceptionInInitializerError
        at
org.apache.ibatis.datasource.pooled.PooledDataSourceFactory.<init>(PooledDataSourceFactory.java:
8)
        at
sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:
39)
        at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:
27)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:
513)
        at java.lang.Class.newInstance0(Class.java:355)
        at java.lang.Class.newInstance(Class.java:308)
        at
org.apache.ibatis.builder.xml.XMLConfigBuilder.dataSourceElement(XMLConfigBuilder.java:
209)
        at
org.apache.ibatis.builder.xml.XMLConfigBuilder.environmentsElement(XMLConfigBuilder.java:
186)
        at
org.apache.ibatis.builder.xml.XMLConfigBuilder.parseConfiguration(XMLConfigBuilder.java:
67)
        at
org.apache.ibatis.builder.xml.XMLConfigBuilder.parse(XMLConfigBuilder.java:
55)
        at
org.apache.ibatis.session.SqlSessionFactoryBuilder.build(SqlSessionFactoryBuilder.java:
29)
        at
org.apache.ibatis.session.SqlSessionFactoryBuilder.build(SqlSessionFactoryBuilder.java:
19)
        at
usample.service.base.CustomServletContextListener.contextInitialized(CustomServletContextListener.java:
31)
        at
org.apache.catalina.core.StandardContext.contextListenerStart(StandardContext.java:
4664)
        at
com.sun.enterprise.web.WebModule.contextListenerStart(WebModule.java:
535)
        at
org.apache.catalina.core.StandardContext.start(StandardContext.java:
5266)
        ... 45 more
Caused by: org.apache.ibatis.logging.LogException: Error creating
logger for class class
org.apache.ibatis.datasource.pooled.PooledDataSource.  Cause:
java.lang.reflect.InvocationTargetException
        at org.apache.ibatis.logging.LogFactory.getLog(LogFactory.java:
43)
        at
org.apache.ibatis.datasource.pooled.PooledDataSource.<clinit>(PooledDataSource.java:
17)
        ... 62 more
Caused by: java.lang.reflect.InvocationTargetException
        at
sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:
39)
        at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:
27)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:
513)
        at org.apache.ibatis.logging.LogFactory.getLog(LogFactory.java:
41)
        ... 63 more
Caused by: java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory
        at
org.apache.ibatis.logging.slf4j.Slf4jImpl.<init>(Slf4jImpl.java:12)
        ... 68 more
Caused by: java.lang.ClassNotFoundException: org.slf4j.LoggerFactory
        at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
        at
org.glassfish.web.loader.WebappClassLoader.findClass(WebappClassLoader.java:
959)
        at
org.glassfish.web.loader.WebappClassLoader.loadClass(WebappClassLoader.java:
1430)
        ... 69 more

WARNING: java.lang.IllegalStateException: ContainerBase.addChild:
start: org.apache.catalina.LifecycleException:
java.lang.ExceptionInInitializerError
java.lang.IllegalStateException: ContainerBase.addChild: start:
org.apache.catalina.LifecycleException:
java.lang.ExceptionInInitializerError
        at
org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:
932)
        at
org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:
912)
        at
org.apache.catalina.core.StandardHost.addChild(StandardHost.java:694)
        at
com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:
1947)
        at
com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:
1619)
        at
com.sun.enterprise.web.WebApplication.start(WebApplication.java:90)
        at org.glassfish.internal.data.EngineRef.start(EngineRef.java:
126)
        at
org.glassfish.internal.data.ModuleInfo.start(ModuleInfo.java:241)
        at
org.glassfish.internal.data.ApplicationInfo.start(ApplicationInfo.java:
236)
        at
com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:
339)
        at
com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:
183)
        at
org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:
272)
        at com.sun.enterprise.v3.admin.CommandRunnerImpl
$1.execute(CommandRunnerImpl.java:310)
        at
com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:
320)
        at
com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:
1121)
        at com.sun.enterprise.v3.admin.CommandRunnerImpl.access
$900(CommandRunnerImpl.java:83)
        at com.sun.enterprise.v3.admin.CommandRunnerImpl
$ExecutionContext.execute(CommandRunnerImpl.java:1235)
        at com.sun.enterprise.v3.admin.CommandRunnerImpl
$ExecutionContext.execute(CommandRunnerImpl.java:1224)
        at
org.glassfish.deployment.admin.ReDeployCommand.execute(ReDeployCommand.java:
96)
        at com.sun.enterprise.v3.admin.CommandRunnerImpl
$1.execute(CommandRunnerImpl.java:305)
        at
com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:
320)
        at
com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:
1176)
        at com.sun.enterprise.v3.admin.CommandRunnerImpl.access
$900(CommandRunnerImpl.java:83)
        at com.sun.enterprise.v3.admin.CommandRunnerImpl
$ExecutionContext.execute(CommandRunnerImpl.java:1235)
        at com.sun.enterprise.v3.admin.CommandRunnerImpl
$ExecutionContext.execute(CommandRunnerImpl.java:1224)
        at
com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:
365)
        at
com.sun.enterprise.v3.admin.AdminAdapter.service(AdminAdapter.java:
204)
        at
com.sun.grizzly.tcp.http11.GrizzlyAdapter.service(GrizzlyAdapter.java:
166)
        at
com.sun.enterprise.v3.server.HK2Dispatcher.dispath(HK2Dispatcher.java:
100)
        at
com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:
245)
        at
com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:
791)
        at
com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:693)
        at
com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:954)
        at
com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:
170)
        at
com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:
135)
        at
com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:
102)
        at
com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:
88)
        at
com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:
76)
        at
com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:
53)
        at
com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:
57)
        at com.sun.grizzly.ContextTask.run(ContextTask.java:69)
        at com.sun.grizzly.util.AbstractThreadPool
$Worker.doWork(AbstractThreadPool.java:330)
        at com.sun.grizzly.util.AbstractThreadPool
$Worker.run(AbstractThreadPool.java:309)
        at java.lang.Thread.run(Thread.java:619)

SEVERE: Exception while invoking class
com.sun.enterprise.web.WebApplication start method
java.lang.Exception: java.lang.IllegalStateException:
ContainerBase.addChild: start: org.apache.catalina.LifecycleException:
java.lang.ExceptionInInitializerError
        at
com.sun.enterprise.web.WebApplication.start(WebApplication.java:117)
        at org.glassfish.internal.data.EngineRef.start(EngineRef.java:
126)
        at
org.glassfish.internal.data.ModuleInfo.start(ModuleInfo.java:241)
        at
org.glassfish.internal.data.ApplicationInfo.start(ApplicationInfo.java:
236)
        at
com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:
339)
        at
com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:
183)
        at
org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:
272)
        at com.sun.enterprise.v3.admin.CommandRunnerImpl
$1.execute(CommandRunnerImpl.java:310)
        at
com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:
320)
        at
com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:
1121)
        at com.sun.enterprise.v3.admin.CommandRunnerImpl.access
$900(CommandRunnerImpl.java:83)
        at com.sun.enterprise.v3.admin.CommandRunnerImpl
$ExecutionContext.execute(CommandRunnerImpl.java:1235)
        at com.sun.enterprise.v3.admin.CommandRunnerImpl
$ExecutionContext.execute(CommandRunnerImpl.java:1224)
        at
org.glassfish.deployment.admin.ReDeployCommand.execute(ReDeployCommand.java:
96)
        at com.sun.enterprise.v3.admin.CommandRunnerImpl
$1.execute(CommandRunnerImpl.java:305)
        at
com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:
320)
        at
com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:
1176)
        at com.sun.enterprise.v3.admin.CommandRunnerImpl.access
$900(CommandRunnerImpl.java:83)
        at com.sun.enterprise.v3.admin.CommandRunnerImpl
$ExecutionContext.execute(CommandRunnerImpl.java:1235)
        at com.sun.enterprise.v3.admin.CommandRunnerImpl
$ExecutionContext.execute(CommandRunnerImpl.java:1224)
        at
com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:
365)
        at
com.sun.enterprise.v3.admin.AdminAdapter.service(AdminAdapter.java:
204)
        at
com.sun.grizzly.tcp.http11.GrizzlyAdapter.service(GrizzlyAdapter.java:
166)
        at
com.sun.enterprise.v3.server.HK2Dispatcher.dispath(HK2Dispatcher.java:
100)
        at
com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:
245)
        at
com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:
791)
        at
com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:693)
        at
com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:954)
        at
com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:
170)
        at
com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:
135)
        at
com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:
102)
        at
com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:
88)
        at
com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:
76)
        at
com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:
53)
        at
com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:
57)
        at com.sun.grizzly.ContextTask.run(ContextTask.java:69)
        at com.sun.grizzly.util.AbstractThreadPool
$Worker.doWork(AbstractThreadPool.java:330)
        at com.sun.grizzly.util.AbstractThreadPool
$Worker.run(AbstractThreadPool.java:309)
        at java.lang.Thread.run(Thread.java:619)

SEVERE: Exception while loading the app
java.lang.Exception: java.lang.IllegalStateException:
ContainerBase.addChild: start: org.apache.catalina.LifecycleException:
java.lang.ExceptionInInitializerError
        at
com.sun.enterprise.web.WebApplication.start(WebApplication.java:117)
        at org.glassfish.internal.data.EngineRef.start(EngineRef.java:
126)
        at
org.glassfish.internal.data.ModuleInfo.start(ModuleInfo.java:241)
        at
org.glassfish.internal.data.ApplicationInfo.start(ApplicationInfo.java:
236)
        at
com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:
339)
        at
com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:
183)
        at
org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:
272)
        at com.sun.enterprise.v3.admin.CommandRunnerImpl
$1.execute(CommandRunnerImpl.java:310)
        at
com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:
320)
        at
com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:
1121)
        at com.sun.enterprise.v3.admin.CommandRunnerImpl.access
$900(CommandRunnerImpl.java:83)
        at com.sun.enterprise.v3.admin.CommandRunnerImpl
$ExecutionContext.execute(CommandRunnerImpl.java:1235)
        at com.sun.enterprise.v3.admin.CommandRunnerImpl
$ExecutionContext.execute(CommandRunnerImpl.java:1224)
        at
org.glassfish.deployment.admin.ReDeployCommand.execute(ReDeployCommand.java:
96)
        at com.sun.enterprise.v3.admin.CommandRunnerImpl
$1.execute(CommandRunnerImpl.java:305)
        at
com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:
320)
        at
com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:
1176)
        at com.sun.enterprise.v3.admin.CommandRunnerImpl.access
$900(CommandRunnerImpl.java:83)
        at com.sun.enterprise.v3.admin.CommandRunnerImpl
$ExecutionContext.execute(CommandRunnerImpl.java:1235)
        at com.sun.enterprise.v3.admin.CommandRunnerImpl
$ExecutionContext.execute(CommandRunnerImpl.java:1224)
        at
com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:
365)
        at
com.sun.enterprise.v3.admin.AdminAdapter.service(AdminAdapter.java:
204)
        at
com.sun.grizzly.tcp.http11.GrizzlyAdapter.service(GrizzlyAdapter.java:
166)
        at
com.sun.enterprise.v3.server.HK2Dispatcher.dispath(HK2Dispatcher.java:
100)
        at
com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:
245)
        at
com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:
791)
        at
com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:693)
        at
com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:954)
        at
com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:
170)
        at
com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:
135)
        at
com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:
102)
        at
com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:
88)
        at
com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:
76)
        at
com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:
53)
        at
com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:
57)
        at com.sun.grizzly.ContextTask.run(ContextTask.java:69)
        at com.sun.grizzly.util.AbstractThreadPool
$Worker.doWork(AbstractThreadPool.java:330)
        at com.sun.grizzly.util.AbstractThreadPool
$Worker.run(AbstractThreadPool.java:309)
        at java.lang.Thread.run(Thread.java:619)

Reply | Threaded
Open this post in threaded view
|

Re: Exception instantiating SqlSessionFactory

Richard Yee
Check your path to your mapper file. It apostate that your reader is null.

Richard

Sent from my iPhone

On Oct 2, 2010, at 7:43 PM, Shorkun <[hidden email]> wrote:

> I'm getting exception instantiating SqlSessionFactory inside
> CustomServletContextListener
>
> My environment :
>
> 1. IDE Netbeans
> 2. Project type Web Project Rest service singleton
> 3. Latest mybatis,
> 4. Database MySQL
> 5. Web Server Glasfish 3 which comes with netbeans
>
> What I'm trying to do : is to instantiate SqlSessionFactory and attach
> it to the Application Context variable, so i can get connection inside
> of each REST Service I'm implementing vs instantiating SessionFactory
> each time.
>
> For this I have created CustomContext listener :
>
> public class CustomServletContextListener implements
> ServletContextListener {
>
>    @Override
>    public void contextInitialized(ServletContextEvent event) {
>
>
>        try {
>
>              ServletContext ctx = event.getServletContext();
>              Reader reader = Resources.getResourceAsReader("usample/
> mybatis/config/SqlMapConfig.xml");
> -->> Exception here              SqlSessionFactory sqlSessionFactory =
> new SqlSessionFactoryBuilder().build(reader,
> "Production_Environment");
>
> ....... ETC.
>
>
> And I'm getting exception below when I'm deploying project using
> netbeans to glasfish.
>
> Can anyone help me out with this ?
> 1. Is it a right way to instantiate a global session factory inside
> java web project ?
> 2. If it is, then why am I getting this exception ? Cause this code
> works in the console app
>
> Thanks,
> Shorkun
>
>
>
> EXCEPTION :
>
>
> INFO: Registering the Jersey servlet application, named
> org.netbeans.rest.application.config.ApplicationConfig, at the servlet
> mapping, /resources/*, with the Application class of the same name
> SEVERE: PWC1306: Startup of context /usServiceServer failed due to
> previous errors
> SEVERE: PWC1305: Exception during cleanup after start failed
> org.apache.catalina.LifecycleException: PWC2769: Manager has not yet
> been started
>        at
> org.apache.catalina.session.StandardManager.stop(StandardManager.java:
> 892)
>        at
> org.apache.catalina.core.StandardContext.stop(StandardContext.java:
> 5456)
>        at com.sun.enterprise.web.WebModule.stop(WebModule.java:530)
>        at
> org.apache.catalina.core.StandardContext.start(StandardContext.java:
> 5284)
>        at com.sun.enterprise.web.WebModule.start(WebModule.java:499)
>        at
> org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:
> 928)
>        at
> org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:
> 912)
>        at
> org.apache.catalina.core.StandardHost.addChild(StandardHost.java:694)
>        at
> com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:
> 1947)
>        at
> com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:
> 1619)
>        at
> com.sun.enterprise.web.WebApplication.start(WebApplication.java:90)
>        at org.glassfish.internal.data.EngineRef.start(EngineRef.java:
> 126)
>        at
> org.glassfish.internal.data.ModuleInfo.start(ModuleInfo.java:241)
>        at
> org.glassfish.internal.data.ApplicationInfo.start(ApplicationInfo.java:
> 236)
>        at
> com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:
> 339)
>        at
> com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:
> 183)
>        at
> org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:
> 272)
>        at com.sun.enterprise.v3.admin.CommandRunnerImpl
> $1.execute(CommandRunnerImpl.java:310)
>        at
> com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:
> 320)
>        at
> com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:
> 1121)
>        at com.sun.enterprise.v3.admin.CommandRunnerImpl.access
> $900(CommandRunnerImpl.java:83)
>        at com.sun.enterprise.v3.admin.CommandRunnerImpl
> $ExecutionContext.execute(CommandRunnerImpl.java:1235)
>        at com.sun.enterprise.v3.admin.CommandRunnerImpl
> $ExecutionContext.execute(CommandRunnerImpl.java:1224)
>        at
> org.glassfish.deployment.admin.ReDeployCommand.execute(ReDeployCommand.java:
> 96)
>        at com.sun.enterprise.v3.admin.CommandRunnerImpl
> $1.execute(CommandRunnerImpl.java:305)
>        at
> com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:
> 320)
>        at
> com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:
> 1176)
>        at com.sun.enterprise.v3.admin.CommandRunnerImpl.access
> $900(CommandRunnerImpl.java:83)
>        at com.sun.enterprise.v3.admin.CommandRunnerImpl
> $ExecutionContext.execute(CommandRunnerImpl.java:1235)
>        at com.sun.enterprise.v3.admin.CommandRunnerImpl
> $ExecutionContext.execute(CommandRunnerImpl.java:1224)
>        at
> com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:
> 365)
>        at
> com.sun.enterprise.v3.admin.AdminAdapter.service(AdminAdapter.java:
> 204)
>        at
> com.sun.grizzly.tcp.http11.GrizzlyAdapter.service(GrizzlyAdapter.java:
> 166)
>        at
> com.sun.enterprise.v3.server.HK2Dispatcher.dispath(HK2Dispatcher.java:
> 100)
>        at
> com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:
> 245)
>        at
> com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:
> 791)
>        at
> com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:693)
>        at
> com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:954)
>        at
> com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:
> 170)
>        at
> com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:
> 135)
>        at
> com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:
> 102)
>        at
> com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:
> 88)
>        at
> com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:
> 76)
>        at
> com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:
> 53)
>        at
> com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:
> 57)
>        at com.sun.grizzly.ContextTask.run(ContextTask.java:69)
>        at com.sun.grizzly.util.AbstractThreadPool
> $Worker.doWork(AbstractThreadPool.java:330)
>        at com.sun.grizzly.util.AbstractThreadPool
> $Worker.run(AbstractThreadPool.java:309)
>        at java.lang.Thread.run(Thread.java:619)
>
> SEVERE: ContainerBase.addChild: start:
> org.apache.catalina.LifecycleException:
> java.lang.ExceptionInInitializerError
>        at
> org.apache.catalina.core.StandardContext.start(StandardContext.java:
> 5289)
>        at com.sun.enterprise.web.WebModule.start(WebModule.java:499)
>        at
> org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:
> 928)
>        at
> org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:
> 912)
>        at
> org.apache.catalina.core.StandardHost.addChild(StandardHost.java:694)
>        at
> com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:
> 1947)
>        at
> com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:
> 1619)
>        at
> com.sun.enterprise.web.WebApplication.start(WebApplication.java:90)
>        at org.glassfish.internal.data.EngineRef.start(EngineRef.java:
> 126)
>        at
> org.glassfish.internal.data.ModuleInfo.start(ModuleInfo.java:241)
>        at
> org.glassfish.internal.data.ApplicationInfo.start(ApplicationInfo.java:
> 236)
>        at
> com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:
> 339)
>        at
> com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:
> 183)
>        at
> org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:
> 272)
>        at com.sun.enterprise.v3.admin.CommandRunnerImpl
> $1.execute(CommandRunnerImpl.java:310)
>        at
> com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:
> 320)
>        at
> com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:
> 1121)
>        at com.sun.enterprise.v3.admin.CommandRunnerImpl.access
> $900(CommandRunnerImpl.java:83)
>        at com.sun.enterprise.v3.admin.CommandRunnerImpl
> $ExecutionContext.execute(CommandRunnerImpl.java:1235)
>        at com.sun.enterprise.v3.admin.CommandRunnerImpl
> $ExecutionContext.execute(CommandRunnerImpl.java:1224)
>        at
> org.glassfish.deployment.admin.ReDeployCommand.execute(ReDeployCommand.java:
> 96)
>        at com.sun.enterprise.v3.admin.CommandRunnerImpl
> $1.execute(CommandRunnerImpl.java:305)
>        at
> com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:
> 320)
>        at
> com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:
> 1176)
>        at com.sun.enterprise.v3.admin.CommandRunnerImpl.access
> $900(CommandRunnerImpl.java:83)
>        at com.sun.enterprise.v3.admin.CommandRunnerImpl
> $ExecutionContext.execute(CommandRunnerImpl.java:1235)
>        at com.sun.enterprise.v3.admin.CommandRunnerImpl
> $ExecutionContext.execute(CommandRunnerImpl.java:1224)
>        at
> com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:
> 365)
>        at
> com.sun.enterprise.v3.admin.AdminAdapter.service(AdminAdapter.java:
> 204)
>        at
> com.sun.grizzly.tcp.http11.GrizzlyAdapter.service(GrizzlyAdapter.java:
> 166)
>        at
> com.sun.enterprise.v3.server.HK2Dispatcher.dispath(HK2Dispatcher.java:
> 100)
>        at
> com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:
> 245)
>        at
> com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:
> 791)
>        at
> com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:693)
>        at
> com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:954)
>        at
> com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:
> 170)
>        at
> com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:
> 135)
>        at
> com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:
> 102)
>        at
> com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:
> 88)
>        at
> com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:
> 76)
>        at
> com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:
> 53)
>        at
> com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:
> 57)
>        at com.sun.grizzly.ContextTask.run(ContextTask.java:69)
>        at com.sun.grizzly.util.AbstractThreadPool
> $Worker.doWork(AbstractThreadPool.java:330)
>        at com.sun.grizzly.util.AbstractThreadPool
> $Worker.run(AbstractThreadPool.java:309)
>        at java.lang.Thread.run(Thread.java:619)
> Caused by: java.lang.ExceptionInInitializerError
>        at
> org.apache.ibatis.datasource.pooled.PooledDataSourceFactory.<init>(PooledDataSourceFactory.java:
> 8)
>        at
> sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
>        at
> sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:
> 39)
>        at
> sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:
> 27)
>        at java.lang.reflect.Constructor.newInstance(Constructor.java:
> 513)
>        at java.lang.Class.newInstance0(Class.java:355)
>        at java.lang.Class.newInstance(Class.java:308)
>        at
> org.apache.ibatis.builder.xml.XMLConfigBuilder.dataSourceElement(XMLConfigBuilder.java:
> 209)
>        at
> org.apache.ibatis.builder.xml.XMLConfigBuilder.environmentsElement(XMLConfigBuilder.java:
> 186)
>        at
> org.apache.ibatis.builder.xml.XMLConfigBuilder.parseConfiguration(XMLConfigBuilder.java:
> 67)
>        at
> org.apache.ibatis.builder.xml.XMLConfigBuilder.parse(XMLConfigBuilder.java:
> 55)
>        at
> org.apache.ibatis.session.SqlSessionFactoryBuilder.build(SqlSessionFactoryBuilder.java:
> 29)
>        at
> org.apache.ibatis.session.SqlSessionFactoryBuilder.build(SqlSessionFactoryBuilder.java:
> 19)
>        at
> usample.service.base.CustomServletContextListener.contextInitialized(CustomServletContextListener.java:
> 31)
>        at
> org.apache.catalina.core.StandardContext.contextListenerStart(StandardContext.java:
> 4664)
>        at
> com.sun.enterprise.web.WebModule.contextListenerStart(WebModule.java:
> 535)
>        at
> org.apache.catalina.core.StandardContext.start(StandardContext.java:
> 5266)
>        ... 45 more
> Caused by: org.apache.ibatis.logging.LogException: Error creating
> logger for class class
> org.apache.ibatis.datasource.pooled.PooledDataSource.  Cause:
> java.lang.reflect.InvocationTargetException
>        at org.apache.ibatis.logging.LogFactory.getLog(LogFactory.java:
> 43)
>        at
> org.apache.ibatis.datasource.pooled.PooledDataSource.<clinit>(PooledDataSource.java:
> 17)
>        ... 62 more
> Caused by: java.lang.reflect.InvocationTargetException
>        at
> sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
>        at
> sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:
> 39)
>        at
> sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:
> 27)
>        at java.lang.reflect.Constructor.newInstance(Constructor.java:
> 513)
>        at org.apache.ibatis.logging.LogFactory.getLog(LogFactory.java:
> 41)
>        ... 63 more
> Caused by: java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory
>        at
> org.apache.ibatis.logging.slf4j.Slf4jImpl.<init>(Slf4jImpl.java:12)
>        ... 68 more
> Caused by: java.lang.ClassNotFoundException: org.slf4j.LoggerFactory
>        at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
>        at java.security.AccessController.doPrivileged(Native Method)
>        at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
>        at
> org.glassfish.web.loader.WebappClassLoader.findClass(WebappClassLoader.java:
> 959)
>        at
> org.glassfish.web.loader.WebappClassLoader.loadClass(WebappClassLoader.java:
> 1430)
>        ... 69 more
>
> WARNING: java.lang.IllegalStateException: ContainerBase.addChild:
> start: org.apache.catalina.LifecycleException:
> java.lang.ExceptionInInitializerError
> java.lang.IllegalStateException: ContainerBase.addChild: start:
> org.apache.catalina.LifecycleException:
> java.lang.ExceptionInInitializerError
>        at
> org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:
> 932)
>        at
> org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:
> 912)
>        at
> org.apache.catalina.core.StandardHost.addChild(StandardHost.java:694)
>        at
> com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:
> 1947)
>        at
> com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:
> 1619)
>        at
> com.sun.enterprise.web.WebApplication.start(WebApplication.java:90)
>        at org.glassfish.internal.data.EngineRef.start(EngineRef.java:
> 126)
>        at
> org.glassfish.internal.data.ModuleInfo.start(ModuleInfo.java:241)
>        at
> org.glassfish.internal.data.ApplicationInfo.start(ApplicationInfo.java:
> 236)
>        at
> com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:
> 339)
>        at
> com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:
> 183)
>        at
> org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:
> 272)
>        at com.sun.enterprise.v3.admin.CommandRunnerImpl
> $1.execute(CommandRunnerImpl.java:310)
>        at
> com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:
> 320)
>        at
> com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:
> 1121)
>        at com.sun.enterprise.v3.admin.CommandRunnerImpl.access
> $900(CommandRunnerImpl.java:83)
>        at com.sun.enterprise.v3.admin.CommandRunnerImpl
> $ExecutionContext.execute(CommandRunnerImpl.java:1235)
>        at com.sun.enterprise.v3.admin.CommandRunnerImpl
> $ExecutionContext.execute(CommandRunnerImpl.java:1224)
>        at
> org.glassfish.deployment.admin.ReDeployCommand.execute(ReDeployCommand.java:
> 96)
>        at com.sun.enterprise.v3.admin.CommandRunnerImpl
> $1.execute(CommandRunnerImpl.java:305)
>        at
> com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:
> 320)
>        at
> com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:
> 1176)
>        at com.sun.enterprise.v3.admin.CommandRunnerImpl.access
> $900(CommandRunnerImpl.java:83)
>        at com.sun.enterprise.v3.admin.CommandRunnerImpl
> $ExecutionContext.execute(CommandRunnerImpl.java:1235)
>        at com.sun.enterprise.v3.admin.CommandRunnerImpl
> $ExecutionContext.execute(CommandRunnerImpl.java:1224)
>        at
> com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:
> 365)
>        at
> com.sun.enterprise.v3.admin.AdminAdapter.service(AdminAdapter.java:
> 204)
>        at
> com.sun.grizzly.tcp.http11.GrizzlyAdapter.service(GrizzlyAdapter.java:
> 166)
>        at
> com.sun.enterprise.v3.server.HK2Dispatcher.dispath(HK2Dispatcher.java:
> 100)
>        at
> com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:
> 245)
>        at
> com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:
> 791)
>        at
> com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:693)
>        at
> com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:954)
>        at
> com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:
> 170)
>        at
> com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:
> 135)
>        at
> com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:
> 102)
>        at
> com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:
> 88)
>        at
> com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:
> 76)
>        at
> com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:
> 53)
>        at
> com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:
> 57)
>        at com.sun.grizzly.ContextTask.run(ContextTask.java:69)
>        at com.sun.grizzly.util.AbstractThreadPool
> $Worker.doWork(AbstractThreadPool.java:330)
>        at com.sun.grizzly.util.AbstractThreadPool
> $Worker.run(AbstractThreadPool.java:309)
>        at java.lang.Thread.run(Thread.java:619)
>
> SEVERE: Exception while invoking class
> com.sun.enterprise.web.WebApplication start method
> java.lang.Exception: java.lang.IllegalStateException:
> ContainerBase.addChild: start: org.apache.catalina.LifecycleException:
> java.lang.ExceptionInInitializerError
>        at
> com.sun.enterprise.web.WebApplication.start(WebApplication.java:117)
>        at org.glassfish.internal.data.EngineRef.start(EngineRef.java:
> 126)
>        at
> org.glassfish.internal.data.ModuleInfo.start(ModuleInfo.java:241)
>        at
> org.glassfish.internal.data.ApplicationInfo.start(ApplicationInfo.java:
> 236)
>        at
> com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:
> 339)
>        at
> com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:
> 183)
>        at
> org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:
> 272)
>        at com.sun.enterprise.v3.admin.CommandRunnerImpl
> $1.execute(CommandRunnerImpl.java:310)
>        at
> com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:
> 320)
>        at
> com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:
> 1121)
>        at com.sun.enterprise.v3.admin.CommandRunnerImpl.access
> $900(CommandRunnerImpl.java:83)
>        at com.sun.enterprise.v3.admin.CommandRunnerImpl
> $ExecutionContext.execute(CommandRunnerImpl.java:1235)
>        at com.sun.enterprise.v3.admin.CommandRunnerImpl
> $ExecutionContext.execute(CommandRunnerImpl.java:1224)
>        at
> org.glassfish.deployment.admin.ReDeployCommand.execute(ReDeployCommand.java:
> 96)
>        at com.sun.enterprise.v3.admin.CommandRunnerImpl
> $1.execute(CommandRunnerImpl.java:305)
>        at
> com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:
> 320)
>        at
> com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:
> 1176)
>        at com.sun.enterprise.v3.admin.CommandRunnerImpl.access
> $900(CommandRunnerImpl.java:83)
>        at com.sun.enterprise.v3.admin.CommandRunnerImpl
> $ExecutionContext.execute(CommandRunnerImpl.java:1235)
>        at com.sun.enterprise.v3.admin.CommandRunnerImpl
> $ExecutionContext.execute(CommandRunnerImpl.java:1224)
>        at
> com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:
> 365)
>        at
> com.sun.enterprise.v3.admin.AdminAdapter.service(AdminAdapter.java:
> 204)
>        at
> com.sun.grizzly.tcp.http11.GrizzlyAdapter.service(GrizzlyAdapter.java:
> 166)
>        at
> com.sun.enterprise.v3.server.HK2Dispatcher.dispath(HK2Dispatcher.java:
> 100)
>        at
> com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:
> 245)
>        at
> com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:
> 791)
>        at
> com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:693)
>        at
> com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:954)
>        at
> com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:
> 170)
>        at
> com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:
> 135)
>        at
> com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:
> 102)
>        at
> com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:
> 88)
>        at
> com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:
> 76)
>        at
> com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:
> 53)
>        at
> com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:
> 57)
>        at com.sun.grizzly.ContextTask.run(ContextTask.java:69)
>        at com.sun.grizzly.util.AbstractThreadPool
> $Worker.doWork(AbstractThreadPool.java:330)
>        at com.sun.grizzly.util.AbstractThreadPool
> $Worker.run(AbstractThreadPool.java:309)
>        at java.lang.Thread.run(Thread.java:619)
>
> SEVERE: Exception while loading the app
> java.lang.Exception: java.lang.IllegalStateException:
> ContainerBase.addChild: start: org.apache.catalina.LifecycleException:
> java.lang.ExceptionInInitializerError
>        at
> com.sun.enterprise.web.WebApplication.start(WebApplication.java:117)
>        at org.glassfish.internal.data.EngineRef.start(EngineRef.java:
> 126)
>        at
> org.glassfish.internal.data.ModuleInfo.start(ModuleInfo.java:241)
>        at
> org.glassfish.internal.data.ApplicationInfo.start(ApplicationInfo.java:
> 236)
>        at
> com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:
> 339)
>        at
> com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:
> 183)
>        at
> org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:
> 272)
>        at com.sun.enterprise.v3.admin.CommandRunnerImpl
> $1.execute(CommandRunnerImpl.java:310)
>        at
> com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:
> 320)
>        at
> com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:
> 1121)
>        at com.sun.enterprise.v3.admin.CommandRunnerImpl.access
> $900(CommandRunnerImpl.java:83)
>        at com.sun.enterprise.v3.admin.CommandRunnerImpl
> $ExecutionContext.execute(CommandRunnerImpl.java:1235)
>        at com.sun.enterprise.v3.admin.CommandRunnerImpl
> $ExecutionContext.execute(CommandRunnerImpl.java:1224)
>        at
> org.glassfish.deployment.admin.ReDeployCommand.execute(ReDeployCommand.java:
> 96)
>        at com.sun.enterprise.v3.admin.CommandRunnerImpl
> $1.execute(CommandRunnerImpl.java:305)
>        at
> com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:
> 320)
>        at
> com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:
> 1176)
>        at com.sun.enterprise.v3.admin.CommandRunnerImpl.access
> $900(CommandRunnerImpl.java:83)
>        at com.sun.enterprise.v3.admin.CommandRunnerImpl
> $ExecutionContext.execute(CommandRunnerImpl.java:1235)
>        at com.sun.enterprise.v3.admin.CommandRunnerImpl
> $ExecutionContext.execute(CommandRunnerImpl.java:1224)
>        at
> com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:
> 365)
>        at
> com.sun.enterprise.v3.admin.AdminAdapter.service(AdminAdapter.java:
> 204)
>        at
> com.sun.grizzly.tcp.http11.GrizzlyAdapter.service(GrizzlyAdapter.java:
> 166)
>        at
> com.sun.enterprise.v3.server.HK2Dispatcher.dispath(HK2Dispatcher.java:
> 100)
>        at
> com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:
> 245)
>        at
> com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:
> 791)
>        at
> com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:693)
>        at
> com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:954)
>        at
> com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:
> 170)
>        at
> com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:
> 135)
>        at
> com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:
> 102)
>        at
> com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:
> 88)
>        at
> com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:
> 76)
>        at
> com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:
> 53)
>        at
> com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:
> 57)
>        at com.sun.grizzly.ContextTask.run(ContextTask.java:69)
>        at com.sun.grizzly.util.AbstractThreadPool
> $Worker.doWork(AbstractThreadPool.java:330)
>        at com.sun.grizzly.util.AbstractThreadPool
> $Worker.run(AbstractThreadPool.java:309)
>        at java.lang.Thread.run(Thread.java:619)
>
Reply | Threaded
Open this post in threaded view
|

Re: Exception instantiating SqlSessionFactory

shorkun
I've checked that, reader is not NULL and reads xml file correctly.
XML File itself, and all the mapping files of mybatis were verified by
instantiating them by java console app.
any other ideas ?

On Oct 2, 7:45 pm, Richard Yee <[hidden email]> wrote:

> Check your path to your mapper file. It apostate that your reader is null.
>
> Richard
>
> Sent from my iPhone
>
> On Oct 2, 2010, at 7:43 PM, Shorkun <[hidden email]> wrote:
>
> > I'm getting exception instantiating SqlSessionFactory inside
> > CustomServletContextListener
>
> > My environment :
>
> > 1. IDE Netbeans
> > 2. Project type Web Project Rest service singleton
> > 3. Latest mybatis,
> > 4. Database MySQL
> > 5. Web Server Glasfish 3 which comes with netbeans
>
> > What I'm trying to do : is to instantiate SqlSessionFactory and attach
> > it to the Application Context variable, so i can get connection inside
> > of each REST Service I'm implementing vs instantiating SessionFactory
> > each time.
>
> > For this I have created CustomContext listener :
>
> > public class CustomServletContextListener implements
> > ServletContextListener {
>
> >    @Override
> >    public void contextInitialized(ServletContextEvent event) {
>
> >        try {
>
> >              ServletContext ctx = event.getServletContext();
> >              Reader reader = Resources.getResourceAsReader("usample/
> > mybatis/config/SqlMapConfig.xml");
> > -->> Exception here              SqlSessionFactory sqlSessionFactory =
> > new SqlSessionFactoryBuilder().build(reader,
> > "Production_Environment");
>
> > ....... ETC.
>
> > And I'm getting exception below when I'm deploying project using
> > netbeans to glasfish.
>
> > Can anyone help me out with this ?
> > 1. Is it a right way to instantiate a global session factory inside
> > java web project ?
> > 2. If it is, then why am I getting this exception ? Cause this code
> > works in the console app
>
> > Thanks,
> > Shorkun
>
> > EXCEPTION :
>
> > INFO: Registering the Jersey servlet application, named
> > org.netbeans.rest.application.config.ApplicationConfig, at the servlet
> > mapping, /resources/*, with the Application class of the same name
> > SEVERE: PWC1306: Startup of context /usServiceServer failed due to
> > previous errors
> > SEVERE: PWC1305: Exception during cleanup after start failed
> > org.apache.catalina.LifecycleException: PWC2769: Manager has not yet
> > been started
> >        at
> > org.apache.catalina.session.StandardManager.stop(StandardManager.java:
> > 892)
> >        at
> > org.apache.catalina.core.StandardContext.stop(StandardContext.java:
> > 5456)
> >        at com.sun.enterprise.web.WebModule.stop(WebModule.java:530)
> >        at
> > org.apache.catalina.core.StandardContext.start(StandardContext.java:
> > 5284)
> >        at com.sun.enterprise.web.WebModule.start(WebModule.java:499)
> >        at
> > org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:
> > 928)
> >        at
> > org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:
> > 912)
> >        at
> > org.apache.catalina.core.StandardHost.addChild(StandardHost.java:694)
> >        at
> > com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:
> > 1947)
> >        at
> > com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:
> > 1619)
> >        at
> > com.sun.enterprise.web.WebApplication.start(WebApplication.java:90)
> >        at org.glassfish.internal.data.EngineRef.start(EngineRef.java:
> > 126)
> >        at
> > org.glassfish.internal.data.ModuleInfo.start(ModuleInfo.java:241)
> >        at
> > org.glassfish.internal.data.ApplicationInfo.start(ApplicationInfo.java:
> > 236)
> >        at
> > com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:
> > 339)
> >        at
> > com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:
> > 183)
> >        at
> > org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:
> > 272)
> >        at com.sun.enterprise.v3.admin.CommandRunnerImpl
> > $1.execute(CommandRunnerImpl.java:310)
> >        at
> > com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:
> > 320)
> >        at
> > com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:
> > 1121)
> >        at com.sun.enterprise.v3.admin.CommandRunnerImpl.access
> > $900(CommandRunnerImpl.java:83)
> >        at com.sun.enterprise.v3.admin.CommandRunnerImpl
> > $ExecutionContext.execute(CommandRunnerImpl.java:1235)
> >        at com.sun.enterprise.v3.admin.CommandRunnerImpl
> > $ExecutionContext.execute(CommandRunnerImpl.java:1224)
> >        at
> > org.glassfish.deployment.admin.ReDeployCommand.execute(ReDeployCommand.java:
> > 96)
> >        at com.sun.enterprise.v3.admin.CommandRunnerImpl
> > $1.execute(CommandRunnerImpl.java:305)
> >        at
> > com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:
> > 320)
> >        at
> > com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:
> > 1176)
> >        at com.sun.enterprise.v3.admin.CommandRunnerImpl.access
> > $900(CommandRunnerImpl.java:83)
> >        at com.sun.enterprise.v3.admin.CommandRunnerImpl
> > $ExecutionContext.execute(CommandRunnerImpl.java:1235)
> >        at com.sun.enterprise.v3.admin.CommandRunnerImpl
> > $ExecutionContext.execute(CommandRunnerImpl.java:1224)
> >        at
> > com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:
> > 365)
> >        at
> > com.sun.enterprise.v3.admin.AdminAdapter.service(AdminAdapter.java:
> > 204)
> >        at
> > com.sun.grizzly.tcp.http11.GrizzlyAdapter.service(GrizzlyAdapter.java:
> > 166)
> >        at
> > com.sun.enterprise.v3.server.HK2Dispatcher.dispath(HK2Dispatcher.java:
> > 100)
> >        at
> > com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:
> > 245)
> >        at
> > com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:
> > 791)
> >        at
> > com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:693)
> >        at
> > com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:954)
> >        at
> > com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:
> > 170)
> >        at
> > com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:
> > 135)
> >        at
> > com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:
> > 102)
> >        at
> > com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:
> > 88)
> >        at
> > com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:
> > 76)
> >        at
> > com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:
> > 53)
> >        at
> > com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:
> > 57)
> >        at com.sun.grizzly.ContextTask.run(ContextTask.java:69)
> >        at com.sun.grizzly.util.AbstractThreadPool
> > $Worker.doWork(AbstractThreadPool.java:330)
> >        at com.sun.grizzly.util.AbstractThreadPool
> > $Worker.run(AbstractThreadPool.java:309)
> >        at java.lang.Thread.run(Thread.java:619)
>
> > SEVERE: ContainerBase.addChild: start:
> > org.apache.catalina.LifecycleException:
> > java.lang.ExceptionInInitializerError
> >        at
> > org.apache.catalina.core.StandardContext.start(StandardContext.java:
> > 5289)
> >        at com.sun.enterprise.web.WebModule.start(WebModule.java:499)
> >        at
> > org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:
> > 928)
> >        at
> > org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:
> > 912)
> >        at
> > org.apache.catalina.core.StandardHost.addChild(StandardHost.java:694)
> >        at
> > com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:
> > 1947)
> >        at
> > com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:
> > 1619)
> >        at
> > com.sun.enterprise.web.WebApplication.start(WebApplication.java:90)
> >        at org.glassfish.internal.data.EngineRef.start(EngineRef.java:
> > 126)
> >        at
> > org.glassfish.internal.data.ModuleInfo.start(ModuleInfo.java:241)
> >        at
> > org.glassfish.internal.data.ApplicationInfo.start(ApplicationInfo.java:
> > 236)
> >        at
> > com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:
> > 339)
> >        at
> > com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:
> > 183)
> >        at
> > org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:
> > 272)
> >        at com.sun.enterprise.v3.admin.CommandRunnerImpl
> > $1.execute(CommandRunnerImpl.java:310)
> >        at
> > com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:
> > 320)
> >        at
> > com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:
> > 1121)
> >        at com.sun.enterprise.v3.admin.CommandRunnerImpl.access
> > $900(CommandRunnerImpl.java:83)
> >        at com.sun.enterprise.v3.admin.CommandRunnerImpl
> > $ExecutionContext.execute(CommandRunnerImpl.java:1235)
> >        at com.sun.enterprise.v3.admin.CommandRunnerImpl
> > $ExecutionContext.execute(CommandRunnerImpl.java:1224)
> >        at
> > org.glassfish.deployment.admin.ReDeployCommand.execute(ReDeployCommand.java:
> > 96)
> >        at com.sun.enterprise.v3.admin.CommandRunnerImpl
> > $1.execute(CommandRunnerImpl.java:305)
> >        at
> > com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:
> > 320)
> >        at
> > com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:
> > 1176)
> >        at com.sun.enterprise.v3.admin.CommandRunnerImpl.access
> > $900(CommandRunnerImpl.java:83)
> >        at com.sun.enterprise.v3.admin.CommandRunnerImpl
> > $ExecutionContext.execute(CommandRunnerImpl.java:1235)
> >        at com.sun.enterprise.v3.admin.CommandRunnerImpl
> > $ExecutionContext.execute(CommandRunnerImpl.java:1224)
> >        at
> > com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:
> > 365)
> >        at
> > com.sun.enterprise.v3.admin.AdminAdapter.service(AdminAdapter.java:
> > 204)
> >        at
> > com.sun.grizzly.tcp.http11.GrizzlyAdapter.service(GrizzlyAdapter.java:
> > 166)
> >        at
> > com.sun.enterprise.v3.server.HK2Dispatcher.dispath(HK2Dispatcher.java:
> > 100)
> >        at
> > com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:
> > 245)
> >        at
> > com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:
> > 791)
> >        at
>
> ...
>
> read more »
Reply | Threaded
Open this post in threaded view
|

Re: Exception instantiating SqlSessionFactory

Richard Yee
Check your web.XML for your jersey servlet config as the exception indicates
-r

Sent from my iPhone

On Oct 2, 2010, at 9:09 PM, Shorkun <[hidden email]> wrote:

> I've checked that, reader is not NULL and reads xml file correctly.
> XML File itself, and all the mapping files of mybatis were verified by
> instantiating them by java console app.
> any other ideas ?
>
> On Oct 2, 7:45 pm, Richard Yee <[hidden email]> wrote:
>> Check your path to your mapper file. It apostate that your reader is null.
>>
>> Richard
>>
>> Sent from my iPhone
>>
>> On Oct 2, 2010, at 7:43 PM, Shorkun <[hidden email]> wrote:
>>
>>> I'm getting exception instantiating SqlSessionFactory inside
>>> CustomServletContextListener
>>
>>> My environment :
>>
>>> 1. IDE Netbeans
>>> 2. Project type Web Project Rest service singleton
>>> 3. Latest mybatis,
>>> 4. Database MySQL
>>> 5. Web Server Glasfish 3 which comes with netbeans
>>
>>> What I'm trying to do : is to instantiate SqlSessionFactory and attach
>>> it to the Application Context variable, so i can get connection inside
>>> of each REST Service I'm implementing vs instantiating SessionFactory
>>> each time.
>>
>>> For this I have created CustomContext listener :
>>
>>> public class CustomServletContextListener implements
>>> ServletContextListener {
>>
>>>    @Override
>>>    public void contextInitialized(ServletContextEvent event) {
>>
>>>        try {
>>
>>>              ServletContext ctx = event.getServletContext();
>>>              Reader reader = Resources.getResourceAsReader("usample/
>>> mybatis/config/SqlMapConfig.xml");
>>> -->> Exception here              SqlSessionFactory sqlSessionFactory =
>>> new SqlSessionFactoryBuilder().build(reader,
>>> "Production_Environment");
>>
>>> ....... ETC.
>>
>>> And I'm getting exception below when I'm deploying project using
>>> netbeans to glasfish.
>>
>>> Can anyone help me out with this ?
>>> 1. Is it a right way to instantiate a global session factory inside
>>> java web project ?
>>> 2. If it is, then why am I getting this exception ? Cause this code
>>> works in the console app
>>
>>> Thanks,
>>> Shorkun
>>
>>> EXCEPTION :
>>
>>> INFO: Registering the Jersey servlet application, named
>>> org.netbeans.rest.application.config.ApplicationConfig, at the servlet
>>> mapping, /resources/*, with the Application class of the same name
>>> SEVERE: PWC1306: Startup of context /usServiceServer failed due to
>>> previous errors
>>> SEVERE: PWC1305: Exception during cleanup after start failed
>>> org.apache.catalina.LifecycleException: PWC2769: Manager has not yet
>>> been started
>>>        at
>>> org.apache.catalina.session.StandardManager.stop(StandardManager.java:
>>> 892)
>>>        at
>>> org.apache.catalina.core.StandardContext.stop(StandardContext.java:
>>> 5456)
>>>        at com.sun.enterprise.web.WebModule.stop(WebModule.java:530)
>>>        at
>>> org.apache.catalina.core.StandardContext.start(StandardContext.java:
>>> 5284)
>>>        at com.sun.enterprise.web.WebModule.start(WebModule.java:499)
>>>        at
>>> org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:
>>> 928)
>>>        at
>>> org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:
>>> 912)
>>>        at
>>> org.apache.catalina.core.StandardHost.addChild(StandardHost.java:694)
>>>        at
>>> com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:
>>> 1947)
>>>        at
>>> com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:
>>> 1619)
>>>        at
>>> com.sun.enterprise.web.WebApplication.start(WebApplication.java:90)
>>>        at org.glassfish.internal.data.EngineRef.start(EngineRef.java:
>>> 126)
>>>        at
>>> org.glassfish.internal.data.ModuleInfo.start(ModuleInfo.java:241)
>>>        at
>>> org.glassfish.internal.data.ApplicationInfo.start(ApplicationInfo.java:
>>> 236)
>>>        at
>>> com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:
>>> 339)
>>>        at
>>> com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:
>>> 183)
>>>        at
>>> org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:
>>> 272)
>>>        at com.sun.enterprise.v3.admin.CommandRunnerImpl
>>> $1.execute(CommandRunnerImpl.java:310)
>>>        at
>>> com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:
>>> 320)
>>>        at
>>> com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:
>>> 1121)
>>>        at com.sun.enterprise.v3.admin.CommandRunnerImpl.access
>>> $900(CommandRunnerImpl.java:83)
>>>        at com.sun.enterprise.v3.admin.CommandRunnerImpl
>>> $ExecutionContext.execute(CommandRunnerImpl.java:1235)
>>>        at com.sun.enterprise.v3.admin.CommandRunnerImpl
>>> $ExecutionContext.execute(CommandRunnerImpl.java:1224)
>>>        at
>>> org.glassfish.deployment.admin.ReDeployCommand.execute(ReDeployCommand.java:
>>> 96)
>>>        at com.sun.enterprise.v3.admin.CommandRunnerImpl
>>> $1.execute(CommandRunnerImpl.java:305)
>>>        at
>>> com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:
>>> 320)
>>>        at
>>> com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:
>>> 1176)
>>>        at com.sun.enterprise.v3.admin.CommandRunnerImpl.access
>>> $900(CommandRunnerImpl.java:83)
>>>        at com.sun.enterprise.v3.admin.CommandRunnerImpl
>>> $ExecutionContext.execute(CommandRunnerImpl.java:1235)
>>>        at com.sun.enterprise.v3.admin.CommandRunnerImpl
>>> $ExecutionContext.execute(CommandRunnerImpl.java:1224)
>>>        at
>>> com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:
>>> 365)
>>>        at
>>> com.sun.enterprise.v3.admin.AdminAdapter.service(AdminAdapter.java:
>>> 204)
>>>        at
>>> com.sun.grizzly.tcp.http11.GrizzlyAdapter.service(GrizzlyAdapter.java:
>>> 166)
>>>        at
>>> com.sun.enterprise.v3.server.HK2Dispatcher.dispath(HK2Dispatcher.java:
>>> 100)
>>>        at
>>> com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:
>>> 245)
>>>        at
>>> com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:
>>> 791)
>>>        at
>>> com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:693)
>>>        at
>>> com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:954)
>>>        at
>>> com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:
>>> 170)
>>>        at
>>> com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:
>>> 135)
>>>        at
>>> com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:
>>> 102)
>>>        at
>>> com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:
>>> 88)
>>>        at
>>> com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:
>>> 76)
>>>        at
>>> com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:
>>> 53)
>>>        at
>>> com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:
>>> 57)
>>>        at com.sun.grizzly.ContextTask.run(ContextTask.java:69)
>>>        at com.sun.grizzly.util.AbstractThreadPool
>>> $Worker.doWork(AbstractThreadPool.java:330)
>>>        at com.sun.grizzly.util.AbstractThreadPool
>>> $Worker.run(AbstractThreadPool.java:309)
>>>        at java.lang.Thread.run(Thread.java:619)
>>
>>> SEVERE: ContainerBase.addChild: start:
>>> org.apache.catalina.LifecycleException:
>>> java.lang.ExceptionInInitializerError
>>>        at
>>> org.apache.catalina.core.StandardContext.start(StandardContext.java:
>>> 5289)
>>>        at com.sun.enterprise.web.WebModule.start(WebModule.java:499)
>>>        at
>>> org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:
>>> 928)
>>>        at
>>> org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:
>>> 912)
>>>        at
>>> org.apache.catalina.core.StandardHost.addChild(StandardHost.java:694)
>>>        at
>>> com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:
>>> 1947)
>>>        at
>>> com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:
>>> 1619)
>>>        at
>>> com.sun.enterprise.web.WebApplication.start(WebApplication.java:90)
>>>        at org.glassfish.internal.data.EngineRef.start(EngineRef.java:
>>> 126)
>>>        at
>>> org.glassfish.internal.data.ModuleInfo.start(ModuleInfo.java:241)
>>>        at
>>> org.glassfish.internal.data.ApplicationInfo.start(ApplicationInfo.java:
>>> 236)
>>>        at
>>> com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:
>>> 339)
>>>        at
>>> com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:
>>> 183)
>>>        at
>>> org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:
>>> 272)
>>>        at com.sun.enterprise.v3.admin.CommandRunnerImpl
>>> $1.execute(CommandRunnerImpl.java:310)
>>>        at
>>> com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:
>>> 320)
>>>        at
>>> com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:
>>> 1121)
>>>        at com.sun.enterprise.v3.admin.CommandRunnerImpl.access
>>> $900(CommandRunnerImpl.java:83)
>>>        at com.sun.enterprise.v3.admin.CommandRunnerImpl
>>> $ExecutionContext.execute(CommandRunnerImpl.java:1235)
>>>        at com.sun.enterprise.v3.admin.CommandRunnerImpl
>>> $ExecutionContext.execute(CommandRunnerImpl.java:1224)
>>>        at
>>> org.glassfish.deployment.admin.ReDeployCommand.execute(ReDeployCommand.java:
>>> 96)
>>>        at com.sun.enterprise.v3.admin.CommandRunnerImpl
>>> $1.execute(CommandRunnerImpl.java:305)
>>>        at
>>> com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:
>>> 320)
>>>        at
>>> com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:
>>> 1176)
>>>        at com.sun.enterprise.v3.admin.CommandRunnerImpl.access
>>> $900(CommandRunnerImpl.java:83)
>>>        at com.sun.enterprise.v3.admin.CommandRunnerImpl
>>> $ExecutionContext.execute(CommandRunnerImpl.java:1235)
>>>        at com.sun.enterprise.v3.admin.CommandRunnerImpl
>>> $ExecutionContext.execute(CommandRunnerImpl.java:1224)
>>>        at
>>> com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:
>>> 365)
>>>        at
>>> com.sun.enterprise.v3.admin.AdminAdapter.service(AdminAdapter.java:
>>> 204)
>>>        at
>>> com.sun.grizzly.tcp.http11.GrizzlyAdapter.service(GrizzlyAdapter.java:
>>> 166)
>>>        at
>>> com.sun.enterprise.v3.server.HK2Dispatcher.dispath(HK2Dispatcher.java:
>>> 100)
>>>        at
>>> com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:
>>> 245)
>>>        at
>>> com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:
>>> 791)
>>>        at
>>
>> ...
>>
>> read more »
Reply | Threaded
Open this post in threaded view
|

Re: Exception instantiating SqlSessionFactory

shorkun
I'm sorry if i'm being annoying, but I just came from .NET world and
not very familiar with java configuration.

I've added web.xml file to the Netbeans web project manually and the
reason for that was just to register a custom listener, so I can
initialize mybatis there.
Here is my web.xml file

<?xml version="1.0" encoding="UTF-8"?>
<web-app>
    <display-name>Custom Context Listerner</display-name>

    <listener>
        <listener-
class>usample.service.base.CustomServletContextListener  </listener-
class>
    </listener>


</web-app>

I'm not sure i understand the error you are referring to, can you
please elaborate ?

On Oct 2, 10:31 pm, Richard Yee <[hidden email]> wrote:

> Check your web.XML for your jersey servlet config as the exception indicates
> -r
>
> Sent from my iPhone
>
> On Oct 2, 2010, at 9:09 PM, Shorkun <[hidden email]> wrote:
>
> > I've checked that, reader is not NULL and reads xml file correctly.
> > XML File itself, and all the mapping files of mybatis were verified by
> > instantiating them by java console app.
> > any other ideas ?
>
> > On Oct 2, 7:45 pm, Richard Yee <[hidden email]> wrote:
> >> Check your path to your mapper file. It apostate that your reader is null.
>
> >> Richard
>
> >> Sent from my iPhone
>
> >> On Oct 2, 2010, at 7:43 PM, Shorkun <[hidden email]> wrote:
>
> >>> I'm getting exception instantiating SqlSessionFactory inside
> >>> CustomServletContextListener
>
> >>> My environment :
>
> >>> 1. IDE Netbeans
> >>> 2. Project type Web Project Rest service singleton
> >>> 3. Latest mybatis,
> >>> 4. Database MySQL
> >>> 5. Web Server Glasfish 3 which comes with netbeans
>
> >>> What I'm trying to do : is to instantiate SqlSessionFactory and attach
> >>> it to the Application Context variable, so i can get connection inside
> >>> of each REST Service I'm implementing vs instantiating SessionFactory
> >>> each time.
>
> >>> For this I have created CustomContext listener :
>
> >>> public class CustomServletContextListener implements
> >>> ServletContextListener {
>
> >>>    @Override
> >>>    public void contextInitialized(ServletContextEvent event) {
>
> >>>        try {
>
> >>>              ServletContext ctx = event.getServletContext();
> >>>              Reader reader = Resources.getResourceAsReader("usample/
> >>> mybatis/config/SqlMapConfig.xml");
> >>> -->> Exception here              SqlSessionFactory sqlSessionFactory =
> >>> new SqlSessionFactoryBuilder().build(reader,
> >>> "Production_Environment");
>
> >>> ....... ETC.
>
> >>> And I'm getting exception below when I'm deploying project using
> >>> netbeans to glasfish.
>
> >>> Can anyone help me out with this ?
> >>> 1. Is it a right way to instantiate a global session factory inside
> >>> java web project ?
> >>> 2. If it is, then why am I getting this exception ? Cause this code
> >>> works in the console app
>
> >>> Thanks,
> >>> Shorkun
>
> >>> EXCEPTION :
>
> >>> INFO: Registering the Jersey servlet application, named
> >>> org.netbeans.rest.application.config.ApplicationConfig, at the servlet
> >>> mapping, /resources/*, with the Application class of the same name
> >>> SEVERE: PWC1306: Startup of context /usServiceServer failed due to
> >>> previous errors
> >>> SEVERE: PWC1305: Exception during cleanup after start failed
> >>> org.apache.catalina.LifecycleException: PWC2769: Manager has not yet
> >>> been started
> >>>        at
> >>> org.apache.catalina.session.StandardManager.stop(StandardManager.java:
> >>> 892)
> >>>        at
> >>> org.apache.catalina.core.StandardContext.stop(StandardContext.java:
> >>> 5456)
> >>>        at com.sun.enterprise.web.WebModule.stop(WebModule.java:530)
> >>>        at
> >>> org.apache.catalina.core.StandardContext.start(StandardContext.java:
> >>> 5284)
> >>>        at com.sun.enterprise.web.WebModule.start(WebModule.java:499)
> >>>        at
> >>> org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:
> >>> 928)
> >>>        at
> >>> org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:
> >>> 912)
> >>>        at
> >>> org.apache.catalina.core.StandardHost.addChild(StandardHost.java:694)
> >>>        at
> >>> com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:
> >>> 1947)
> >>>        at
> >>> com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:
> >>> 1619)
> >>>        at
> >>> com.sun.enterprise.web.WebApplication.start(WebApplication.java:90)
> >>>        at org.glassfish.internal.data.EngineRef.start(EngineRef.java:
> >>> 126)
> >>>        at
> >>> org.glassfish.internal.data.ModuleInfo.start(ModuleInfo.java:241)
> >>>        at
> >>> org.glassfish.internal.data.ApplicationInfo.start(ApplicationInfo.java:
> >>> 236)
> >>>        at
> >>> com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:
> >>> 339)
> >>>        at
> >>> com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:
> >>> 183)
> >>>        at
> >>> org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:
> >>> 272)
> >>>        at com.sun.enterprise.v3.admin.CommandRunnerImpl
> >>> $1.execute(CommandRunnerImpl.java:310)
> >>>        at
> >>> com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:
> >>> 320)
> >>>        at
> >>> com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:
> >>> 1121)
> >>>        at com.sun.enterprise.v3.admin.CommandRunnerImpl.access
> >>> $900(CommandRunnerImpl.java:83)
> >>>        at com.sun.enterprise.v3.admin.CommandRunnerImpl
> >>> $ExecutionContext.execute(CommandRunnerImpl.java:1235)
> >>>        at com.sun.enterprise.v3.admin.CommandRunnerImpl
> >>> $ExecutionContext.execute(CommandRunnerImpl.java:1224)
> >>>        at
> >>> org.glassfish.deployment.admin.ReDeployCommand.execute(ReDeployCommand.java:
> >>> 96)
> >>>        at com.sun.enterprise.v3.admin.CommandRunnerImpl
> >>> $1.execute(CommandRunnerImpl.java:305)
> >>>        at
> >>> com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:
> >>> 320)
> >>>        at
> >>> com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:
> >>> 1176)
> >>>        at com.sun.enterprise.v3.admin.CommandRunnerImpl.access
> >>> $900(CommandRunnerImpl.java:83)
> >>>        at com.sun.enterprise.v3.admin.CommandRunnerImpl
> >>> $ExecutionContext.execute(CommandRunnerImpl.java:1235)
> >>>        at com.sun.enterprise.v3.admin.CommandRunnerImpl
> >>> $ExecutionContext.execute(CommandRunnerImpl.java:1224)
> >>>        at
> >>> com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:
> >>> 365)
> >>>        at
> >>> com.sun.enterprise.v3.admin.AdminAdapter.service(AdminAdapter.java:
> >>> 204)
> >>>        at
> >>> com.sun.grizzly.tcp.http11.GrizzlyAdapter.service(GrizzlyAdapter.java:
> >>> 166)
> >>>        at
> >>> com.sun.enterprise.v3.server.HK2Dispatcher.dispath(HK2Dispatcher.java:
> >>> 100)
> >>>        at
> >>> com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:
> >>> 245)
> >>>        at
> >>> com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:
> >>> 791)
> >>>        at
> >>> com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:693)
> >>>        at
> >>> com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:954)
> >>>        at
> >>> com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:
> >>> 170)
> >>>        at
> >>> com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:
> >>> 135)
> >>>        at
> >>> com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:
> >>> 102)
> >>>        at
> >>> com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:
> >>> 88)
> >>>        at
> >>> com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:
> >>> 76)
> >>>        at
> >>> com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:
> >>> 53)
> >>>        at
> >>> com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:
> >>> 57)
> >>>        at com.sun.grizzly.ContextTask.run(ContextTask.java:69)
> >>>        at com.sun.grizzly.util.AbstractThreadPool
> >>> $Worker.doWork(AbstractThreadPool.java:330)
> >>>        at com.sun.grizzly.util.AbstractThreadPool
> >>> $Worker.run(AbstractThreadPool.java:309)
> >>>        at java.lang.Thread.run(Thread.java:619)
>
> >>> SEVERE: ContainerBase.addChild: start:
> >>> org.apache.catalina.LifecycleException:
> >>> java.lang.ExceptionInInitializerError
> >>>        at
> >>> org.apache.catalina.core.StandardContext.start(StandardContext.java:
> >>> 5289)
> >>>        at com.sun.enterprise.web.WebModule.start(WebModule.java:499)
> >>>        at
> >>> org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:
> >>> 928)
> >>>        at
> >>> org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:
> >>> 912)
> >>>        at
> >>> org.apache.catalina.core.StandardHost.addChild(StandardHost.java:694)
> >>>        at
> >>> com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:
> >>> 1947)
> >>>        at
> >>> com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:
> >>> 1619)
> >>>        at
> >>> com.sun.enterprise.web.WebApplication.start(WebApplication.java:90)
> >>>        at org.glassfish.internal.data.EngineRef.start(EngineRef.java:
> >>> 126)
> >>>        at
> >>> org.glassfish.internal.data.ModuleInfo.start(ModuleInfo.java:241)
> >>>        at
> >>> org.glassfish.internal.data.ApplicationInfo.start(ApplicationInfo.java:
> >>> 236)
> >>>        at
> >>> com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:
> >>> 339)
> >>>        at
> >>> com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:
> >>> 183)
> >>>        at
> >>> org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:
> >>> 272)
> >>>        at com.sun.enterprise.v3.admin.CommandRunnerImpl
> >>> $1.execute(CommandRunnerImpl.java:310)
> >>>        at
> >>> com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:
> >>> 320)
> >>>        at
> >>> com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:
> >>> 1121)
> >>>        at com.sun.enterprise.v3.admin.CommandRunnerImpl.access
> >>> $900(CommandRunnerImpl.java:83)
> >>>        at com.sun.enterprise.v3.admin.CommandRunnerImpl
> >>> $ExecutionContext.execute(CommandRunnerImpl.java:1235)
> >>>        at com.sun.enterprise.v3.admin.CommandRunnerImpl
> >>> $ExecutionContext.execute(CommandRunnerImpl.java:1224)
> >>>        at
> >>> org.glassfish.deployment.admin.ReDeployCommand.execute(ReDeployCommand.java:
> >>> 96)
> >>>        at com.sun.enterprise.v3.admin.CommandRunnerImpl
> >>> $1.execute(CommandRunnerImpl.java:305)
> >>>        at
> >>> com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:
> >>> 320)
> >>>        at
> >>> com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:
>
> ...
>
> read more »
Reply | Threaded
Open this post in threaded view
|

Re: Exception instantiating SqlSessionFactory

Richard Yee
I was going by this message in your logs

plicationConfig, at the servlet
mapping, /resources/*, with the Application class of the same name
SEVERE: PWC1306: Startup of context /usServiceServer failed due to
previous errors
SEVERE: PWC1305: Exception during cleanup after start failed
org.apache.catalina.LifecycleException: PWC2769: Manager has not yet
been started
Can you print out the actual exception or the stack trace that I thrown in the context listener? Are you using a debugger?

Richard
Reply | Threaded
Open this post in threaded view
|

Re: Exception instantiating SqlSessionFactory

shorkun
Actually, after looking at deployment log, I found that if I have a
line of code which initializes sqlsessionfactory inside of context
listener, then project fails deployment

In-place deployment at C:\DEV\Projects_Java\uSamplePlatform
\usServiceServer\build\web
Initializing...
deploy?path=C:\DEV\Projects_Java\Platform\usServiceServer\build
\web&name=usServiceServer&force=true failed on GlassFish Server 3
C:\DEV\Projects_Java\Platform\usServiceServer\nbproject\build-impl.xml:
711: The module has not been deployed.
BUILD FAILED (total time: 7 seconds)

if I comment this line out :

MySessionFactory = new SqlSessionFactoryBuilder().build(reader,
"Development_Environment");

Deployment works ...
and the buld-impl.xml: 7711 line looks like this

<target if="netbeans.home" name="-run-deploy-nb">
        <nbdeploy clientUrlPart="${client.urlPart}" debugmode="false"
forceRedeploy="${forceRedeploy}"/>
    </target>

On Oct 3, 9:50 am, Richard Yee <[hidden email]> wrote:

> I was going by this message in your logs
>
> >>>> plicationConfig, at the servlet
> >>>> mapping, /resources/*, with the Application class of the same name
> >>>> SEVERE: PWC1306: Startup of context /usServiceServer failed due to
> >>>> previous errors
> >>>> SEVERE: PWC1305: Exception during cleanup after start failed
> >>>> org.apache.catalina.LifecycleException: PWC2769: Manager has not yet
> >>>> been started
>
> Can you print out the actual exception or the stack trace that I thrown in the context listener? Are you using a debugger?
>
> Richard
Reply | Threaded
Open this post in threaded view
|

Re: Exception instantiating SqlSessionFactory

Richard Yee
Use the debugger and find out what exception is being thrown. Mybatis usually emits pretty detailed error messages. Otherwise, we have to guess what is going on.

Richard

Sent from my iPhone

On Oct 3, 2010, at 12:00 PM, Shorkun <[hidden email]> wrote:

> Actually, after looking at deployment log, I found that if I have a
> line of code which initializes sqlsessionfactory inside of context
> listener, then project fails deployment
>
> In-place deployment at C:\DEV\Projects_Java\uSamplePlatform
> \usServiceServer\build\web
> Initializing...
> deploy?path=C:\DEV\Projects_Java\Platform\usServiceServer\build
> \web&name=usServiceServer&force=true failed on GlassFish Server 3
> C:\DEV\Projects_Java\Platform\usServiceServer\nbproject\build-impl.xml:
> 711: The module has not been deployed.
> BUILD FAILED (total time: 7 seconds)
>
> if I comment this line out :
>
> MySessionFactory = new SqlSessionFactoryBuilder().build(reader,
> "Development_Environment");
>
> Deployment works ...
> and the buld-impl.xml: 7711 line looks like this
>
> <target if="netbeans.home" name="-run-deploy-nb">
>        <nbdeploy clientUrlPart="${client.urlPart}" debugmode="false"
> forceRedeploy="${forceRedeploy}"/>
>    </target>
>
> On Oct 3, 9:50 am, Richard Yee <[hidden email]> wrote:
>> I was going by this message in your logs
>>
>>>>>> plicationConfig, at the servlet
>>>>>> mapping, /resources/*, with the Application class of the same name
>>>>>> SEVERE: PWC1306: Startup of context /usServiceServer failed due to
>>>>>> previous errors
>>>>>> SEVERE: PWC1305: Exception during cleanup after start failed
>>>>>> org.apache.catalina.LifecycleException: PWC2769: Manager has not yet
>>>>>> been started
>>
>> Can you print out the actual exception or the stack trace that I thrown in the context listener? Are you using a debugger?
>>
>> Richard
Tim
Reply | Threaded
Open this post in threaded view
|

Re: Exception instantiating SqlSessionFactory

Tim
The problem is that he is trying to use a slf4j and didn't add an appropriate jar. Since he is from the .NET world he prob didn't understand that from the original stacktrace. Question for the OP, are you using maven? It may sound unrelated to ask about your build tool of choice but I can probably fix this in 2 seconds if you are.

On Oct 3, 2010, at 6:00 PM, Richard Yee <[hidden email]> wrote:

> Use the debugger and find out what exception is being thrown. Mybatis usually emits pretty detailed error messages. Otherwise, we have to guess what is going on.
>
> Richard
>
> Sent from my iPhone
>
> On Oct 3, 2010, at 12:00 PM, Shorkun <[hidden email]> wrote:
>
>> Actually, after looking at deployment log, I found that if I have a
>> line of code which initializes sqlsessionfactory inside of context
>> listener, then project fails deployment
>>
>> In-place deployment at C:\DEV\Projects_Java\uSamplePlatform
>> \usServiceServer\build\web
>> Initializing...
>> deploy?path=C:\DEV\Projects_Java\Platform\usServiceServer\build
>> \web&name=usServiceServer&force=true failed on GlassFish Server 3
>> C:\DEV\Projects_Java\Platform\usServiceServer\nbproject\build-impl.xml:
>> 711: The module has not been deployed.
>> BUILD FAILED (total time: 7 seconds)
>>
>> if I comment this line out :
>>
>> MySessionFactory = new SqlSessionFactoryBuilder().build(reader,
>> "Development_Environment");
>>
>> Deployment works ...
>> and the buld-impl.xml: 7711 line looks like this
>>
>> <target if="netbeans.home" name="-run-deploy-nb">
>>       <nbdeploy clientUrlPart="${client.urlPart}" debugmode="false"
>> forceRedeploy="${forceRedeploy}"/>
>>   </target>
>>
>> On Oct 3, 9:50 am, Richard Yee <[hidden email]> wrote:
>>> I was going by this message in your logs
>>>
>>>>>>> plicationConfig, at the servlet
>>>>>>> mapping, /resources/*, with the Application class of the same name
>>>>>>> SEVERE: PWC1306: Startup of context /usServiceServer failed due to
>>>>>>> previous errors
>>>>>>> SEVERE: PWC1305: Exception during cleanup after start failed
>>>>>>> org.apache.catalina.LifecycleException: PWC2769: Manager has not yet
>>>>>>> been started
>>>
>>> Can you print out the actual exception or the stack trace that I thrown in the context listener? Are you using a debugger?
>>>
>>> Richard
Tim
Reply | Threaded
Open this post in threaded view
|

Re: Exception instantiating SqlSessionFactory

Tim
Sry got some food in me and read the rest of the thread. Since you are using ant you'll have to find the sfl4j-api jar and an implementation jar. I like logback myself but if you are in a hurry you can use slf4j-noop (or something like that).

On Oct 3, 2010, at 7:30 PM, Tim Chen <[hidden email]> wrote:

> The problem is that he is trying to use a slf4j and didn't add an appropriate jar. Since he is from the .NET world he prob didn't understand that from the original stacktrace. Question for the OP, are you using maven? It may sound unrelated to ask about your build tool of choice but I can probably fix this in 2 seconds if you are.
>
> On Oct 3, 2010, at 6:00 PM, Richard Yee <[hidden email]> wrote:
>
>> Use the debugger and find out what exception is being thrown. Mybatis usually emits pretty detailed error messages. Otherwise, we have to guess what is going on.
>>
>> Richard
>>
>> Sent from my iPhone
>>
>> On Oct 3, 2010, at 12:00 PM, Shorkun <[hidden email]> wrote:
>>
>>> Actually, after looking at deployment log, I found that if I have a
>>> line of code which initializes sqlsessionfactory inside of context
>>> listener, then project fails deployment
>>>
>>> In-place deployment at C:\DEV\Projects_Java\uSamplePlatform
>>> \usServiceServer\build\web
>>> Initializing...
>>> deploy?path=C:\DEV\Projects_Java\Platform\usServiceServer\build
>>> \web&name=usServiceServer&force=true failed on GlassFish Server 3
>>> C:\DEV\Projects_Java\Platform\usServiceServer\nbproject\build-impl.xml:
>>> 711: The module has not been deployed.
>>> BUILD FAILED (total time: 7 seconds)
>>>
>>> if I comment this line out :
>>>
>>> MySessionFactory = new SqlSessionFactoryBuilder().build(reader,
>>> "Development_Environment");
>>>
>>> Deployment works ...
>>> and the buld-impl.xml: 7711 line looks like this
>>>
>>> <target if="netbeans.home" name="-run-deploy-nb">
>>>      <nbdeploy clientUrlPart="${client.urlPart}" debugmode="false"
>>> forceRedeploy="${forceRedeploy}"/>
>>>  </target>
>>>
>>> On Oct 3, 9:50 am, Richard Yee <[hidden email]> wrote:
>>>> I was going by this message in your logs
>>>>
>>>>>>>> plicationConfig, at the servlet
>>>>>>>> mapping, /resources/*, with the Application class of the same name
>>>>>>>> SEVERE: PWC1306: Startup of context /usServiceServer failed due to
>>>>>>>> previous errors
>>>>>>>> SEVERE: PWC1305: Exception during cleanup after start failed
>>>>>>>> org.apache.catalina.LifecycleException: PWC2769: Manager has not yet
>>>>>>>> been started
>>>>
>>>> Can you print out the actual exception or the stack trace that I thrown in the context listener? Are you using a debugger?
>>>>
>>>> Richard
Reply | Threaded
Open this post in threaded view
|

Re: Exception instantiating SqlSessionFactory

Eduardo Macarron

I am having exactly the same issue with your same config: Netbeans 6.9
+ Glassfish 3. I will try to see what is happening.
Reply | Threaded
Open this post in threaded view
|

Re: Exception instantiating SqlSessionFactory

Eduardo Macarron
It seems a glassfish problem. Glassfish comes with slf4j so MyBatis
detects it and tries to use it. Mybatis executes this two sentences

Resources.classForName(testClassName);
Logger log = LoggerFactory.getLogger(Prueba.class);

Surprisingly the first one works but the second fails with
java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory. So I would
say that slf4j logging system seems to be unusable.

To solve this I can think in two possibilities:
- change the order so that MyBatis tries first another log system
- change mybatis to to try loogers calling getLogger (not just loading
the class)

I will add an issue for this.