This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
The moose likes Tomcat and the fly likes Applications becomes very slow on Tomcat6 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Applications becomes very slow on Tomcat6" Watch "Applications becomes very slow on Tomcat6" New topic
Author

Applications becomes very slow on Tomcat6

Gautam Panpatil
Greenhorn

Joined: Sep 28, 2013
Posts: 22
Hi...
I am using tomcat 6+cent os +spring mvc and i am trying to same web application on different port no but same tomcat 6 server
like
http://9.9.9.9:port no1/index.jsp
http://9.9.9.9:port no2/index.jsp
and main thing both application connect to different databases.When i am restarting the server these applications work fine for only static pages when i am doing some operations on any one , then second one automatically slow and after some time first one is also down .
please tell me where i ma wrong because when i am accessing these application single hand then work fine .

Thanks in advanced .!!!

Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15632
    
  15

Welcome to the JavaRanch, Gautam!

I'm afraid that there's nothing we can tell you. Tomcat itself is not sensitive to such configurations. You need to look in detail at what the applications are doing.


Customer surveys are for companies who didn't pay proper attention to begin with.
Gautam Panpatil
Greenhorn

Joined: Sep 28, 2013
Posts: 22
Hi Tim
Thanks for reply.

According to my observation tomcat having error i got yesterday

Caused by: java.lang.OutOfMemoryError: PermGen space
2013-10-01 10:25:11,184 ERROR BasicLazyInitializer:166 - Javassist Enhancement failed: com.vms.persistence.domain.OrgType
java.lang.RuntimeException: by java.lang.OutOfMemoryError: PermGen space
at javassist.util.proxy.ProxyFactory.createClass3(ProxyFactory.java:344)
at javassist.util.proxy.ProxyFactory.createClass2(ProxyFactory.java:314)
at javassist.util.proxy.ProxyFactory.createClass(ProxyFactory.java:273)
at org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer.getProxyFactory(JavassistLazyInitializer.java:163)
at org.hibernate.proxy.pojo.javassist.JavassistProxyFactory.postInstantiate(JavassistProxyFactory.java:66)
at org.hibernate.tuple.entity.PojoEntityTuplizer.buildProxyFactory(PojoEntityTuplizer.java:187)
at org.hibernate.tuple.entity.AbstractEntityTuplizer.<init>(AbstractEntityTuplizer.java:170)
at org.hibernate.tuple.entity.PojoEntityTuplizer.<init>(PojoEntityTuplizer.java:77)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.hibernate.tuple.entity.EntityTuplizerFactory.constructTuplizer(EntityTuplizerFactory.java:107)
at org.hibernate.tuple.entity.EntityTuplizerFactory.constructDefaultTuplizer(EntityTuplizerFactory.java:135)
at org.hibernate.tuple.entity.EntityEntityModeToTuplizerMapping.<init>(EntityEntityModeToTuplizerMapping.java:80)
at org.hibernate.tuple.entity.EntityMetamodel.<init>(EntityMetamodel.java:323)
at org.hibernate.persister.entity.AbstractEntityPersister.<init>(AbstractEntityPersister.java:475)
at org.hibernate.persister.entity.SingleTableEntityPersister.<init>(SingleTableEntityPersister.java:133)
at org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:84)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:295)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1385)
at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:954)
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:891)
at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:74)
at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:225)
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:308)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1477)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1417)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(DefaultListableBeanFactory.java:398)
at org.springframework.beans.factory.BeanFactoryUtils.beansOfTypeIncludingAncestors(BeanFactoryUtils.java:275)
at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.detectPersistenceExceptionTranslators(PersistenceExceptionTranslationInterceptor.java:139)
at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.<init>(PersistenceExceptionTranslationInterceptor.java:79)
at org.springframework.dao.annotation.PersistenceExceptionTranslationAdvisor.<init>(PersistenceExceptionTranslationAdvisor.java:70)
at org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor.setBeanFactory(PersistenceExceptionTranslationPostProcessor.java:99)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeAwareMethods(AbstractAutowireCapableBeanFactory.java:1439)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1408)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
at org.springframework.context.support.AbstractApplicationContext.registerBeanPostProcessors(AbstractApplicationContext.java:710)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:410)
at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:442)
at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:458)
at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:339)
at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:306)
at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:127)
at javax.servlet.GenericServlet.init(GenericServlet.java:212)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1213)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1026)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4421)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4734)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:799)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:779)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:601)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:943)
at org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:778)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:504)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1317)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:324)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:142)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1065)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:840)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463)
at org.apache.catalina.core.StandardService.start(StandardService.java:525)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:754)
at org.apache.catalina.startup.Catalina.start(Catalina.java:595)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
Caused by: javassist.CannotCompileException: by java.lang.OutOfMemoryError: PermGen space
at javassist.util.proxy.FactoryHelper.toClass(FactoryHelper.java:169)
at javassist.util.proxy.ProxyFactory.createClass3(ProxyFactory.java:339)
... 81 more


So the application become hang . Any solutions for that
Thanks
Regards,
Gautam Panpatil
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39544
    
  27
That usually happens at some point when you reload web apps repeatedly. Just restart Tomcat and it should work fine.


