Jpa2/hibernate c3p0 pool configuration lead connection and thread leaks - jpa-2.0

I am trying to use c3p0 as connection pool provider in my application (jpa 2 and hibernate core 3.3.2) but c3p0 getting too much connection from database.This is same problem but answer not helped.I am getting entitymanager from entitymanager factory and storing entitymanager in a thread local variable,thus a am using a fresh entiymanager for each request.(by the way if i use hibernate default pool no problem)
<property name="hibernate.connection.provider_class"
value="org.hibernate.connection.C3P0ConnectionProvider" />
<property name="hibernate.c3p0.min_size" value="1" />
<property name="hibernate.c3p0.max_size" value="10" />
<property name="hibernate. c3p0.initialPoolSize" value="3" />
<property name="hibernate.c3p0.numHelperThreads" value="3" />
<property name="hibernate.c3p0.maxPoolSize" value="10" />
<property name="hibernate.c3p0.minPoolSize" value="1" />
<property name="hibernate.c3p0.maxIdleTime" value="3600" />
<property name="hibernate.c3p0.maxIdleTimeExcessConnections" value="300" />
<property name="hibernate.c3p0.unreturnedConnectionTimeout" value="3600" />
<property name="hibernate.c3p0.acquire_increment" value="1" />
<property name="hibernate.c3p0.idle_test_period" value="3000" />
<property name="hibernate.c3p0.max_statements" value="0" />
<property name="hibernate.c3p0.timeout" value="300" />
<property name="hibernate.c3p0.breakAfterAcquireFailure" value="false" />
<property name="hibernate.c3p0.acquireRetryAttempts" value="1" />
<property name="hibernate.c3p0.acquireRetryDelay" value="100" / >

Can you ensure that you are not defining pool at both datasource and sessionFactory level.

Related

issue when profiling JVM Thread Pool ( under Spring intégration + Weblogic )

I have to maintain an application under Spring Integration (SI) and Weblogic 11g (with no workmanager configuration).
When I'm testing the performance on this application with JProfiler, I see a strange behavior regarding the threads : http://postimg.org/image/60w21njp3/
a thread pool with (approximatively) 160 threads
threads which are always created and destroyed
Under Spring, we use a SimpleAsyncTaskExecutor named "guillaume" and injected into a ListenerContainer like this :
<bean id="listenersExecutor" class="org.springframework.core.task.SimpleAsyncTaskExecutor">
<property name="threadNamePrefix" value="guillaume-" />
<property name="daemon" value="true" />
</bean>
With :
<bean id="myListener" class="org.springframework.jms.listener.DefaultMessageListenerContainer">
<property name="connectionFactory" ref="..." />
<property name="destination" ref="..." />
<property name="transactionManager" ref="..." />
<property name="taskExecutor" ref="listenersExecutor" />
<property name="errorHandler" ref="..." />
<property name="concurrentConsumers" value="..." />
<property name="idleConsumerLimit" value="..." />
<property name="cacheLevelName" value="..." />
</bean>
My question
I quote Javadoc on SimpleAsyncTaskExecutor :
TaskExecutor implementation that fires up a new Thread for each task, executing it asynchronously.
Who created the threadpool into JVM named "guillaume" ? not Spring ? Weblogic ?
Even if I don't have any activities with the SI, are there threads which are created and destroyed ?
Let me know if you need any additional informations.
Thanks.

How to display shrepoint list with folders using xslt

