Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » SessionCustomizer not used
SessionCustomizer not used [message #1385376] Fri, 06 June 2014 01:28 Go to next message
Tom Dunstan is currently offline Tom DunstanFriend
Messages: 2
Registered: June 2014
Junior Member
Hi all

I'm attempting to get a SessionCustomizer working, but it seems to mostly not get called when I'm performing actual queries.

I'm running EclipseLink 2.5.1 in Glassfish 4, using a JNDI data source of type OracleConnectionPoolDataSource. My persistence.xml looks like this:

<persistence xmlns-stuff-omitted-due-to-forum-thinking-its-a-link version="2.1">
    <persistence-unit name="foo">
    	<jta-data-source>jdbc/FooDS</jta-data-source>
    	<exclude-unlisted-classes>false</exclude-unlisted-classes>
    	<properties>
    		<property name="eclipselink.session.customizer" value="com.foo.MySessionCustomizer"/>
    	</properties>
    </persistence-unit>
</persistence>


My SessionCustomizer does get called once or twice during startup, but not when I run a query. My customizer replaces the connector with one which returns a wrapped connection object, but that connector never gets used at query time - sticking a breakpoint on JNDIConnector shows that the default connector is getting called directly.

My session customizer does this:
public class MySessionCustomizer implements SessionCustomizer {
    public void customize(Session session) throws Exception {
        session.getLogin().setConnector(new FooConnector(session.getLogin().getConnector()));
    }
}

public class FooConnector implements Connector {
    Connector target;
    public FooConnector(Connector target) { this.target = target; }

    public Connection connect(Properties properties, Session session) {
        return new ConnectionWrapper(target.connect(properties, session));
    }
    ...
}



So in theory when trying to obtain a connection EclipseLink should be calling the connector that I have configured, but it doesn't. The stacktrace from hitting the breakpoint in JNDIConnector show this code path:

Daemon Thread [http-listener-1(2)] (Suspended (breakpoint at line 95 in JNDIConnector))	
	owns: DatabaseAccessor  (id=9822)	
	JNDIConnector.connect(Properties, Session) line: 95	
	DatabaseLogin(DatasourceLogin).connectToDatasource(Accessor, Session) line: 162	
	DatabaseAccessor(DatasourceAccessor).connectInternal(Login, AbstractSession) line: 346	
	DatabaseAccessor.connectInternal(Login, AbstractSession) line: 307	
	DatabaseAccessor(DatasourceAccessor).reconnect(AbstractSession) line: 581	
	DatabaseAccessor.reconnect(AbstractSession) line: 1625	
	DatabaseAccessor(DatasourceAccessor).incrementCallCount(AbstractSession) line: 321	
	DatabaseAccessor.basicExecuteCall(Call, AbstractRecord, AbstractSession, boolean) line: 613	
	DatabaseAccessor.executeCall(Call, AbstractRecord, AbstractSession) line: 558	
	ServerSession(AbstractSession).basicExecuteCall(Call, AbstractRecord, DatabaseQuery) line: 1991	
	ServerSession.executeCall(Call, AbstractRecord, DatabaseQuery) line: 570	
	ExpressionQueryMechanism(DatasourceCallQueryMechanism).executeCall(DatasourceCall) line: 242	
	ExpressionQueryMechanism(DatasourceCallQueryMechanism).executeCall() line: 228	
	ExpressionQueryMechanism(DatasourceCallQueryMechanism).executeSelectCall() line: 299	
	ExpressionQueryMechanism(DatasourceCallQueryMechanism).selectAllRows() line: 694	
	ExpressionQueryMechanism.selectAllRowsFromTable() line: 2738	
	ExpressionQueryMechanism.selectAllRows() line: 2691	
	ReadAllQuery.executeObjectLevelReadQuery() line: 495	
	ReadAllQuery(ObjectLevelReadQuery).executeDatabaseQuery() line: 1168	
	ReadAllQuery(DatabaseQuery).execute(AbstractSession, AbstractRecord) line: 899	
	ReadAllQuery(ObjectLevelReadQuery).execute(AbstractSession, AbstractRecord) line: 1127	
	ReadAllQuery.execute(AbstractSession, AbstractRecord) line: 403	
	ReadAllQuery(ObjectLevelReadQuery).executeInUnitOfWork(UnitOfWorkImpl, AbstractRecord) line: 1215	
	RepeatableWriteUnitOfWork(UnitOfWorkImpl).internalExecuteQuery(DatabaseQuery, AbstractRecord) line: 2896	
	RepeatableWriteUnitOfWork(AbstractSession).executeQuery(DatabaseQuery, AbstractRecord, int) line: 1793	
	RepeatableWriteUnitOfWork(AbstractSession).executeQuery(DatabaseQuery, AbstractRecord) line: 1775	
	RepeatableWriteUnitOfWork(AbstractSession).executeQuery(DatabaseQuery, List) line: 1740	
	EJBQueryImpl<X>(QueryImpl).executeReadQuery() line: 258	
	EJBQueryImpl<X>(QueryImpl).getResultList() line: 469	
	AuthorisationServiceImpl.getAll() line: 51	
	NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not available [native method]	
	NativeMethodAccessorImpl.invoke(Object, Object[]) line: 57	
	DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 43	
	Method.invoke(Object, Object...) line: 606	
	EJBSecurityManager.runMethod(Method, Object, Object[]) line: 1081	
	EJBSecurityManager.invoke(Method, boolean, Object, Object[]) line: 1153	
	StatelessSessionContainer(BaseContainer).invokeBeanMethod(EjbInvocation) line: 4695	
	EjbInvocation.invokeBeanMethod() line: 630	
	AroundInvokeChainImpl.invokeNext(int, InterceptorManager$AroundInvokeContext) line: 822	
	EjbInvocation.proceed() line: 582	
	SessionBeanInterceptor(AbstractEJBRequestScopeActivationInterceptor).aroundInvoke(InvocationContext) line: 46	
	NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not available [native method]	
	NativeMethodAccessorImpl.invoke(Object, Object[]) line: 57	
	DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 43	
	Method.invoke(Object, Object...) line: 606	
	AroundInvokeInterceptor.intercept(InterceptorManager$AroundInvokeContext) line: 883	
	AroundInvokeChainImpl.invokeNext(int, InterceptorManager$AroundInvokeContext) line: 822	
	EjbInvocation.proceed() line: 582	
	_SystemInterceptorProxy_Serializable(SystemInterceptorProxy).doCall(InvocationContext, Method) line: 163	
	_SystemInterceptorProxy_Serializable(SystemInterceptorProxy).aroundInvoke(InvocationContext) line: 140	
	NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not available [native method]	
	NativeMethodAccessorImpl.invoke(Object, Object[]) line: 57	
	DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 43	
	Method.invoke(Object, Object...) line: 606	
	AroundInvokeInterceptor.intercept(InterceptorManager$AroundInvokeContext) line: 883	
	AroundInvokeChainImpl.invokeNext(int, InterceptorManager$AroundInvokeContext) line: 822	
	InterceptorManager.intercept(InterceptorManager$InterceptorChain, InterceptorManager$AroundInvokeContext) line: 369	
	StatelessSessionContainer(BaseContainer).__intercept(EjbInvocation) line: 4667	
	StatelessSessionContainer(BaseContainer).intercept(EjbInvocation) line: 4655	
	EJBLocalObjectInvocationHandler.invoke(Class, Method, Object[]) line: 212	
	EJBLocalObjectInvocationHandlerDelegate.invoke(Object, Method, Object[]) line: 88	
	$Proxy284.getAll() line: not available	
	Licences.findLicences(UriInfo) line: 39	
	NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not available [native method]	
	NativeMethodAccessorImpl.invoke(Object, Object[]) line: 57	
	DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 43	
	Method.invoke(Object, Object...) line: 606	
	ResourceMethodInvocationHandlerFactory$1.invoke(Object, Method, Object[]) line: 81	
	JavaResourceMethodDispatcherProvider$TypeOutInvoker(AbstractJavaResourceMethodDispatcher).invoke(Object, Object...) line: 125	
	JavaResourceMethodDispatcherProvider$TypeOutInvoker.doDispatch(Object, Request) line: 195	
	JavaResourceMethodDispatcherProvider$TypeOutInvoker(AbstractJavaResourceMethodDispatcher).dispatch(Object, Request) line: 91	
	ResourceMethodInvoker.invoke(ContainerRequest, Object) line: 346	
	ResourceMethodInvoker.apply(ContainerRequest) line: 341	
	ResourceMethodInvoker.apply(Object) line: 101	
	ServerRuntime$1.run() line: 224	
	Errors$1.call() line: 271	
	Errors$1.call() line: 267	
	Errors.process(Callable<T>, boolean) line: 315	
	Errors.process(Producer<T>, boolean) line: 297	
	Errors.process(Runnable) line: 267	
	RequestScope.runInScope(Runnable) line: 317	
	ServerRuntime.process(ContainerRequest) line: 198	
	ApplicationHandler.handle(ContainerRequest) line: 946	
	WebComponent.service(URI, URI, HttpServletRequest, HttpServletResponse) line: 323	
	ServletContainer.service(URI, URI, HttpServletRequest, HttpServletResponse) line: 372	
	ServletContainer.service(HttpServletRequest, HttpServletResponse) line: 335	
	ServletContainer.service(ServletRequest, ServletResponse) line: 218	
	StandardWrapper.service(ServletRequest, ServletResponse, Servlet) line: 1682	
	ApplicationFilterChain.internalDoFilter(ServletRequest, ServletResponse) line: 344	
	ApplicationFilterChain.doFilter(ServletRequest, ServletResponse) line: 214	
	ProfilingFilter.doFilter(ServletRequest, ServletResponse, FilterChain) line: 85	
	ApplicationFilterChain.internalDoFilter(ServletRequest, ServletResponse) line: 256	
	ApplicationFilterChain.doFilter(ServletRequest, ServletResponse) line: 214	
	StandardWrapperValve.invoke(Request, Response) line: 316	
	StandardContextValve.invoke(Request, Response) line: 160	
	WebPipeline(StandardPipeline).doInvoke(Request, Response, boolean) line: 734	
	WebPipeline(StandardPipeline).invoke(Request, Response) line: 673	
	WebPipeline.invoke(Request, Response) line: 99	
	StandardHostValve.invoke(Request, Response) line: 174	
	CoyoteAdapter.doService(Request, Request, Response, Response, boolean) line: 357	
	CoyoteAdapter.service(Request, Response) line: 260	
	ContainerMapper.service(Request, Response) line: 188	
	ContainerMapper(HttpHandler).runService(Request, Response) line: 191	
	ContainerMapper(HttpHandler).doHandle(Request, Response) line: 168	
	HttpServerFilter.handleRead(FilterChainContext) line: 189	
	ExecutorResolver$9.execute(Filter, FilterChainContext) line: 119	
	DefaultFilterChain.executeFilter(FilterExecutor, Filter, FilterChainContext) line: 288	
	DefaultFilterChain.executeChainPart(FilterChainContext, FilterExecutor, int, int, DefaultFilterChain$FiltersState) line: 206	
	DefaultFilterChain.execute(FilterChainContext) line: 136	
	DefaultFilterChain.process(Context) line: 114	
	ProcessorExecutor.execute(Context) line: 77	
	TCPNIOTransport.fireIOEvent(IOEvent, Connection, IOEventProcessingHandler) line: 838	
	AbstractIOStrategy.fireIOEvent(Connection, IOEvent, IOEventProcessingHandler, Logger) line: 113	
	WorkerThreadIOStrategy.run0(Connection, IOEvent, IOEventProcessingHandler) line: 115	
	WorkerThreadIOStrategy.access$100(Connection, IOEvent, IOEventProcessingHandler) line: 55	
	WorkerThreadIOStrategy$WorkerThreadRunnable.run() line: 135	
	FixedThreadPool$BasicWorker(AbstractThreadPool$Worker).doWork() line: 564	
	FixedThreadPool$BasicWorker(AbstractThreadPool$Worker).run() line: 544	
	DefaultWorkerThread(Thread).run() line: 744	


I really just want the equivalent of the Hibernate ConnectionProvider interface (can't link to it as I have less than 5 posts, it's google-able). It seemed like replacing the connector in a session customizer was the way to do it, but the new connector just doesn't get used.

Any suggestions?

Thanks

Tom
Re: SessionCustomizer not used [message #1385691 is a reply to message #1385376] Tue, 10 June 2014 14:21 Go to previous messageGo to next message
Chris Delahunt is currently offline Chris DelahuntFriend
Messages: 1389
Registered: July 2009
Senior Member
ServerSessions use two connection pools each with their own connector - the default one which you are setting the connector on is used for writes, while the readpool is cloned from it used for reads.

Try calling ((ServerSession)this.session).getReadConnectionPool().getLogin().setConnector(new FooConnector(session.getLogin().getConnector()));
as well, though I'm surprised it needs to be. You might check when the read pool is being set with breakpoints in your debugger.

Best Regards,
Chris
Re: SessionCustomizer not used [message #1386244 is a reply to message #1385691] Mon, 16 June 2014 06:32 Go to previous message
Tom Dunstan is currently offline Tom DunstanFriend
Messages: 2
Registered: June 2014
Junior Member
That did the trick, thanks.

Someone with edit permissions might want to update https://wiki.eclipse.org/EclipseLink/UserGuide/JPA/Advanced_JPA_Development/Customizers as it has an example of setting a custom connector but doesn't mention the second read-pool.

Cheer

Tom
Previous Topic:UnaryTableSequence per entity vs single table-sequence table
Next Topic:EL QBE JPA2
Goto Forum:
  


Current Time: Tue Mar 19 05:48:41 GMT 2024

Powered by FUDForum. Page generated in 0.02435 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top