Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[eclipselink-users] Re : Anyone using EL with newer Tomcat Servlet Environment and JNDI datasource?

I've dozens of systems running 2.5.0 and tomcat 7 and 8 this way. Do you have a stack trace or similar? 

 

Enviado do meu Telefone LG

------ Mensagem original ------
De: Markus Kolb
Data: 15/10/2014 11h15
Para: EclipseLink User Discussions;
Assunto:Re: [eclipselink-users] Anyone using EL with newer Tomcat Servlet Environment and JNDI datasource?

Hi,
sorry, as I've written before, I've already tried it with the 
SessionCustomizer.
The reference is the link to the wiki ;-)
But it does not provide the solution for my problem.

kr
Markus


Am 2014-10-15 15:59, schrieb Edson Carlos Ericksson Richter:
> Yes, it works.
> But you need a "trick" (I've adapted from example available in the
> Internet - but I lost the reference):
> 
> package my.pack;
> 
> import javax.naming.InitialContext;
> import org.eclipse.persistence.config.SessionCustomizer;
> import org.eclipse.persistence.sessions.Connector;
> import org.eclipse.persistence.sessions.JNDIConnector;
> import org.eclipse.persistence.sessions.Session;
> 
> public class JPACustomizer implements SessionCustomizer {
> 
>   public JPACustomizer() {
>   }
> 
>   @Override
>   public void customize(Session session) throws Exception {
>     JNDIConnector connector;
> 
>     try {
>       new InitialContext();
>       Connector conn = session.getLogin().getConnector();
> 
>       if (conn instanceof JNDIConnector) {
>         connector = (JNDIConnector) conn; // possible CCE
>         connector.setLookupType(JNDIConnector.STRING_LOOKUP);
>       }
> 
>     } catch (Exception e) {
>       Util.debug(e);
>     }
>   }
> }
> 
> 
> then in configuration file, you will have to put (inside properties):
> 
>    transaction-type="RESOURCE_LOCAL">
> org.eclipse.persistence.jpa.PersistenceProviderjava:comp/env/jdbc/myDataSourcefalse
>     ALL
>     NONE
>     
>        value="my.pack.JPACustomizer"/>
> ...
> 
> 
> Kind regards,
> 
> Edson Richter
> 
> 
> On 15-10-2014 10:31, Markus Kolb wrote:
>> Hello,
>> does anyone use current EclipseLink version with a up-to-date Tomcat 
>> Servlet Container and JNDI non-jta-datasource?
>> I try to get this working for some hours now...
>> - EclipseLink 2.5.2 (also tried 2.5.0)
>> - Tomcat 8.0.14 (but also 7.0.40 tried)
>> 
>> The Tomcat configuration is working. I can lookup the datasource in my 
>> application code.
>> But EclipseLink throws a NullPointerException in its 
>> JNDIConnector.connect(...).
>> I've reported this as 
>> https://bugs.eclipse.org/bugs/show_bug.cgi?id=447264
>> 
>> I've also tried 
>> https://wiki.eclipse.org/EclipseLink/Examples/JPA/Tomcat_Web_Tutorial#Session_Customizer.
>> Result: Same NPE.
>> 
>> I'm using now a Jetty Container 9.2.3 with EclipseLink 2.5.2 and the 
>> same WAR just works.
>> 
>> Is there any trick to get this working in Tomcat?
>> 
>> Thanks
>> Markus
>> _______________________________________________
>> eclipselink-users mailing list
>> eclipselink-users@xxxxxxxxxxx
>> To change your delivery options, retrieve your password, or 
>> unsubscribe from this list, visit
>> https://dev.eclipse.org/mailman/listinfo/eclipselink-users
> 
> 
> 
> _______________________________________________
> eclipselink-users mailing list
> eclipselink-users@xxxxxxxxxxx
> To change your delivery options, retrieve your password, or
> unsubscribe from this list, visit
> https://dev.eclipse.org/mailman/listinfo/eclipselink-users
_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/eclipselink-users


Back to the top