I have custom list which i need to display in webPartPage using XSLT. I create view, where just one field Title and set scope="recursive", but on the page displays only the folder title.
<View BaseViewID="2" Type="HTML" TabularView="FALSE" Scope="Recursive">
<Toolbar Type="Standard" />
<ViewFields>
<FieldRef Name="Title"/>
</ViewFields>
<RowLimit Paged="TRUE">10</RowLimit>
</View>
i have feature that link it
<File Path="MainPage/default.aspx" Url="default.aspx">
<View WebPartOrder="1" WebPartZoneID="Main" BaseViewID="2" List="$Resources:core,lists_Folder;/RequestList">
<![CDATA[
<webParts>
<webPart xmlns="http://schemas.microsoft.com/WebPart/v3">
<metaData>
<type name="Microsoft.SharePoint.WebPartPages.XsltListViewWebPart, Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" />
<importErrorMessage>Невозможно импортировать эту веб-часть.</importErrorMessage>
</metaData>
<data>
<properties>
<property name="InitialAsyncDataFetch" type="bool">False</property>
<property name="ChromeType" type="chrometype">Default</property>
<property name="Title" type="string" />
<property name="Height" type="string" />
<property name="CacheXslStorage" type="bool">True</property>
<property name="ListDisplayName" type="string" />
<property name="AllowZoneChange" type="bool">True</property>
<property name="AllowEdit" type="bool">True</property>
<property name="XmlDefinitionLink" type="string" />
<property name="DataFields" type="string" />
<property name="Hidden" type="bool">False</property>
<property name="ListName" type="string">{39C129CE-1800-48EB-A8ED-1C304C1FE457}</property>
<property name="NoDefaultStyle" type="string" null="true" />
<property name="AutoRefresh" type="bool">False</property>
<property name="ViewFlag" type="string">8388621</property>
<property name="Direction" type="direction">NotSet</property>
<property name="AutoRefreshInterval" type="int">60</property>
<property name="AllowConnect" type="bool">True</property>
<property name="Description" type="string" />
<property name="AllowClose" type="bool">True</property>
<property name="ShowWithSampleData" type="bool">False</property>
<property name="ParameterBindings" type="string">
<ParameterBinding Name="dvt_sortdir" Location="Postback;Connection"/>
<ParameterBinding Name="dvt_sortfield" Location="Postback;Connection"/>
<ParameterBinding Name="dvt_startposition" Location="Postback" DefaultValue=""/>
<ParameterBinding Name="dvt_firstrow" Location="Postback;Connection"/>
<ParameterBinding Name="OpenMenuKeyAccessible" Location="Resource(wss,OpenMenuKeyAccessible)" />
<ParameterBinding Name="open_menu" Location="Resource(wss,open_menu)" />
<ParameterBinding Name="select_deselect_all" Location="Resource(wss,select_deselect_all)" />
<ParameterBinding Name="idPresEnabled" Location="Resource(wss,idPresEnabled)" />
<ParameterBinding Name="NoAnnouncements" Location="Resource(wss,noXinviewofY_LIST)" />
<ParameterBinding Name="NoAnnouncementsHowTo" Location="Resource(wss,noXinviewofY_DEFAULT)" />
</property>
<property name="Xsl" type="string" null="true" />
<property name="CacheXslTimeOut" type="int">86400</property>
<property name="WebId" type="System.Guid, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">00000000-0000-0000-0000-000000000000</property>
<property name="ListUrl" type="string" />
<property name="DataSourceID" type="string" />
<property name="FireInitialRow" type="bool">True</property>
<property name="ManualRefresh" type="bool">False</property>
<property name="ViewFlags" type="Microsoft.SharePoint.SPViewFlags, Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c">Html, TabularView, Hidden, Mobile</property>
<property name="ChromeState" type="chromestate">Normal</property>
<property name="AllowHide" type="bool">True</property>
<property name="PageSize" type="int">-1</property>
<property name="SampleData" type="string" null="true" />
<property name="BaseXsltHashKey" type="string" null="true" />
<property name="AsyncRefresh" type="bool">False</property>
<property name="HelpMode" type="helpmode">Modeless</property>
<property name="ListId" type="System.Guid, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">39c129ce-1800-48eb-a8ed-1c304c1fe457</property>
<property name="DataSourceMode" type="Microsoft.SharePoint.WebControls.SPDataSourceMode, Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c">List</property>
<property name="AllowMinimize" type="bool">True</property>
<property name="TitleUrl" type="string">default.aspx</property>
<property name="CatalogIconImageUrl" type="string">/_layouts/images/itgen.png</property>
<property name="DataSourcesString" type="string" />
<property name="GhostedXslLink" type="string">main.xsl</property>
<property name="PageType" type="Microsoft.SharePoint.PAGETYPE, Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c">PAGE_NORMALVIEW</property>
<property name="DisplayName" type="string" />
<property name="UseSQLDataSourcePaging" type="bool">True</property>
<property name="Width" type="string" />
<property name="ExportMode" type="exportmode">All</property>
<property name="XslLink" type="string">/_layouts/[]/xsl/archive.xsl</property>
<property name="ViewContentTypeId" type="string">0x</property>
<property name="HelpUrl" type="string" />
<property name="XmlDefinition" type="string" />
<property name="Default" type="string" />
<property name="TitleIconImageUrl" type="string" />
<property name="MissingAssembly" type="string">Невозможно импортировать эту веб-часть.</property>
<property name="SelectParameters" type="string" />
</properties>
</data>
</webPart>
</webParts>
]]>
</View>
</File>
and simple xsl like there
http://msdn.microsoft.com/en-us/library/ff604024(v=office.14).aspx
You need to add Scope="Recursive" into second View (where you define WebPartZone and etc.)
Let's try:
<File Path="MainPage/default.aspx" Url="default.aspx">
<View WebPartOrder="1" WebPartZoneID="Main" BaseViewID="2" List="$Resources:core,lists_Folder;/RequestList" Scope="Recursive">
...