Ping & DNS - updated with new look and Ping home screen widget
Gautam Panpatil
Greenhorn

Joined: Sep 28, 2013
Posts: 22
Hi Marshal
Thanks for reply
I was try to restart the tomcat but still application becomes slow and after some times it gives error out of memory

Thanks
Regards,
Gautam
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39544
    
  27
If it does that without web app reloads, then you should bump up the PermGen space (maybe to 128MB, the default is 64MB).

What's taking up the memory? Have you hooked up a tool like VisualVM to the Tomcat to look at the memory?
Gautam Panpatil
Greenhorn

Joined: Sep 28, 2013
Posts: 22
Hi Marshal
Ok i will increase PermGen space in tomcat
Thanks for reply

Regards,
Gautam Panpatil
Gautam Panpatil
Greenhorn

Joined: Sep 28, 2013
Posts: 22
Hi Marshal
Can you please tell mi in which file i have to change Perm Space because from other resources i found that there must be catalina.sh or catalina.bat but in my tomcat 6 on centos
i didn't found these file even tomcat2.exe also, will please help regarding to this

Thanks !!
Regards,
Gautam
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39544
    
  27
That's a JVM startup parameter, so if your Tocmat doesn't use the standard scripts (in which case catalina.sh/.bat would be the right place), then you need to find out how the JVM is started, and make the change in that script.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15632
    
  15

Try this. Create a file named TOMCAT_HOME/bin/setenv.sh, where "TOMCAT_HOME" is Tomcat's root (CATALINA_HOME/CATALINA_BASE).

Put the following text in it:



Adjust as needed.
Gautam Panpatil
Greenhorn

Joined: Sep 28, 2013
Posts: 22
k Marshal
Gautam Panpatil
Greenhorn

Joined: Sep 28, 2013
Posts: 22
Hi..
Thanks for reply k so now i have to create an .sh file in tomcat directory then write the code which is right for Perm Space

Thanks for suggestions
Regards,
Gautam
Gautam Panpatil
Greenhorn

Joined: Sep 28, 2013
Posts: 22
hi

how to increase PermGen space in tomcat on Centos 6.4
any body known .Its urgent

Regards,
Gautam
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15632
    
  15

This is for Tomcat 6, any Linux system (including CentOS)

Create a file TOMCAT_HOME/bin/setenv.sh and put the following line of text in it. Adjust as needed.



Default PermGen size is 128M. Usually 256M is enough for expanded system requirements, but I went higher on the server I copied this from.
Gautam Panpatil
Greenhorn

Joined: Sep 28, 2013
Posts: 22
Hi...
Thanks for reply . should i copy only the you given line ??
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39544
    
  27
What else were you thinking of copying? Tim's post from October 3rd is very specific, isn't it?
Gautam Panpatil
Greenhorn

Joined: Sep 28, 2013
Posts: 22
Thanks for reply i have made changes and check whether it works or not


Thanks
Gautam Panpatil
Greenhorn

Joined: Sep 28, 2013
Posts: 22
Hi ...
Its not working after some time site again slow .... i am Thank ful for every one but the problem is not solved till now ,it's really urgent please help me

Thanks

Regards,
Gautam
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39544
    
  27
What is the connection between the site being slow, and the java.lang.OutOfMemoryError: PermGen space problem? This fix only addresses the latter.

As Tim said, the slowness likely results from within your code - so the first step might be start measuring which app components are slowing down.
Gautam Panpatil
Greenhorn

Joined: Sep 28, 2013
Posts: 22
site is going well on local machine as i said earlier , i am using

http://9.9.9.9:port no1/index.jsp
http://9.9.9.9:port no2/index.jsp

k So whenever i deploying on server it becomes slow on linux(Centos) and it gives java.lang.OutOfMemoryError: PermGen space
error in log file and application stop the processing
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39544
    
  27
So the change you made did not help at all with the PermGen space issue? You're not repeatedly undeploying and redeploying the app without restarting the server, right? Because that is a typical scenario that will lead to PermGen problems, as I said before.

If that is not the problem, I would start hooking up some tools to the server to see what's happening, like VisualVM to examine memory and thread usage, or a debugger to step through the code to try and find where the slowness comes from.
Gautam Panpatil
Greenhorn

Joined: Sep 28, 2013
Posts: 22
I am always restarting the server when i m deploying on server as well database service also but the problem again same
i will try to find out from increasing the size of MAVEN also
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39544
    
  27
Maven is a build tool, it has no impact on runtime problems.
Gautam Panpatil
Greenhorn

Joined: Sep 28, 2013
Posts: 22
Yes you are right ... no effect on run time any other suggestions please
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39544
    
  27
I already suggested hooking up a debugger and/or VisualVM.
Gautam Panpatil
Greenhorn

Joined: Sep 28, 2013
Posts: 22
Server having 4GB Hard disk and i3 Processor still memory issues ??
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Applications becomes very slow on Tomcat6
 
Similar Threads
problem with performance tomcat
IBM HTTP (Apache) Server & Tomcat
Apache.exe process uses 100% CPU
Several Tomcat instances on one machine??
Tomcat 7 maintaining more than one session