Problems writing a for-each select with filters on multiple fields

I have an xml document with nodes that look like this:
<SQLIndexUsage>
<Property Name="database_name">ClearTrace</Property>
<Property Name="Object_Name">CTTraceSummary</Property>
<Property Name="Schema_name">dbo</Property>
<Property Name="Index_name">IX_CTTraceSummary_Date</Property>
<Property Name="Type_Desc">NONCLUSTERED</Property>
<Property Name="user_seeks" />
<Property Name="user_scans" />
<Property Name="user_lookups" />
<Property Name="user_updates" />
<Property Name="usage_ratio">0.00</Property>
<Property Name="RowError" />
<Property Name="RowState">Detached</Property>
<Property Name="Table" />
<Property Name="ItemArray">
<Property>ClearTrace</Property>
<Property>CTTraceSummary</Property>
<Property>dbo</Property>
<Property>IX_CTTraceSummary_Date</Property>
<Property>NONCLUSTERED</Property>
<Property />
<Property />
<Property />
<Property />
<Property>0.00</Property>
</Property>
<Property Name="HasErrors">False</Property>
</SQLIndexUsage>
How do I write a for-each select that will filter on multiple fields, I was working on something like this:
<xsl:for-each select="/objects/SQLIndexUsage/Property[#Name ='user_seeks'][1]!='' or /objects/SQLIndexUsage/Property[#Name ='user_scans']!='' or /objects/SQLIndexUsage/Property[#Name ='user_updates']!=''">
Or am I looking at this wrong?
In general, you should keep the conditions in a single predicate:
/objects/SQLIndexUsage/Property[
(#Name ='user_seeks' or #Name='user_scans' or #Name='user_updates') and .!='']
This is even shorter:
/objects/SQLIndexUsage/Property[
#Name[.='user_seeks' or .='user_scans' or .='user_updates'] and .!='']
This is complicated a bit by your position condition, but you can still do this (with union):
/objects/SQLIndexUsage/Property[#Name='user_seeks' and .!=''][1] |
/objects/SQLIndexUsage/Property[
(#Name='user_scans' or #Name='user_updates') and .!='']
Note: I've left /objects on the expression, even though your sample XML doesn't show it. I'm guessing you're actually working with a larger document.

Apache CXF + resource handler with embedded jetty in osgi with spring dm

I'm trying to run an apache cxf endpoint in an equinox osgi environment with jetty 7. I need the endpoint to be on address http://x.x.x.x:8080/ws/endpoint1 and have static resources on the root path http://x.x.x.x:8080/*.
I have a dedicated bundle for this purpose containing the cxf libraries. Spring dynamic modules are part of my target platform.
After some research I tried to start the jetty webserver in my spring application context.
<bean id="Server" class="org.eclipse.jetty.server.Server"
init-method="start" destroy-method="stop">
<property name="connectors">
<list>
<bean id="Connector" class="org.eclipse.jetty.server.nio.SelectChannelConnector">
<property name="port" value="8080" />
</bean>
</list>
</property>
<property name="handler">
<bean id="handlers" class="org.eclipse.jetty.server.handler.HandlerList">
<property name="handlers">
<list>
<bean class="org.eclipse.jetty.server.handler.ResourceHandler">
<property name="directoriesListed" value="true" />
<property name="welcomeFiles">
<list>
<value>index.html</value>
</list>
</property>
<property name="resourceBase" value="./someDir" />
</bean>
<ref bean="web-service-cxf" />
<bean class="org.eclipse.jetty.server.handler.DefaultHandler" />
</list>
</property>
</bean>
</property>
</bean>
<bean name="web-service-cxf" class="org.eclipse.jetty.servlet.ServletContextHandler">
<property name="contextPath" value="/ws" />
<property name="handler">
<bean class="org.eclipse.jetty.servlet.ServletHandler">
<property name="servlets">
<list>
<bean class="org.eclipse.jetty.servlet.ServletHolder">
<property name="name" value="cxf-servlet-holder" />
<property name="servlet">
<bean class="org.apache.cxf.transport.servlet.CXFServlet">
</bean>
</property>
</bean>
</list>
</property>
<property name="servletMappings">
<list>
<bean class="org.eclipse.jetty.servlet.ServletMapping">
<property name="servletName" value="cxf-servlet-holder" />
<property name="pathSpec" value="/*" />
</bean>
</list>
</property>
</bean>
</property>
</bean>
My WebService Endpoint is declared with:
<import resource="classpath:META-INF/cxf/cxf.xml" />
<import resource="classpath:META-INF/cxf/cxf-servlet.xml" />
<bean id="someService" class="abc.xyz.SomeClass" />
<jaxws:endpoint id="endpointId" implementor="#someBean"
address="/endpoint1">
</jaxws:endpoint>
Unfortunatly this is not working. I can reach the static resources, but not the webservice.
The log says, the WebService is published under address /endpoint1. No warnings, no exceptions.
When I change the address of the webservice to its full url
<bean id="someService" class="abc.xyz.SomeClass" />
<jaxws:endpoint id="endpointId" implementor="#someBean"
address="http://x.x.x.x:8080/ws/endpoint1">
</jaxws:endpoint>
the webservice works fine, but the static ressources are not available any more.
Is it possible with a configuration like this to publish an endpoint to a running jetty with relative address? Or am I totally wrong? Most examples I found on the web use a web.xml, but I'm not working with an application server like tomcat and need the application to be a standalone eclipse app.
Spend the whole last two nights on this, any help is highly appreciated.
Kind regards,
Onno
There are sooo many samples here. U shud be able to find what u r looking for
http://svn.apache.org/repos/asf/cxf/branches/2.4.x-fixes/distribution/src/main/release/samples

Spring, Apache CXF and Embedded Jetty

I'm trying create a web service capable server using Apache CXF, Spring and an embedded Jetty server. When I run my project the server seems to initialize correctly, however when I navigate to http://localhost:8080/SomeService expecting to see the service WSDL, instead I get the following exception:
SEVERE: /SomeService
java.lang.NullPointerException
at org.apache.cxf.transport.servlet.AbstractCXFServlet.invoke(AbstractCXFServlet.java:163)
at org.apache.cxf.transport.servlet.AbstractCXFServlet.doGet(AbstractCXFServlet.java:145)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:693)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:806)
at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:502)
at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:389)
at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
at org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.Server.handle(Server.java:324)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:535)
at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:865)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:539)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:409)
at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:520)
Any ideas?
Here's the Java main()
public static void main(String[] args) throws Exception {
new ClassPathXmlApplicationContext(new String[] {"beans-jetty.xml"});
}
beans-jetty.xml
<bean id="propertyConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location" value="file:conf/server.properties" />
</bean>
<bean id="server"
class="org.mortbay.jetty.Server"
init-method="start"
destroy-method="stop">
<property name="connectors">
<list>
<bean id="connector" class="org.mortbay.jetty.nio.SelectChannelConnector">
<property name="host" value="${server.address}"/>
<property name="port" value="${server.port}"/>
</bean>
</list>
</property>
<property name="handlers">
<list>
<ref bean="context-cxf"/>
</list>
</property>
</bean>
<bean name="context-cxf" class="org.mortbay.jetty.servlet.Context">
<property name="contextPath" value="/" />
<property name="handler">
<bean class="org.mortbay.jetty.servlet.ServletHandler">
<property name="servlets">
<list>
<bean class="org.mortbay.jetty.servlet.ServletHolder">
<property name="name" value="cxf-servlet-holder" />
<property name="servlet">
<bean class="org.apache.cxf.transport.servlet.CXFServlet" />
</property>
</bean>
</list>
</property>
<property name="servletMappings">
<list>
<bean class="org.mortbay.jetty.servlet.ServletMapping">
<property name="servletName" value="cxf-servlet-holder" />
<property name="pathSpec" value="/*" />
</bean>
</list>
</property>
</bean>
</property>
</bean>
<import resource="classpath:META-INF/cxf/cxf-servlet.xml" />
<import resource="classpath:/beans-cxf.xml" />
beans-cxf.xml
<import resource="classpath:META-INF/cxf/cxf.xml" />
<import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />
<jaxws:endpoint
id="someService"
implementor="com.awebster.gitta.services.SomeServiceImpl"
address="${server.address}" />
I should mention that I'm using the Maven one-jar plugin, although I doubt that makes any difference to this problem.
Many Thanks in advance!
Anthony