You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomee.apache.org by James Green <ja...@gmail.com> on 2013/07/01 12:57:37 UTC

Re: Reconnect if JPA fails at boot?

In our case we have two EJBs, both @Singleton and @Startup, one depends on
the other. One is a cache façade and the other loads data via JPA and feeds
it into the cache. An external schedule fires a servlet that reloads the
cache from the database.

What's happening is that without MySQL we see EJB exceptions that they
cannot be created and thus we are dead.

I've just tried adding autoReconnect=true inside a <Resource> but that made
no difference. I also tried adding ,autoReconnect=true to
ConnectionProperties and ConnectionFactoryProperties without any change but
I'm not convinced that would have fixed the problem here.

Is it instead the case that within the EJB I should be trapping
connectivity problems such as PersistenceException and allowing the
containing to gracefully start up and naturally keep trying anyway?

James



On 28 June 2013 17:10, José Luis Cetina <ma...@gmail.com> wrote:

> I had a similar problem and what i did was set the autoReconnect attribute
> to true en my tomee.xml datasource.
> What do you mean with retry until the connection springs to life? do you
> have some schedules or jobs running and want to retry again when the
> connection is available again? or just want when somebody click any button
> the app can connect again (this was my case)??
>
>
> 2013/6/28 Romain Manni-Bucau <rm...@gmail.com>
>
> > With an ejb timer?
> > Le 28 juin 2013 17:46, "James Green" <ja...@gmail.com> a écrit
> :
> >
> > > Hopefully a quick one.
> > >
> > > On boot our application attempts to read data through a JPA
> > EntityManager.
> > > If the database connection fails at this point the entire application
> is
> > > effectively dead.
> > >
> > > Is there a way to essentially ask the database layer to retry until the
> > > connection springs to life?
> > >
> > > Thanks,
> > >
> > > James
> > >
> >
>
>
>
> --
> -------------------------------------------------------------------
> *SCJA. José Luis Cetina*
> -------------------------------------------------------------------
>

Re: Reconnect if JPA fails at boot?

Posted by omisaye_infotech <om...@yahoo.com>.
     Hello  to all my brother.pls i'm new to restful web service and also new in using the new apache TomeePlus .My aim of using restful webservice is to integrate it in my web e-comerce websit.


    FIRST:
My IDE is Netbeans 7.3.1,
        In my sql ,I built a database called oko which is made up on table with ID,firstname and Lastname, this is just for testing purposes.
        in My netbeans i built a web app called AGAIN
in thsi AGAIN I built entity beans from my  Mysql database,"entity class = Oko.java"
i built restful web service from entity class "Oko.java";
        i used glassfish server 3.2.
when i tested  the restful webservice  it work pretty well.
i was very happy with this !!.
  
SECOND :
       Now i tried to do thesame thing with my  apache TomeePlus server ,
       but it is not working .
       i included "mysql driver jar file " to TomeePlus /lib,
       i Fololwed the step on FIRST:
       it gave me an error which has kept me one week trying to resolve.
 
ERROR  :
        SEVERE: Servlet.service() for servlet [ServletAdaptor] in context with path [/AGAIN] threw exception
java.lang.NullPointerException
at service.AbstractFacade.findAll(AbstractFacade.java:40)
at service.OkoFacadeREST.findAll(OkoFacadeREST.java:66)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.sun.jersey.spi.container.JavaMethodInvokerFactory$1.invoke(JavaMethodInvokerFactory.java:60)
at com.sun.jersey.server.impl.model.method.dispatch.AbstractResourceMethodDispatchProvider$TypeOutInvoker._dispatch(AbstractResourceMethodDispatchProvider.java:185)
at com.sun.jersey.server.impl.model.method.dispatch.ResourceJavaMethodDispatcher.dispatch(ResourceJavaMethodDispatcher.java:75)
at com.sun.jersey.server.impl.uri.rules.HttpMethodRule.accept(HttpMethodRule.java:302)
at com.sun.jersey.server.impl.uri.rules.ResourceClassRule.accept(ResourceClassRule.java:108)
at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147)
at com.sun.jersey.server.impl.uri.rules.RootResourceClassesRule.accept(RootResourceClassesRule.java:84)
at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1480)
at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1411)
at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1360)
at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1350)
at com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:416)
at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:538)
at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:716)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:936)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1004)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:724)





WEB.XML:
      My web.xml file looks like this

     <?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
    <servlet>
        <servlet-name>ServletAdaptor</servlet-name>
        <servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
        <init-param>
            <description>Multiple packages, separated by semicolon(;), can be specified in param-value</description>
            <param-name>com.sun.jersey.config.property.packages</param-name>
            <param-value>service</param-value>
        </init-param>
        <init-param>
            <param-name>com.sun.jersey.api.json.POJOMappingFeature</param-name>
            <param-value>true</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>ServletAdaptor</servlet-name>
        <url-pattern>/webresources/*</url-pattern>
    </servlet-mapping>
    <session-config>
        <session-timeout>
            30
        </session-timeout>
    </session-config>
</web-app>


 
CONTEXT.XML:

My context.xml file looks like this
   <?xml version="1.0" encoding="UTF-8"?>
<Context antiJARLocking="true" path="/AGAIN"/>



PERSISTENCE.XML:



  My persistence .xml  file looks like this 


<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<persistence xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.1" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
  <persistence-unit name="AGAINPU" transaction-type="RESOURCE_LOCAL">
    <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
    <class>PAC.Oko</class>
    <exclude-unlisted-classes>false</exclude-unlisted-classes>
    <properties>
      <property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/okolotesting?zeroDateTimeBehavior=convertToNull"/>
      <property name="javax.persistence.jdbc.password" value="root"/>
      <property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver"/>
      <property name="javax.persistence.jdbc.user" value="root"/>
    </properties>
  </persistence-unit>
</persistence>



.Please brothers this has kept me almost a week of  nigthless sleep.
i need your help and support pleas.
You can also contact me via E-mail  :omisaye_infotech@yahoo.com
 THANKS FOR YOUR HELP!!



--
View this message in context: http://openejb.979440.n4.nabble.com/Reconnect-if-JPA-fails-at-boot-tp4663998p4664052.html
Sent from the OpenEJB User mailing list archive at Nabble.com.

Re: Reconnect if JPA fails at boot?

Posted by James Green <ja...@gmail.com>.
Romain's emails tend to assume you know what's he's talking about ;-) On
this matter I've no idea how to provide the dictionary to JPA and how it
fits in with our existing design so if the "magic" appears as an example
I'll certainly give it shot!



On 1 July 2013 17:17, Howard W. Smith, Jr. <sm...@gmail.com> wrote:

> Will you be trying the magic that Romain recommended?
>  On Jul 1, 2013 10:34 AM, "James Green" <ja...@gmail.com> wrote:
>
> > I was asking about cold boot, specifically. It is when the application
> > server begins that the JPA implementation performs the Entity mapping, so
> > if the database is not available presumably it remains dead until the
> > application server itself is restarted?
> >
> > Unless you already have the magic installed that Romain refers to.
> >
> >
> > On 1 July 2013 15:24, José Luis Cetina <ma...@gmail.com> wrote:
> >
> > > My entire app use database and of course the app doesnt work if the
> > > database is unavailable, but when the database server is available
> again
> > > the webapp can use the database again without restarting TomEE.
> > >
> > > I dont know if i response your question.
> > >
> > >
> > > 2013/7/1 James Green <ja...@gmail.com>
> > >
> > > > Are you saying your application starts from cold without the
> database,
> > > the
> > > > operates fine without intervention once the database becomes
> available?
> > > >
> > > >
> > > > On 1 July 2013 14:26, José Luis Cetina <ma...@gmail.com> wrote:
> > > >
> > > > > I have also differents server, 1 one database and 2 for TomEE
> (using
> > > > > memcached + cluster) and with autoReconnect=true i dont have any
> > issue
> > > > when
> > > > > the database server reboot, i set this attribute (autoReconnect)
> > after
> > > i
> > > > > experiment your same problems, when the database server rebooted my
> > > apps
> > > > > cant connect anymore to the database server, i had to stop and
> start
> > > > tomee
> > > > > again for work. But then, i add that option and now i work with any
> > > > > problem.
> > > > >
> > > > > Here is a example of my Resource:
> > > > >
> > > > > <Resource id="ANY_NAME" type="DataSource">
> > > > >   JdbcDriver com.mysql.jdbc.Driver
> > > > >   JdbcUrl
> > > > >
> > > > >
> > > >
> > >
> >
> jdbc:mysql://any_ip:3306/any_database?zeroDateTimeBehavior=convertToNull&amp;rewriteBatchedStatements=true&amp;autoReconnect=true
> > > > >   UserName any_user
> > > > >   Password any_password
> > > > >   JtaManaged true
> > > > >   InitialSize=3
> > > > >   MaxActive=100
> > > > >   ValidationQuery=SELECT 1
> > > > >   TestOnBorrow=true
> > > > > </Resource>
> > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > > > 2013/7/1 James Green <ja...@gmail.com>
> > > > >
> > > > > > This now sounds substantially more complex than my design (which
> > uses
> > > > > > @PersistenceContext(unitName="accounts")) caters for. Is there an
> > > > example
> > > > > > of what you mean somewhere so I can scope the work out?
> > > > > >
> > > > > > Thanks
> > > > > > James
> > > > > >
> > > > > >
> > > > > > On 1 July 2013 12:44, Romain Manni-Bucau <rm...@gmail.com>
> > > > wrote:
> > > > > >
> > > > > > > Hi
> > > > > > >
> > > > > > > it depends your config and that's probably more an openjpa
> > question
> > > > but
> > > > > > > basically you'll need to provide the dictionnary to use since
> > > openjpa
> > > > > > will
> > > > > > > not be able to read database metadata (at least).
> > > > > > >
> > > > > > > *Romain Manni-Bucau*
> > > > > > > *Twitter: @rmannibucau <https://twitter.com/rmannibucau>*
> > > > > > > *Blog: **http://rmannibucau.wordpress.com/*<
> > > > > > > http://rmannibucau.wordpress.com/>
> > > > > > > *LinkedIn: **http://fr.linkedin.com/in/rmannibucau*
> > > > > > > *Github: https://github.com/rmannibucau*
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > 2013/7/1 James Green <ja...@gmail.com>
> > > > > > >
> > > > > > > > I've suppressed the RuntimeExceptions encountered as EJBs
> fire
> > > and
> > > > > > access
> > > > > > > > JPA, however I have a new problem now:
> > > > > > > >
> > > > > > > > Caused by: <openjpa-2.2.0-r422266:1244990 nonfatal user
> error>
> > > > > > > > org.apache.openjpa.persistence.ArgumentException: An error
> > > occurred
> > > > > > while
> > > > > > > > parsing the query filter "SELECT a FROM Account a". Error
> > > message:
> > > > > The
> > > > > > > name
> > > > > > > > "Account" is not a recognized entity or identifier. Known
> > entity
> > > > > names:
> > > > > > > []
> > > > > > > >
> > > > > > > > It seems the JPA component was unable to map my @Entity
> classes
> > > > > because
> > > > > > > the
> > > > > > > > connection did not exist at startup. What do I need to do to
> > work
> > > > > > around
> > > > > > > > this?
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > On 1 July 2013 12:07, Romain Manni-Bucau <
> > rmannibucau@gmail.com>
> > > > > > wrote:
> > > > > > > >
> > > > > > > > > yep
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > basically get injected the timerservice (
> > > > > > > > >
> > > http://docs.oracle.com/javaee/6/api/javax/ejb/TimerService.html
> > > > ),
> > > > > in
> > > > > > > > your
> > > > > > > > > init method you try to get your data, if not trigger a
> later
> > > > > > > > > invocation (
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> http://docs.oracle.com/javaee/6/api/javax/ejb/TimerService.html#createSingleActionTimer(java.util.Date
> > > > > > > > > ,
> > > > > > > > > javax.ejb.TimerConfig)). While it fails trigger another one
> > > when
> > > > > > > invoked.
> > > > > > > > > When it succeeds you are done.
> > > > > > > > >
> > > > > > > > > *Romain Manni-Bucau*
> > > > > > > > > *Twitter: @rmannibucau <https://twitter.com/rmannibucau>*
> > > > > > > > > *Blog: **http://rmannibucau.wordpress.com/*<
> > > > > > > > > http://rmannibucau.wordpress.com/>
> > > > > > > > > *LinkedIn: **http://fr.linkedin.com/in/rmannibucau*
> > > > > > > > > *Github: https://github.com/rmannibucau*
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > 2013/7/1 James Green <ja...@gmail.com>
> > > > > > > > >
> > > > > > > > > > In our case we have two EJBs, both @Singleton and
> @Startup,
> > > one
> > > > > > > depends
> > > > > > > > > on
> > > > > > > > > > the other. One is a cache façade and the other loads data
> > via
> > > > JPA
> > > > > > and
> > > > > > > > > feeds
> > > > > > > > > > it into the cache. An external schedule fires a servlet
> > that
> > > > > > reloads
> > > > > > > > the
> > > > > > > > > > cache from the database.
> > > > > > > > > >
> > > > > > > > > > What's happening is that without MySQL we see EJB
> > exceptions
> > > > that
> > > > > > > they
> > > > > > > > > > cannot be created and thus we are dead.
> > > > > > > > > >
> > > > > > > > > > I've just tried adding autoReconnect=true inside a
> > <Resource>
> > > > but
> > > > > > > that
> > > > > > > > > made
> > > > > > > > > > no difference. I also tried adding ,autoReconnect=true to
> > > > > > > > > > ConnectionProperties and ConnectionFactoryProperties
> > without
> > > > any
> > > > > > > change
> > > > > > > > > but
> > > > > > > > > > I'm not convinced that would have fixed the problem here.
> > > > > > > > > >
> > > > > > > > > > Is it instead the case that within the EJB I should be
> > > trapping
> > > > > > > > > > connectivity problems such as PersistenceException and
> > > allowing
> > > > > the
> > > > > > > > > > containing to gracefully start up and naturally keep
> trying
> > > > > anyway?
> > > > > > > > > >
> > > > > > > > > > James
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > On 28 June 2013 17:10, José Luis Cetina <
> > > maxtorzito@gmail.com>
> > > > > > > wrote:
> > > > > > > > > >
> > > > > > > > > > > I had a similar problem and what i did was set the
> > > > > autoReconnect
> > > > > > > > > > attribute
> > > > > > > > > > > to true en my tomee.xml datasource.
> > > > > > > > > > > What do you mean with retry until the connection
> springs
> > to
> > > > > life?
> > > > > > > do
> > > > > > > > > you
> > > > > > > > > > > have some schedules or jobs running and want to retry
> > again
> > > > > when
> > > > > > > the
> > > > > > > > > > > connection is available again? or just want when
> somebody
> > > > click
> > > > > > any
> > > > > > > > > > button
> > > > > > > > > > > the app can connect again (this was my case)??
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > 2013/6/28 Romain Manni-Bucau <rm...@gmail.com>
> > > > > > > > > > >
> > > > > > > > > > > > With an ejb timer?
> > > > > > > > > > > > Le 28 juin 2013 17:46, "James Green" <
> > > > > james.mk.green@gmail.com
> > > > > > >
> > > > > > > a
> > > > > > > > > > écrit
> > > > > > > > > > > :
> > > > > > > > > > > >
> > > > > > > > > > > > > Hopefully a quick one.
> > > > > > > > > > > > >
> > > > > > > > > > > > > On boot our application attempts to read data
> > through a
> > > > JPA
> > > > > > > > > > > > EntityManager.
> > > > > > > > > > > > > If the database connection fails at this point the
> > > entire
> > > > > > > > > application
> > > > > > > > > > > is
> > > > > > > > > > > > > effectively dead.
> > > > > > > > > > > > >
> > > > > > > > > > > > > Is there a way to essentially ask the database
> layer
> > to
> > > > > retry
> > > > > > > > until
> > > > > > > > > > the
> > > > > > > > > > > > > connection springs to life?
> > > > > > > > > > > > >
> > > > > > > > > > > > > Thanks,
> > > > > > > > > > > > >
> > > > > > > > > > > > > James
> > > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > --
> > > > > > > > > > >
> > > > > >
> -------------------------------------------------------------------
> > > > > > > > > > > *SCJA. José Luis Cetina*
> > > > > > > > > > >
> > > > > >
> -------------------------------------------------------------------
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > > >
> > > > >
> > > > > --
> > > > > -------------------------------------------------------------------
> > > > > *SCJA. José Luis Cetina*
> > > > > -------------------------------------------------------------------
> > > > >
> > > >
> > >
> > >
> > >
> > > --
> > > -------------------------------------------------------------------
> > > *SCJA. José Luis Cetina*
> > > -------------------------------------------------------------------
> > >
> >
>

Re: Reconnect if JPA fails at boot?

Posted by Romain Manni-Bucau <rm...@gmail.com>.
i mean you can say you dont want to rely on it but supposing you can is not
a big assumption (that's startup) and eases the dev a lot

*Romain Manni-Bucau*
*Twitter: @rmannibucau <https://twitter.com/rmannibucau>*
*Blog: **http://rmannibucau.wordpress.com/*<http://rmannibucau.wordpress.com/>
*LinkedIn: **http://fr.linkedin.com/in/rmannibucau*
*Github: https://github.com/rmannibucau*



2013/7/2 James Green <ja...@gmail.com>

> Why would anyone rely on a particular resource being available at startup?
> Other than the container, every external resource is liable to failure at
> some point. We build applications to cover that contingency by issuing
> error while the resource is not available, then performing work while they
> are available.
>
> Reading around it seems this is far more complicated than it perhaps ought
> to be, with autoreconnect having serious implications in a transactional
> environment. That said, our JPA use is current read-only.
>
> I'm minded to continue this problem on an openjpa mailing list and see if I
> can narrow down precisely what we want to do. Thanks for your time & help
> regardless, always welcomed.
>
> James
>
>
> On 2 July 2013 14:08, Romain Manni-Bucau <rm...@gmail.com> wrote:
>
> > wait, here you speak about startup, if you can't rely on it even at
> startup
> > you'll have to configure explicitely your jpa provider not not need it
> and
> > your pool to automatically reconnect when needed. that's the main
> > constraints.
> >
> > *Romain Manni-Bucau*
> > *Twitter: @rmannibucau <https://twitter.com/rmannibucau>*
> > *Blog: **http://rmannibucau.wordpress.com/*<
> > http://rmannibucau.wordpress.com/>
> > *LinkedIn: **http://fr.linkedin.com/in/rmannibucau*
> > *Github: https://github.com/rmannibucau*
> >
> >
> >
> > 2013/7/2 James Green <ja...@gmail.com>
> >
> > > A database is merely a resource - same as a message queue or a file. In
> > > technology we never rely on them so we have to test the recovery of our
> > > software instead. So I am here :)
> > >
> > >
> > > On 2 July 2013 12:48, Romain Manni-Bucau <rm...@gmail.com>
> wrote:
> > >
> > > > no, this is another error, not sure why ATM but it should be an easy
> > one.
> > > > If that's because the database was not here you'll need to ensure the
> > > > datasource is here before using the entity manager for the first time
> > or
> > > to
> > > > list classes manually.
> > > >
> > > > that said to be honest if you *can't* rely on your database at all
> you
> > > > should just use something else
> > > >
> > > > *Romain Manni-Bucau*
> > > > *Twitter: @rmannibucau <https://twitter.com/rmannibucau>*
> > > > *Blog: **http://rmannibucau.wordpress.com/*<
> > > > http://rmannibucau.wordpress.com/>
> > > > *LinkedIn: **http://fr.linkedin.com/in/rmannibucau*
> > > > *Github: https://github.com/rmannibucau*
> > > >
> > > >
> > > >
> > > > 2013/7/2 James Green <ja...@gmail.com>
> > > >
> > > > > That will also fix the original error - that the list of mapped
> > classes
> > > > is
> > > > > empty? Copy of the error again:
> > > > >
> > > > > Caused by: <openjpa-2.2.0-r422266:1244990 nonfatal user error>
> > > > > org.apache.openjpa.persistence.ArgumentException: An error occurred
> > > while
> > > > > parsing the query filter "SELECT a FROM Account a". Error message:
> > The
> > > > name
> > > > > "Account" is not a recognized entity or identifier. Known entity
> > names:
> > > > []
> > > > >
> > > > >
> > > > >
> > > > >
> > > > > On 2 July 2013 12:31, Romain Manni-Bucau <rm...@gmail.com>
> > > wrote:
> > > > >
> > > > > > just add in your persistence unit the needed property (sample for
> > > > > > mysql: <property
> > > > > > name="openjpa.jdbc.DBDictionary" value="mysql"/> )
> > > > > >
> > > > > > *Romain Manni-Bucau*
> > > > > > *Twitter: @rmannibucau <https://twitter.com/rmannibucau>*
> > > > > > *Blog: **http://rmannibucau.wordpress.com/*<
> > > > > > http://rmannibucau.wordpress.com/>
> > > > > > *LinkedIn: **http://fr.linkedin.com/in/rmannibucau*
> > > > > > *Github: https://github.com/rmannibucau*
> > > > > >
> > > > > >
> > > > > >
> > > > > > 2013/7/2 James Green <ja...@gmail.com>
> > > > > >
> > > > > > > The documentation link you supplied: I'm not sure what I am
> > looking
> > > > for
> > > > > > in
> > > > > > > it. That's what I meant to say.
> > > > > > >
> > > > > > > To cut this down is there a demonstration project where this is
> > > > already
> > > > > > > correctly configured? May be simpler than explaining the
> changes
> > to
> > > > me
> > > > > :)
> > > > > > >
> > > > > > >
> > > > > > > On 2 July 2013 12:14, Romain Manni-Bucau <
> rmannibucau@gmail.com>
> > > > > wrote:
> > > > > > >
> > > > > > > > didnt get the first sentence
> > > > > > > >
> > > > > > > > about the "make it worse" it is what i explained in my
> previous
> > > > > answer:
> > > > > > > if
> > > > > > > > you start without a db and openjpa uses automatically the
> wrong
> > > > > > > dictionnary
> > > > > > > > then even if the db is back and the pool well configured, the
> > jpa
> > > > > layer
> > > > > > > > will generate wrong SQL so it will not work, so your app is
> > > broken
> > > > > > > whatever
> > > > > > > > the db state is.
> > > > > > > >
> > > > > > > > *Romain Manni-Bucau*
> > > > > > > > *Twitter: @rmannibucau <https://twitter.com/rmannibucau>*
> > > > > > > > *Blog: **http://rmannibucau.wordpress.com/*<
> > > > > > > > http://rmannibucau.wordpress.com/>
> > > > > > > > *LinkedIn: **http://fr.linkedin.com/in/rmannibucau*
> > > > > > > > *Github: https://github.com/rmannibucau*
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > 2013/7/2 James Green <ja...@gmail.com>
> > > > > > > >
> > > > > > > > > Am I looking for something letting me list the classes I
> want
> > > > > mapped?
> > > > > > > The
> > > > > > > > > error I see shows an empty list, hence this particular
> > > question.
> > > > > > > > >
> > > > > > > > > You say it doesn't solve our issue and can actually make it
> > > > worse?
> > > > > > Care
> > > > > > > > to
> > > > > > > > > elaborate?
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > On 2 July 2013 09:17, Romain Manni-Bucau <
> > > rmannibucau@gmail.com>
> > > > > > > wrote:
> > > > > > > > >
> > > > > > > > > > the dict doc is here
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> http://openjpa.apache.org/builds/2.2.2/apache-openjpa/docs/ref_guide_dbsetup_dbsupport.html
> > > > > > > > > >
> > > > > > > > > > it is important to set it if the database can be down at
> > > > startup
> > > > > > > > > otherwise
> > > > > > > > > > you can end up with a wrong dict (generally the generic
> > one)
> > > > and
> > > > > > then
> > > > > > > > > when
> > > > > > > > > > the database is up again SQL stuff will not work
> > > > > > > > > >
> > > > > > > > > > it doesn't solve your issue but it can make it worse
> > > > > > > > > >
> > > > > > > > > > *Romain Manni-Bucau*
> > > > > > > > > > *Twitter: @rmannibucau <https://twitter.com/rmannibucau
> >*
> > > > > > > > > > *Blog: **http://rmannibucau.wordpress.com/*<
> > > > > > > > > > http://rmannibucau.wordpress.com/>
> > > > > > > > > > *LinkedIn: **http://fr.linkedin.com/in/rmannibucau*
> > > > > > > > > > *Github: https://github.com/rmannibucau*
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > 2013/7/2 James Green <ja...@gmail.com>
> > > > > > > > > >
> > > > > > > > > > > That's exactly what I want. All I have are EJBs with
> > entity
> > > > > > > managers
> > > > > > > > > > > injected via @PersistenceContext (exactly as we are
> > taught
> > > in
> > > > > the
> > > > > > > > > > > "Beginning Java EE 6 Platform with Glassfish 3" book
> > which
> > > is
> > > > > how
> > > > > > > > this
> > > > > > > > > > > application began life.
> > > > > > > > > > >
> > > > > > > > > > > So what's the difference I wonder? Romain talks about
> > > adding
> > > > a
> > > > > > > > > dictionary
> > > > > > > > > > > but I didn't spot anything spectacularly obvious in a
> > > browse
> > > > of
> > > > > > the
> > > > > > > > > > OpenJPA
> > > > > > > > > > > user guide yesterday (indeed on the subject of
> injection
> > it
> > > > > told
> > > > > > me
> > > > > > > > to
> > > > > > > > > > > refer to my application server documentation...).
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > On 1 July 2013 18:05, José Luis Cetina <
> > > maxtorzito@gmail.com
> > > > >
> > > > > > > wrote:
> > > > > > > > > > >
> > > > > > > > > > > > I did this test:
> > > > > > > > > > > >
> > > > > > > > > > > > 1. Stop TomEE
> > > > > > > > > > > > 2. Shutdown my database server
> > > > > > > > > > > > 3. Start TomEE
> > > > > > > > > > > > 4. Try to access to my app, i could access but when i
> > hit
> > > > my
> > > > > > > login
> > > > > > > > > > button
> > > > > > > > > > > > for example then i get this error:
> > > > > > > > > > > >
> > > > > > > >
> > > > com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException:
> > > > > > > > > > > > Could not create connection to database server.
> > Attempted
> > > > > > > > reconnect 3
> > > > > > > > > > > > times. Giving up.
> > > > > > > > > > > > 5. Start up my database server
> > > > > > > > > > > > 6. Wait for my database to be ready, i refresh the
> page
> > > > then
> > > > > > hit
> > > > > > > > > again
> > > > > > > > > > at
> > > > > > > > > > > > the login button, then my app run without problem (in
> > > this
> > > > > > point
> > > > > > > i
> > > > > > > > > DONT
> > > > > > > > > > > > stop/start TomEE again).
> > > > > > > > > > > >
> > > > > > > > > > > > Is this the behavior that you need/want it??
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > *Remeber that i have tomee and database in separate
> > > > server's
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > 2013/7/1 Howard W. Smith, Jr. <
> smithh032772@gmail.com>
> > > > > > > > > > > >
> > > > > > > > > > > > > Will you be trying the magic that Romain
> recommended?
> > > > > > > > > > > > >  On Jul 1, 2013 10:34 AM, "James Green" <
> > > > > > > > james.mk.green@gmail.com>
> > > > > > > > > > > > wrote:
> > > > > > > > > > > > >
> > > > > > > > > > > > > > I was asking about cold boot, specifically. It is
> > > when
> > > > > the
> > > > > > > > > > > application
> > > > > > > > > > > > > > server begins that the JPA implementation
> performs
> > > the
> > > > > > Entity
> > > > > > > > > > > mapping,
> > > > > > > > > > > > so
> > > > > > > > > > > > > > if the database is not available presumably it
> > > remains
> > > > > dead
> > > > > > > > until
> > > > > > > > > > the
> > > > > > > > > > > > > > application server itself is restarted?
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > Unless you already have the magic installed that
> > > Romain
> > > > > > > refers
> > > > > > > > > to.
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > On 1 July 2013 15:24, José Luis Cetina <
> > > > > > maxtorzito@gmail.com
> > > > > > > >
> > > > > > > > > > wrote:
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > > My entire app use database and of course the
> app
> > > > doesnt
> > > > > > > work
> > > > > > > > if
> > > > > > > > > > the
> > > > > > > > > > > > > > > database is unavailable, but when the database
> > > server
> > > > > is
> > > > > > > > > > available
> > > > > > > > > > > > > again
> > > > > > > > > > > > > > > the webapp can use the database again without
> > > > > restarting
> > > > > > > > TomEE.
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > I dont know if i response your question.
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > 2013/7/1 James Green <james.mk.green@gmail.com
> >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > Are you saying your application starts from
> > cold
> > > > > > without
> > > > > > > > the
> > > > > > > > > > > > > database,
> > > > > > > > > > > > > > > the
> > > > > > > > > > > > > > > > operates fine without intervention once the
> > > > database
> > > > > > > > becomes
> > > > > > > > > > > > > available?
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > On 1 July 2013 14:26, José Luis Cetina <
> > > > > > > > maxtorzito@gmail.com
> > > > > > > > > >
> > > > > > > > > > > > wrote:
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > I have also differents server, 1 one
> database
> > > > and 2
> > > > > > for
> > > > > > > > > TomEE
> > > > > > > > > > > > > (using
> > > > > > > > > > > > > > > > > memcached + cluster) and with
> > > autoReconnect=true
> > > > i
> > > > > > dont
> > > > > > > > > have
> > > > > > > > > > > any
> > > > > > > > > > > > > > issue
> > > > > > > > > > > > > > > > when
> > > > > > > > > > > > > > > > > the database server reboot, i set this
> > > attribute
> > > > > > > > > > > (autoReconnect)
> > > > > > > > > > > > > > after
> > > > > > > > > > > > > > > i
> > > > > > > > > > > > > > > > > experiment your same problems, when the
> > > database
> > > > > > server
> > > > > > > > > > > rebooted
> > > > > > > > > > > > my
> > > > > > > > > > > > > > > apps
> > > > > > > > > > > > > > > > > cant connect anymore to the database
> server,
> > i
> > > > had
> > > > > to
> > > > > > > > stop
> > > > > > > > > > and
> > > > > > > > > > > > > start
> > > > > > > > > > > > > > > > tomee
> > > > > > > > > > > > > > > > > again for work. But then, i add that option
> > and
> > > > > now i
> > > > > > > > work
> > > > > > > > > > with
> > > > > > > > > > > > any
> > > > > > > > > > > > > > > > > problem.
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > Here is a example of my Resource:
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > <Resource id="ANY_NAME" type="DataSource">
> > > > > > > > > > > > > > > > >   JdbcDriver com.mysql.jdbc.Driver
> > > > > > > > > > > > > > > > >   JdbcUrl
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> jdbc:mysql://any_ip:3306/any_database?zeroDateTimeBehavior=convertToNull&amp;rewriteBatchedStatements=true&amp;autoReconnect=true
> > > > > > > > > > > > > > > > >   UserName any_user
> > > > > > > > > > > > > > > > >   Password any_password
> > > > > > > > > > > > > > > > >   JtaManaged true
> > > > > > > > > > > > > > > > >   InitialSize=3
> > > > > > > > > > > > > > > > >   MaxActive=100
> > > > > > > > > > > > > > > > >   ValidationQuery=SELECT 1
> > > > > > > > > > > > > > > > >   TestOnBorrow=true
> > > > > > > > > > > > > > > > > </Resource>
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > 2013/7/1 James Green <
> > james.mk.green@gmail.com
> > > >
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > This now sounds substantially more
> complex
> > > than
> > > > > my
> > > > > > > > design
> > > > > > > > > > > > (which
> > > > > > > > > > > > > > uses
> > > > > > > > > > > > > > > > > > @PersistenceContext(unitName="accounts"))
> > > > caters
> > > > > > for.
> > > > > > > > Is
> > > > > > > > > > > there
> > > > > > > > > > > > an
> > > > > > > > > > > > > > > > example
> > > > > > > > > > > > > > > > > > of what you mean somewhere so I can scope
> > the
> > > > > work
> > > > > > > out?
> > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > Thanks
> > > > > > > > > > > > > > > > > > James
> > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > On 1 July 2013 12:44, Romain Manni-Bucau
> <
> > > > > > > > > > > > rmannibucau@gmail.com>
> > > > > > > > > > > > > > > > wrote:
> > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > Hi
> > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > it depends your config and that's
> > probably
> > > > more
> > > > > > an
> > > > > > > > > > openjpa
> > > > > > > > > > > > > > question
> > > > > > > > > > > > > > > > but
> > > > > > > > > > > > > > > > > > > basically you'll need to provide the
> > > > > dictionnary
> > > > > > to
> > > > > > > > use
> > > > > > > > > > > since
> > > > > > > > > > > > > > > openjpa
> > > > > > > > > > > > > > > > > > will
> > > > > > > > > > > > > > > > > > > not be able to read database metadata
> (at
> > > > > least).
> > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > *Romain Manni-Bucau*
> > > > > > > > > > > > > > > > > > > *Twitter: @rmannibucau <
> > > > > > > > > https://twitter.com/rmannibucau
> > > > > > > > > > >*
> > > > > > > > > > > > > > > > > > > *Blog: **
> > > http://rmannibucau.wordpress.com/*<
> > > > > > > > > > > > > > > > > > > http://rmannibucau.wordpress.com/>
> > > > > > > > > > > > > > > > > > > *LinkedIn: **
> > > > > > > http://fr.linkedin.com/in/rmannibucau*
> > > > > > > > > > > > > > > > > > > *Github:
> https://github.com/rmannibucau*
> > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > 2013/7/1 James Green <
> > > > james.mk.green@gmail.com
> > > > > >
> > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > > I've suppressed the RuntimeExceptions
> > > > > > encountered
> > > > > > > > as
> > > > > > > > > > EJBs
> > > > > > > > > > > > > fire
> > > > > > > > > > > > > > > and
> > > > > > > > > > > > > > > > > > access
> > > > > > > > > > > > > > > > > > > > JPA, however I have a new problem
> now:
> > > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > > Caused by:
> > <openjpa-2.2.0-r422266:1244990
> > > > > > > nonfatal
> > > > > > > > > user
> > > > > > > > > > > > > error>
> > > > > > > > > > > > > > > > > > > >
> > > > > > org.apache.openjpa.persistence.ArgumentException:
> > > > > > > > An
> > > > > > > > > > > error
> > > > > > > > > > > > > > > occurred
> > > > > > > > > > > > > > > > > > while
> > > > > > > > > > > > > > > > > > > > parsing the query filter "SELECT a
> FROM
> > > > > Account
> > > > > > > a".
> > > > > > > > > > Error
> > > > > > > > > > > > > > > message:
> > > > > > > > > > > > > > > > > The
> > > > > > > > > > > > > > > > > > > name
> > > > > > > > > > > > > > > > > > > > "Account" is not a recognized entity
> or
> > > > > > > identifier.
> > > > > > > > > > Known
> > > > > > > > > > > > > > entity
> > > > > > > > > > > > > > > > > names:
> > > > > > > > > > > > > > > > > > > []
> > > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > > It seems the JPA component was unable
> > to
> > > > map
> > > > > my
> > > > > > > > > @Entity
> > > > > > > > > > > > > classes
> > > > > > > > > > > > > > > > > because
> > > > > > > > > > > > > > > > > > > the
> > > > > > > > > > > > > > > > > > > > connection did not exist at startup.
> > What
> > > > do
> > > > > I
> > > > > > > need
> > > > > > > > > to
> > > > > > > > > > do
> > > > > > > > > > > > to
> > > > > > > > > > > > > > work
> > > > > > > > > > > > > > > > > > around
> > > > > > > > > > > > > > > > > > > > this?
> > > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > > On 1 July 2013 12:07, Romain
> > Manni-Bucau
> > > <
> > > > > > > > > > > > > > rmannibucau@gmail.com>
> > > > > > > > > > > > > > > > > > wrote:
> > > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > > > yep
> > > > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > > > basically get injected the
> > > timerservice (
> > > > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > >
> > > http://docs.oracle.com/javaee/6/api/javax/ejb/TimerService.html
> > > > > > > > > > > > > > > > ),
> > > > > > > > > > > > > > > > > in
> > > > > > > > > > > > > > > > > > > > your
> > > > > > > > > > > > > > > > > > > > > init method you try to get your
> data,
> > > if
> > > > > not
> > > > > > > > > trigger
> > > > > > > > > > a
> > > > > > > > > > > > > later
> > > > > > > > > > > > > > > > > > > > > invocation (
> > > > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> http://docs.oracle.com/javaee/6/api/javax/ejb/TimerService.html#createSingleActionTimer(java.util.Date
> > > > > > > > > > > > > > > > > > > > > ,
> > > > > > > > > > > > > > > > > > > > > javax.ejb.TimerConfig)). While it
> > fails
> > > > > > trigger
> > > > > > > > > > another
> > > > > > > > > > > > one
> > > > > > > > > > > > > > > when
> > > > > > > > > > > > > > > > > > > invoked.
> > > > > > > > > > > > > > > > > > > > > When it succeeds you are done.
> > > > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > > > *Romain Manni-Bucau*
> > > > > > > > > > > > > > > > > > > > > *Twitter: @rmannibucau <
> > > > > > > > > > > https://twitter.com/rmannibucau
> > > > > > > > > > > > >*
> > > > > > > > > > > > > > > > > > > > > *Blog: **
> > > > > http://rmannibucau.wordpress.com/*<
> > > > > > > > > > > > > > > > > > > > > http://rmannibucau.wordpress.com/>
> > > > > > > > > > > > > > > > > > > > > *LinkedIn: **
> > > > > > > > > http://fr.linkedin.com/in/rmannibucau*
> > > > > > > > > > > > > > > > > > > > > *Github:
> > > https://github.com/rmannibucau*
> > > > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > > > 2013/7/1 James Green <
> > > > > > james.mk.green@gmail.com
> > > > > > > >
> > > > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > > > > In our case we have two EJBs,
> both
> > > > > > @Singleton
> > > > > > > > and
> > > > > > > > > > > > > @Startup,
> > > > > > > > > > > > > > > one
> > > > > > > > > > > > > > > > > > > depends
> > > > > > > > > > > > > > > > > > > > > on
> > > > > > > > > > > > > > > > > > > > > > the other. One is a cache façade
> > and
> > > > the
> > > > > > > other
> > > > > > > > > > loads
> > > > > > > > > > > > data
> > > > > > > > > > > > > > via
> > > > > > > > > > > > > > > > JPA
> > > > > > > > > > > > > > > > > > and
> > > > > > > > > > > > > > > > > > > > > feeds
> > > > > > > > > > > > > > > > > > > > > > it into the cache. An external
> > > schedule
> > > > > > > fires a
> > > > > > > > > > > servlet
> > > > > > > > > > > > > > that
> > > > > > > > > > > > > > > > > > reloads
> > > > > > > > > > > > > > > > > > > > the
> > > > > > > > > > > > > > > > > > > > > > cache from the database.
> > > > > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > > > > What's happening is that without
> > > MySQL
> > > > we
> > > > > > see
> > > > > > > > EJB
> > > > > > > > > > > > > > exceptions
> > > > > > > > > > > > > > > > that
> > > > > > > > > > > > > > > > > > > they
> > > > > > > > > > > > > > > > > > > > > > cannot be created and thus we are
> > > dead.
> > > > > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > > > > I've just tried adding
> > > > autoReconnect=true
> > > > > > > > inside
> > > > > > > > > a
> > > > > > > > > > > > > > <Resource>
> > > > > > > > > > > > > > > > but
> > > > > > > > > > > > > > > > > > > that
> > > > > > > > > > > > > > > > > > > > > made
> > > > > > > > > > > > > > > > > > > > > > no difference. I also tried
> adding
> > > > > > > > > > > ,autoReconnect=true
> > > > > > > > > > > > to
> > > > > > > > > > > > > > > > > > > > > > ConnectionProperties and
> > > > > > > > > > ConnectionFactoryProperties
> > > > > > > > > > > > > > without
> > > > > > > > > > > > > > > > any
> > > > > > > > > > > > > > > > > > > change
> > > > > > > > > > > > > > > > > > > > > but
> > > > > > > > > > > > > > > > > > > > > > I'm not convinced that would have
> > > fixed
> > > > > the
> > > > > > > > > problem
> > > > > > > > > > > > here.
> > > > > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > > > > Is it instead the case that
> within
> > > the
> > > > > EJB
> > > > > > I
> > > > > > > > > should
> > > > > > > > > > > be
> > > > > > > > > > > > > > > trapping
> > > > > > > > > > > > > > > > > > > > > > connectivity problems such as
> > > > > > > > > PersistenceException
> > > > > > > > > > > and
> > > > > > > > > > > > > > > allowing
> > > > > > > > > > > > > > > > > the
> > > > > > > > > > > > > > > > > > > > > > containing to gracefully start up
> > and
> > > > > > > naturally
> > > > > > > > > > keep
> > > > > > > > > > > > > trying
> > > > > > > > > > > > > > > > > anyway?
> > > > > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > > > > James
> > > > > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > > > > On 28 June 2013 17:10, José Luis
> > > > Cetina <
> > > > > > > > > > > > > > > maxtorzito@gmail.com>
> > > > > > > > > > > > > > > > > > > wrote:
> > > > > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > > > > > I had a similar problem and
> what
> > i
> > > > did
> > > > > > was
> > > > > > > > set
> > > > > > > > > > the
> > > > > > > > > > > > > > > > > autoReconnect
> > > > > > > > > > > > > > > > > > > > > > attribute
> > > > > > > > > > > > > > > > > > > > > > > to true en my tomee.xml
> > datasource.
> > > > > > > > > > > > > > > > > > > > > > > What do you mean with retry
> until
> > > the
> > > > > > > > > connection
> > > > > > > > > > > > > springs
> > > > > > > > > > > > > > to
> > > > > > > > > > > > > > > > > life?
> > > > > > > > > > > > > > > > > > > do
> > > > > > > > > > > > > > > > > > > > > you
> > > > > > > > > > > > > > > > > > > > > > > have some schedules or jobs
> > running
> > > > and
> > > > > > > want
> > > > > > > > to
> > > > > > > > > > > retry
> > > > > > > > > > > > > > again
> > > > > > > > > > > > > > > > > when
> > > > > > > > > > > > > > > > > > > the
> > > > > > > > > > > > > > > > > > > > > > > connection is available again?
> or
> > > > just
> > > > > > want
> > > > > > > > > when
> > > > > > > > > > > > > somebody
> > > > > > > > > > > > > > > > click
> > > > > > > > > > > > > > > > > > any
> > > > > > > > > > > > > > > > > > > > > > button
> > > > > > > > > > > > > > > > > > > > > > > the app can connect again (this
> > was
> > > > my
> > > > > > > > case)??
> > > > > > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > > > > > 2013/6/28 Romain Manni-Bucau <
> > > > > > > > > > > rmannibucau@gmail.com>
> > > > > > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > > > > > > With an ejb timer?
> > > > > > > > > > > > > > > > > > > > > > > > Le 28 juin 2013 17:46, "James
> > > > Green"
> > > > > <
> > > > > > > > > > > > > > > > > james.mk.green@gmail.com
> > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > a
> > > > > > > > > > > > > > > > > > > > > > écrit
> > > > > > > > > > > > > > > > > > > > > > > :
> > > > > > > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > > > > > > > Hopefully a quick one.
> > > > > > > > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > > > > > > > On boot our application
> > > attempts
> > > > to
> > > > > > > read
> > > > > > > > > data
> > > > > > > > > > > > > > through a
> > > > > > > > > > > > > > > > JPA
> > > > > > > > > > > > > > > > > > > > > > > > EntityManager.
> > > > > > > > > > > > > > > > > > > > > > > > > If the database connection
> > > fails
> > > > at
> > > > > > > this
> > > > > > > > > > point
> > > > > > > > > > > > the
> > > > > > > > > > > > > > > entire
> > > > > > > > > > > > > > > > > > > > > application
> > > > > > > > > > > > > > > > > > > > > > > is
> > > > > > > > > > > > > > > > > > > > > > > > > effectively dead.
> > > > > > > > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > > > > > > > Is there a way to
> essentially
> > > ask
> > > > > the
> > > > > > > > > > database
> > > > > > > > > > > > > layer
> > > > > > > > > > > > > > to
> > > > > > > > > > > > > > > > > retry
> > > > > > > > > > > > > > > > > > > > until
> > > > > > > > > > > > > > > > > > > > > > the
> > > > > > > > > > > > > > > > > > > > > > > > > connection springs to life?
> > > > > > > > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > > > > > > > Thanks,
> > > > > > > > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > > > > > > > James
> > > > > > > > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > > > > > --
> > > > > > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > >
> > > -------------------------------------------------------------------
> > > > > > > > > > > > > > > > > > > > > > > *SCJA. José Luis Cetina*
> > > > > > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > >
> > > -------------------------------------------------------------------
> > > > > > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > --
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > >
> > -------------------------------------------------------------------
> > > > > > > > > > > > > > > > > *SCJA. José Luis Cetina*
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > >
> > -------------------------------------------------------------------
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > --
> > > > > > > > > > > > > > >
> > > > > > > > > >
> > > > > -------------------------------------------------------------------
> > > > > > > > > > > > > > > *SCJA. José Luis Cetina*
> > > > > > > > > > > > > > >
> > > > > > > > > >
> > > > > -------------------------------------------------------------------
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > --
> > > > > > > > > > > >
> > > > > > >
> > -------------------------------------------------------------------
> > > > > > > > > > > > *SCJA. José Luis Cetina*
> > > > > > > > > > > >
> > > > > > >
> > -------------------------------------------------------------------
> > > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
>

Re: Reconnect if JPA fails at boot?

Posted by James Green <ja...@gmail.com>.
Why would anyone rely on a particular resource being available at startup?
Other than the container, every external resource is liable to failure at
some point. We build applications to cover that contingency by issuing
error while the resource is not available, then performing work while they
are available.

Reading around it seems this is far more complicated than it perhaps ought
to be, with autoreconnect having serious implications in a transactional
environment. That said, our JPA use is current read-only.

I'm minded to continue this problem on an openjpa mailing list and see if I
can narrow down precisely what we want to do. Thanks for your time & help
regardless, always welcomed.

James


On 2 July 2013 14:08, Romain Manni-Bucau <rm...@gmail.com> wrote:

> wait, here you speak about startup, if you can't rely on it even at startup
> you'll have to configure explicitely your jpa provider not not need it and
> your pool to automatically reconnect when needed. that's the main
> constraints.
>
> *Romain Manni-Bucau*
> *Twitter: @rmannibucau <https://twitter.com/rmannibucau>*
> *Blog: **http://rmannibucau.wordpress.com/*<
> http://rmannibucau.wordpress.com/>
> *LinkedIn: **http://fr.linkedin.com/in/rmannibucau*
> *Github: https://github.com/rmannibucau*
>
>
>
> 2013/7/2 James Green <ja...@gmail.com>
>
> > A database is merely a resource - same as a message queue or a file. In
> > technology we never rely on them so we have to test the recovery of our
> > software instead. So I am here :)
> >
> >
> > On 2 July 2013 12:48, Romain Manni-Bucau <rm...@gmail.com> wrote:
> >
> > > no, this is another error, not sure why ATM but it should be an easy
> one.
> > > If that's because the database was not here you'll need to ensure the
> > > datasource is here before using the entity manager for the first time
> or
> > to
> > > list classes manually.
> > >
> > > that said to be honest if you *can't* rely on your database at all you
> > > should just use something else
> > >
> > > *Romain Manni-Bucau*
> > > *Twitter: @rmannibucau <https://twitter.com/rmannibucau>*
> > > *Blog: **http://rmannibucau.wordpress.com/*<
> > > http://rmannibucau.wordpress.com/>
> > > *LinkedIn: **http://fr.linkedin.com/in/rmannibucau*
> > > *Github: https://github.com/rmannibucau*
> > >
> > >
> > >
> > > 2013/7/2 James Green <ja...@gmail.com>
> > >
> > > > That will also fix the original error - that the list of mapped
> classes
> > > is
> > > > empty? Copy of the error again:
> > > >
> > > > Caused by: <openjpa-2.2.0-r422266:1244990 nonfatal user error>
> > > > org.apache.openjpa.persistence.ArgumentException: An error occurred
> > while
> > > > parsing the query filter "SELECT a FROM Account a". Error message:
> The
> > > name
> > > > "Account" is not a recognized entity or identifier. Known entity
> names:
> > > []
> > > >
> > > >
> > > >
> > > >
> > > > On 2 July 2013 12:31, Romain Manni-Bucau <rm...@gmail.com>
> > wrote:
> > > >
> > > > > just add in your persistence unit the needed property (sample for
> > > > > mysql: <property
> > > > > name="openjpa.jdbc.DBDictionary" value="mysql"/> )
> > > > >
> > > > > *Romain Manni-Bucau*
> > > > > *Twitter: @rmannibucau <https://twitter.com/rmannibucau>*
> > > > > *Blog: **http://rmannibucau.wordpress.com/*<
> > > > > http://rmannibucau.wordpress.com/>
> > > > > *LinkedIn: **http://fr.linkedin.com/in/rmannibucau*
> > > > > *Github: https://github.com/rmannibucau*
> > > > >
> > > > >
> > > > >
> > > > > 2013/7/2 James Green <ja...@gmail.com>
> > > > >
> > > > > > The documentation link you supplied: I'm not sure what I am
> looking
> > > for
> > > > > in
> > > > > > it. That's what I meant to say.
> > > > > >
> > > > > > To cut this down is there a demonstration project where this is
> > > already
> > > > > > correctly configured? May be simpler than explaining the changes
> to
> > > me
> > > > :)
> > > > > >
> > > > > >
> > > > > > On 2 July 2013 12:14, Romain Manni-Bucau <rm...@gmail.com>
> > > > wrote:
> > > > > >
> > > > > > > didnt get the first sentence
> > > > > > >
> > > > > > > about the "make it worse" it is what i explained in my previous
> > > > answer:
> > > > > > if
> > > > > > > you start without a db and openjpa uses automatically the wrong
> > > > > > dictionnary
> > > > > > > then even if the db is back and the pool well configured, the
> jpa
> > > > layer
> > > > > > > will generate wrong SQL so it will not work, so your app is
> > broken
> > > > > > whatever
> > > > > > > the db state is.
> > > > > > >
> > > > > > > *Romain Manni-Bucau*
> > > > > > > *Twitter: @rmannibucau <https://twitter.com/rmannibucau>*
> > > > > > > *Blog: **http://rmannibucau.wordpress.com/*<
> > > > > > > http://rmannibucau.wordpress.com/>
> > > > > > > *LinkedIn: **http://fr.linkedin.com/in/rmannibucau*
> > > > > > > *Github: https://github.com/rmannibucau*
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > 2013/7/2 James Green <ja...@gmail.com>
> > > > > > >
> > > > > > > > Am I looking for something letting me list the classes I want
> > > > mapped?
> > > > > > The
> > > > > > > > error I see shows an empty list, hence this particular
> > question.
> > > > > > > >
> > > > > > > > You say it doesn't solve our issue and can actually make it
> > > worse?
> > > > > Care
> > > > > > > to
> > > > > > > > elaborate?
> > > > > > > >
> > > > > > > >
> > > > > > > > On 2 July 2013 09:17, Romain Manni-Bucau <
> > rmannibucau@gmail.com>
> > > > > > wrote:
> > > > > > > >
> > > > > > > > > the dict doc is here
> > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> http://openjpa.apache.org/builds/2.2.2/apache-openjpa/docs/ref_guide_dbsetup_dbsupport.html
> > > > > > > > >
> > > > > > > > > it is important to set it if the database can be down at
> > > startup
> > > > > > > > otherwise
> > > > > > > > > you can end up with a wrong dict (generally the generic
> one)
> > > and
> > > > > then
> > > > > > > > when
> > > > > > > > > the database is up again SQL stuff will not work
> > > > > > > > >
> > > > > > > > > it doesn't solve your issue but it can make it worse
> > > > > > > > >
> > > > > > > > > *Romain Manni-Bucau*
> > > > > > > > > *Twitter: @rmannibucau <https://twitter.com/rmannibucau>*
> > > > > > > > > *Blog: **http://rmannibucau.wordpress.com/*<
> > > > > > > > > http://rmannibucau.wordpress.com/>
> > > > > > > > > *LinkedIn: **http://fr.linkedin.com/in/rmannibucau*
> > > > > > > > > *Github: https://github.com/rmannibucau*
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > 2013/7/2 James Green <ja...@gmail.com>
> > > > > > > > >
> > > > > > > > > > That's exactly what I want. All I have are EJBs with
> entity
> > > > > > managers
> > > > > > > > > > injected via @PersistenceContext (exactly as we are
> taught
> > in
> > > > the
> > > > > > > > > > "Beginning Java EE 6 Platform with Glassfish 3" book
> which
> > is
> > > > how
> > > > > > > this
> > > > > > > > > > application began life.
> > > > > > > > > >
> > > > > > > > > > So what's the difference I wonder? Romain talks about
> > adding
> > > a
> > > > > > > > dictionary
> > > > > > > > > > but I didn't spot anything spectacularly obvious in a
> > browse
> > > of
> > > > > the
> > > > > > > > > OpenJPA
> > > > > > > > > > user guide yesterday (indeed on the subject of injection
> it
> > > > told
> > > > > me
> > > > > > > to
> > > > > > > > > > refer to my application server documentation...).
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > On 1 July 2013 18:05, José Luis Cetina <
> > maxtorzito@gmail.com
> > > >
> > > > > > wrote:
> > > > > > > > > >
> > > > > > > > > > > I did this test:
> > > > > > > > > > >
> > > > > > > > > > > 1. Stop TomEE
> > > > > > > > > > > 2. Shutdown my database server
> > > > > > > > > > > 3. Start TomEE
> > > > > > > > > > > 4. Try to access to my app, i could access but when i
> hit
> > > my
> > > > > > login
> > > > > > > > > button
> > > > > > > > > > > for example then i get this error:
> > > > > > > > > > >
> > > > > > >
> > > com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException:
> > > > > > > > > > > Could not create connection to database server.
> Attempted
> > > > > > > reconnect 3
> > > > > > > > > > > times. Giving up.
> > > > > > > > > > > 5. Start up my database server
> > > > > > > > > > > 6. Wait for my database to be ready, i refresh the page
> > > then
> > > > > hit
> > > > > > > > again
> > > > > > > > > at
> > > > > > > > > > > the login button, then my app run without problem (in
> > this
> > > > > point
> > > > > > i
> > > > > > > > DONT
> > > > > > > > > > > stop/start TomEE again).
> > > > > > > > > > >
> > > > > > > > > > > Is this the behavior that you need/want it??
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > *Remeber that i have tomee and database in separate
> > > server's
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > 2013/7/1 Howard W. Smith, Jr. <sm...@gmail.com>
> > > > > > > > > > >
> > > > > > > > > > > > Will you be trying the magic that Romain recommended?
> > > > > > > > > > > >  On Jul 1, 2013 10:34 AM, "James Green" <
> > > > > > > james.mk.green@gmail.com>
> > > > > > > > > > > wrote:
> > > > > > > > > > > >
> > > > > > > > > > > > > I was asking about cold boot, specifically. It is
> > when
> > > > the
> > > > > > > > > > application
> > > > > > > > > > > > > server begins that the JPA implementation performs
> > the
> > > > > Entity
> > > > > > > > > > mapping,
> > > > > > > > > > > so
> > > > > > > > > > > > > if the database is not available presumably it
> > remains
> > > > dead
> > > > > > > until
> > > > > > > > > the
> > > > > > > > > > > > > application server itself is restarted?
> > > > > > > > > > > > >
> > > > > > > > > > > > > Unless you already have the magic installed that
> > Romain
> > > > > > refers
> > > > > > > > to.
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > > On 1 July 2013 15:24, José Luis Cetina <
> > > > > maxtorzito@gmail.com
> > > > > > >
> > > > > > > > > wrote:
> > > > > > > > > > > > >
> > > > > > > > > > > > > > My entire app use database and of course the app
> > > doesnt
> > > > > > work
> > > > > > > if
> > > > > > > > > the
> > > > > > > > > > > > > > database is unavailable, but when the database
> > server
> > > > is
> > > > > > > > > available
> > > > > > > > > > > > again
> > > > > > > > > > > > > > the webapp can use the database again without
> > > > restarting
> > > > > > > TomEE.
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > I dont know if i response your question.
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > 2013/7/1 James Green <ja...@gmail.com>
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > > Are you saying your application starts from
> cold
> > > > > without
> > > > > > > the
> > > > > > > > > > > > database,
> > > > > > > > > > > > > > the
> > > > > > > > > > > > > > > operates fine without intervention once the
> > > database
> > > > > > > becomes
> > > > > > > > > > > > available?
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > On 1 July 2013 14:26, José Luis Cetina <
> > > > > > > maxtorzito@gmail.com
> > > > > > > > >
> > > > > > > > > > > wrote:
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > I have also differents server, 1 one database
> > > and 2
> > > > > for
> > > > > > > > TomEE
> > > > > > > > > > > > (using
> > > > > > > > > > > > > > > > memcached + cluster) and with
> > autoReconnect=true
> > > i
> > > > > dont
> > > > > > > > have
> > > > > > > > > > any
> > > > > > > > > > > > > issue
> > > > > > > > > > > > > > > when
> > > > > > > > > > > > > > > > the database server reboot, i set this
> > attribute
> > > > > > > > > > (autoReconnect)
> > > > > > > > > > > > > after
> > > > > > > > > > > > > > i
> > > > > > > > > > > > > > > > experiment your same problems, when the
> > database
> > > > > server
> > > > > > > > > > rebooted
> > > > > > > > > > > my
> > > > > > > > > > > > > > apps
> > > > > > > > > > > > > > > > cant connect anymore to the database server,
> i
> > > had
> > > > to
> > > > > > > stop
> > > > > > > > > and
> > > > > > > > > > > > start
> > > > > > > > > > > > > > > tomee
> > > > > > > > > > > > > > > > again for work. But then, i add that option
> and
> > > > now i
> > > > > > > work
> > > > > > > > > with
> > > > > > > > > > > any
> > > > > > > > > > > > > > > > problem.
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > Here is a example of my Resource:
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > <Resource id="ANY_NAME" type="DataSource">
> > > > > > > > > > > > > > > >   JdbcDriver com.mysql.jdbc.Driver
> > > > > > > > > > > > > > > >   JdbcUrl
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> jdbc:mysql://any_ip:3306/any_database?zeroDateTimeBehavior=convertToNull&amp;rewriteBatchedStatements=true&amp;autoReconnect=true
> > > > > > > > > > > > > > > >   UserName any_user
> > > > > > > > > > > > > > > >   Password any_password
> > > > > > > > > > > > > > > >   JtaManaged true
> > > > > > > > > > > > > > > >   InitialSize=3
> > > > > > > > > > > > > > > >   MaxActive=100
> > > > > > > > > > > > > > > >   ValidationQuery=SELECT 1
> > > > > > > > > > > > > > > >   TestOnBorrow=true
> > > > > > > > > > > > > > > > </Resource>
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > 2013/7/1 James Green <
> james.mk.green@gmail.com
> > >
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > This now sounds substantially more complex
> > than
> > > > my
> > > > > > > design
> > > > > > > > > > > (which
> > > > > > > > > > > > > uses
> > > > > > > > > > > > > > > > > @PersistenceContext(unitName="accounts"))
> > > caters
> > > > > for.
> > > > > > > Is
> > > > > > > > > > there
> > > > > > > > > > > an
> > > > > > > > > > > > > > > example
> > > > > > > > > > > > > > > > > of what you mean somewhere so I can scope
> the
> > > > work
> > > > > > out?
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > Thanks
> > > > > > > > > > > > > > > > > James
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > On 1 July 2013 12:44, Romain Manni-Bucau <
> > > > > > > > > > > rmannibucau@gmail.com>
> > > > > > > > > > > > > > > wrote:
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > Hi
> > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > it depends your config and that's
> probably
> > > more
> > > > > an
> > > > > > > > > openjpa
> > > > > > > > > > > > > question
> > > > > > > > > > > > > > > but
> > > > > > > > > > > > > > > > > > basically you'll need to provide the
> > > > dictionnary
> > > > > to
> > > > > > > use
> > > > > > > > > > since
> > > > > > > > > > > > > > openjpa
> > > > > > > > > > > > > > > > > will
> > > > > > > > > > > > > > > > > > not be able to read database metadata (at
> > > > least).
> > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > *Romain Manni-Bucau*
> > > > > > > > > > > > > > > > > > *Twitter: @rmannibucau <
> > > > > > > > https://twitter.com/rmannibucau
> > > > > > > > > >*
> > > > > > > > > > > > > > > > > > *Blog: **
> > http://rmannibucau.wordpress.com/*<
> > > > > > > > > > > > > > > > > > http://rmannibucau.wordpress.com/>
> > > > > > > > > > > > > > > > > > *LinkedIn: **
> > > > > > http://fr.linkedin.com/in/rmannibucau*
> > > > > > > > > > > > > > > > > > *Github: https://github.com/rmannibucau*
> > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > 2013/7/1 James Green <
> > > james.mk.green@gmail.com
> > > > >
> > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > I've suppressed the RuntimeExceptions
> > > > > encountered
> > > > > > > as
> > > > > > > > > EJBs
> > > > > > > > > > > > fire
> > > > > > > > > > > > > > and
> > > > > > > > > > > > > > > > > access
> > > > > > > > > > > > > > > > > > > JPA, however I have a new problem now:
> > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > Caused by:
> <openjpa-2.2.0-r422266:1244990
> > > > > > nonfatal
> > > > > > > > user
> > > > > > > > > > > > error>
> > > > > > > > > > > > > > > > > > >
> > > > > org.apache.openjpa.persistence.ArgumentException:
> > > > > > > An
> > > > > > > > > > error
> > > > > > > > > > > > > > occurred
> > > > > > > > > > > > > > > > > while
> > > > > > > > > > > > > > > > > > > parsing the query filter "SELECT a FROM
> > > > Account
> > > > > > a".
> > > > > > > > > Error
> > > > > > > > > > > > > > message:
> > > > > > > > > > > > > > > > The
> > > > > > > > > > > > > > > > > > name
> > > > > > > > > > > > > > > > > > > "Account" is not a recognized entity or
> > > > > > identifier.
> > > > > > > > > Known
> > > > > > > > > > > > > entity
> > > > > > > > > > > > > > > > names:
> > > > > > > > > > > > > > > > > > []
> > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > It seems the JPA component was unable
> to
> > > map
> > > > my
> > > > > > > > @Entity
> > > > > > > > > > > > classes
> > > > > > > > > > > > > > > > because
> > > > > > > > > > > > > > > > > > the
> > > > > > > > > > > > > > > > > > > connection did not exist at startup.
> What
> > > do
> > > > I
> > > > > > need
> > > > > > > > to
> > > > > > > > > do
> > > > > > > > > > > to
> > > > > > > > > > > > > work
> > > > > > > > > > > > > > > > > around
> > > > > > > > > > > > > > > > > > > this?
> > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > On 1 July 2013 12:07, Romain
> Manni-Bucau
> > <
> > > > > > > > > > > > > rmannibucau@gmail.com>
> > > > > > > > > > > > > > > > > wrote:
> > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > > yep
> > > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > > basically get injected the
> > timerservice (
> > > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > >
> > http://docs.oracle.com/javaee/6/api/javax/ejb/TimerService.html
> > > > > > > > > > > > > > > ),
> > > > > > > > > > > > > > > > in
> > > > > > > > > > > > > > > > > > > your
> > > > > > > > > > > > > > > > > > > > init method you try to get your data,
> > if
> > > > not
> > > > > > > > trigger
> > > > > > > > > a
> > > > > > > > > > > > later
> > > > > > > > > > > > > > > > > > > > invocation (
> > > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> http://docs.oracle.com/javaee/6/api/javax/ejb/TimerService.html#createSingleActionTimer(java.util.Date
> > > > > > > > > > > > > > > > > > > > ,
> > > > > > > > > > > > > > > > > > > > javax.ejb.TimerConfig)). While it
> fails
> > > > > trigger
> > > > > > > > > another
> > > > > > > > > > > one
> > > > > > > > > > > > > > when
> > > > > > > > > > > > > > > > > > invoked.
> > > > > > > > > > > > > > > > > > > > When it succeeds you are done.
> > > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > > *Romain Manni-Bucau*
> > > > > > > > > > > > > > > > > > > > *Twitter: @rmannibucau <
> > > > > > > > > > https://twitter.com/rmannibucau
> > > > > > > > > > > >*
> > > > > > > > > > > > > > > > > > > > *Blog: **
> > > > http://rmannibucau.wordpress.com/*<
> > > > > > > > > > > > > > > > > > > > http://rmannibucau.wordpress.com/>
> > > > > > > > > > > > > > > > > > > > *LinkedIn: **
> > > > > > > > http://fr.linkedin.com/in/rmannibucau*
> > > > > > > > > > > > > > > > > > > > *Github:
> > https://github.com/rmannibucau*
> > > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > > 2013/7/1 James Green <
> > > > > james.mk.green@gmail.com
> > > > > > >
> > > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > > > In our case we have two EJBs, both
> > > > > @Singleton
> > > > > > > and
> > > > > > > > > > > > @Startup,
> > > > > > > > > > > > > > one
> > > > > > > > > > > > > > > > > > depends
> > > > > > > > > > > > > > > > > > > > on
> > > > > > > > > > > > > > > > > > > > > the other. One is a cache façade
> and
> > > the
> > > > > > other
> > > > > > > > > loads
> > > > > > > > > > > data
> > > > > > > > > > > > > via
> > > > > > > > > > > > > > > JPA
> > > > > > > > > > > > > > > > > and
> > > > > > > > > > > > > > > > > > > > feeds
> > > > > > > > > > > > > > > > > > > > > it into the cache. An external
> > schedule
> > > > > > fires a
> > > > > > > > > > servlet
> > > > > > > > > > > > > that
> > > > > > > > > > > > > > > > > reloads
> > > > > > > > > > > > > > > > > > > the
> > > > > > > > > > > > > > > > > > > > > cache from the database.
> > > > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > > > What's happening is that without
> > MySQL
> > > we
> > > > > see
> > > > > > > EJB
> > > > > > > > > > > > > exceptions
> > > > > > > > > > > > > > > that
> > > > > > > > > > > > > > > > > > they
> > > > > > > > > > > > > > > > > > > > > cannot be created and thus we are
> > dead.
> > > > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > > > I've just tried adding
> > > autoReconnect=true
> > > > > > > inside
> > > > > > > > a
> > > > > > > > > > > > > <Resource>
> > > > > > > > > > > > > > > but
> > > > > > > > > > > > > > > > > > that
> > > > > > > > > > > > > > > > > > > > made
> > > > > > > > > > > > > > > > > > > > > no difference. I also tried adding
> > > > > > > > > > ,autoReconnect=true
> > > > > > > > > > > to
> > > > > > > > > > > > > > > > > > > > > ConnectionProperties and
> > > > > > > > > ConnectionFactoryProperties
> > > > > > > > > > > > > without
> > > > > > > > > > > > > > > any
> > > > > > > > > > > > > > > > > > change
> > > > > > > > > > > > > > > > > > > > but
> > > > > > > > > > > > > > > > > > > > > I'm not convinced that would have
> > fixed
> > > > the
> > > > > > > > problem
> > > > > > > > > > > here.
> > > > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > > > Is it instead the case that within
> > the
> > > > EJB
> > > > > I
> > > > > > > > should
> > > > > > > > > > be
> > > > > > > > > > > > > > trapping
> > > > > > > > > > > > > > > > > > > > > connectivity problems such as
> > > > > > > > PersistenceException
> > > > > > > > > > and
> > > > > > > > > > > > > > allowing
> > > > > > > > > > > > > > > > the
> > > > > > > > > > > > > > > > > > > > > containing to gracefully start up
> and
> > > > > > naturally
> > > > > > > > > keep
> > > > > > > > > > > > trying
> > > > > > > > > > > > > > > > anyway?
> > > > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > > > James
> > > > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > > > On 28 June 2013 17:10, José Luis
> > > Cetina <
> > > > > > > > > > > > > > maxtorzito@gmail.com>
> > > > > > > > > > > > > > > > > > wrote:
> > > > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > > > > I had a similar problem and what
> i
> > > did
> > > > > was
> > > > > > > set
> > > > > > > > > the
> > > > > > > > > > > > > > > > autoReconnect
> > > > > > > > > > > > > > > > > > > > > attribute
> > > > > > > > > > > > > > > > > > > > > > to true en my tomee.xml
> datasource.
> > > > > > > > > > > > > > > > > > > > > > What do you mean with retry until
> > the
> > > > > > > > connection
> > > > > > > > > > > > springs
> > > > > > > > > > > > > to
> > > > > > > > > > > > > > > > life?
> > > > > > > > > > > > > > > > > > do
> > > > > > > > > > > > > > > > > > > > you
> > > > > > > > > > > > > > > > > > > > > > have some schedules or jobs
> running
> > > and
> > > > > > want
> > > > > > > to
> > > > > > > > > > retry
> > > > > > > > > > > > > again
> > > > > > > > > > > > > > > > when
> > > > > > > > > > > > > > > > > > the
> > > > > > > > > > > > > > > > > > > > > > connection is available again? or
> > > just
> > > > > want
> > > > > > > > when
> > > > > > > > > > > > somebody
> > > > > > > > > > > > > > > click
> > > > > > > > > > > > > > > > > any
> > > > > > > > > > > > > > > > > > > > > button
> > > > > > > > > > > > > > > > > > > > > > the app can connect again (this
> was
> > > my
> > > > > > > case)??
> > > > > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > > > > 2013/6/28 Romain Manni-Bucau <
> > > > > > > > > > rmannibucau@gmail.com>
> > > > > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > > > > > With an ejb timer?
> > > > > > > > > > > > > > > > > > > > > > > Le 28 juin 2013 17:46, "James
> > > Green"
> > > > <
> > > > > > > > > > > > > > > > james.mk.green@gmail.com
> > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > a
> > > > > > > > > > > > > > > > > > > > > écrit
> > > > > > > > > > > > > > > > > > > > > > :
> > > > > > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > > > > > > Hopefully a quick one.
> > > > > > > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > > > > > > On boot our application
> > attempts
> > > to
> > > > > > read
> > > > > > > > data
> > > > > > > > > > > > > through a
> > > > > > > > > > > > > > > JPA
> > > > > > > > > > > > > > > > > > > > > > > EntityManager.
> > > > > > > > > > > > > > > > > > > > > > > > If the database connection
> > fails
> > > at
> > > > > > this
> > > > > > > > > point
> > > > > > > > > > > the
> > > > > > > > > > > > > > entire
> > > > > > > > > > > > > > > > > > > > application
> > > > > > > > > > > > > > > > > > > > > > is
> > > > > > > > > > > > > > > > > > > > > > > > effectively dead.
> > > > > > > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > > > > > > Is there a way to essentially
> > ask
> > > > the
> > > > > > > > > database
> > > > > > > > > > > > layer
> > > > > > > > > > > > > to
> > > > > > > > > > > > > > > > retry
> > > > > > > > > > > > > > > > > > > until
> > > > > > > > > > > > > > > > > > > > > the
> > > > > > > > > > > > > > > > > > > > > > > > connection springs to life?
> > > > > > > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > > > > > > Thanks,
> > > > > > > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > > > > > > James
> > > > > > > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > > > > --
> > > > > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > >
> > -------------------------------------------------------------------
> > > > > > > > > > > > > > > > > > > > > > *SCJA. José Luis Cetina*
> > > > > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > >
> > -------------------------------------------------------------------
> > > > > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > --
> > > > > > > > > > > > > > > >
> > > > > > > > > > >
> > > > > >
> -------------------------------------------------------------------
> > > > > > > > > > > > > > > > *SCJA. José Luis Cetina*
> > > > > > > > > > > > > > > >
> > > > > > > > > > >
> > > > > >
> -------------------------------------------------------------------
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > --
> > > > > > > > > > > > > >
> > > > > > > > >
> > > > -------------------------------------------------------------------
> > > > > > > > > > > > > > *SCJA. José Luis Cetina*
> > > > > > > > > > > > > >
> > > > > > > > >
> > > > -------------------------------------------------------------------
> > > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > --
> > > > > > > > > > >
> > > > > >
> -------------------------------------------------------------------
> > > > > > > > > > > *SCJA. José Luis Cetina*
> > > > > > > > > > >
> > > > > >
> -------------------------------------------------------------------
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
>

Re: Reconnect if JPA fails at boot?

Posted by Romain Manni-Bucau <rm...@gmail.com>.
wait, here you speak about startup, if you can't rely on it even at startup
you'll have to configure explicitely your jpa provider not not need it and
your pool to automatically reconnect when needed. that's the main
constraints.

*Romain Manni-Bucau*
*Twitter: @rmannibucau <https://twitter.com/rmannibucau>*
*Blog: **http://rmannibucau.wordpress.com/*<http://rmannibucau.wordpress.com/>
*LinkedIn: **http://fr.linkedin.com/in/rmannibucau*
*Github: https://github.com/rmannibucau*



2013/7/2 James Green <ja...@gmail.com>

> A database is merely a resource - same as a message queue or a file. In
> technology we never rely on them so we have to test the recovery of our
> software instead. So I am here :)
>
>
> On 2 July 2013 12:48, Romain Manni-Bucau <rm...@gmail.com> wrote:
>
> > no, this is another error, not sure why ATM but it should be an easy one.
> > If that's because the database was not here you'll need to ensure the
> > datasource is here before using the entity manager for the first time or
> to
> > list classes manually.
> >
> > that said to be honest if you *can't* rely on your database at all you
> > should just use something else
> >
> > *Romain Manni-Bucau*
> > *Twitter: @rmannibucau <https://twitter.com/rmannibucau>*
> > *Blog: **http://rmannibucau.wordpress.com/*<
> > http://rmannibucau.wordpress.com/>
> > *LinkedIn: **http://fr.linkedin.com/in/rmannibucau*
> > *Github: https://github.com/rmannibucau*
> >
> >
> >
> > 2013/7/2 James Green <ja...@gmail.com>
> >
> > > That will also fix the original error - that the list of mapped classes
> > is
> > > empty? Copy of the error again:
> > >
> > > Caused by: <openjpa-2.2.0-r422266:1244990 nonfatal user error>
> > > org.apache.openjpa.persistence.ArgumentException: An error occurred
> while
> > > parsing the query filter "SELECT a FROM Account a". Error message: The
> > name
> > > "Account" is not a recognized entity or identifier. Known entity names:
> > []
> > >
> > >
> > >
> > >
> > > On 2 July 2013 12:31, Romain Manni-Bucau <rm...@gmail.com>
> wrote:
> > >
> > > > just add in your persistence unit the needed property (sample for
> > > > mysql: <property
> > > > name="openjpa.jdbc.DBDictionary" value="mysql"/> )
> > > >
> > > > *Romain Manni-Bucau*
> > > > *Twitter: @rmannibucau <https://twitter.com/rmannibucau>*
> > > > *Blog: **http://rmannibucau.wordpress.com/*<
> > > > http://rmannibucau.wordpress.com/>
> > > > *LinkedIn: **http://fr.linkedin.com/in/rmannibucau*
> > > > *Github: https://github.com/rmannibucau*
> > > >
> > > >
> > > >
> > > > 2013/7/2 James Green <ja...@gmail.com>
> > > >
> > > > > The documentation link you supplied: I'm not sure what I am looking
> > for
> > > > in
> > > > > it. That's what I meant to say.
> > > > >
> > > > > To cut this down is there a demonstration project where this is
> > already
> > > > > correctly configured? May be simpler than explaining the changes to
> > me
> > > :)
> > > > >
> > > > >
> > > > > On 2 July 2013 12:14, Romain Manni-Bucau <rm...@gmail.com>
> > > wrote:
> > > > >
> > > > > > didnt get the first sentence
> > > > > >
> > > > > > about the "make it worse" it is what i explained in my previous
> > > answer:
> > > > > if
> > > > > > you start without a db and openjpa uses automatically the wrong
> > > > > dictionnary
> > > > > > then even if the db is back and the pool well configured, the jpa
> > > layer
> > > > > > will generate wrong SQL so it will not work, so your app is
> broken
> > > > > whatever
> > > > > > the db state is.
> > > > > >
> > > > > > *Romain Manni-Bucau*
> > > > > > *Twitter: @rmannibucau <https://twitter.com/rmannibucau>*
> > > > > > *Blog: **http://rmannibucau.wordpress.com/*<
> > > > > > http://rmannibucau.wordpress.com/>
> > > > > > *LinkedIn: **http://fr.linkedin.com/in/rmannibucau*
> > > > > > *Github: https://github.com/rmannibucau*
> > > > > >
> > > > > >
> > > > > >
> > > > > > 2013/7/2 James Green <ja...@gmail.com>
> > > > > >
> > > > > > > Am I looking for something letting me list the classes I want
> > > mapped?
> > > > > The
> > > > > > > error I see shows an empty list, hence this particular
> question.
> > > > > > >
> > > > > > > You say it doesn't solve our issue and can actually make it
> > worse?
> > > > Care
> > > > > > to
> > > > > > > elaborate?
> > > > > > >
> > > > > > >
> > > > > > > On 2 July 2013 09:17, Romain Manni-Bucau <
> rmannibucau@gmail.com>
> > > > > wrote:
> > > > > > >
> > > > > > > > the dict doc is here
> > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> http://openjpa.apache.org/builds/2.2.2/apache-openjpa/docs/ref_guide_dbsetup_dbsupport.html
> > > > > > > >
> > > > > > > > it is important to set it if the database can be down at
> > startup
> > > > > > > otherwise
> > > > > > > > you can end up with a wrong dict (generally the generic one)
> > and
> > > > then
> > > > > > > when
> > > > > > > > the database is up again SQL stuff will not work
> > > > > > > >
> > > > > > > > it doesn't solve your issue but it can make it worse
> > > > > > > >
> > > > > > > > *Romain Manni-Bucau*
> > > > > > > > *Twitter: @rmannibucau <https://twitter.com/rmannibucau>*
> > > > > > > > *Blog: **http://rmannibucau.wordpress.com/*<
> > > > > > > > http://rmannibucau.wordpress.com/>
> > > > > > > > *LinkedIn: **http://fr.linkedin.com/in/rmannibucau*
> > > > > > > > *Github: https://github.com/rmannibucau*
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > 2013/7/2 James Green <ja...@gmail.com>
> > > > > > > >
> > > > > > > > > That's exactly what I want. All I have are EJBs with entity
> > > > > managers
> > > > > > > > > injected via @PersistenceContext (exactly as we are taught
> in
> > > the
> > > > > > > > > "Beginning Java EE 6 Platform with Glassfish 3" book which
> is
> > > how
> > > > > > this
> > > > > > > > > application began life.
> > > > > > > > >
> > > > > > > > > So what's the difference I wonder? Romain talks about
> adding
> > a
> > > > > > > dictionary
> > > > > > > > > but I didn't spot anything spectacularly obvious in a
> browse
> > of
> > > > the
> > > > > > > > OpenJPA
> > > > > > > > > user guide yesterday (indeed on the subject of injection it
> > > told
> > > > me
> > > > > > to
> > > > > > > > > refer to my application server documentation...).
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > On 1 July 2013 18:05, José Luis Cetina <
> maxtorzito@gmail.com
> > >
> > > > > wrote:
> > > > > > > > >
> > > > > > > > > > I did this test:
> > > > > > > > > >
> > > > > > > > > > 1. Stop TomEE
> > > > > > > > > > 2. Shutdown my database server
> > > > > > > > > > 3. Start TomEE
> > > > > > > > > > 4. Try to access to my app, i could access but when i hit
> > my
> > > > > login
> > > > > > > > button
> > > > > > > > > > for example then i get this error:
> > > > > > > > > >
> > > > > >
> > com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException:
> > > > > > > > > > Could not create connection to database server. Attempted
> > > > > > reconnect 3
> > > > > > > > > > times. Giving up.
> > > > > > > > > > 5. Start up my database server
> > > > > > > > > > 6. Wait for my database to be ready, i refresh the page
> > then
> > > > hit
> > > > > > > again
> > > > > > > > at
> > > > > > > > > > the login button, then my app run without problem (in
> this
> > > > point
> > > > > i
> > > > > > > DONT
> > > > > > > > > > stop/start TomEE again).
> > > > > > > > > >
> > > > > > > > > > Is this the behavior that you need/want it??
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > *Remeber that i have tomee and database in separate
> > server's
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > 2013/7/1 Howard W. Smith, Jr. <sm...@gmail.com>
> > > > > > > > > >
> > > > > > > > > > > Will you be trying the magic that Romain recommended?
> > > > > > > > > > >  On Jul 1, 2013 10:34 AM, "James Green" <
> > > > > > james.mk.green@gmail.com>
> > > > > > > > > > wrote:
> > > > > > > > > > >
> > > > > > > > > > > > I was asking about cold boot, specifically. It is
> when
> > > the
> > > > > > > > > application
> > > > > > > > > > > > server begins that the JPA implementation performs
> the
> > > > Entity
> > > > > > > > > mapping,
> > > > > > > > > > so
> > > > > > > > > > > > if the database is not available presumably it
> remains
> > > dead
> > > > > > until
> > > > > > > > the
> > > > > > > > > > > > application server itself is restarted?
> > > > > > > > > > > >
> > > > > > > > > > > > Unless you already have the magic installed that
> Romain
> > > > > refers
> > > > > > > to.
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > On 1 July 2013 15:24, José Luis Cetina <
> > > > maxtorzito@gmail.com
> > > > > >
> > > > > > > > wrote:
> > > > > > > > > > > >
> > > > > > > > > > > > > My entire app use database and of course the app
> > doesnt
> > > > > work
> > > > > > if
> > > > > > > > the
> > > > > > > > > > > > > database is unavailable, but when the database
> server
> > > is
> > > > > > > > available
> > > > > > > > > > > again
> > > > > > > > > > > > > the webapp can use the database again without
> > > restarting
> > > > > > TomEE.
> > > > > > > > > > > > >
> > > > > > > > > > > > > I dont know if i response your question.
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > > 2013/7/1 James Green <ja...@gmail.com>
> > > > > > > > > > > > >
> > > > > > > > > > > > > > Are you saying your application starts from cold
> > > > without
> > > > > > the
> > > > > > > > > > > database,
> > > > > > > > > > > > > the
> > > > > > > > > > > > > > operates fine without intervention once the
> > database
> > > > > > becomes
> > > > > > > > > > > available?
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > On 1 July 2013 14:26, José Luis Cetina <
> > > > > > maxtorzito@gmail.com
> > > > > > > >
> > > > > > > > > > wrote:
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > > I have also differents server, 1 one database
> > and 2
> > > > for
> > > > > > > TomEE
> > > > > > > > > > > (using
> > > > > > > > > > > > > > > memcached + cluster) and with
> autoReconnect=true
> > i
> > > > dont
> > > > > > > have
> > > > > > > > > any
> > > > > > > > > > > > issue
> > > > > > > > > > > > > > when
> > > > > > > > > > > > > > > the database server reboot, i set this
> attribute
> > > > > > > > > (autoReconnect)
> > > > > > > > > > > > after
> > > > > > > > > > > > > i
> > > > > > > > > > > > > > > experiment your same problems, when the
> database
> > > > server
> > > > > > > > > rebooted
> > > > > > > > > > my
> > > > > > > > > > > > > apps
> > > > > > > > > > > > > > > cant connect anymore to the database server, i
> > had
> > > to
> > > > > > stop
> > > > > > > > and
> > > > > > > > > > > start
> > > > > > > > > > > > > > tomee
> > > > > > > > > > > > > > > again for work. But then, i add that option and
> > > now i
> > > > > > work
> > > > > > > > with
> > > > > > > > > > any
> > > > > > > > > > > > > > > problem.
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > Here is a example of my Resource:
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > <Resource id="ANY_NAME" type="DataSource">
> > > > > > > > > > > > > > >   JdbcDriver com.mysql.jdbc.Driver
> > > > > > > > > > > > > > >   JdbcUrl
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> jdbc:mysql://any_ip:3306/any_database?zeroDateTimeBehavior=convertToNull&amp;rewriteBatchedStatements=true&amp;autoReconnect=true
> > > > > > > > > > > > > > >   UserName any_user
> > > > > > > > > > > > > > >   Password any_password
> > > > > > > > > > > > > > >   JtaManaged true
> > > > > > > > > > > > > > >   InitialSize=3
> > > > > > > > > > > > > > >   MaxActive=100
> > > > > > > > > > > > > > >   ValidationQuery=SELECT 1
> > > > > > > > > > > > > > >   TestOnBorrow=true
> > > > > > > > > > > > > > > </Resource>
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > 2013/7/1 James Green <james.mk.green@gmail.com
> >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > This now sounds substantially more complex
> than
> > > my
> > > > > > design
> > > > > > > > > > (which
> > > > > > > > > > > > uses
> > > > > > > > > > > > > > > > @PersistenceContext(unitName="accounts"))
> > caters
> > > > for.
> > > > > > Is
> > > > > > > > > there
> > > > > > > > > > an
> > > > > > > > > > > > > > example
> > > > > > > > > > > > > > > > of what you mean somewhere so I can scope the
> > > work
> > > > > out?
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > Thanks
> > > > > > > > > > > > > > > > James
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > On 1 July 2013 12:44, Romain Manni-Bucau <
> > > > > > > > > > rmannibucau@gmail.com>
> > > > > > > > > > > > > > wrote:
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > Hi
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > it depends your config and that's probably
> > more
> > > > an
> > > > > > > > openjpa
> > > > > > > > > > > > question
> > > > > > > > > > > > > > but
> > > > > > > > > > > > > > > > > basically you'll need to provide the
> > > dictionnary
> > > > to
> > > > > > use
> > > > > > > > > since
> > > > > > > > > > > > > openjpa
> > > > > > > > > > > > > > > > will
> > > > > > > > > > > > > > > > > not be able to read database metadata (at
> > > least).
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > *Romain Manni-Bucau*
> > > > > > > > > > > > > > > > > *Twitter: @rmannibucau <
> > > > > > > https://twitter.com/rmannibucau
> > > > > > > > >*
> > > > > > > > > > > > > > > > > *Blog: **
> http://rmannibucau.wordpress.com/*<
> > > > > > > > > > > > > > > > > http://rmannibucau.wordpress.com/>
> > > > > > > > > > > > > > > > > *LinkedIn: **
> > > > > http://fr.linkedin.com/in/rmannibucau*
> > > > > > > > > > > > > > > > > *Github: https://github.com/rmannibucau*
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > 2013/7/1 James Green <
> > james.mk.green@gmail.com
> > > >
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > I've suppressed the RuntimeExceptions
> > > > encountered
> > > > > > as
> > > > > > > > EJBs
> > > > > > > > > > > fire
> > > > > > > > > > > > > and
> > > > > > > > > > > > > > > > access
> > > > > > > > > > > > > > > > > > JPA, however I have a new problem now:
> > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > Caused by: <openjpa-2.2.0-r422266:1244990
> > > > > nonfatal
> > > > > > > user
> > > > > > > > > > > error>
> > > > > > > > > > > > > > > > > >
> > > > org.apache.openjpa.persistence.ArgumentException:
> > > > > > An
> > > > > > > > > error
> > > > > > > > > > > > > occurred
> > > > > > > > > > > > > > > > while
> > > > > > > > > > > > > > > > > > parsing the query filter "SELECT a FROM
> > > Account
> > > > > a".
> > > > > > > > Error
> > > > > > > > > > > > > message:
> > > > > > > > > > > > > > > The
> > > > > > > > > > > > > > > > > name
> > > > > > > > > > > > > > > > > > "Account" is not a recognized entity or
> > > > > identifier.
> > > > > > > > Known
> > > > > > > > > > > > entity
> > > > > > > > > > > > > > > names:
> > > > > > > > > > > > > > > > > []
> > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > It seems the JPA component was unable to
> > map
> > > my
> > > > > > > @Entity
> > > > > > > > > > > classes
> > > > > > > > > > > > > > > because
> > > > > > > > > > > > > > > > > the
> > > > > > > > > > > > > > > > > > connection did not exist at startup. What
> > do
> > > I
> > > > > need
> > > > > > > to
> > > > > > > > do
> > > > > > > > > > to
> > > > > > > > > > > > work
> > > > > > > > > > > > > > > > around
> > > > > > > > > > > > > > > > > > this?
> > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > On 1 July 2013 12:07, Romain Manni-Bucau
> <
> > > > > > > > > > > > rmannibucau@gmail.com>
> > > > > > > > > > > > > > > > wrote:
> > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > yep
> > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > basically get injected the
> timerservice (
> > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > >
> http://docs.oracle.com/javaee/6/api/javax/ejb/TimerService.html
> > > > > > > > > > > > > > ),
> > > > > > > > > > > > > > > in
> > > > > > > > > > > > > > > > > > your
> > > > > > > > > > > > > > > > > > > init method you try to get your data,
> if
> > > not
> > > > > > > trigger
> > > > > > > > a
> > > > > > > > > > > later
> > > > > > > > > > > > > > > > > > > invocation (
> > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> http://docs.oracle.com/javaee/6/api/javax/ejb/TimerService.html#createSingleActionTimer(java.util.Date
> > > > > > > > > > > > > > > > > > > ,
> > > > > > > > > > > > > > > > > > > javax.ejb.TimerConfig)). While it fails
> > > > trigger
> > > > > > > > another
> > > > > > > > > > one
> > > > > > > > > > > > > when
> > > > > > > > > > > > > > > > > invoked.
> > > > > > > > > > > > > > > > > > > When it succeeds you are done.
> > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > *Romain Manni-Bucau*
> > > > > > > > > > > > > > > > > > > *Twitter: @rmannibucau <
> > > > > > > > > https://twitter.com/rmannibucau
> > > > > > > > > > >*
> > > > > > > > > > > > > > > > > > > *Blog: **
> > > http://rmannibucau.wordpress.com/*<
> > > > > > > > > > > > > > > > > > > http://rmannibucau.wordpress.com/>
> > > > > > > > > > > > > > > > > > > *LinkedIn: **
> > > > > > > http://fr.linkedin.com/in/rmannibucau*
> > > > > > > > > > > > > > > > > > > *Github:
> https://github.com/rmannibucau*
> > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > 2013/7/1 James Green <
> > > > james.mk.green@gmail.com
> > > > > >
> > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > > In our case we have two EJBs, both
> > > > @Singleton
> > > > > > and
> > > > > > > > > > > @Startup,
> > > > > > > > > > > > > one
> > > > > > > > > > > > > > > > > depends
> > > > > > > > > > > > > > > > > > > on
> > > > > > > > > > > > > > > > > > > > the other. One is a cache façade and
> > the
> > > > > other
> > > > > > > > loads
> > > > > > > > > > data
> > > > > > > > > > > > via
> > > > > > > > > > > > > > JPA
> > > > > > > > > > > > > > > > and
> > > > > > > > > > > > > > > > > > > feeds
> > > > > > > > > > > > > > > > > > > > it into the cache. An external
> schedule
> > > > > fires a
> > > > > > > > > servlet
> > > > > > > > > > > > that
> > > > > > > > > > > > > > > > reloads
> > > > > > > > > > > > > > > > > > the
> > > > > > > > > > > > > > > > > > > > cache from the database.
> > > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > > What's happening is that without
> MySQL
> > we
> > > > see
> > > > > > EJB
> > > > > > > > > > > > exceptions
> > > > > > > > > > > > > > that
> > > > > > > > > > > > > > > > > they
> > > > > > > > > > > > > > > > > > > > cannot be created and thus we are
> dead.
> > > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > > I've just tried adding
> > autoReconnect=true
> > > > > > inside
> > > > > > > a
> > > > > > > > > > > > <Resource>
> > > > > > > > > > > > > > but
> > > > > > > > > > > > > > > > > that
> > > > > > > > > > > > > > > > > > > made
> > > > > > > > > > > > > > > > > > > > no difference. I also tried adding
> > > > > > > > > ,autoReconnect=true
> > > > > > > > > > to
> > > > > > > > > > > > > > > > > > > > ConnectionProperties and
> > > > > > > > ConnectionFactoryProperties
> > > > > > > > > > > > without
> > > > > > > > > > > > > > any
> > > > > > > > > > > > > > > > > change
> > > > > > > > > > > > > > > > > > > but
> > > > > > > > > > > > > > > > > > > > I'm not convinced that would have
> fixed
> > > the
> > > > > > > problem
> > > > > > > > > > here.
> > > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > > Is it instead the case that within
> the
> > > EJB
> > > > I
> > > > > > > should
> > > > > > > > > be
> > > > > > > > > > > > > trapping
> > > > > > > > > > > > > > > > > > > > connectivity problems such as
> > > > > > > PersistenceException
> > > > > > > > > and
> > > > > > > > > > > > > allowing
> > > > > > > > > > > > > > > the
> > > > > > > > > > > > > > > > > > > > containing to gracefully start up and
> > > > > naturally
> > > > > > > > keep
> > > > > > > > > > > trying
> > > > > > > > > > > > > > > anyway?
> > > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > > James
> > > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > > On 28 June 2013 17:10, José Luis
> > Cetina <
> > > > > > > > > > > > > maxtorzito@gmail.com>
> > > > > > > > > > > > > > > > > wrote:
> > > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > > > I had a similar problem and what i
> > did
> > > > was
> > > > > > set
> > > > > > > > the
> > > > > > > > > > > > > > > autoReconnect
> > > > > > > > > > > > > > > > > > > > attribute
> > > > > > > > > > > > > > > > > > > > > to true en my tomee.xml datasource.
> > > > > > > > > > > > > > > > > > > > > What do you mean with retry until
> the
> > > > > > > connection
> > > > > > > > > > > springs
> > > > > > > > > > > > to
> > > > > > > > > > > > > > > life?
> > > > > > > > > > > > > > > > > do
> > > > > > > > > > > > > > > > > > > you
> > > > > > > > > > > > > > > > > > > > > have some schedules or jobs running
> > and
> > > > > want
> > > > > > to
> > > > > > > > > retry
> > > > > > > > > > > > again
> > > > > > > > > > > > > > > when
> > > > > > > > > > > > > > > > > the
> > > > > > > > > > > > > > > > > > > > > connection is available again? or
> > just
> > > > want
> > > > > > > when
> > > > > > > > > > > somebody
> > > > > > > > > > > > > > click
> > > > > > > > > > > > > > > > any
> > > > > > > > > > > > > > > > > > > > button
> > > > > > > > > > > > > > > > > > > > > the app can connect again (this was
> > my
> > > > > > case)??
> > > > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > > > 2013/6/28 Romain Manni-Bucau <
> > > > > > > > > rmannibucau@gmail.com>
> > > > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > > > > With an ejb timer?
> > > > > > > > > > > > > > > > > > > > > > Le 28 juin 2013 17:46, "James
> > Green"
> > > <
> > > > > > > > > > > > > > > james.mk.green@gmail.com
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > a
> > > > > > > > > > > > > > > > > > > > écrit
> > > > > > > > > > > > > > > > > > > > > :
> > > > > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > > > > > Hopefully a quick one.
> > > > > > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > > > > > On boot our application
> attempts
> > to
> > > > > read
> > > > > > > data
> > > > > > > > > > > > through a
> > > > > > > > > > > > > > JPA
> > > > > > > > > > > > > > > > > > > > > > EntityManager.
> > > > > > > > > > > > > > > > > > > > > > > If the database connection
> fails
> > at
> > > > > this
> > > > > > > > point
> > > > > > > > > > the
> > > > > > > > > > > > > entire
> > > > > > > > > > > > > > > > > > > application
> > > > > > > > > > > > > > > > > > > > > is
> > > > > > > > > > > > > > > > > > > > > > > effectively dead.
> > > > > > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > > > > > Is there a way to essentially
> ask
> > > the
> > > > > > > > database
> > > > > > > > > > > layer
> > > > > > > > > > > > to
> > > > > > > > > > > > > > > retry
> > > > > > > > > > > > > > > > > > until
> > > > > > > > > > > > > > > > > > > > the
> > > > > > > > > > > > > > > > > > > > > > > connection springs to life?
> > > > > > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > > > > > Thanks,
> > > > > > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > > > > > James
> > > > > > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > > > --
> > > > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > >
> > > > > > > > > > >
> > > > > >
> -------------------------------------------------------------------
> > > > > > > > > > > > > > > > > > > > > *SCJA. José Luis Cetina*
> > > > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > >
> > > > > > > > > > >
> > > > > >
> -------------------------------------------------------------------
> > > > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > --
> > > > > > > > > > > > > > >
> > > > > > > > > >
> > > > > -------------------------------------------------------------------
> > > > > > > > > > > > > > > *SCJA. José Luis Cetina*
> > > > > > > > > > > > > > >
> > > > > > > > > >
> > > > > -------------------------------------------------------------------
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > > --
> > > > > > > > > > > > >
> > > > > > > >
> > > -------------------------------------------------------------------
> > > > > > > > > > > > > *SCJA. José Luis Cetina*
> > > > > > > > > > > > >
> > > > > > > >
> > > -------------------------------------------------------------------
> > > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > --
> > > > > > > > > >
> > > > > -------------------------------------------------------------------
> > > > > > > > > > *SCJA. José Luis Cetina*
> > > > > > > > > >
> > > > > -------------------------------------------------------------------
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
>

Re: Reconnect if JPA fails at boot?

Posted by James Green <ja...@gmail.com>.
A database is merely a resource - same as a message queue or a file. In
technology we never rely on them so we have to test the recovery of our
software instead. So I am here :)


On 2 July 2013 12:48, Romain Manni-Bucau <rm...@gmail.com> wrote:

> no, this is another error, not sure why ATM but it should be an easy one.
> If that's because the database was not here you'll need to ensure the
> datasource is here before using the entity manager for the first time or to
> list classes manually.
>
> that said to be honest if you *can't* rely on your database at all you
> should just use something else
>
> *Romain Manni-Bucau*
> *Twitter: @rmannibucau <https://twitter.com/rmannibucau>*
> *Blog: **http://rmannibucau.wordpress.com/*<
> http://rmannibucau.wordpress.com/>
> *LinkedIn: **http://fr.linkedin.com/in/rmannibucau*
> *Github: https://github.com/rmannibucau*
>
>
>
> 2013/7/2 James Green <ja...@gmail.com>
>
> > That will also fix the original error - that the list of mapped classes
> is
> > empty? Copy of the error again:
> >
> > Caused by: <openjpa-2.2.0-r422266:1244990 nonfatal user error>
> > org.apache.openjpa.persistence.ArgumentException: An error occurred while
> > parsing the query filter "SELECT a FROM Account a". Error message: The
> name
> > "Account" is not a recognized entity or identifier. Known entity names:
> []
> >
> >
> >
> >
> > On 2 July 2013 12:31, Romain Manni-Bucau <rm...@gmail.com> wrote:
> >
> > > just add in your persistence unit the needed property (sample for
> > > mysql: <property
> > > name="openjpa.jdbc.DBDictionary" value="mysql"/> )
> > >
> > > *Romain Manni-Bucau*
> > > *Twitter: @rmannibucau <https://twitter.com/rmannibucau>*
> > > *Blog: **http://rmannibucau.wordpress.com/*<
> > > http://rmannibucau.wordpress.com/>
> > > *LinkedIn: **http://fr.linkedin.com/in/rmannibucau*
> > > *Github: https://github.com/rmannibucau*
> > >
> > >
> > >
> > > 2013/7/2 James Green <ja...@gmail.com>
> > >
> > > > The documentation link you supplied: I'm not sure what I am looking
> for
> > > in
> > > > it. That's what I meant to say.
> > > >
> > > > To cut this down is there a demonstration project where this is
> already
> > > > correctly configured? May be simpler than explaining the changes to
> me
> > :)
> > > >
> > > >
> > > > On 2 July 2013 12:14, Romain Manni-Bucau <rm...@gmail.com>
> > wrote:
> > > >
> > > > > didnt get the first sentence
> > > > >
> > > > > about the "make it worse" it is what i explained in my previous
> > answer:
> > > > if
> > > > > you start without a db and openjpa uses automatically the wrong
> > > > dictionnary
> > > > > then even if the db is back and the pool well configured, the jpa
> > layer
> > > > > will generate wrong SQL so it will not work, so your app is broken
> > > > whatever
> > > > > the db state is.
> > > > >
> > > > > *Romain Manni-Bucau*
> > > > > *Twitter: @rmannibucau <https://twitter.com/rmannibucau>*
> > > > > *Blog: **http://rmannibucau.wordpress.com/*<
> > > > > http://rmannibucau.wordpress.com/>
> > > > > *LinkedIn: **http://fr.linkedin.com/in/rmannibucau*
> > > > > *Github: https://github.com/rmannibucau*
> > > > >
> > > > >
> > > > >
> > > > > 2013/7/2 James Green <ja...@gmail.com>
> > > > >
> > > > > > Am I looking for something letting me list the classes I want
> > mapped?
> > > > The
> > > > > > error I see shows an empty list, hence this particular question.
> > > > > >
> > > > > > You say it doesn't solve our issue and can actually make it
> worse?
> > > Care
> > > > > to
> > > > > > elaborate?
> > > > > >
> > > > > >
> > > > > > On 2 July 2013 09:17, Romain Manni-Bucau <rm...@gmail.com>
> > > > wrote:
> > > > > >
> > > > > > > the dict doc is here
> > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> http://openjpa.apache.org/builds/2.2.2/apache-openjpa/docs/ref_guide_dbsetup_dbsupport.html
> > > > > > >
> > > > > > > it is important to set it if the database can be down at
> startup
> > > > > > otherwise
> > > > > > > you can end up with a wrong dict (generally the generic one)
> and
> > > then
> > > > > > when
> > > > > > > the database is up again SQL stuff will not work
> > > > > > >
> > > > > > > it doesn't solve your issue but it can make it worse
> > > > > > >
> > > > > > > *Romain Manni-Bucau*
> > > > > > > *Twitter: @rmannibucau <https://twitter.com/rmannibucau>*
> > > > > > > *Blog: **http://rmannibucau.wordpress.com/*<
> > > > > > > http://rmannibucau.wordpress.com/>
> > > > > > > *LinkedIn: **http://fr.linkedin.com/in/rmannibucau*
> > > > > > > *Github: https://github.com/rmannibucau*
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > 2013/7/2 James Green <ja...@gmail.com>
> > > > > > >
> > > > > > > > That's exactly what I want. All I have are EJBs with entity
> > > > managers
> > > > > > > > injected via @PersistenceContext (exactly as we are taught in
> > the
> > > > > > > > "Beginning Java EE 6 Platform with Glassfish 3" book which is
> > how
> > > > > this
> > > > > > > > application began life.
> > > > > > > >
> > > > > > > > So what's the difference I wonder? Romain talks about adding
> a
> > > > > > dictionary
> > > > > > > > but I didn't spot anything spectacularly obvious in a browse
> of
> > > the
> > > > > > > OpenJPA
> > > > > > > > user guide yesterday (indeed on the subject of injection it
> > told
> > > me
> > > > > to
> > > > > > > > refer to my application server documentation...).
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > On 1 July 2013 18:05, José Luis Cetina <maxtorzito@gmail.com
> >
> > > > wrote:
> > > > > > > >
> > > > > > > > > I did this test:
> > > > > > > > >
> > > > > > > > > 1. Stop TomEE
> > > > > > > > > 2. Shutdown my database server
> > > > > > > > > 3. Start TomEE
> > > > > > > > > 4. Try to access to my app, i could access but when i hit
> my
> > > > login
> > > > > > > button
> > > > > > > > > for example then i get this error:
> > > > > > > > >
> > > > >
> com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException:
> > > > > > > > > Could not create connection to database server. Attempted
> > > > > reconnect 3
> > > > > > > > > times. Giving up.
> > > > > > > > > 5. Start up my database server
> > > > > > > > > 6. Wait for my database to be ready, i refresh the page
> then
> > > hit
> > > > > > again
> > > > > > > at
> > > > > > > > > the login button, then my app run without problem (in this
> > > point
> > > > i
> > > > > > DONT
> > > > > > > > > stop/start TomEE again).
> > > > > > > > >
> > > > > > > > > Is this the behavior that you need/want it??
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > *Remeber that i have tomee and database in separate
> server's
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > 2013/7/1 Howard W. Smith, Jr. <sm...@gmail.com>
> > > > > > > > >
> > > > > > > > > > Will you be trying the magic that Romain recommended?
> > > > > > > > > >  On Jul 1, 2013 10:34 AM, "James Green" <
> > > > > james.mk.green@gmail.com>
> > > > > > > > > wrote:
> > > > > > > > > >
> > > > > > > > > > > I was asking about cold boot, specifically. It is when
> > the
> > > > > > > > application
> > > > > > > > > > > server begins that the JPA implementation performs the
> > > Entity
> > > > > > > > mapping,
> > > > > > > > > so
> > > > > > > > > > > if the database is not available presumably it remains
> > dead
> > > > > until
> > > > > > > the
> > > > > > > > > > > application server itself is restarted?
> > > > > > > > > > >
> > > > > > > > > > > Unless you already have the magic installed that Romain
> > > > refers
> > > > > > to.
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > On 1 July 2013 15:24, José Luis Cetina <
> > > maxtorzito@gmail.com
> > > > >
> > > > > > > wrote:
> > > > > > > > > > >
> > > > > > > > > > > > My entire app use database and of course the app
> doesnt
> > > > work
> > > > > if
> > > > > > > the
> > > > > > > > > > > > database is unavailable, but when the database server
> > is
> > > > > > > available
> > > > > > > > > > again
> > > > > > > > > > > > the webapp can use the database again without
> > restarting
> > > > > TomEE.
> > > > > > > > > > > >
> > > > > > > > > > > > I dont know if i response your question.
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > 2013/7/1 James Green <ja...@gmail.com>
> > > > > > > > > > > >
> > > > > > > > > > > > > Are you saying your application starts from cold
> > > without
> > > > > the
> > > > > > > > > > database,
> > > > > > > > > > > > the
> > > > > > > > > > > > > operates fine without intervention once the
> database
> > > > > becomes
> > > > > > > > > > available?
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > > On 1 July 2013 14:26, José Luis Cetina <
> > > > > maxtorzito@gmail.com
> > > > > > >
> > > > > > > > > wrote:
> > > > > > > > > > > > >
> > > > > > > > > > > > > > I have also differents server, 1 one database
> and 2
> > > for
> > > > > > TomEE
> > > > > > > > > > (using
> > > > > > > > > > > > > > memcached + cluster) and with autoReconnect=true
> i
> > > dont
> > > > > > have
> > > > > > > > any
> > > > > > > > > > > issue
> > > > > > > > > > > > > when
> > > > > > > > > > > > > > the database server reboot, i set this attribute
> > > > > > > > (autoReconnect)
> > > > > > > > > > > after
> > > > > > > > > > > > i
> > > > > > > > > > > > > > experiment your same problems, when the database
> > > server
> > > > > > > > rebooted
> > > > > > > > > my
> > > > > > > > > > > > apps
> > > > > > > > > > > > > > cant connect anymore to the database server, i
> had
> > to
> > > > > stop
> > > > > > > and
> > > > > > > > > > start
> > > > > > > > > > > > > tomee
> > > > > > > > > > > > > > again for work. But then, i add that option and
> > now i
> > > > > work
> > > > > > > with
> > > > > > > > > any
> > > > > > > > > > > > > > problem.
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > Here is a example of my Resource:
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > <Resource id="ANY_NAME" type="DataSource">
> > > > > > > > > > > > > >   JdbcDriver com.mysql.jdbc.Driver
> > > > > > > > > > > > > >   JdbcUrl
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> jdbc:mysql://any_ip:3306/any_database?zeroDateTimeBehavior=convertToNull&amp;rewriteBatchedStatements=true&amp;autoReconnect=true
> > > > > > > > > > > > > >   UserName any_user
> > > > > > > > > > > > > >   Password any_password
> > > > > > > > > > > > > >   JtaManaged true
> > > > > > > > > > > > > >   InitialSize=3
> > > > > > > > > > > > > >   MaxActive=100
> > > > > > > > > > > > > >   ValidationQuery=SELECT 1
> > > > > > > > > > > > > >   TestOnBorrow=true
> > > > > > > > > > > > > > </Resource>
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > 2013/7/1 James Green <ja...@gmail.com>
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > > This now sounds substantially more complex than
> > my
> > > > > design
> > > > > > > > > (which
> > > > > > > > > > > uses
> > > > > > > > > > > > > > > @PersistenceContext(unitName="accounts"))
> caters
> > > for.
> > > > > Is
> > > > > > > > there
> > > > > > > > > an
> > > > > > > > > > > > > example
> > > > > > > > > > > > > > > of what you mean somewhere so I can scope the
> > work
> > > > out?
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > Thanks
> > > > > > > > > > > > > > > James
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > On 1 July 2013 12:44, Romain Manni-Bucau <
> > > > > > > > > rmannibucau@gmail.com>
> > > > > > > > > > > > > wrote:
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > Hi
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > it depends your config and that's probably
> more
> > > an
> > > > > > > openjpa
> > > > > > > > > > > question
> > > > > > > > > > > > > but
> > > > > > > > > > > > > > > > basically you'll need to provide the
> > dictionnary
> > > to
> > > > > use
> > > > > > > > since
> > > > > > > > > > > > openjpa
> > > > > > > > > > > > > > > will
> > > > > > > > > > > > > > > > not be able to read database metadata (at
> > least).
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > *Romain Manni-Bucau*
> > > > > > > > > > > > > > > > *Twitter: @rmannibucau <
> > > > > > https://twitter.com/rmannibucau
> > > > > > > >*
> > > > > > > > > > > > > > > > *Blog: **http://rmannibucau.wordpress.com/*<
> > > > > > > > > > > > > > > > http://rmannibucau.wordpress.com/>
> > > > > > > > > > > > > > > > *LinkedIn: **
> > > > http://fr.linkedin.com/in/rmannibucau*
> > > > > > > > > > > > > > > > *Github: https://github.com/rmannibucau*
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > 2013/7/1 James Green <
> james.mk.green@gmail.com
> > >
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > I've suppressed the RuntimeExceptions
> > > encountered
> > > > > as
> > > > > > > EJBs
> > > > > > > > > > fire
> > > > > > > > > > > > and
> > > > > > > > > > > > > > > access
> > > > > > > > > > > > > > > > > JPA, however I have a new problem now:
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > Caused by: <openjpa-2.2.0-r422266:1244990
> > > > nonfatal
> > > > > > user
> > > > > > > > > > error>
> > > > > > > > > > > > > > > > >
> > > org.apache.openjpa.persistence.ArgumentException:
> > > > > An
> > > > > > > > error
> > > > > > > > > > > > occurred
> > > > > > > > > > > > > > > while
> > > > > > > > > > > > > > > > > parsing the query filter "SELECT a FROM
> > Account
> > > > a".
> > > > > > > Error
> > > > > > > > > > > > message:
> > > > > > > > > > > > > > The
> > > > > > > > > > > > > > > > name
> > > > > > > > > > > > > > > > > "Account" is not a recognized entity or
> > > > identifier.
> > > > > > > Known
> > > > > > > > > > > entity
> > > > > > > > > > > > > > names:
> > > > > > > > > > > > > > > > []
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > It seems the JPA component was unable to
> map
> > my
> > > > > > @Entity
> > > > > > > > > > classes
> > > > > > > > > > > > > > because
> > > > > > > > > > > > > > > > the
> > > > > > > > > > > > > > > > > connection did not exist at startup. What
> do
> > I
> > > > need
> > > > > > to
> > > > > > > do
> > > > > > > > > to
> > > > > > > > > > > work
> > > > > > > > > > > > > > > around
> > > > > > > > > > > > > > > > > this?
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > On 1 July 2013 12:07, Romain Manni-Bucau <
> > > > > > > > > > > rmannibucau@gmail.com>
> > > > > > > > > > > > > > > wrote:
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > yep
> > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > basically get injected the timerservice (
> > > > > > > > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > http://docs.oracle.com/javaee/6/api/javax/ejb/TimerService.html
> > > > > > > > > > > > > ),
> > > > > > > > > > > > > > in
> > > > > > > > > > > > > > > > > your
> > > > > > > > > > > > > > > > > > init method you try to get your data, if
> > not
> > > > > > trigger
> > > > > > > a
> > > > > > > > > > later
> > > > > > > > > > > > > > > > > > invocation (
> > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> http://docs.oracle.com/javaee/6/api/javax/ejb/TimerService.html#createSingleActionTimer(java.util.Date
> > > > > > > > > > > > > > > > > > ,
> > > > > > > > > > > > > > > > > > javax.ejb.TimerConfig)). While it fails
> > > trigger
> > > > > > > another
> > > > > > > > > one
> > > > > > > > > > > > when
> > > > > > > > > > > > > > > > invoked.
> > > > > > > > > > > > > > > > > > When it succeeds you are done.
> > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > *Romain Manni-Bucau*
> > > > > > > > > > > > > > > > > > *Twitter: @rmannibucau <
> > > > > > > > https://twitter.com/rmannibucau
> > > > > > > > > >*
> > > > > > > > > > > > > > > > > > *Blog: **
> > http://rmannibucau.wordpress.com/*<
> > > > > > > > > > > > > > > > > > http://rmannibucau.wordpress.com/>
> > > > > > > > > > > > > > > > > > *LinkedIn: **
> > > > > > http://fr.linkedin.com/in/rmannibucau*
> > > > > > > > > > > > > > > > > > *Github: https://github.com/rmannibucau*
> > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > 2013/7/1 James Green <
> > > james.mk.green@gmail.com
> > > > >
> > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > In our case we have two EJBs, both
> > > @Singleton
> > > > > and
> > > > > > > > > > @Startup,
> > > > > > > > > > > > one
> > > > > > > > > > > > > > > > depends
> > > > > > > > > > > > > > > > > > on
> > > > > > > > > > > > > > > > > > > the other. One is a cache façade and
> the
> > > > other
> > > > > > > loads
> > > > > > > > > data
> > > > > > > > > > > via
> > > > > > > > > > > > > JPA
> > > > > > > > > > > > > > > and
> > > > > > > > > > > > > > > > > > feeds
> > > > > > > > > > > > > > > > > > > it into the cache. An external schedule
> > > > fires a
> > > > > > > > servlet
> > > > > > > > > > > that
> > > > > > > > > > > > > > > reloads
> > > > > > > > > > > > > > > > > the
> > > > > > > > > > > > > > > > > > > cache from the database.
> > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > What's happening is that without MySQL
> we
> > > see
> > > > > EJB
> > > > > > > > > > > exceptions
> > > > > > > > > > > > > that
> > > > > > > > > > > > > > > > they
> > > > > > > > > > > > > > > > > > > cannot be created and thus we are dead.
> > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > I've just tried adding
> autoReconnect=true
> > > > > inside
> > > > > > a
> > > > > > > > > > > <Resource>
> > > > > > > > > > > > > but
> > > > > > > > > > > > > > > > that
> > > > > > > > > > > > > > > > > > made
> > > > > > > > > > > > > > > > > > > no difference. I also tried adding
> > > > > > > > ,autoReconnect=true
> > > > > > > > > to
> > > > > > > > > > > > > > > > > > > ConnectionProperties and
> > > > > > > ConnectionFactoryProperties
> > > > > > > > > > > without
> > > > > > > > > > > > > any
> > > > > > > > > > > > > > > > change
> > > > > > > > > > > > > > > > > > but
> > > > > > > > > > > > > > > > > > > I'm not convinced that would have fixed
> > the
> > > > > > problem
> > > > > > > > > here.
> > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > Is it instead the case that within the
> > EJB
> > > I
> > > > > > should
> > > > > > > > be
> > > > > > > > > > > > trapping
> > > > > > > > > > > > > > > > > > > connectivity problems such as
> > > > > > PersistenceException
> > > > > > > > and
> > > > > > > > > > > > allowing
> > > > > > > > > > > > > > the
> > > > > > > > > > > > > > > > > > > containing to gracefully start up and
> > > > naturally
> > > > > > > keep
> > > > > > > > > > trying
> > > > > > > > > > > > > > anyway?
> > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > James
> > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > On 28 June 2013 17:10, José Luis
> Cetina <
> > > > > > > > > > > > maxtorzito@gmail.com>
> > > > > > > > > > > > > > > > wrote:
> > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > > I had a similar problem and what i
> did
> > > was
> > > > > set
> > > > > > > the
> > > > > > > > > > > > > > autoReconnect
> > > > > > > > > > > > > > > > > > > attribute
> > > > > > > > > > > > > > > > > > > > to true en my tomee.xml datasource.
> > > > > > > > > > > > > > > > > > > > What do you mean with retry until the
> > > > > > connection
> > > > > > > > > > springs
> > > > > > > > > > > to
> > > > > > > > > > > > > > life?
> > > > > > > > > > > > > > > > do
> > > > > > > > > > > > > > > > > > you
> > > > > > > > > > > > > > > > > > > > have some schedules or jobs running
> and
> > > > want
> > > > > to
> > > > > > > > retry
> > > > > > > > > > > again
> > > > > > > > > > > > > > when
> > > > > > > > > > > > > > > > the
> > > > > > > > > > > > > > > > > > > > connection is available again? or
> just
> > > want
> > > > > > when
> > > > > > > > > > somebody
> > > > > > > > > > > > > click
> > > > > > > > > > > > > > > any
> > > > > > > > > > > > > > > > > > > button
> > > > > > > > > > > > > > > > > > > > the app can connect again (this was
> my
> > > > > case)??
> > > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > > 2013/6/28 Romain Manni-Bucau <
> > > > > > > > rmannibucau@gmail.com>
> > > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > > > With an ejb timer?
> > > > > > > > > > > > > > > > > > > > > Le 28 juin 2013 17:46, "James
> Green"
> > <
> > > > > > > > > > > > > > james.mk.green@gmail.com
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > a
> > > > > > > > > > > > > > > > > > > écrit
> > > > > > > > > > > > > > > > > > > > :
> > > > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > > > > Hopefully a quick one.
> > > > > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > > > > On boot our application attempts
> to
> > > > read
> > > > > > data
> > > > > > > > > > > through a
> > > > > > > > > > > > > JPA
> > > > > > > > > > > > > > > > > > > > > EntityManager.
> > > > > > > > > > > > > > > > > > > > > > If the database connection fails
> at
> > > > this
> > > > > > > point
> > > > > > > > > the
> > > > > > > > > > > > entire
> > > > > > > > > > > > > > > > > > application
> > > > > > > > > > > > > > > > > > > > is
> > > > > > > > > > > > > > > > > > > > > > effectively dead.
> > > > > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > > > > Is there a way to essentially ask
> > the
> > > > > > > database
> > > > > > > > > > layer
> > > > > > > > > > > to
> > > > > > > > > > > > > > retry
> > > > > > > > > > > > > > > > > until
> > > > > > > > > > > > > > > > > > > the
> > > > > > > > > > > > > > > > > > > > > > connection springs to life?
> > > > > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > > > > Thanks,
> > > > > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > > > > James
> > > > > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > > --
> > > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > >
> > > > > -------------------------------------------------------------------
> > > > > > > > > > > > > > > > > > > > *SCJA. José Luis Cetina*
> > > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > >
> > > > > -------------------------------------------------------------------
> > > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > --
> > > > > > > > > > > > > >
> > > > > > > > >
> > > > -------------------------------------------------------------------
> > > > > > > > > > > > > > *SCJA. José Luis Cetina*
> > > > > > > > > > > > > >
> > > > > > > > >
> > > > -------------------------------------------------------------------
> > > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > --
> > > > > > > > > > > >
> > > > > > >
> > -------------------------------------------------------------------
> > > > > > > > > > > > *SCJA. José Luis Cetina*
> > > > > > > > > > > >
> > > > > > >
> > -------------------------------------------------------------------
> > > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > --
> > > > > > > > >
> > > > -------------------------------------------------------------------
> > > > > > > > > *SCJA. José Luis Cetina*
> > > > > > > > >
> > > > -------------------------------------------------------------------
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
>

Re: Reconnect if JPA fails at boot?

Posted by Romain Manni-Bucau <rm...@gmail.com>.
no, this is another error, not sure why ATM but it should be an easy one.
If that's because the database was not here you'll need to ensure the
datasource is here before using the entity manager for the first time or to
list classes manually.

that said to be honest if you *can't* rely on your database at all you
should just use something else

*Romain Manni-Bucau*
*Twitter: @rmannibucau <https://twitter.com/rmannibucau>*
*Blog: **http://rmannibucau.wordpress.com/*<http://rmannibucau.wordpress.com/>
*LinkedIn: **http://fr.linkedin.com/in/rmannibucau*
*Github: https://github.com/rmannibucau*



2013/7/2 James Green <ja...@gmail.com>

> That will also fix the original error - that the list of mapped classes is
> empty? Copy of the error again:
>
> Caused by: <openjpa-2.2.0-r422266:1244990 nonfatal user error>
> org.apache.openjpa.persistence.ArgumentException: An error occurred while
> parsing the query filter "SELECT a FROM Account a". Error message: The name
> "Account" is not a recognized entity or identifier. Known entity names: []
>
>
>
>
> On 2 July 2013 12:31, Romain Manni-Bucau <rm...@gmail.com> wrote:
>
> > just add in your persistence unit the needed property (sample for
> > mysql: <property
> > name="openjpa.jdbc.DBDictionary" value="mysql"/> )
> >
> > *Romain Manni-Bucau*
> > *Twitter: @rmannibucau <https://twitter.com/rmannibucau>*
> > *Blog: **http://rmannibucau.wordpress.com/*<
> > http://rmannibucau.wordpress.com/>
> > *LinkedIn: **http://fr.linkedin.com/in/rmannibucau*
> > *Github: https://github.com/rmannibucau*
> >
> >
> >
> > 2013/7/2 James Green <ja...@gmail.com>
> >
> > > The documentation link you supplied: I'm not sure what I am looking for
> > in
> > > it. That's what I meant to say.
> > >
> > > To cut this down is there a demonstration project where this is already
> > > correctly configured? May be simpler than explaining the changes to me
> :)
> > >
> > >
> > > On 2 July 2013 12:14, Romain Manni-Bucau <rm...@gmail.com>
> wrote:
> > >
> > > > didnt get the first sentence
> > > >
> > > > about the "make it worse" it is what i explained in my previous
> answer:
> > > if
> > > > you start without a db and openjpa uses automatically the wrong
> > > dictionnary
> > > > then even if the db is back and the pool well configured, the jpa
> layer
> > > > will generate wrong SQL so it will not work, so your app is broken
> > > whatever
> > > > the db state is.
> > > >
> > > > *Romain Manni-Bucau*
> > > > *Twitter: @rmannibucau <https://twitter.com/rmannibucau>*
> > > > *Blog: **http://rmannibucau.wordpress.com/*<
> > > > http://rmannibucau.wordpress.com/>
> > > > *LinkedIn: **http://fr.linkedin.com/in/rmannibucau*
> > > > *Github: https://github.com/rmannibucau*
> > > >
> > > >
> > > >
> > > > 2013/7/2 James Green <ja...@gmail.com>
> > > >
> > > > > Am I looking for something letting me list the classes I want
> mapped?
> > > The
> > > > > error I see shows an empty list, hence this particular question.
> > > > >
> > > > > You say it doesn't solve our issue and can actually make it worse?
> > Care
> > > > to
> > > > > elaborate?
> > > > >
> > > > >
> > > > > On 2 July 2013 09:17, Romain Manni-Bucau <rm...@gmail.com>
> > > wrote:
> > > > >
> > > > > > the dict doc is here
> > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> http://openjpa.apache.org/builds/2.2.2/apache-openjpa/docs/ref_guide_dbsetup_dbsupport.html
> > > > > >
> > > > > > it is important to set it if the database can be down at startup
> > > > > otherwise
> > > > > > you can end up with a wrong dict (generally the generic one) and
> > then
> > > > > when
> > > > > > the database is up again SQL stuff will not work
> > > > > >
> > > > > > it doesn't solve your issue but it can make it worse
> > > > > >
> > > > > > *Romain Manni-Bucau*
> > > > > > *Twitter: @rmannibucau <https://twitter.com/rmannibucau>*
> > > > > > *Blog: **http://rmannibucau.wordpress.com/*<
> > > > > > http://rmannibucau.wordpress.com/>
> > > > > > *LinkedIn: **http://fr.linkedin.com/in/rmannibucau*
> > > > > > *Github: https://github.com/rmannibucau*
> > > > > >
> > > > > >
> > > > > >
> > > > > > 2013/7/2 James Green <ja...@gmail.com>
> > > > > >
> > > > > > > That's exactly what I want. All I have are EJBs with entity
> > > managers
> > > > > > > injected via @PersistenceContext (exactly as we are taught in
> the
> > > > > > > "Beginning Java EE 6 Platform with Glassfish 3" book which is
> how
> > > > this
> > > > > > > application began life.
> > > > > > >
> > > > > > > So what's the difference I wonder? Romain talks about adding a
> > > > > dictionary
> > > > > > > but I didn't spot anything spectacularly obvious in a browse of
> > the
> > > > > > OpenJPA
> > > > > > > user guide yesterday (indeed on the subject of injection it
> told
> > me
> > > > to
> > > > > > > refer to my application server documentation...).
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > On 1 July 2013 18:05, José Luis Cetina <ma...@gmail.com>
> > > wrote:
> > > > > > >
> > > > > > > > I did this test:
> > > > > > > >
> > > > > > > > 1. Stop TomEE
> > > > > > > > 2. Shutdown my database server
> > > > > > > > 3. Start TomEE
> > > > > > > > 4. Try to access to my app, i could access but when i hit my
> > > login
> > > > > > button
> > > > > > > > for example then i get this error:
> > > > > > > >
> > > > com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException:
> > > > > > > > Could not create connection to database server. Attempted
> > > > reconnect 3
> > > > > > > > times. Giving up.
> > > > > > > > 5. Start up my database server
> > > > > > > > 6. Wait for my database to be ready, i refresh the page then
> > hit
> > > > > again
> > > > > > at
> > > > > > > > the login button, then my app run without problem (in this
> > point
> > > i
> > > > > DONT
> > > > > > > > stop/start TomEE again).
> > > > > > > >
> > > > > > > > Is this the behavior that you need/want it??
> > > > > > > >
> > > > > > > >
> > > > > > > > *Remeber that i have tomee and database in separate server's
> > > > > > > >
> > > > > > > >
> > > > > > > > 2013/7/1 Howard W. Smith, Jr. <sm...@gmail.com>
> > > > > > > >
> > > > > > > > > Will you be trying the magic that Romain recommended?
> > > > > > > > >  On Jul 1, 2013 10:34 AM, "James Green" <
> > > > james.mk.green@gmail.com>
> > > > > > > > wrote:
> > > > > > > > >
> > > > > > > > > > I was asking about cold boot, specifically. It is when
> the
> > > > > > > application
> > > > > > > > > > server begins that the JPA implementation performs the
> > Entity
> > > > > > > mapping,
> > > > > > > > so
> > > > > > > > > > if the database is not available presumably it remains
> dead
> > > > until
> > > > > > the
> > > > > > > > > > application server itself is restarted?
> > > > > > > > > >
> > > > > > > > > > Unless you already have the magic installed that Romain
> > > refers
> > > > > to.
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > On 1 July 2013 15:24, José Luis Cetina <
> > maxtorzito@gmail.com
> > > >
> > > > > > wrote:
> > > > > > > > > >
> > > > > > > > > > > My entire app use database and of course the app doesnt
> > > work
> > > > if
> > > > > > the
> > > > > > > > > > > database is unavailable, but when the database server
> is
> > > > > > available
> > > > > > > > > again
> > > > > > > > > > > the webapp can use the database again without
> restarting
> > > > TomEE.
> > > > > > > > > > >
> > > > > > > > > > > I dont know if i response your question.
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > 2013/7/1 James Green <ja...@gmail.com>
> > > > > > > > > > >
> > > > > > > > > > > > Are you saying your application starts from cold
> > without
> > > > the
> > > > > > > > > database,
> > > > > > > > > > > the
> > > > > > > > > > > > operates fine without intervention once the database
> > > > becomes
> > > > > > > > > available?
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > On 1 July 2013 14:26, José Luis Cetina <
> > > > maxtorzito@gmail.com
> > > > > >
> > > > > > > > wrote:
> > > > > > > > > > > >
> > > > > > > > > > > > > I have also differents server, 1 one database and 2
> > for
> > > > > TomEE
> > > > > > > > > (using
> > > > > > > > > > > > > memcached + cluster) and with autoReconnect=true i
> > dont
> > > > > have
> > > > > > > any
> > > > > > > > > > issue
> > > > > > > > > > > > when
> > > > > > > > > > > > > the database server reboot, i set this attribute
> > > > > > > (autoReconnect)
> > > > > > > > > > after
> > > > > > > > > > > i
> > > > > > > > > > > > > experiment your same problems, when the database
> > server
> > > > > > > rebooted
> > > > > > > > my
> > > > > > > > > > > apps
> > > > > > > > > > > > > cant connect anymore to the database server, i had
> to
> > > > stop
> > > > > > and
> > > > > > > > > start
> > > > > > > > > > > > tomee
> > > > > > > > > > > > > again for work. But then, i add that option and
> now i
> > > > work
> > > > > > with
> > > > > > > > any
> > > > > > > > > > > > > problem.
> > > > > > > > > > > > >
> > > > > > > > > > > > > Here is a example of my Resource:
> > > > > > > > > > > > >
> > > > > > > > > > > > > <Resource id="ANY_NAME" type="DataSource">
> > > > > > > > > > > > >   JdbcDriver com.mysql.jdbc.Driver
> > > > > > > > > > > > >   JdbcUrl
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> jdbc:mysql://any_ip:3306/any_database?zeroDateTimeBehavior=convertToNull&amp;rewriteBatchedStatements=true&amp;autoReconnect=true
> > > > > > > > > > > > >   UserName any_user
> > > > > > > > > > > > >   Password any_password
> > > > > > > > > > > > >   JtaManaged true
> > > > > > > > > > > > >   InitialSize=3
> > > > > > > > > > > > >   MaxActive=100
> > > > > > > > > > > > >   ValidationQuery=SELECT 1
> > > > > > > > > > > > >   TestOnBorrow=true
> > > > > > > > > > > > > </Resource>
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > > 2013/7/1 James Green <ja...@gmail.com>
> > > > > > > > > > > > >
> > > > > > > > > > > > > > This now sounds substantially more complex than
> my
> > > > design
> > > > > > > > (which
> > > > > > > > > > uses
> > > > > > > > > > > > > > @PersistenceContext(unitName="accounts")) caters
> > for.
> > > > Is
> > > > > > > there
> > > > > > > > an
> > > > > > > > > > > > example
> > > > > > > > > > > > > > of what you mean somewhere so I can scope the
> work
> > > out?
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > Thanks
> > > > > > > > > > > > > > James
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > On 1 July 2013 12:44, Romain Manni-Bucau <
> > > > > > > > rmannibucau@gmail.com>
> > > > > > > > > > > > wrote:
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > > Hi
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > it depends your config and that's probably more
> > an
> > > > > > openjpa
> > > > > > > > > > question
> > > > > > > > > > > > but
> > > > > > > > > > > > > > > basically you'll need to provide the
> dictionnary
> > to
> > > > use
> > > > > > > since
> > > > > > > > > > > openjpa
> > > > > > > > > > > > > > will
> > > > > > > > > > > > > > > not be able to read database metadata (at
> least).
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > *Romain Manni-Bucau*
> > > > > > > > > > > > > > > *Twitter: @rmannibucau <
> > > > > https://twitter.com/rmannibucau
> > > > > > >*
> > > > > > > > > > > > > > > *Blog: **http://rmannibucau.wordpress.com/*<
> > > > > > > > > > > > > > > http://rmannibucau.wordpress.com/>
> > > > > > > > > > > > > > > *LinkedIn: **
> > > http://fr.linkedin.com/in/rmannibucau*
> > > > > > > > > > > > > > > *Github: https://github.com/rmannibucau*
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > 2013/7/1 James Green <james.mk.green@gmail.com
> >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > I've suppressed the RuntimeExceptions
> > encountered
> > > > as
> > > > > > EJBs
> > > > > > > > > fire
> > > > > > > > > > > and
> > > > > > > > > > > > > > access
> > > > > > > > > > > > > > > > JPA, however I have a new problem now:
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > Caused by: <openjpa-2.2.0-r422266:1244990
> > > nonfatal
> > > > > user
> > > > > > > > > error>
> > > > > > > > > > > > > > > >
> > org.apache.openjpa.persistence.ArgumentException:
> > > > An
> > > > > > > error
> > > > > > > > > > > occurred
> > > > > > > > > > > > > > while
> > > > > > > > > > > > > > > > parsing the query filter "SELECT a FROM
> Account
> > > a".
> > > > > > Error
> > > > > > > > > > > message:
> > > > > > > > > > > > > The
> > > > > > > > > > > > > > > name
> > > > > > > > > > > > > > > > "Account" is not a recognized entity or
> > > identifier.
> > > > > > Known
> > > > > > > > > > entity
> > > > > > > > > > > > > names:
> > > > > > > > > > > > > > > []
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > It seems the JPA component was unable to map
> my
> > > > > @Entity
> > > > > > > > > classes
> > > > > > > > > > > > > because
> > > > > > > > > > > > > > > the
> > > > > > > > > > > > > > > > connection did not exist at startup. What do
> I
> > > need
> > > > > to
> > > > > > do
> > > > > > > > to
> > > > > > > > > > work
> > > > > > > > > > > > > > around
> > > > > > > > > > > > > > > > this?
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > On 1 July 2013 12:07, Romain Manni-Bucau <
> > > > > > > > > > rmannibucau@gmail.com>
> > > > > > > > > > > > > > wrote:
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > yep
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > basically get injected the timerservice (
> > > > > > > > > > > > > > > > >
> > > > > > > > > > >
> > > > > http://docs.oracle.com/javaee/6/api/javax/ejb/TimerService.html
> > > > > > > > > > > > ),
> > > > > > > > > > > > > in
> > > > > > > > > > > > > > > > your
> > > > > > > > > > > > > > > > > init method you try to get your data, if
> not
> > > > > trigger
> > > > > > a
> > > > > > > > > later
> > > > > > > > > > > > > > > > > invocation (
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> http://docs.oracle.com/javaee/6/api/javax/ejb/TimerService.html#createSingleActionTimer(java.util.Date
> > > > > > > > > > > > > > > > > ,
> > > > > > > > > > > > > > > > > javax.ejb.TimerConfig)). While it fails
> > trigger
> > > > > > another
> > > > > > > > one
> > > > > > > > > > > when
> > > > > > > > > > > > > > > invoked.
> > > > > > > > > > > > > > > > > When it succeeds you are done.
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > *Romain Manni-Bucau*
> > > > > > > > > > > > > > > > > *Twitter: @rmannibucau <
> > > > > > > https://twitter.com/rmannibucau
> > > > > > > > >*
> > > > > > > > > > > > > > > > > *Blog: **
> http://rmannibucau.wordpress.com/*<
> > > > > > > > > > > > > > > > > http://rmannibucau.wordpress.com/>
> > > > > > > > > > > > > > > > > *LinkedIn: **
> > > > > http://fr.linkedin.com/in/rmannibucau*
> > > > > > > > > > > > > > > > > *Github: https://github.com/rmannibucau*
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > 2013/7/1 James Green <
> > james.mk.green@gmail.com
> > > >
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > In our case we have two EJBs, both
> > @Singleton
> > > > and
> > > > > > > > > @Startup,
> > > > > > > > > > > one
> > > > > > > > > > > > > > > depends
> > > > > > > > > > > > > > > > > on
> > > > > > > > > > > > > > > > > > the other. One is a cache façade and the
> > > other
> > > > > > loads
> > > > > > > > data
> > > > > > > > > > via
> > > > > > > > > > > > JPA
> > > > > > > > > > > > > > and
> > > > > > > > > > > > > > > > > feeds
> > > > > > > > > > > > > > > > > > it into the cache. An external schedule
> > > fires a
> > > > > > > servlet
> > > > > > > > > > that
> > > > > > > > > > > > > > reloads
> > > > > > > > > > > > > > > > the
> > > > > > > > > > > > > > > > > > cache from the database.
> > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > What's happening is that without MySQL we
> > see
> > > > EJB
> > > > > > > > > > exceptions
> > > > > > > > > > > > that
> > > > > > > > > > > > > > > they
> > > > > > > > > > > > > > > > > > cannot be created and thus we are dead.
> > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > I've just tried adding autoReconnect=true
> > > > inside
> > > > > a
> > > > > > > > > > <Resource>
> > > > > > > > > > > > but
> > > > > > > > > > > > > > > that
> > > > > > > > > > > > > > > > > made
> > > > > > > > > > > > > > > > > > no difference. I also tried adding
> > > > > > > ,autoReconnect=true
> > > > > > > > to
> > > > > > > > > > > > > > > > > > ConnectionProperties and
> > > > > > ConnectionFactoryProperties
> > > > > > > > > > without
> > > > > > > > > > > > any
> > > > > > > > > > > > > > > change
> > > > > > > > > > > > > > > > > but
> > > > > > > > > > > > > > > > > > I'm not convinced that would have fixed
> the
> > > > > problem
> > > > > > > > here.
> > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > Is it instead the case that within the
> EJB
> > I
> > > > > should
> > > > > > > be
> > > > > > > > > > > trapping
> > > > > > > > > > > > > > > > > > connectivity problems such as
> > > > > PersistenceException
> > > > > > > and
> > > > > > > > > > > allowing
> > > > > > > > > > > > > the
> > > > > > > > > > > > > > > > > > containing to gracefully start up and
> > > naturally
> > > > > > keep
> > > > > > > > > trying
> > > > > > > > > > > > > anyway?
> > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > James
> > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > On 28 June 2013 17:10, José Luis Cetina <
> > > > > > > > > > > maxtorzito@gmail.com>
> > > > > > > > > > > > > > > wrote:
> > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > I had a similar problem and what i did
> > was
> > > > set
> > > > > > the
> > > > > > > > > > > > > autoReconnect
> > > > > > > > > > > > > > > > > > attribute
> > > > > > > > > > > > > > > > > > > to true en my tomee.xml datasource.
> > > > > > > > > > > > > > > > > > > What do you mean with retry until the
> > > > > connection
> > > > > > > > > springs
> > > > > > > > > > to
> > > > > > > > > > > > > life?
> > > > > > > > > > > > > > > do
> > > > > > > > > > > > > > > > > you
> > > > > > > > > > > > > > > > > > > have some schedules or jobs running and
> > > want
> > > > to
> > > > > > > retry
> > > > > > > > > > again
> > > > > > > > > > > > > when
> > > > > > > > > > > > > > > the
> > > > > > > > > > > > > > > > > > > connection is available again? or just
> > want
> > > > > when
> > > > > > > > > somebody
> > > > > > > > > > > > click
> > > > > > > > > > > > > > any
> > > > > > > > > > > > > > > > > > button
> > > > > > > > > > > > > > > > > > > the app can connect again (this was my
> > > > case)??
> > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > 2013/6/28 Romain Manni-Bucau <
> > > > > > > rmannibucau@gmail.com>
> > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > > With an ejb timer?
> > > > > > > > > > > > > > > > > > > > Le 28 juin 2013 17:46, "James Green"
> <
> > > > > > > > > > > > > james.mk.green@gmail.com
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > a
> > > > > > > > > > > > > > > > > > écrit
> > > > > > > > > > > > > > > > > > > :
> > > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > > > Hopefully a quick one.
> > > > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > > > On boot our application attempts to
> > > read
> > > > > data
> > > > > > > > > > through a
> > > > > > > > > > > > JPA
> > > > > > > > > > > > > > > > > > > > EntityManager.
> > > > > > > > > > > > > > > > > > > > > If the database connection fails at
> > > this
> > > > > > point
> > > > > > > > the
> > > > > > > > > > > entire
> > > > > > > > > > > > > > > > > application
> > > > > > > > > > > > > > > > > > > is
> > > > > > > > > > > > > > > > > > > > > effectively dead.
> > > > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > > > Is there a way to essentially ask
> the
> > > > > > database
> > > > > > > > > layer
> > > > > > > > > > to
> > > > > > > > > > > > > retry
> > > > > > > > > > > > > > > > until
> > > > > > > > > > > > > > > > > > the
> > > > > > > > > > > > > > > > > > > > > connection springs to life?
> > > > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > > > Thanks,
> > > > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > > > James
> > > > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > --
> > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > >
> > > > -------------------------------------------------------------------
> > > > > > > > > > > > > > > > > > > *SCJA. José Luis Cetina*
> > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > >
> > > > -------------------------------------------------------------------
> > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > > --
> > > > > > > > > > > > >
> > > > > > > >
> > > -------------------------------------------------------------------
> > > > > > > > > > > > > *SCJA. José Luis Cetina*
> > > > > > > > > > > > >
> > > > > > > >
> > > -------------------------------------------------------------------
> > > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > --
> > > > > > > > > > >
> > > > > >
> -------------------------------------------------------------------
> > > > > > > > > > > *SCJA. José Luis Cetina*
> > > > > > > > > > >
> > > > > >
> -------------------------------------------------------------------
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > --
> > > > > > > >
> > > -------------------------------------------------------------------
> > > > > > > > *SCJA. José Luis Cetina*
> > > > > > > >
> > > -------------------------------------------------------------------
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
>

Re: Reconnect if JPA fails at boot?

Posted by James Green <ja...@gmail.com>.
That will also fix the original error - that the list of mapped classes is
empty? Copy of the error again:

Caused by: <openjpa-2.2.0-r422266:1244990 nonfatal user error>
org.apache.openjpa.persistence.ArgumentException: An error occurred while
parsing the query filter "SELECT a FROM Account a". Error message: The name
"Account" is not a recognized entity or identifier. Known entity names: []




On 2 July 2013 12:31, Romain Manni-Bucau <rm...@gmail.com> wrote:

> just add in your persistence unit the needed property (sample for
> mysql: <property
> name="openjpa.jdbc.DBDictionary" value="mysql"/> )
>
> *Romain Manni-Bucau*
> *Twitter: @rmannibucau <https://twitter.com/rmannibucau>*
> *Blog: **http://rmannibucau.wordpress.com/*<
> http://rmannibucau.wordpress.com/>
> *LinkedIn: **http://fr.linkedin.com/in/rmannibucau*
> *Github: https://github.com/rmannibucau*
>
>
>
> 2013/7/2 James Green <ja...@gmail.com>
>
> > The documentation link you supplied: I'm not sure what I am looking for
> in
> > it. That's what I meant to say.
> >
> > To cut this down is there a demonstration project where this is already
> > correctly configured? May be simpler than explaining the changes to me :)
> >
> >
> > On 2 July 2013 12:14, Romain Manni-Bucau <rm...@gmail.com> wrote:
> >
> > > didnt get the first sentence
> > >
> > > about the "make it worse" it is what i explained in my previous answer:
> > if
> > > you start without a db and openjpa uses automatically the wrong
> > dictionnary
> > > then even if the db is back and the pool well configured, the jpa layer
> > > will generate wrong SQL so it will not work, so your app is broken
> > whatever
> > > the db state is.
> > >
> > > *Romain Manni-Bucau*
> > > *Twitter: @rmannibucau <https://twitter.com/rmannibucau>*
> > > *Blog: **http://rmannibucau.wordpress.com/*<
> > > http://rmannibucau.wordpress.com/>
> > > *LinkedIn: **http://fr.linkedin.com/in/rmannibucau*
> > > *Github: https://github.com/rmannibucau*
> > >
> > >
> > >
> > > 2013/7/2 James Green <ja...@gmail.com>
> > >
> > > > Am I looking for something letting me list the classes I want mapped?
> > The
> > > > error I see shows an empty list, hence this particular question.
> > > >
> > > > You say it doesn't solve our issue and can actually make it worse?
> Care
> > > to
> > > > elaborate?
> > > >
> > > >
> > > > On 2 July 2013 09:17, Romain Manni-Bucau <rm...@gmail.com>
> > wrote:
> > > >
> > > > > the dict doc is here
> > > > >
> > > > >
> > > >
> > >
> >
> http://openjpa.apache.org/builds/2.2.2/apache-openjpa/docs/ref_guide_dbsetup_dbsupport.html
> > > > >
> > > > > it is important to set it if the database can be down at startup
> > > > otherwise
> > > > > you can end up with a wrong dict (generally the generic one) and
> then
> > > > when
> > > > > the database is up again SQL stuff will not work
> > > > >
> > > > > it doesn't solve your issue but it can make it worse
> > > > >
> > > > > *Romain Manni-Bucau*
> > > > > *Twitter: @rmannibucau <https://twitter.com/rmannibucau>*
> > > > > *Blog: **http://rmannibucau.wordpress.com/*<
> > > > > http://rmannibucau.wordpress.com/>
> > > > > *LinkedIn: **http://fr.linkedin.com/in/rmannibucau*
> > > > > *Github: https://github.com/rmannibucau*
> > > > >
> > > > >
> > > > >
> > > > > 2013/7/2 James Green <ja...@gmail.com>
> > > > >
> > > > > > That's exactly what I want. All I have are EJBs with entity
> > managers
> > > > > > injected via @PersistenceContext (exactly as we are taught in the
> > > > > > "Beginning Java EE 6 Platform with Glassfish 3" book which is how
> > > this
> > > > > > application began life.
> > > > > >
> > > > > > So what's the difference I wonder? Romain talks about adding a
> > > > dictionary
> > > > > > but I didn't spot anything spectacularly obvious in a browse of
> the
> > > > > OpenJPA
> > > > > > user guide yesterday (indeed on the subject of injection it told
> me
> > > to
> > > > > > refer to my application server documentation...).
> > > > > >
> > > > > >
> > > > > >
> > > > > > On 1 July 2013 18:05, José Luis Cetina <ma...@gmail.com>
> > wrote:
> > > > > >
> > > > > > > I did this test:
> > > > > > >
> > > > > > > 1. Stop TomEE
> > > > > > > 2. Shutdown my database server
> > > > > > > 3. Start TomEE
> > > > > > > 4. Try to access to my app, i could access but when i hit my
> > login
> > > > > button
> > > > > > > for example then i get this error:
> > > > > > >
> > > com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException:
> > > > > > > Could not create connection to database server. Attempted
> > > reconnect 3
> > > > > > > times. Giving up.
> > > > > > > 5. Start up my database server
> > > > > > > 6. Wait for my database to be ready, i refresh the page then
> hit
> > > > again
> > > > > at
> > > > > > > the login button, then my app run without problem (in this
> point
> > i
> > > > DONT
> > > > > > > stop/start TomEE again).
> > > > > > >
> > > > > > > Is this the behavior that you need/want it??
> > > > > > >
> > > > > > >
> > > > > > > *Remeber that i have tomee and database in separate server's
> > > > > > >
> > > > > > >
> > > > > > > 2013/7/1 Howard W. Smith, Jr. <sm...@gmail.com>
> > > > > > >
> > > > > > > > Will you be trying the magic that Romain recommended?
> > > > > > > >  On Jul 1, 2013 10:34 AM, "James Green" <
> > > james.mk.green@gmail.com>
> > > > > > > wrote:
> > > > > > > >
> > > > > > > > > I was asking about cold boot, specifically. It is when the
> > > > > > application
> > > > > > > > > server begins that the JPA implementation performs the
> Entity
> > > > > > mapping,
> > > > > > > so
> > > > > > > > > if the database is not available presumably it remains dead
> > > until
> > > > > the
> > > > > > > > > application server itself is restarted?
> > > > > > > > >
> > > > > > > > > Unless you already have the magic installed that Romain
> > refers
> > > > to.
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > On 1 July 2013 15:24, José Luis Cetina <
> maxtorzito@gmail.com
> > >
> > > > > wrote:
> > > > > > > > >
> > > > > > > > > > My entire app use database and of course the app doesnt
> > work
> > > if
> > > > > the
> > > > > > > > > > database is unavailable, but when the database server is
> > > > > available
> > > > > > > > again
> > > > > > > > > > the webapp can use the database again without restarting
> > > TomEE.
> > > > > > > > > >
> > > > > > > > > > I dont know if i response your question.
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > 2013/7/1 James Green <ja...@gmail.com>
> > > > > > > > > >
> > > > > > > > > > > Are you saying your application starts from cold
> without
> > > the
> > > > > > > > database,
> > > > > > > > > > the
> > > > > > > > > > > operates fine without intervention once the database
> > > becomes
> > > > > > > > available?
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > On 1 July 2013 14:26, José Luis Cetina <
> > > maxtorzito@gmail.com
> > > > >
> > > > > > > wrote:
> > > > > > > > > > >
> > > > > > > > > > > > I have also differents server, 1 one database and 2
> for
> > > > TomEE
> > > > > > > > (using
> > > > > > > > > > > > memcached + cluster) and with autoReconnect=true i
> dont
> > > > have
> > > > > > any
> > > > > > > > > issue
> > > > > > > > > > > when
> > > > > > > > > > > > the database server reboot, i set this attribute
> > > > > > (autoReconnect)
> > > > > > > > > after
> > > > > > > > > > i
> > > > > > > > > > > > experiment your same problems, when the database
> server
> > > > > > rebooted
> > > > > > > my
> > > > > > > > > > apps
> > > > > > > > > > > > cant connect anymore to the database server, i had to
> > > stop
> > > > > and
> > > > > > > > start
> > > > > > > > > > > tomee
> > > > > > > > > > > > again for work. But then, i add that option and now i
> > > work
> > > > > with
> > > > > > > any
> > > > > > > > > > > > problem.
> > > > > > > > > > > >
> > > > > > > > > > > > Here is a example of my Resource:
> > > > > > > > > > > >
> > > > > > > > > > > > <Resource id="ANY_NAME" type="DataSource">
> > > > > > > > > > > >   JdbcDriver com.mysql.jdbc.Driver
> > > > > > > > > > > >   JdbcUrl
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> jdbc:mysql://any_ip:3306/any_database?zeroDateTimeBehavior=convertToNull&amp;rewriteBatchedStatements=true&amp;autoReconnect=true
> > > > > > > > > > > >   UserName any_user
> > > > > > > > > > > >   Password any_password
> > > > > > > > > > > >   JtaManaged true
> > > > > > > > > > > >   InitialSize=3
> > > > > > > > > > > >   MaxActive=100
> > > > > > > > > > > >   ValidationQuery=SELECT 1
> > > > > > > > > > > >   TestOnBorrow=true
> > > > > > > > > > > > </Resource>
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > 2013/7/1 James Green <ja...@gmail.com>
> > > > > > > > > > > >
> > > > > > > > > > > > > This now sounds substantially more complex than my
> > > design
> > > > > > > (which
> > > > > > > > > uses
> > > > > > > > > > > > > @PersistenceContext(unitName="accounts")) caters
> for.
> > > Is
> > > > > > there
> > > > > > > an
> > > > > > > > > > > example
> > > > > > > > > > > > > of what you mean somewhere so I can scope the work
> > out?
> > > > > > > > > > > > >
> > > > > > > > > > > > > Thanks
> > > > > > > > > > > > > James
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > > On 1 July 2013 12:44, Romain Manni-Bucau <
> > > > > > > rmannibucau@gmail.com>
> > > > > > > > > > > wrote:
> > > > > > > > > > > > >
> > > > > > > > > > > > > > Hi
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > it depends your config and that's probably more
> an
> > > > > openjpa
> > > > > > > > > question
> > > > > > > > > > > but
> > > > > > > > > > > > > > basically you'll need to provide the dictionnary
> to
> > > use
> > > > > > since
> > > > > > > > > > openjpa
> > > > > > > > > > > > > will
> > > > > > > > > > > > > > not be able to read database metadata (at least).
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > *Romain Manni-Bucau*
> > > > > > > > > > > > > > *Twitter: @rmannibucau <
> > > > https://twitter.com/rmannibucau
> > > > > >*
> > > > > > > > > > > > > > *Blog: **http://rmannibucau.wordpress.com/*<
> > > > > > > > > > > > > > http://rmannibucau.wordpress.com/>
> > > > > > > > > > > > > > *LinkedIn: **
> > http://fr.linkedin.com/in/rmannibucau*
> > > > > > > > > > > > > > *Github: https://github.com/rmannibucau*
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > 2013/7/1 James Green <ja...@gmail.com>
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > > I've suppressed the RuntimeExceptions
> encountered
> > > as
> > > > > EJBs
> > > > > > > > fire
> > > > > > > > > > and
> > > > > > > > > > > > > access
> > > > > > > > > > > > > > > JPA, however I have a new problem now:
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > Caused by: <openjpa-2.2.0-r422266:1244990
> > nonfatal
> > > > user
> > > > > > > > error>
> > > > > > > > > > > > > > >
> org.apache.openjpa.persistence.ArgumentException:
> > > An
> > > > > > error
> > > > > > > > > > occurred
> > > > > > > > > > > > > while
> > > > > > > > > > > > > > > parsing the query filter "SELECT a FROM Account
> > a".
> > > > > Error
> > > > > > > > > > message:
> > > > > > > > > > > > The
> > > > > > > > > > > > > > name
> > > > > > > > > > > > > > > "Account" is not a recognized entity or
> > identifier.
> > > > > Known
> > > > > > > > > entity
> > > > > > > > > > > > names:
> > > > > > > > > > > > > > []
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > It seems the JPA component was unable to map my
> > > > @Entity
> > > > > > > > classes
> > > > > > > > > > > > because
> > > > > > > > > > > > > > the
> > > > > > > > > > > > > > > connection did not exist at startup. What do I
> > need
> > > > to
> > > > > do
> > > > > > > to
> > > > > > > > > work
> > > > > > > > > > > > > around
> > > > > > > > > > > > > > > this?
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > On 1 July 2013 12:07, Romain Manni-Bucau <
> > > > > > > > > rmannibucau@gmail.com>
> > > > > > > > > > > > > wrote:
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > yep
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > basically get injected the timerservice (
> > > > > > > > > > > > > > > >
> > > > > > > > > >
> > > > http://docs.oracle.com/javaee/6/api/javax/ejb/TimerService.html
> > > > > > > > > > > ),
> > > > > > > > > > > > in
> > > > > > > > > > > > > > > your
> > > > > > > > > > > > > > > > init method you try to get your data, if not
> > > > trigger
> > > > > a
> > > > > > > > later
> > > > > > > > > > > > > > > > invocation (
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> http://docs.oracle.com/javaee/6/api/javax/ejb/TimerService.html#createSingleActionTimer(java.util.Date
> > > > > > > > > > > > > > > > ,
> > > > > > > > > > > > > > > > javax.ejb.TimerConfig)). While it fails
> trigger
> > > > > another
> > > > > > > one
> > > > > > > > > > when
> > > > > > > > > > > > > > invoked.
> > > > > > > > > > > > > > > > When it succeeds you are done.
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > *Romain Manni-Bucau*
> > > > > > > > > > > > > > > > *Twitter: @rmannibucau <
> > > > > > https://twitter.com/rmannibucau
> > > > > > > >*
> > > > > > > > > > > > > > > > *Blog: **http://rmannibucau.wordpress.com/*<
> > > > > > > > > > > > > > > > http://rmannibucau.wordpress.com/>
> > > > > > > > > > > > > > > > *LinkedIn: **
> > > > http://fr.linkedin.com/in/rmannibucau*
> > > > > > > > > > > > > > > > *Github: https://github.com/rmannibucau*
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > 2013/7/1 James Green <
> james.mk.green@gmail.com
> > >
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > In our case we have two EJBs, both
> @Singleton
> > > and
> > > > > > > > @Startup,
> > > > > > > > > > one
> > > > > > > > > > > > > > depends
> > > > > > > > > > > > > > > > on
> > > > > > > > > > > > > > > > > the other. One is a cache façade and the
> > other
> > > > > loads
> > > > > > > data
> > > > > > > > > via
> > > > > > > > > > > JPA
> > > > > > > > > > > > > and
> > > > > > > > > > > > > > > > feeds
> > > > > > > > > > > > > > > > > it into the cache. An external schedule
> > fires a
> > > > > > servlet
> > > > > > > > > that
> > > > > > > > > > > > > reloads
> > > > > > > > > > > > > > > the
> > > > > > > > > > > > > > > > > cache from the database.
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > What's happening is that without MySQL we
> see
> > > EJB
> > > > > > > > > exceptions
> > > > > > > > > > > that
> > > > > > > > > > > > > > they
> > > > > > > > > > > > > > > > > cannot be created and thus we are dead.
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > I've just tried adding autoReconnect=true
> > > inside
> > > > a
> > > > > > > > > <Resource>
> > > > > > > > > > > but
> > > > > > > > > > > > > > that
> > > > > > > > > > > > > > > > made
> > > > > > > > > > > > > > > > > no difference. I also tried adding
> > > > > > ,autoReconnect=true
> > > > > > > to
> > > > > > > > > > > > > > > > > ConnectionProperties and
> > > > > ConnectionFactoryProperties
> > > > > > > > > without
> > > > > > > > > > > any
> > > > > > > > > > > > > > change
> > > > > > > > > > > > > > > > but
> > > > > > > > > > > > > > > > > I'm not convinced that would have fixed the
> > > > problem
> > > > > > > here.
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > Is it instead the case that within the EJB
> I
> > > > should
> > > > > > be
> > > > > > > > > > trapping
> > > > > > > > > > > > > > > > > connectivity problems such as
> > > > PersistenceException
> > > > > > and
> > > > > > > > > > allowing
> > > > > > > > > > > > the
> > > > > > > > > > > > > > > > > containing to gracefully start up and
> > naturally
> > > > > keep
> > > > > > > > trying
> > > > > > > > > > > > anyway?
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > James
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > On 28 June 2013 17:10, José Luis Cetina <
> > > > > > > > > > maxtorzito@gmail.com>
> > > > > > > > > > > > > > wrote:
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > I had a similar problem and what i did
> was
> > > set
> > > > > the
> > > > > > > > > > > > autoReconnect
> > > > > > > > > > > > > > > > > attribute
> > > > > > > > > > > > > > > > > > to true en my tomee.xml datasource.
> > > > > > > > > > > > > > > > > > What do you mean with retry until the
> > > > connection
> > > > > > > > springs
> > > > > > > > > to
> > > > > > > > > > > > life?
> > > > > > > > > > > > > > do
> > > > > > > > > > > > > > > > you
> > > > > > > > > > > > > > > > > > have some schedules or jobs running and
> > want
> > > to
> > > > > > retry
> > > > > > > > > again
> > > > > > > > > > > > when
> > > > > > > > > > > > > > the
> > > > > > > > > > > > > > > > > > connection is available again? or just
> want
> > > > when
> > > > > > > > somebody
> > > > > > > > > > > click
> > > > > > > > > > > > > any
> > > > > > > > > > > > > > > > > button
> > > > > > > > > > > > > > > > > > the app can connect again (this was my
> > > case)??
> > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > 2013/6/28 Romain Manni-Bucau <
> > > > > > rmannibucau@gmail.com>
> > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > With an ejb timer?
> > > > > > > > > > > > > > > > > > > Le 28 juin 2013 17:46, "James Green" <
> > > > > > > > > > > > james.mk.green@gmail.com
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > a
> > > > > > > > > > > > > > > > > écrit
> > > > > > > > > > > > > > > > > > :
> > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > > Hopefully a quick one.
> > > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > > On boot our application attempts to
> > read
> > > > data
> > > > > > > > > through a
> > > > > > > > > > > JPA
> > > > > > > > > > > > > > > > > > > EntityManager.
> > > > > > > > > > > > > > > > > > > > If the database connection fails at
> > this
> > > > > point
> > > > > > > the
> > > > > > > > > > entire
> > > > > > > > > > > > > > > > application
> > > > > > > > > > > > > > > > > > is
> > > > > > > > > > > > > > > > > > > > effectively dead.
> > > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > > Is there a way to essentially ask the
> > > > > database
> > > > > > > > layer
> > > > > > > > > to
> > > > > > > > > > > > retry
> > > > > > > > > > > > > > > until
> > > > > > > > > > > > > > > > > the
> > > > > > > > > > > > > > > > > > > > connection springs to life?
> > > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > > Thanks,
> > > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > > James
> > > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > --
> > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > >
> > > -------------------------------------------------------------------
> > > > > > > > > > > > > > > > > > *SCJA. José Luis Cetina*
> > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > >
> > > -------------------------------------------------------------------
> > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > --
> > > > > > > > > > > >
> > > > > > >
> > -------------------------------------------------------------------
> > > > > > > > > > > > *SCJA. José Luis Cetina*
> > > > > > > > > > > >
> > > > > > >
> > -------------------------------------------------------------------
> > > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > --
> > > > > > > > > >
> > > > > -------------------------------------------------------------------
> > > > > > > > > > *SCJA. José Luis Cetina*
> > > > > > > > > >
> > > > > -------------------------------------------------------------------
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > --
> > > > > > >
> > -------------------------------------------------------------------
> > > > > > > *SCJA. José Luis Cetina*
> > > > > > >
> > -------------------------------------------------------------------
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
>

Re: Reconnect if JPA fails at boot?

Posted by Romain Manni-Bucau <rm...@gmail.com>.
just add in your persistence unit the needed property (sample for
mysql: <property
name="openjpa.jdbc.DBDictionary" value="mysql"/> )

*Romain Manni-Bucau*
*Twitter: @rmannibucau <https://twitter.com/rmannibucau>*
*Blog: **http://rmannibucau.wordpress.com/*<http://rmannibucau.wordpress.com/>
*LinkedIn: **http://fr.linkedin.com/in/rmannibucau*
*Github: https://github.com/rmannibucau*



2013/7/2 James Green <ja...@gmail.com>

> The documentation link you supplied: I'm not sure what I am looking for in
> it. That's what I meant to say.
>
> To cut this down is there a demonstration project where this is already
> correctly configured? May be simpler than explaining the changes to me :)
>
>
> On 2 July 2013 12:14, Romain Manni-Bucau <rm...@gmail.com> wrote:
>
> > didnt get the first sentence
> >
> > about the "make it worse" it is what i explained in my previous answer:
> if
> > you start without a db and openjpa uses automatically the wrong
> dictionnary
> > then even if the db is back and the pool well configured, the jpa layer
> > will generate wrong SQL so it will not work, so your app is broken
> whatever
> > the db state is.
> >
> > *Romain Manni-Bucau*
> > *Twitter: @rmannibucau <https://twitter.com/rmannibucau>*
> > *Blog: **http://rmannibucau.wordpress.com/*<
> > http://rmannibucau.wordpress.com/>
> > *LinkedIn: **http://fr.linkedin.com/in/rmannibucau*
> > *Github: https://github.com/rmannibucau*
> >
> >
> >
> > 2013/7/2 James Green <ja...@gmail.com>
> >
> > > Am I looking for something letting me list the classes I want mapped?
> The
> > > error I see shows an empty list, hence this particular question.
> > >
> > > You say it doesn't solve our issue and can actually make it worse? Care
> > to
> > > elaborate?
> > >
> > >
> > > On 2 July 2013 09:17, Romain Manni-Bucau <rm...@gmail.com>
> wrote:
> > >
> > > > the dict doc is here
> > > >
> > > >
> > >
> >
> http://openjpa.apache.org/builds/2.2.2/apache-openjpa/docs/ref_guide_dbsetup_dbsupport.html
> > > >
> > > > it is important to set it if the database can be down at startup
> > > otherwise
> > > > you can end up with a wrong dict (generally the generic one) and then
> > > when
> > > > the database is up again SQL stuff will not work
> > > >
> > > > it doesn't solve your issue but it can make it worse
> > > >
> > > > *Romain Manni-Bucau*
> > > > *Twitter: @rmannibucau <https://twitter.com/rmannibucau>*
> > > > *Blog: **http://rmannibucau.wordpress.com/*<
> > > > http://rmannibucau.wordpress.com/>
> > > > *LinkedIn: **http://fr.linkedin.com/in/rmannibucau*
> > > > *Github: https://github.com/rmannibucau*
> > > >
> > > >
> > > >
> > > > 2013/7/2 James Green <ja...@gmail.com>
> > > >
> > > > > That's exactly what I want. All I have are EJBs with entity
> managers
> > > > > injected via @PersistenceContext (exactly as we are taught in the
> > > > > "Beginning Java EE 6 Platform with Glassfish 3" book which is how
> > this
> > > > > application began life.
> > > > >
> > > > > So what's the difference I wonder? Romain talks about adding a
> > > dictionary
> > > > > but I didn't spot anything spectacularly obvious in a browse of the
> > > > OpenJPA
> > > > > user guide yesterday (indeed on the subject of injection it told me
> > to
> > > > > refer to my application server documentation...).
> > > > >
> > > > >
> > > > >
> > > > > On 1 July 2013 18:05, José Luis Cetina <ma...@gmail.com>
> wrote:
> > > > >
> > > > > > I did this test:
> > > > > >
> > > > > > 1. Stop TomEE
> > > > > > 2. Shutdown my database server
> > > > > > 3. Start TomEE
> > > > > > 4. Try to access to my app, i could access but when i hit my
> login
> > > > button
> > > > > > for example then i get this error:
> > > > > >
> > com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException:
> > > > > > Could not create connection to database server. Attempted
> > reconnect 3
> > > > > > times. Giving up.
> > > > > > 5. Start up my database server
> > > > > > 6. Wait for my database to be ready, i refresh the page then hit
> > > again
> > > > at
> > > > > > the login button, then my app run without problem (in this point
> i
> > > DONT
> > > > > > stop/start TomEE again).
> > > > > >
> > > > > > Is this the behavior that you need/want it??
> > > > > >
> > > > > >
> > > > > > *Remeber that i have tomee and database in separate server's
> > > > > >
> > > > > >
> > > > > > 2013/7/1 Howard W. Smith, Jr. <sm...@gmail.com>
> > > > > >
> > > > > > > Will you be trying the magic that Romain recommended?
> > > > > > >  On Jul 1, 2013 10:34 AM, "James Green" <
> > james.mk.green@gmail.com>
> > > > > > wrote:
> > > > > > >
> > > > > > > > I was asking about cold boot, specifically. It is when the
> > > > > application
> > > > > > > > server begins that the JPA implementation performs the Entity
> > > > > mapping,
> > > > > > so
> > > > > > > > if the database is not available presumably it remains dead
> > until
> > > > the
> > > > > > > > application server itself is restarted?
> > > > > > > >
> > > > > > > > Unless you already have the magic installed that Romain
> refers
> > > to.
> > > > > > > >
> > > > > > > >
> > > > > > > > On 1 July 2013 15:24, José Luis Cetina <maxtorzito@gmail.com
> >
> > > > wrote:
> > > > > > > >
> > > > > > > > > My entire app use database and of course the app doesnt
> work
> > if
> > > > the
> > > > > > > > > database is unavailable, but when the database server is
> > > > available
> > > > > > > again
> > > > > > > > > the webapp can use the database again without restarting
> > TomEE.
> > > > > > > > >
> > > > > > > > > I dont know if i response your question.
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > 2013/7/1 James Green <ja...@gmail.com>
> > > > > > > > >
> > > > > > > > > > Are you saying your application starts from cold without
> > the
> > > > > > > database,
> > > > > > > > > the
> > > > > > > > > > operates fine without intervention once the database
> > becomes
> > > > > > > available?
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > On 1 July 2013 14:26, José Luis Cetina <
> > maxtorzito@gmail.com
> > > >
> > > > > > wrote:
> > > > > > > > > >
> > > > > > > > > > > I have also differents server, 1 one database and 2 for
> > > TomEE
> > > > > > > (using
> > > > > > > > > > > memcached + cluster) and with autoReconnect=true i dont
> > > have
> > > > > any
> > > > > > > > issue
> > > > > > > > > > when
> > > > > > > > > > > the database server reboot, i set this attribute
> > > > > (autoReconnect)
> > > > > > > > after
> > > > > > > > > i
> > > > > > > > > > > experiment your same problems, when the database server
> > > > > rebooted
> > > > > > my
> > > > > > > > > apps
> > > > > > > > > > > cant connect anymore to the database server, i had to
> > stop
> > > > and
> > > > > > > start
> > > > > > > > > > tomee
> > > > > > > > > > > again for work. But then, i add that option and now i
> > work
> > > > with
> > > > > > any
> > > > > > > > > > > problem.
> > > > > > > > > > >
> > > > > > > > > > > Here is a example of my Resource:
> > > > > > > > > > >
> > > > > > > > > > > <Resource id="ANY_NAME" type="DataSource">
> > > > > > > > > > >   JdbcDriver com.mysql.jdbc.Driver
> > > > > > > > > > >   JdbcUrl
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> jdbc:mysql://any_ip:3306/any_database?zeroDateTimeBehavior=convertToNull&amp;rewriteBatchedStatements=true&amp;autoReconnect=true
> > > > > > > > > > >   UserName any_user
> > > > > > > > > > >   Password any_password
> > > > > > > > > > >   JtaManaged true
> > > > > > > > > > >   InitialSize=3
> > > > > > > > > > >   MaxActive=100
> > > > > > > > > > >   ValidationQuery=SELECT 1
> > > > > > > > > > >   TestOnBorrow=true
> > > > > > > > > > > </Resource>
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > 2013/7/1 James Green <ja...@gmail.com>
> > > > > > > > > > >
> > > > > > > > > > > > This now sounds substantially more complex than my
> > design
> > > > > > (which
> > > > > > > > uses
> > > > > > > > > > > > @PersistenceContext(unitName="accounts")) caters for.
> > Is
> > > > > there
> > > > > > an
> > > > > > > > > > example
> > > > > > > > > > > > of what you mean somewhere so I can scope the work
> out?
> > > > > > > > > > > >
> > > > > > > > > > > > Thanks
> > > > > > > > > > > > James
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > On 1 July 2013 12:44, Romain Manni-Bucau <
> > > > > > rmannibucau@gmail.com>
> > > > > > > > > > wrote:
> > > > > > > > > > > >
> > > > > > > > > > > > > Hi
> > > > > > > > > > > > >
> > > > > > > > > > > > > it depends your config and that's probably more an
> > > > openjpa
> > > > > > > > question
> > > > > > > > > > but
> > > > > > > > > > > > > basically you'll need to provide the dictionnary to
> > use
> > > > > since
> > > > > > > > > openjpa
> > > > > > > > > > > > will
> > > > > > > > > > > > > not be able to read database metadata (at least).
> > > > > > > > > > > > >
> > > > > > > > > > > > > *Romain Manni-Bucau*
> > > > > > > > > > > > > *Twitter: @rmannibucau <
> > > https://twitter.com/rmannibucau
> > > > >*
> > > > > > > > > > > > > *Blog: **http://rmannibucau.wordpress.com/*<
> > > > > > > > > > > > > http://rmannibucau.wordpress.com/>
> > > > > > > > > > > > > *LinkedIn: **
> http://fr.linkedin.com/in/rmannibucau*
> > > > > > > > > > > > > *Github: https://github.com/rmannibucau*
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > > 2013/7/1 James Green <ja...@gmail.com>
> > > > > > > > > > > > >
> > > > > > > > > > > > > > I've suppressed the RuntimeExceptions encountered
> > as
> > > > EJBs
> > > > > > > fire
> > > > > > > > > and
> > > > > > > > > > > > access
> > > > > > > > > > > > > > JPA, however I have a new problem now:
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > Caused by: <openjpa-2.2.0-r422266:1244990
> nonfatal
> > > user
> > > > > > > error>
> > > > > > > > > > > > > > org.apache.openjpa.persistence.ArgumentException:
> > An
> > > > > error
> > > > > > > > > occurred
> > > > > > > > > > > > while
> > > > > > > > > > > > > > parsing the query filter "SELECT a FROM Account
> a".
> > > > Error
> > > > > > > > > message:
> > > > > > > > > > > The
> > > > > > > > > > > > > name
> > > > > > > > > > > > > > "Account" is not a recognized entity or
> identifier.
> > > > Known
> > > > > > > > entity
> > > > > > > > > > > names:
> > > > > > > > > > > > > []
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > It seems the JPA component was unable to map my
> > > @Entity
> > > > > > > classes
> > > > > > > > > > > because
> > > > > > > > > > > > > the
> > > > > > > > > > > > > > connection did not exist at startup. What do I
> need
> > > to
> > > > do
> > > > > > to
> > > > > > > > work
> > > > > > > > > > > > around
> > > > > > > > > > > > > > this?
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > On 1 July 2013 12:07, Romain Manni-Bucau <
> > > > > > > > rmannibucau@gmail.com>
> > > > > > > > > > > > wrote:
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > > yep
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > basically get injected the timerservice (
> > > > > > > > > > > > > > >
> > > > > > > > >
> > > http://docs.oracle.com/javaee/6/api/javax/ejb/TimerService.html
> > > > > > > > > > ),
> > > > > > > > > > > in
> > > > > > > > > > > > > > your
> > > > > > > > > > > > > > > init method you try to get your data, if not
> > > trigger
> > > > a
> > > > > > > later
> > > > > > > > > > > > > > > invocation (
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> http://docs.oracle.com/javaee/6/api/javax/ejb/TimerService.html#createSingleActionTimer(java.util.Date
> > > > > > > > > > > > > > > ,
> > > > > > > > > > > > > > > javax.ejb.TimerConfig)). While it fails trigger
> > > > another
> > > > > > one
> > > > > > > > > when
> > > > > > > > > > > > > invoked.
> > > > > > > > > > > > > > > When it succeeds you are done.
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > *Romain Manni-Bucau*
> > > > > > > > > > > > > > > *Twitter: @rmannibucau <
> > > > > https://twitter.com/rmannibucau
> > > > > > >*
> > > > > > > > > > > > > > > *Blog: **http://rmannibucau.wordpress.com/*<
> > > > > > > > > > > > > > > http://rmannibucau.wordpress.com/>
> > > > > > > > > > > > > > > *LinkedIn: **
> > > http://fr.linkedin.com/in/rmannibucau*
> > > > > > > > > > > > > > > *Github: https://github.com/rmannibucau*
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > 2013/7/1 James Green <james.mk.green@gmail.com
> >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > In our case we have two EJBs, both @Singleton
> > and
> > > > > > > @Startup,
> > > > > > > > > one
> > > > > > > > > > > > > depends
> > > > > > > > > > > > > > > on
> > > > > > > > > > > > > > > > the other. One is a cache façade and the
> other
> > > > loads
> > > > > > data
> > > > > > > > via
> > > > > > > > > > JPA
> > > > > > > > > > > > and
> > > > > > > > > > > > > > > feeds
> > > > > > > > > > > > > > > > it into the cache. An external schedule
> fires a
> > > > > servlet
> > > > > > > > that
> > > > > > > > > > > > reloads
> > > > > > > > > > > > > > the
> > > > > > > > > > > > > > > > cache from the database.
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > What's happening is that without MySQL we see
> > EJB
> > > > > > > > exceptions
> > > > > > > > > > that
> > > > > > > > > > > > > they
> > > > > > > > > > > > > > > > cannot be created and thus we are dead.
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > I've just tried adding autoReconnect=true
> > inside
> > > a
> > > > > > > > <Resource>
> > > > > > > > > > but
> > > > > > > > > > > > > that
> > > > > > > > > > > > > > > made
> > > > > > > > > > > > > > > > no difference. I also tried adding
> > > > > ,autoReconnect=true
> > > > > > to
> > > > > > > > > > > > > > > > ConnectionProperties and
> > > > ConnectionFactoryProperties
> > > > > > > > without
> > > > > > > > > > any
> > > > > > > > > > > > > change
> > > > > > > > > > > > > > > but
> > > > > > > > > > > > > > > > I'm not convinced that would have fixed the
> > > problem
> > > > > > here.
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > Is it instead the case that within the EJB I
> > > should
> > > > > be
> > > > > > > > > trapping
> > > > > > > > > > > > > > > > connectivity problems such as
> > > PersistenceException
> > > > > and
> > > > > > > > > allowing
> > > > > > > > > > > the
> > > > > > > > > > > > > > > > containing to gracefully start up and
> naturally
> > > > keep
> > > > > > > trying
> > > > > > > > > > > anyway?
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > James
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > On 28 June 2013 17:10, José Luis Cetina <
> > > > > > > > > maxtorzito@gmail.com>
> > > > > > > > > > > > > wrote:
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > I had a similar problem and what i did was
> > set
> > > > the
> > > > > > > > > > > autoReconnect
> > > > > > > > > > > > > > > > attribute
> > > > > > > > > > > > > > > > > to true en my tomee.xml datasource.
> > > > > > > > > > > > > > > > > What do you mean with retry until the
> > > connection
> > > > > > > springs
> > > > > > > > to
> > > > > > > > > > > life?
> > > > > > > > > > > > > do
> > > > > > > > > > > > > > > you
> > > > > > > > > > > > > > > > > have some schedules or jobs running and
> want
> > to
> > > > > retry
> > > > > > > > again
> > > > > > > > > > > when
> > > > > > > > > > > > > the
> > > > > > > > > > > > > > > > > connection is available again? or just want
> > > when
> > > > > > > somebody
> > > > > > > > > > click
> > > > > > > > > > > > any
> > > > > > > > > > > > > > > > button
> > > > > > > > > > > > > > > > > the app can connect again (this was my
> > case)??
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > 2013/6/28 Romain Manni-Bucau <
> > > > > rmannibucau@gmail.com>
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > With an ejb timer?
> > > > > > > > > > > > > > > > > > Le 28 juin 2013 17:46, "James Green" <
> > > > > > > > > > > james.mk.green@gmail.com
> > > > > > > > > > > > >
> > > > > > > > > > > > > a
> > > > > > > > > > > > > > > > écrit
> > > > > > > > > > > > > > > > > :
> > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > Hopefully a quick one.
> > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > On boot our application attempts to
> read
> > > data
> > > > > > > > through a
> > > > > > > > > > JPA
> > > > > > > > > > > > > > > > > > EntityManager.
> > > > > > > > > > > > > > > > > > > If the database connection fails at
> this
> > > > point
> > > > > > the
> > > > > > > > > entire
> > > > > > > > > > > > > > > application
> > > > > > > > > > > > > > > > > is
> > > > > > > > > > > > > > > > > > > effectively dead.
> > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > Is there a way to essentially ask the
> > > > database
> > > > > > > layer
> > > > > > > > to
> > > > > > > > > > > retry
> > > > > > > > > > > > > > until
> > > > > > > > > > > > > > > > the
> > > > > > > > > > > > > > > > > > > connection springs to life?
> > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > Thanks,
> > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > James
> > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > --
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > >
> > -------------------------------------------------------------------
> > > > > > > > > > > > > > > > > *SCJA. José Luis Cetina*
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > >
> > -------------------------------------------------------------------
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > --
> > > > > > > > > > >
> > > > > >
> -------------------------------------------------------------------
> > > > > > > > > > > *SCJA. José Luis Cetina*
> > > > > > > > > > >
> > > > > >
> -------------------------------------------------------------------
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > --
> > > > > > > > >
> > > > -------------------------------------------------------------------
> > > > > > > > > *SCJA. José Luis Cetina*
> > > > > > > > >
> > > > -------------------------------------------------------------------
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > > --
> > > > > >
> -------------------------------------------------------------------
> > > > > > *SCJA. José Luis Cetina*
> > > > > >
> -------------------------------------------------------------------
> > > > > >
> > > > >
> > > >
> > >
> >
>

Re: Reconnect if JPA fails at boot?

Posted by James Green <ja...@gmail.com>.
The documentation link you supplied: I'm not sure what I am looking for in
it. That's what I meant to say.

To cut this down is there a demonstration project where this is already
correctly configured? May be simpler than explaining the changes to me :)


On 2 July 2013 12:14, Romain Manni-Bucau <rm...@gmail.com> wrote:

> didnt get the first sentence
>
> about the "make it worse" it is what i explained in my previous answer: if
> you start without a db and openjpa uses automatically the wrong dictionnary
> then even if the db is back and the pool well configured, the jpa layer
> will generate wrong SQL so it will not work, so your app is broken whatever
> the db state is.
>
> *Romain Manni-Bucau*
> *Twitter: @rmannibucau <https://twitter.com/rmannibucau>*
> *Blog: **http://rmannibucau.wordpress.com/*<
> http://rmannibucau.wordpress.com/>
> *LinkedIn: **http://fr.linkedin.com/in/rmannibucau*
> *Github: https://github.com/rmannibucau*
>
>
>
> 2013/7/2 James Green <ja...@gmail.com>
>
> > Am I looking for something letting me list the classes I want mapped? The
> > error I see shows an empty list, hence this particular question.
> >
> > You say it doesn't solve our issue and can actually make it worse? Care
> to
> > elaborate?
> >
> >
> > On 2 July 2013 09:17, Romain Manni-Bucau <rm...@gmail.com> wrote:
> >
> > > the dict doc is here
> > >
> > >
> >
> http://openjpa.apache.org/builds/2.2.2/apache-openjpa/docs/ref_guide_dbsetup_dbsupport.html
> > >
> > > it is important to set it if the database can be down at startup
> > otherwise
> > > you can end up with a wrong dict (generally the generic one) and then
> > when
> > > the database is up again SQL stuff will not work
> > >
> > > it doesn't solve your issue but it can make it worse
> > >
> > > *Romain Manni-Bucau*
> > > *Twitter: @rmannibucau <https://twitter.com/rmannibucau>*
> > > *Blog: **http://rmannibucau.wordpress.com/*<
> > > http://rmannibucau.wordpress.com/>
> > > *LinkedIn: **http://fr.linkedin.com/in/rmannibucau*
> > > *Github: https://github.com/rmannibucau*
> > >
> > >
> > >
> > > 2013/7/2 James Green <ja...@gmail.com>
> > >
> > > > That's exactly what I want. All I have are EJBs with entity managers
> > > > injected via @PersistenceContext (exactly as we are taught in the
> > > > "Beginning Java EE 6 Platform with Glassfish 3" book which is how
> this
> > > > application began life.
> > > >
> > > > So what's the difference I wonder? Romain talks about adding a
> > dictionary
> > > > but I didn't spot anything spectacularly obvious in a browse of the
> > > OpenJPA
> > > > user guide yesterday (indeed on the subject of injection it told me
> to
> > > > refer to my application server documentation...).
> > > >
> > > >
> > > >
> > > > On 1 July 2013 18:05, José Luis Cetina <ma...@gmail.com> wrote:
> > > >
> > > > > I did this test:
> > > > >
> > > > > 1. Stop TomEE
> > > > > 2. Shutdown my database server
> > > > > 3. Start TomEE
> > > > > 4. Try to access to my app, i could access but when i hit my login
> > > button
> > > > > for example then i get this error:
> > > > >
> com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException:
> > > > > Could not create connection to database server. Attempted
> reconnect 3
> > > > > times. Giving up.
> > > > > 5. Start up my database server
> > > > > 6. Wait for my database to be ready, i refresh the page then hit
> > again
> > > at
> > > > > the login button, then my app run without problem (in this point i
> > DONT
> > > > > stop/start TomEE again).
> > > > >
> > > > > Is this the behavior that you need/want it??
> > > > >
> > > > >
> > > > > *Remeber that i have tomee and database in separate server's
> > > > >
> > > > >
> > > > > 2013/7/1 Howard W. Smith, Jr. <sm...@gmail.com>
> > > > >
> > > > > > Will you be trying the magic that Romain recommended?
> > > > > >  On Jul 1, 2013 10:34 AM, "James Green" <
> james.mk.green@gmail.com>
> > > > > wrote:
> > > > > >
> > > > > > > I was asking about cold boot, specifically. It is when the
> > > > application
> > > > > > > server begins that the JPA implementation performs the Entity
> > > > mapping,
> > > > > so
> > > > > > > if the database is not available presumably it remains dead
> until
> > > the
> > > > > > > application server itself is restarted?
> > > > > > >
> > > > > > > Unless you already have the magic installed that Romain refers
> > to.
> > > > > > >
> > > > > > >
> > > > > > > On 1 July 2013 15:24, José Luis Cetina <ma...@gmail.com>
> > > wrote:
> > > > > > >
> > > > > > > > My entire app use database and of course the app doesnt work
> if
> > > the
> > > > > > > > database is unavailable, but when the database server is
> > > available
> > > > > > again
> > > > > > > > the webapp can use the database again without restarting
> TomEE.
> > > > > > > >
> > > > > > > > I dont know if i response your question.
> > > > > > > >
> > > > > > > >
> > > > > > > > 2013/7/1 James Green <ja...@gmail.com>
> > > > > > > >
> > > > > > > > > Are you saying your application starts from cold without
> the
> > > > > > database,
> > > > > > > > the
> > > > > > > > > operates fine without intervention once the database
> becomes
> > > > > > available?
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > On 1 July 2013 14:26, José Luis Cetina <
> maxtorzito@gmail.com
> > >
> > > > > wrote:
> > > > > > > > >
> > > > > > > > > > I have also differents server, 1 one database and 2 for
> > TomEE
> > > > > > (using
> > > > > > > > > > memcached + cluster) and with autoReconnect=true i dont
> > have
> > > > any
> > > > > > > issue
> > > > > > > > > when
> > > > > > > > > > the database server reboot, i set this attribute
> > > > (autoReconnect)
> > > > > > > after
> > > > > > > > i
> > > > > > > > > > experiment your same problems, when the database server
> > > > rebooted
> > > > > my
> > > > > > > > apps
> > > > > > > > > > cant connect anymore to the database server, i had to
> stop
> > > and
> > > > > > start
> > > > > > > > > tomee
> > > > > > > > > > again for work. But then, i add that option and now i
> work
> > > with
> > > > > any
> > > > > > > > > > problem.
> > > > > > > > > >
> > > > > > > > > > Here is a example of my Resource:
> > > > > > > > > >
> > > > > > > > > > <Resource id="ANY_NAME" type="DataSource">
> > > > > > > > > >   JdbcDriver com.mysql.jdbc.Driver
> > > > > > > > > >   JdbcUrl
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> jdbc:mysql://any_ip:3306/any_database?zeroDateTimeBehavior=convertToNull&amp;rewriteBatchedStatements=true&amp;autoReconnect=true
> > > > > > > > > >   UserName any_user
> > > > > > > > > >   Password any_password
> > > > > > > > > >   JtaManaged true
> > > > > > > > > >   InitialSize=3
> > > > > > > > > >   MaxActive=100
> > > > > > > > > >   ValidationQuery=SELECT 1
> > > > > > > > > >   TestOnBorrow=true
> > > > > > > > > > </Resource>
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > 2013/7/1 James Green <ja...@gmail.com>
> > > > > > > > > >
> > > > > > > > > > > This now sounds substantially more complex than my
> design
> > > > > (which
> > > > > > > uses
> > > > > > > > > > > @PersistenceContext(unitName="accounts")) caters for.
> Is
> > > > there
> > > > > an
> > > > > > > > > example
> > > > > > > > > > > of what you mean somewhere so I can scope the work out?
> > > > > > > > > > >
> > > > > > > > > > > Thanks
> > > > > > > > > > > James
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > On 1 July 2013 12:44, Romain Manni-Bucau <
> > > > > rmannibucau@gmail.com>
> > > > > > > > > wrote:
> > > > > > > > > > >
> > > > > > > > > > > > Hi
> > > > > > > > > > > >
> > > > > > > > > > > > it depends your config and that's probably more an
> > > openjpa
> > > > > > > question
> > > > > > > > > but
> > > > > > > > > > > > basically you'll need to provide the dictionnary to
> use
> > > > since
> > > > > > > > openjpa
> > > > > > > > > > > will
> > > > > > > > > > > > not be able to read database metadata (at least).
> > > > > > > > > > > >
> > > > > > > > > > > > *Romain Manni-Bucau*
> > > > > > > > > > > > *Twitter: @rmannibucau <
> > https://twitter.com/rmannibucau
> > > >*
> > > > > > > > > > > > *Blog: **http://rmannibucau.wordpress.com/*<
> > > > > > > > > > > > http://rmannibucau.wordpress.com/>
> > > > > > > > > > > > *LinkedIn: **http://fr.linkedin.com/in/rmannibucau*
> > > > > > > > > > > > *Github: https://github.com/rmannibucau*
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > 2013/7/1 James Green <ja...@gmail.com>
> > > > > > > > > > > >
> > > > > > > > > > > > > I've suppressed the RuntimeExceptions encountered
> as
> > > EJBs
> > > > > > fire
> > > > > > > > and
> > > > > > > > > > > access
> > > > > > > > > > > > > JPA, however I have a new problem now:
> > > > > > > > > > > > >
> > > > > > > > > > > > > Caused by: <openjpa-2.2.0-r422266:1244990 nonfatal
> > user
> > > > > > error>
> > > > > > > > > > > > > org.apache.openjpa.persistence.ArgumentException:
> An
> > > > error
> > > > > > > > occurred
> > > > > > > > > > > while
> > > > > > > > > > > > > parsing the query filter "SELECT a FROM Account a".
> > > Error
> > > > > > > > message:
> > > > > > > > > > The
> > > > > > > > > > > > name
> > > > > > > > > > > > > "Account" is not a recognized entity or identifier.
> > > Known
> > > > > > > entity
> > > > > > > > > > names:
> > > > > > > > > > > > []
> > > > > > > > > > > > >
> > > > > > > > > > > > > It seems the JPA component was unable to map my
> > @Entity
> > > > > > classes
> > > > > > > > > > because
> > > > > > > > > > > > the
> > > > > > > > > > > > > connection did not exist at startup. What do I need
> > to
> > > do
> > > > > to
> > > > > > > work
> > > > > > > > > > > around
> > > > > > > > > > > > > this?
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > > On 1 July 2013 12:07, Romain Manni-Bucau <
> > > > > > > rmannibucau@gmail.com>
> > > > > > > > > > > wrote:
> > > > > > > > > > > > >
> > > > > > > > > > > > > > yep
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > basically get injected the timerservice (
> > > > > > > > > > > > > >
> > > > > > > >
> > http://docs.oracle.com/javaee/6/api/javax/ejb/TimerService.html
> > > > > > > > > ),
> > > > > > > > > > in
> > > > > > > > > > > > > your
> > > > > > > > > > > > > > init method you try to get your data, if not
> > trigger
> > > a
> > > > > > later
> > > > > > > > > > > > > > invocation (
> > > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> http://docs.oracle.com/javaee/6/api/javax/ejb/TimerService.html#createSingleActionTimer(java.util.Date
> > > > > > > > > > > > > > ,
> > > > > > > > > > > > > > javax.ejb.TimerConfig)). While it fails trigger
> > > another
> > > > > one
> > > > > > > > when
> > > > > > > > > > > > invoked.
> > > > > > > > > > > > > > When it succeeds you are done.
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > *Romain Manni-Bucau*
> > > > > > > > > > > > > > *Twitter: @rmannibucau <
> > > > https://twitter.com/rmannibucau
> > > > > >*
> > > > > > > > > > > > > > *Blog: **http://rmannibucau.wordpress.com/*<
> > > > > > > > > > > > > > http://rmannibucau.wordpress.com/>
> > > > > > > > > > > > > > *LinkedIn: **
> > http://fr.linkedin.com/in/rmannibucau*
> > > > > > > > > > > > > > *Github: https://github.com/rmannibucau*
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > 2013/7/1 James Green <ja...@gmail.com>
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > > In our case we have two EJBs, both @Singleton
> and
> > > > > > @Startup,
> > > > > > > > one
> > > > > > > > > > > > depends
> > > > > > > > > > > > > > on
> > > > > > > > > > > > > > > the other. One is a cache façade and the other
> > > loads
> > > > > data
> > > > > > > via
> > > > > > > > > JPA
> > > > > > > > > > > and
> > > > > > > > > > > > > > feeds
> > > > > > > > > > > > > > > it into the cache. An external schedule fires a
> > > > servlet
> > > > > > > that
> > > > > > > > > > > reloads
> > > > > > > > > > > > > the
> > > > > > > > > > > > > > > cache from the database.
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > What's happening is that without MySQL we see
> EJB
> > > > > > > exceptions
> > > > > > > > > that
> > > > > > > > > > > > they
> > > > > > > > > > > > > > > cannot be created and thus we are dead.
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > I've just tried adding autoReconnect=true
> inside
> > a
> > > > > > > <Resource>
> > > > > > > > > but
> > > > > > > > > > > > that
> > > > > > > > > > > > > > made
> > > > > > > > > > > > > > > no difference. I also tried adding
> > > > ,autoReconnect=true
> > > > > to
> > > > > > > > > > > > > > > ConnectionProperties and
> > > ConnectionFactoryProperties
> > > > > > > without
> > > > > > > > > any
> > > > > > > > > > > > change
> > > > > > > > > > > > > > but
> > > > > > > > > > > > > > > I'm not convinced that would have fixed the
> > problem
> > > > > here.
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > Is it instead the case that within the EJB I
> > should
> > > > be
> > > > > > > > trapping
> > > > > > > > > > > > > > > connectivity problems such as
> > PersistenceException
> > > > and
> > > > > > > > allowing
> > > > > > > > > > the
> > > > > > > > > > > > > > > containing to gracefully start up and naturally
> > > keep
> > > > > > trying
> > > > > > > > > > anyway?
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > James
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > On 28 June 2013 17:10, José Luis Cetina <
> > > > > > > > maxtorzito@gmail.com>
> > > > > > > > > > > > wrote:
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > I had a similar problem and what i did was
> set
> > > the
> > > > > > > > > > autoReconnect
> > > > > > > > > > > > > > > attribute
> > > > > > > > > > > > > > > > to true en my tomee.xml datasource.
> > > > > > > > > > > > > > > > What do you mean with retry until the
> > connection
> > > > > > springs
> > > > > > > to
> > > > > > > > > > life?
> > > > > > > > > > > > do
> > > > > > > > > > > > > > you
> > > > > > > > > > > > > > > > have some schedules or jobs running and want
> to
> > > > retry
> > > > > > > again
> > > > > > > > > > when
> > > > > > > > > > > > the
> > > > > > > > > > > > > > > > connection is available again? or just want
> > when
> > > > > > somebody
> > > > > > > > > click
> > > > > > > > > > > any
> > > > > > > > > > > > > > > button
> > > > > > > > > > > > > > > > the app can connect again (this was my
> case)??
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > 2013/6/28 Romain Manni-Bucau <
> > > > rmannibucau@gmail.com>
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > With an ejb timer?
> > > > > > > > > > > > > > > > > Le 28 juin 2013 17:46, "James Green" <
> > > > > > > > > > james.mk.green@gmail.com
> > > > > > > > > > > >
> > > > > > > > > > > > a
> > > > > > > > > > > > > > > écrit
> > > > > > > > > > > > > > > > :
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > Hopefully a quick one.
> > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > On boot our application attempts to read
> > data
> > > > > > > through a
> > > > > > > > > JPA
> > > > > > > > > > > > > > > > > EntityManager.
> > > > > > > > > > > > > > > > > > If the database connection fails at this
> > > point
> > > > > the
> > > > > > > > entire
> > > > > > > > > > > > > > application
> > > > > > > > > > > > > > > > is
> > > > > > > > > > > > > > > > > > effectively dead.
> > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > Is there a way to essentially ask the
> > > database
> > > > > > layer
> > > > > > > to
> > > > > > > > > > retry
> > > > > > > > > > > > > until
> > > > > > > > > > > > > > > the
> > > > > > > > > > > > > > > > > > connection springs to life?
> > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > Thanks,
> > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > James
> > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > --
> > > > > > > > > > > > > > > >
> > > > > > > > > > >
> > > > > >
> -------------------------------------------------------------------
> > > > > > > > > > > > > > > > *SCJA. José Luis Cetina*
> > > > > > > > > > > > > > > >
> > > > > > > > > > >
> > > > > >
> -------------------------------------------------------------------
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > --
> > > > > > > > > >
> > > > > -------------------------------------------------------------------
> > > > > > > > > > *SCJA. José Luis Cetina*
> > > > > > > > > >
> > > > > -------------------------------------------------------------------
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > --
> > > > > > > >
> > > -------------------------------------------------------------------
> > > > > > > > *SCJA. José Luis Cetina*
> > > > > > > >
> > > -------------------------------------------------------------------
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > > >
> > > > >
> > > > > --
> > > > > -------------------------------------------------------------------
> > > > > *SCJA. José Luis Cetina*
> > > > > -------------------------------------------------------------------
> > > > >
> > > >
> > >
> >
>

Re: Reconnect if JPA fails at boot?

Posted by Romain Manni-Bucau <rm...@gmail.com>.
didnt get the first sentence

about the "make it worse" it is what i explained in my previous answer: if
you start without a db and openjpa uses automatically the wrong dictionnary
then even if the db is back and the pool well configured, the jpa layer
will generate wrong SQL so it will not work, so your app is broken whatever
the db state is.

*Romain Manni-Bucau*
*Twitter: @rmannibucau <https://twitter.com/rmannibucau>*
*Blog: **http://rmannibucau.wordpress.com/*<http://rmannibucau.wordpress.com/>
*LinkedIn: **http://fr.linkedin.com/in/rmannibucau*
*Github: https://github.com/rmannibucau*



2013/7/2 James Green <ja...@gmail.com>

> Am I looking for something letting me list the classes I want mapped? The
> error I see shows an empty list, hence this particular question.
>
> You say it doesn't solve our issue and can actually make it worse? Care to
> elaborate?
>
>
> On 2 July 2013 09:17, Romain Manni-Bucau <rm...@gmail.com> wrote:
>
> > the dict doc is here
> >
> >
> http://openjpa.apache.org/builds/2.2.2/apache-openjpa/docs/ref_guide_dbsetup_dbsupport.html
> >
> > it is important to set it if the database can be down at startup
> otherwise
> > you can end up with a wrong dict (generally the generic one) and then
> when
> > the database is up again SQL stuff will not work
> >
> > it doesn't solve your issue but it can make it worse
> >
> > *Romain Manni-Bucau*
> > *Twitter: @rmannibucau <https://twitter.com/rmannibucau>*
> > *Blog: **http://rmannibucau.wordpress.com/*<
> > http://rmannibucau.wordpress.com/>
> > *LinkedIn: **http://fr.linkedin.com/in/rmannibucau*
> > *Github: https://github.com/rmannibucau*
> >
> >
> >
> > 2013/7/2 James Green <ja...@gmail.com>
> >
> > > That's exactly what I want. All I have are EJBs with entity managers
> > > injected via @PersistenceContext (exactly as we are taught in the
> > > "Beginning Java EE 6 Platform with Glassfish 3" book which is how this
> > > application began life.
> > >
> > > So what's the difference I wonder? Romain talks about adding a
> dictionary
> > > but I didn't spot anything spectacularly obvious in a browse of the
> > OpenJPA
> > > user guide yesterday (indeed on the subject of injection it told me to
> > > refer to my application server documentation...).
> > >
> > >
> > >
> > > On 1 July 2013 18:05, José Luis Cetina <ma...@gmail.com> wrote:
> > >
> > > > I did this test:
> > > >
> > > > 1. Stop TomEE
> > > > 2. Shutdown my database server
> > > > 3. Start TomEE
> > > > 4. Try to access to my app, i could access but when i hit my login
> > button
> > > > for example then i get this error:
> > > > com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException:
> > > > Could not create connection to database server. Attempted reconnect 3
> > > > times. Giving up.
> > > > 5. Start up my database server
> > > > 6. Wait for my database to be ready, i refresh the page then hit
> again
> > at
> > > > the login button, then my app run without problem (in this point i
> DONT
> > > > stop/start TomEE again).
> > > >
> > > > Is this the behavior that you need/want it??
> > > >
> > > >
> > > > *Remeber that i have tomee and database in separate server's
> > > >
> > > >
> > > > 2013/7/1 Howard W. Smith, Jr. <sm...@gmail.com>
> > > >
> > > > > Will you be trying the magic that Romain recommended?
> > > > >  On Jul 1, 2013 10:34 AM, "James Green" <ja...@gmail.com>
> > > > wrote:
> > > > >
> > > > > > I was asking about cold boot, specifically. It is when the
> > > application
> > > > > > server begins that the JPA implementation performs the Entity
> > > mapping,
> > > > so
> > > > > > if the database is not available presumably it remains dead until
> > the
> > > > > > application server itself is restarted?
> > > > > >
> > > > > > Unless you already have the magic installed that Romain refers
> to.
> > > > > >
> > > > > >
> > > > > > On 1 July 2013 15:24, José Luis Cetina <ma...@gmail.com>
> > wrote:
> > > > > >
> > > > > > > My entire app use database and of course the app doesnt work if
> > the
> > > > > > > database is unavailable, but when the database server is
> > available
> > > > > again
> > > > > > > the webapp can use the database again without restarting TomEE.
> > > > > > >
> > > > > > > I dont know if i response your question.
> > > > > > >
> > > > > > >
> > > > > > > 2013/7/1 James Green <ja...@gmail.com>
> > > > > > >
> > > > > > > > Are you saying your application starts from cold without the
> > > > > database,
> > > > > > > the
> > > > > > > > operates fine without intervention once the database becomes
> > > > > available?
> > > > > > > >
> > > > > > > >
> > > > > > > > On 1 July 2013 14:26, José Luis Cetina <maxtorzito@gmail.com
> >
> > > > wrote:
> > > > > > > >
> > > > > > > > > I have also differents server, 1 one database and 2 for
> TomEE
> > > > > (using
> > > > > > > > > memcached + cluster) and with autoReconnect=true i dont
> have
> > > any
> > > > > > issue
> > > > > > > > when
> > > > > > > > > the database server reboot, i set this attribute
> > > (autoReconnect)
> > > > > > after
> > > > > > > i
> > > > > > > > > experiment your same problems, when the database server
> > > rebooted
> > > > my
> > > > > > > apps
> > > > > > > > > cant connect anymore to the database server, i had to stop
> > and
> > > > > start
> > > > > > > > tomee
> > > > > > > > > again for work. But then, i add that option and now i work
> > with
> > > > any
> > > > > > > > > problem.
> > > > > > > > >
> > > > > > > > > Here is a example of my Resource:
> > > > > > > > >
> > > > > > > > > <Resource id="ANY_NAME" type="DataSource">
> > > > > > > > >   JdbcDriver com.mysql.jdbc.Driver
> > > > > > > > >   JdbcUrl
> > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> jdbc:mysql://any_ip:3306/any_database?zeroDateTimeBehavior=convertToNull&amp;rewriteBatchedStatements=true&amp;autoReconnect=true
> > > > > > > > >   UserName any_user
> > > > > > > > >   Password any_password
> > > > > > > > >   JtaManaged true
> > > > > > > > >   InitialSize=3
> > > > > > > > >   MaxActive=100
> > > > > > > > >   ValidationQuery=SELECT 1
> > > > > > > > >   TestOnBorrow=true
> > > > > > > > > </Resource>
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > 2013/7/1 James Green <ja...@gmail.com>
> > > > > > > > >
> > > > > > > > > > This now sounds substantially more complex than my design
> > > > (which
> > > > > > uses
> > > > > > > > > > @PersistenceContext(unitName="accounts")) caters for. Is
> > > there
> > > > an
> > > > > > > > example
> > > > > > > > > > of what you mean somewhere so I can scope the work out?
> > > > > > > > > >
> > > > > > > > > > Thanks
> > > > > > > > > > James
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > On 1 July 2013 12:44, Romain Manni-Bucau <
> > > > rmannibucau@gmail.com>
> > > > > > > > wrote:
> > > > > > > > > >
> > > > > > > > > > > Hi
> > > > > > > > > > >
> > > > > > > > > > > it depends your config and that's probably more an
> > openjpa
> > > > > > question
> > > > > > > > but
> > > > > > > > > > > basically you'll need to provide the dictionnary to use
> > > since
> > > > > > > openjpa
> > > > > > > > > > will
> > > > > > > > > > > not be able to read database metadata (at least).
> > > > > > > > > > >
> > > > > > > > > > > *Romain Manni-Bucau*
> > > > > > > > > > > *Twitter: @rmannibucau <
> https://twitter.com/rmannibucau
> > >*
> > > > > > > > > > > *Blog: **http://rmannibucau.wordpress.com/*<
> > > > > > > > > > > http://rmannibucau.wordpress.com/>
> > > > > > > > > > > *LinkedIn: **http://fr.linkedin.com/in/rmannibucau*
> > > > > > > > > > > *Github: https://github.com/rmannibucau*
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > 2013/7/1 James Green <ja...@gmail.com>
> > > > > > > > > > >
> > > > > > > > > > > > I've suppressed the RuntimeExceptions encountered as
> > EJBs
> > > > > fire
> > > > > > > and
> > > > > > > > > > access
> > > > > > > > > > > > JPA, however I have a new problem now:
> > > > > > > > > > > >
> > > > > > > > > > > > Caused by: <openjpa-2.2.0-r422266:1244990 nonfatal
> user
> > > > > error>
> > > > > > > > > > > > org.apache.openjpa.persistence.ArgumentException: An
> > > error
> > > > > > > occurred
> > > > > > > > > > while
> > > > > > > > > > > > parsing the query filter "SELECT a FROM Account a".
> > Error
> > > > > > > message:
> > > > > > > > > The
> > > > > > > > > > > name
> > > > > > > > > > > > "Account" is not a recognized entity or identifier.
> > Known
> > > > > > entity
> > > > > > > > > names:
> > > > > > > > > > > []
> > > > > > > > > > > >
> > > > > > > > > > > > It seems the JPA component was unable to map my
> @Entity
> > > > > classes
> > > > > > > > > because
> > > > > > > > > > > the
> > > > > > > > > > > > connection did not exist at startup. What do I need
> to
> > do
> > > > to
> > > > > > work
> > > > > > > > > > around
> > > > > > > > > > > > this?
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > On 1 July 2013 12:07, Romain Manni-Bucau <
> > > > > > rmannibucau@gmail.com>
> > > > > > > > > > wrote:
> > > > > > > > > > > >
> > > > > > > > > > > > > yep
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > > basically get injected the timerservice (
> > > > > > > > > > > > >
> > > > > > >
> http://docs.oracle.com/javaee/6/api/javax/ejb/TimerService.html
> > > > > > > > ),
> > > > > > > > > in
> > > > > > > > > > > > your
> > > > > > > > > > > > > init method you try to get your data, if not
> trigger
> > a
> > > > > later
> > > > > > > > > > > > > invocation (
> > > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> http://docs.oracle.com/javaee/6/api/javax/ejb/TimerService.html#createSingleActionTimer(java.util.Date
> > > > > > > > > > > > > ,
> > > > > > > > > > > > > javax.ejb.TimerConfig)). While it fails trigger
> > another
> > > > one
> > > > > > > when
> > > > > > > > > > > invoked.
> > > > > > > > > > > > > When it succeeds you are done.
> > > > > > > > > > > > >
> > > > > > > > > > > > > *Romain Manni-Bucau*
> > > > > > > > > > > > > *Twitter: @rmannibucau <
> > > https://twitter.com/rmannibucau
> > > > >*
> > > > > > > > > > > > > *Blog: **http://rmannibucau.wordpress.com/*<
> > > > > > > > > > > > > http://rmannibucau.wordpress.com/>
> > > > > > > > > > > > > *LinkedIn: **
> http://fr.linkedin.com/in/rmannibucau*
> > > > > > > > > > > > > *Github: https://github.com/rmannibucau*
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > > 2013/7/1 James Green <ja...@gmail.com>
> > > > > > > > > > > > >
> > > > > > > > > > > > > > In our case we have two EJBs, both @Singleton and
> > > > > @Startup,
> > > > > > > one
> > > > > > > > > > > depends
> > > > > > > > > > > > > on
> > > > > > > > > > > > > > the other. One is a cache façade and the other
> > loads
> > > > data
> > > > > > via
> > > > > > > > JPA
> > > > > > > > > > and
> > > > > > > > > > > > > feeds
> > > > > > > > > > > > > > it into the cache. An external schedule fires a
> > > servlet
> > > > > > that
> > > > > > > > > > reloads
> > > > > > > > > > > > the
> > > > > > > > > > > > > > cache from the database.
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > What's happening is that without MySQL we see EJB
> > > > > > exceptions
> > > > > > > > that
> > > > > > > > > > > they
> > > > > > > > > > > > > > cannot be created and thus we are dead.
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > I've just tried adding autoReconnect=true inside
> a
> > > > > > <Resource>
> > > > > > > > but
> > > > > > > > > > > that
> > > > > > > > > > > > > made
> > > > > > > > > > > > > > no difference. I also tried adding
> > > ,autoReconnect=true
> > > > to
> > > > > > > > > > > > > > ConnectionProperties and
> > ConnectionFactoryProperties
> > > > > > without
> > > > > > > > any
> > > > > > > > > > > change
> > > > > > > > > > > > > but
> > > > > > > > > > > > > > I'm not convinced that would have fixed the
> problem
> > > > here.
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > Is it instead the case that within the EJB I
> should
> > > be
> > > > > > > trapping
> > > > > > > > > > > > > > connectivity problems such as
> PersistenceException
> > > and
> > > > > > > allowing
> > > > > > > > > the
> > > > > > > > > > > > > > containing to gracefully start up and naturally
> > keep
> > > > > trying
> > > > > > > > > anyway?
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > James
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > On 28 June 2013 17:10, José Luis Cetina <
> > > > > > > maxtorzito@gmail.com>
> > > > > > > > > > > wrote:
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > > I had a similar problem and what i did was set
> > the
> > > > > > > > > autoReconnect
> > > > > > > > > > > > > > attribute
> > > > > > > > > > > > > > > to true en my tomee.xml datasource.
> > > > > > > > > > > > > > > What do you mean with retry until the
> connection
> > > > > springs
> > > > > > to
> > > > > > > > > life?
> > > > > > > > > > > do
> > > > > > > > > > > > > you
> > > > > > > > > > > > > > > have some schedules or jobs running and want to
> > > retry
> > > > > > again
> > > > > > > > > when
> > > > > > > > > > > the
> > > > > > > > > > > > > > > connection is available again? or just want
> when
> > > > > somebody
> > > > > > > > click
> > > > > > > > > > any
> > > > > > > > > > > > > > button
> > > > > > > > > > > > > > > the app can connect again (this was my case)??
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > 2013/6/28 Romain Manni-Bucau <
> > > rmannibucau@gmail.com>
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > With an ejb timer?
> > > > > > > > > > > > > > > > Le 28 juin 2013 17:46, "James Green" <
> > > > > > > > > james.mk.green@gmail.com
> > > > > > > > > > >
> > > > > > > > > > > a
> > > > > > > > > > > > > > écrit
> > > > > > > > > > > > > > > :
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > Hopefully a quick one.
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > On boot our application attempts to read
> data
> > > > > > through a
> > > > > > > > JPA
> > > > > > > > > > > > > > > > EntityManager.
> > > > > > > > > > > > > > > > > If the database connection fails at this
> > point
> > > > the
> > > > > > > entire
> > > > > > > > > > > > > application
> > > > > > > > > > > > > > > is
> > > > > > > > > > > > > > > > > effectively dead.
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > Is there a way to essentially ask the
> > database
> > > > > layer
> > > > > > to
> > > > > > > > > retry
> > > > > > > > > > > > until
> > > > > > > > > > > > > > the
> > > > > > > > > > > > > > > > > connection springs to life?
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > Thanks,
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > James
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > --
> > > > > > > > > > > > > > >
> > > > > > > > > >
> > > > > -------------------------------------------------------------------
> > > > > > > > > > > > > > > *SCJA. José Luis Cetina*
> > > > > > > > > > > > > > >
> > > > > > > > > >
> > > > > -------------------------------------------------------------------
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > --
> > > > > > > > >
> > > > -------------------------------------------------------------------
> > > > > > > > > *SCJA. José Luis Cetina*
> > > > > > > > >
> > > > -------------------------------------------------------------------
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > --
> > > > > > >
> > -------------------------------------------------------------------
> > > > > > > *SCJA. José Luis Cetina*
> > > > > > >
> > -------------------------------------------------------------------
> > > > > > >
> > > > > >
> > > > >
> > > >
> > > >
> > > >
> > > > --
> > > > -------------------------------------------------------------------
> > > > *SCJA. José Luis Cetina*
> > > > -------------------------------------------------------------------
> > > >
> > >
> >
>

Re: Reconnect if JPA fails at boot?

Posted by James Green <ja...@gmail.com>.
Am I looking for something letting me list the classes I want mapped? The
error I see shows an empty list, hence this particular question.

You say it doesn't solve our issue and can actually make it worse? Care to
elaborate?


On 2 July 2013 09:17, Romain Manni-Bucau <rm...@gmail.com> wrote:

> the dict doc is here
>
> http://openjpa.apache.org/builds/2.2.2/apache-openjpa/docs/ref_guide_dbsetup_dbsupport.html
>
> it is important to set it if the database can be down at startup otherwise
> you can end up with a wrong dict (generally the generic one) and then when
> the database is up again SQL stuff will not work
>
> it doesn't solve your issue but it can make it worse
>
> *Romain Manni-Bucau*
> *Twitter: @rmannibucau <https://twitter.com/rmannibucau>*
> *Blog: **http://rmannibucau.wordpress.com/*<
> http://rmannibucau.wordpress.com/>
> *LinkedIn: **http://fr.linkedin.com/in/rmannibucau*
> *Github: https://github.com/rmannibucau*
>
>
>
> 2013/7/2 James Green <ja...@gmail.com>
>
> > That's exactly what I want. All I have are EJBs with entity managers
> > injected via @PersistenceContext (exactly as we are taught in the
> > "Beginning Java EE 6 Platform with Glassfish 3" book which is how this
> > application began life.
> >
> > So what's the difference I wonder? Romain talks about adding a dictionary
> > but I didn't spot anything spectacularly obvious in a browse of the
> OpenJPA
> > user guide yesterday (indeed on the subject of injection it told me to
> > refer to my application server documentation...).
> >
> >
> >
> > On 1 July 2013 18:05, José Luis Cetina <ma...@gmail.com> wrote:
> >
> > > I did this test:
> > >
> > > 1. Stop TomEE
> > > 2. Shutdown my database server
> > > 3. Start TomEE
> > > 4. Try to access to my app, i could access but when i hit my login
> button
> > > for example then i get this error:
> > > com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException:
> > > Could not create connection to database server. Attempted reconnect 3
> > > times. Giving up.
> > > 5. Start up my database server
> > > 6. Wait for my database to be ready, i refresh the page then hit again
> at
> > > the login button, then my app run without problem (in this point i DONT
> > > stop/start TomEE again).
> > >
> > > Is this the behavior that you need/want it??
> > >
> > >
> > > *Remeber that i have tomee and database in separate server's
> > >
> > >
> > > 2013/7/1 Howard W. Smith, Jr. <sm...@gmail.com>
> > >
> > > > Will you be trying the magic that Romain recommended?
> > > >  On Jul 1, 2013 10:34 AM, "James Green" <ja...@gmail.com>
> > > wrote:
> > > >
> > > > > I was asking about cold boot, specifically. It is when the
> > application
> > > > > server begins that the JPA implementation performs the Entity
> > mapping,
> > > so
> > > > > if the database is not available presumably it remains dead until
> the
> > > > > application server itself is restarted?
> > > > >
> > > > > Unless you already have the magic installed that Romain refers to.
> > > > >
> > > > >
> > > > > On 1 July 2013 15:24, José Luis Cetina <ma...@gmail.com>
> wrote:
> > > > >
> > > > > > My entire app use database and of course the app doesnt work if
> the
> > > > > > database is unavailable, but when the database server is
> available
> > > > again
> > > > > > the webapp can use the database again without restarting TomEE.
> > > > > >
> > > > > > I dont know if i response your question.
> > > > > >
> > > > > >
> > > > > > 2013/7/1 James Green <ja...@gmail.com>
> > > > > >
> > > > > > > Are you saying your application starts from cold without the
> > > > database,
> > > > > > the
> > > > > > > operates fine without intervention once the database becomes
> > > > available?
> > > > > > >
> > > > > > >
> > > > > > > On 1 July 2013 14:26, José Luis Cetina <ma...@gmail.com>
> > > wrote:
> > > > > > >
> > > > > > > > I have also differents server, 1 one database and 2 for TomEE
> > > > (using
> > > > > > > > memcached + cluster) and with autoReconnect=true i dont have
> > any
> > > > > issue
> > > > > > > when
> > > > > > > > the database server reboot, i set this attribute
> > (autoReconnect)
> > > > > after
> > > > > > i
> > > > > > > > experiment your same problems, when the database server
> > rebooted
> > > my
> > > > > > apps
> > > > > > > > cant connect anymore to the database server, i had to stop
> and
> > > > start
> > > > > > > tomee
> > > > > > > > again for work. But then, i add that option and now i work
> with
> > > any
> > > > > > > > problem.
> > > > > > > >
> > > > > > > > Here is a example of my Resource:
> > > > > > > >
> > > > > > > > <Resource id="ANY_NAME" type="DataSource">
> > > > > > > >   JdbcDriver com.mysql.jdbc.Driver
> > > > > > > >   JdbcUrl
> > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> jdbc:mysql://any_ip:3306/any_database?zeroDateTimeBehavior=convertToNull&amp;rewriteBatchedStatements=true&amp;autoReconnect=true
> > > > > > > >   UserName any_user
> > > > > > > >   Password any_password
> > > > > > > >   JtaManaged true
> > > > > > > >   InitialSize=3
> > > > > > > >   MaxActive=100
> > > > > > > >   ValidationQuery=SELECT 1
> > > > > > > >   TestOnBorrow=true
> > > > > > > > </Resource>
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > 2013/7/1 James Green <ja...@gmail.com>
> > > > > > > >
> > > > > > > > > This now sounds substantially more complex than my design
> > > (which
> > > > > uses
> > > > > > > > > @PersistenceContext(unitName="accounts")) caters for. Is
> > there
> > > an
> > > > > > > example
> > > > > > > > > of what you mean somewhere so I can scope the work out?
> > > > > > > > >
> > > > > > > > > Thanks
> > > > > > > > > James
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > On 1 July 2013 12:44, Romain Manni-Bucau <
> > > rmannibucau@gmail.com>
> > > > > > > wrote:
> > > > > > > > >
> > > > > > > > > > Hi
> > > > > > > > > >
> > > > > > > > > > it depends your config and that's probably more an
> openjpa
> > > > > question
> > > > > > > but
> > > > > > > > > > basically you'll need to provide the dictionnary to use
> > since
> > > > > > openjpa
> > > > > > > > > will
> > > > > > > > > > not be able to read database metadata (at least).
> > > > > > > > > >
> > > > > > > > > > *Romain Manni-Bucau*
> > > > > > > > > > *Twitter: @rmannibucau <https://twitter.com/rmannibucau
> >*
> > > > > > > > > > *Blog: **http://rmannibucau.wordpress.com/*<
> > > > > > > > > > http://rmannibucau.wordpress.com/>
> > > > > > > > > > *LinkedIn: **http://fr.linkedin.com/in/rmannibucau*
> > > > > > > > > > *Github: https://github.com/rmannibucau*
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > 2013/7/1 James Green <ja...@gmail.com>
> > > > > > > > > >
> > > > > > > > > > > I've suppressed the RuntimeExceptions encountered as
> EJBs
> > > > fire
> > > > > > and
> > > > > > > > > access
> > > > > > > > > > > JPA, however I have a new problem now:
> > > > > > > > > > >
> > > > > > > > > > > Caused by: <openjpa-2.2.0-r422266:1244990 nonfatal user
> > > > error>
> > > > > > > > > > > org.apache.openjpa.persistence.ArgumentException: An
> > error
> > > > > > occurred
> > > > > > > > > while
> > > > > > > > > > > parsing the query filter "SELECT a FROM Account a".
> Error
> > > > > > message:
> > > > > > > > The
> > > > > > > > > > name
> > > > > > > > > > > "Account" is not a recognized entity or identifier.
> Known
> > > > > entity
> > > > > > > > names:
> > > > > > > > > > []
> > > > > > > > > > >
> > > > > > > > > > > It seems the JPA component was unable to map my @Entity
> > > > classes
> > > > > > > > because
> > > > > > > > > > the
> > > > > > > > > > > connection did not exist at startup. What do I need to
> do
> > > to
> > > > > work
> > > > > > > > > around
> > > > > > > > > > > this?
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > On 1 July 2013 12:07, Romain Manni-Bucau <
> > > > > rmannibucau@gmail.com>
> > > > > > > > > wrote:
> > > > > > > > > > >
> > > > > > > > > > > > yep
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > basically get injected the timerservice (
> > > > > > > > > > > >
> > > > > > http://docs.oracle.com/javaee/6/api/javax/ejb/TimerService.html
> > > > > > > ),
> > > > > > > > in
> > > > > > > > > > > your
> > > > > > > > > > > > init method you try to get your data, if not trigger
> a
> > > > later
> > > > > > > > > > > > invocation (
> > > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> http://docs.oracle.com/javaee/6/api/javax/ejb/TimerService.html#createSingleActionTimer(java.util.Date
> > > > > > > > > > > > ,
> > > > > > > > > > > > javax.ejb.TimerConfig)). While it fails trigger
> another
> > > one
> > > > > > when
> > > > > > > > > > invoked.
> > > > > > > > > > > > When it succeeds you are done.
> > > > > > > > > > > >
> > > > > > > > > > > > *Romain Manni-Bucau*
> > > > > > > > > > > > *Twitter: @rmannibucau <
> > https://twitter.com/rmannibucau
> > > >*
> > > > > > > > > > > > *Blog: **http://rmannibucau.wordpress.com/*<
> > > > > > > > > > > > http://rmannibucau.wordpress.com/>
> > > > > > > > > > > > *LinkedIn: **http://fr.linkedin.com/in/rmannibucau*
> > > > > > > > > > > > *Github: https://github.com/rmannibucau*
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > 2013/7/1 James Green <ja...@gmail.com>
> > > > > > > > > > > >
> > > > > > > > > > > > > In our case we have two EJBs, both @Singleton and
> > > > @Startup,
> > > > > > one
> > > > > > > > > > depends
> > > > > > > > > > > > on
> > > > > > > > > > > > > the other. One is a cache façade and the other
> loads
> > > data
> > > > > via
> > > > > > > JPA
> > > > > > > > > and
> > > > > > > > > > > > feeds
> > > > > > > > > > > > > it into the cache. An external schedule fires a
> > servlet
> > > > > that
> > > > > > > > > reloads
> > > > > > > > > > > the
> > > > > > > > > > > > > cache from the database.
> > > > > > > > > > > > >
> > > > > > > > > > > > > What's happening is that without MySQL we see EJB
> > > > > exceptions
> > > > > > > that
> > > > > > > > > > they
> > > > > > > > > > > > > cannot be created and thus we are dead.
> > > > > > > > > > > > >
> > > > > > > > > > > > > I've just tried adding autoReconnect=true inside a
> > > > > <Resource>
> > > > > > > but
> > > > > > > > > > that
> > > > > > > > > > > > made
> > > > > > > > > > > > > no difference. I also tried adding
> > ,autoReconnect=true
> > > to
> > > > > > > > > > > > > ConnectionProperties and
> ConnectionFactoryProperties
> > > > > without
> > > > > > > any
> > > > > > > > > > change
> > > > > > > > > > > > but
> > > > > > > > > > > > > I'm not convinced that would have fixed the problem
> > > here.
> > > > > > > > > > > > >
> > > > > > > > > > > > > Is it instead the case that within the EJB I should
> > be
> > > > > > trapping
> > > > > > > > > > > > > connectivity problems such as PersistenceException
> > and
> > > > > > allowing
> > > > > > > > the
> > > > > > > > > > > > > containing to gracefully start up and naturally
> keep
> > > > trying
> > > > > > > > anyway?
> > > > > > > > > > > > >
> > > > > > > > > > > > > James
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > > On 28 June 2013 17:10, José Luis Cetina <
> > > > > > maxtorzito@gmail.com>
> > > > > > > > > > wrote:
> > > > > > > > > > > > >
> > > > > > > > > > > > > > I had a similar problem and what i did was set
> the
> > > > > > > > autoReconnect
> > > > > > > > > > > > > attribute
> > > > > > > > > > > > > > to true en my tomee.xml datasource.
> > > > > > > > > > > > > > What do you mean with retry until the connection
> > > > springs
> > > > > to
> > > > > > > > life?
> > > > > > > > > > do
> > > > > > > > > > > > you
> > > > > > > > > > > > > > have some schedules or jobs running and want to
> > retry
> > > > > again
> > > > > > > > when
> > > > > > > > > > the
> > > > > > > > > > > > > > connection is available again? or just want when
> > > > somebody
> > > > > > > click
> > > > > > > > > any
> > > > > > > > > > > > > button
> > > > > > > > > > > > > > the app can connect again (this was my case)??
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > 2013/6/28 Romain Manni-Bucau <
> > rmannibucau@gmail.com>
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > > With an ejb timer?
> > > > > > > > > > > > > > > Le 28 juin 2013 17:46, "James Green" <
> > > > > > > > james.mk.green@gmail.com
> > > > > > > > > >
> > > > > > > > > > a
> > > > > > > > > > > > > écrit
> > > > > > > > > > > > > > :
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > Hopefully a quick one.
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > On boot our application attempts to read data
> > > > > through a
> > > > > > > JPA
> > > > > > > > > > > > > > > EntityManager.
> > > > > > > > > > > > > > > > If the database connection fails at this
> point
> > > the
> > > > > > entire
> > > > > > > > > > > > application
> > > > > > > > > > > > > > is
> > > > > > > > > > > > > > > > effectively dead.
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > Is there a way to essentially ask the
> database
> > > > layer
> > > > > to
> > > > > > > > retry
> > > > > > > > > > > until
> > > > > > > > > > > > > the
> > > > > > > > > > > > > > > > connection springs to life?
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > Thanks,
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > James
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > --
> > > > > > > > > > > > > >
> > > > > > > > >
> > > > -------------------------------------------------------------------
> > > > > > > > > > > > > > *SCJA. José Luis Cetina*
> > > > > > > > > > > > > >
> > > > > > > > >
> > > > -------------------------------------------------------------------
> > > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > --
> > > > > > > >
> > > -------------------------------------------------------------------
> > > > > > > > *SCJA. José Luis Cetina*
> > > > > > > >
> > > -------------------------------------------------------------------
> > > > > > > >
> > > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > > --
> > > > > >
> -------------------------------------------------------------------
> > > > > > *SCJA. José Luis Cetina*
> > > > > >
> -------------------------------------------------------------------
> > > > > >
> > > > >
> > > >
> > >
> > >
> > >
> > > --
> > > -------------------------------------------------------------------
> > > *SCJA. José Luis Cetina*
> > > -------------------------------------------------------------------
> > >
> >
>

Re: Reconnect if JPA fails at boot?

Posted by Romain Manni-Bucau <rm...@gmail.com>.
the dict doc is here
http://openjpa.apache.org/builds/2.2.2/apache-openjpa/docs/ref_guide_dbsetup_dbsupport.html

it is important to set it if the database can be down at startup otherwise
you can end up with a wrong dict (generally the generic one) and then when
the database is up again SQL stuff will not work

it doesn't solve your issue but it can make it worse

*Romain Manni-Bucau*
*Twitter: @rmannibucau <https://twitter.com/rmannibucau>*
*Blog: **http://rmannibucau.wordpress.com/*<http://rmannibucau.wordpress.com/>
*LinkedIn: **http://fr.linkedin.com/in/rmannibucau*
*Github: https://github.com/rmannibucau*



2013/7/2 James Green <ja...@gmail.com>

> That's exactly what I want. All I have are EJBs with entity managers
> injected via @PersistenceContext (exactly as we are taught in the
> "Beginning Java EE 6 Platform with Glassfish 3" book which is how this
> application began life.
>
> So what's the difference I wonder? Romain talks about adding a dictionary
> but I didn't spot anything spectacularly obvious in a browse of the OpenJPA
> user guide yesterday (indeed on the subject of injection it told me to
> refer to my application server documentation...).
>
>
>
> On 1 July 2013 18:05, José Luis Cetina <ma...@gmail.com> wrote:
>
> > I did this test:
> >
> > 1. Stop TomEE
> > 2. Shutdown my database server
> > 3. Start TomEE
> > 4. Try to access to my app, i could access but when i hit my login button
> > for example then i get this error:
> > com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException:
> > Could not create connection to database server. Attempted reconnect 3
> > times. Giving up.
> > 5. Start up my database server
> > 6. Wait for my database to be ready, i refresh the page then hit again at
> > the login button, then my app run without problem (in this point i DONT
> > stop/start TomEE again).
> >
> > Is this the behavior that you need/want it??
> >
> >
> > *Remeber that i have tomee and database in separate server's
> >
> >
> > 2013/7/1 Howard W. Smith, Jr. <sm...@gmail.com>
> >
> > > Will you be trying the magic that Romain recommended?
> > >  On Jul 1, 2013 10:34 AM, "James Green" <ja...@gmail.com>
> > wrote:
> > >
> > > > I was asking about cold boot, specifically. It is when the
> application
> > > > server begins that the JPA implementation performs the Entity
> mapping,
> > so
> > > > if the database is not available presumably it remains dead until the
> > > > application server itself is restarted?
> > > >
> > > > Unless you already have the magic installed that Romain refers to.
> > > >
> > > >
> > > > On 1 July 2013 15:24, José Luis Cetina <ma...@gmail.com> wrote:
> > > >
> > > > > My entire app use database and of course the app doesnt work if the
> > > > > database is unavailable, but when the database server is available
> > > again
> > > > > the webapp can use the database again without restarting TomEE.
> > > > >
> > > > > I dont know if i response your question.
> > > > >
> > > > >
> > > > > 2013/7/1 James Green <ja...@gmail.com>
> > > > >
> > > > > > Are you saying your application starts from cold without the
> > > database,
> > > > > the
> > > > > > operates fine without intervention once the database becomes
> > > available?
> > > > > >
> > > > > >
> > > > > > On 1 July 2013 14:26, José Luis Cetina <ma...@gmail.com>
> > wrote:
> > > > > >
> > > > > > > I have also differents server, 1 one database and 2 for TomEE
> > > (using
> > > > > > > memcached + cluster) and with autoReconnect=true i dont have
> any
> > > > issue
> > > > > > when
> > > > > > > the database server reboot, i set this attribute
> (autoReconnect)
> > > > after
> > > > > i
> > > > > > > experiment your same problems, when the database server
> rebooted
> > my
> > > > > apps
> > > > > > > cant connect anymore to the database server, i had to stop and
> > > start
> > > > > > tomee
> > > > > > > again for work. But then, i add that option and now i work with
> > any
> > > > > > > problem.
> > > > > > >
> > > > > > > Here is a example of my Resource:
> > > > > > >
> > > > > > > <Resource id="ANY_NAME" type="DataSource">
> > > > > > >   JdbcDriver com.mysql.jdbc.Driver
> > > > > > >   JdbcUrl
> > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> jdbc:mysql://any_ip:3306/any_database?zeroDateTimeBehavior=convertToNull&amp;rewriteBatchedStatements=true&amp;autoReconnect=true
> > > > > > >   UserName any_user
> > > > > > >   Password any_password
> > > > > > >   JtaManaged true
> > > > > > >   InitialSize=3
> > > > > > >   MaxActive=100
> > > > > > >   ValidationQuery=SELECT 1
> > > > > > >   TestOnBorrow=true
> > > > > > > </Resource>
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > 2013/7/1 James Green <ja...@gmail.com>
> > > > > > >
> > > > > > > > This now sounds substantially more complex than my design
> > (which
> > > > uses
> > > > > > > > @PersistenceContext(unitName="accounts")) caters for. Is
> there
> > an
> > > > > > example
> > > > > > > > of what you mean somewhere so I can scope the work out?
> > > > > > > >
> > > > > > > > Thanks
> > > > > > > > James
> > > > > > > >
> > > > > > > >
> > > > > > > > On 1 July 2013 12:44, Romain Manni-Bucau <
> > rmannibucau@gmail.com>
> > > > > > wrote:
> > > > > > > >
> > > > > > > > > Hi
> > > > > > > > >
> > > > > > > > > it depends your config and that's probably more an openjpa
> > > > question
> > > > > > but
> > > > > > > > > basically you'll need to provide the dictionnary to use
> since
> > > > > openjpa
> > > > > > > > will
> > > > > > > > > not be able to read database metadata (at least).
> > > > > > > > >
> > > > > > > > > *Romain Manni-Bucau*
> > > > > > > > > *Twitter: @rmannibucau <https://twitter.com/rmannibucau>*
> > > > > > > > > *Blog: **http://rmannibucau.wordpress.com/*<
> > > > > > > > > http://rmannibucau.wordpress.com/>
> > > > > > > > > *LinkedIn: **http://fr.linkedin.com/in/rmannibucau*
> > > > > > > > > *Github: https://github.com/rmannibucau*
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > 2013/7/1 James Green <ja...@gmail.com>
> > > > > > > > >
> > > > > > > > > > I've suppressed the RuntimeExceptions encountered as EJBs
> > > fire
> > > > > and
> > > > > > > > access
> > > > > > > > > > JPA, however I have a new problem now:
> > > > > > > > > >
> > > > > > > > > > Caused by: <openjpa-2.2.0-r422266:1244990 nonfatal user
> > > error>
> > > > > > > > > > org.apache.openjpa.persistence.ArgumentException: An
> error
> > > > > occurred
> > > > > > > > while
> > > > > > > > > > parsing the query filter "SELECT a FROM Account a". Error
> > > > > message:
> > > > > > > The
> > > > > > > > > name
> > > > > > > > > > "Account" is not a recognized entity or identifier. Known
> > > > entity
> > > > > > > names:
> > > > > > > > > []
> > > > > > > > > >
> > > > > > > > > > It seems the JPA component was unable to map my @Entity
> > > classes
> > > > > > > because
> > > > > > > > > the
> > > > > > > > > > connection did not exist at startup. What do I need to do
> > to
> > > > work
> > > > > > > > around
> > > > > > > > > > this?
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > On 1 July 2013 12:07, Romain Manni-Bucau <
> > > > rmannibucau@gmail.com>
> > > > > > > > wrote:
> > > > > > > > > >
> > > > > > > > > > > yep
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > basically get injected the timerservice (
> > > > > > > > > > >
> > > > > http://docs.oracle.com/javaee/6/api/javax/ejb/TimerService.html
> > > > > > ),
> > > > > > > in
> > > > > > > > > > your
> > > > > > > > > > > init method you try to get your data, if not trigger a
> > > later
> > > > > > > > > > > invocation (
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> http://docs.oracle.com/javaee/6/api/javax/ejb/TimerService.html#createSingleActionTimer(java.util.Date
> > > > > > > > > > > ,
> > > > > > > > > > > javax.ejb.TimerConfig)). While it fails trigger another
> > one
> > > > > when
> > > > > > > > > invoked.
> > > > > > > > > > > When it succeeds you are done.
> > > > > > > > > > >
> > > > > > > > > > > *Romain Manni-Bucau*
> > > > > > > > > > > *Twitter: @rmannibucau <
> https://twitter.com/rmannibucau
> > >*
> > > > > > > > > > > *Blog: **http://rmannibucau.wordpress.com/*<
> > > > > > > > > > > http://rmannibucau.wordpress.com/>
> > > > > > > > > > > *LinkedIn: **http://fr.linkedin.com/in/rmannibucau*
> > > > > > > > > > > *Github: https://github.com/rmannibucau*
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > 2013/7/1 James Green <ja...@gmail.com>
> > > > > > > > > > >
> > > > > > > > > > > > In our case we have two EJBs, both @Singleton and
> > > @Startup,
> > > > > one
> > > > > > > > > depends
> > > > > > > > > > > on
> > > > > > > > > > > > the other. One is a cache façade and the other loads
> > data
> > > > via
> > > > > > JPA
> > > > > > > > and
> > > > > > > > > > > feeds
> > > > > > > > > > > > it into the cache. An external schedule fires a
> servlet
> > > > that
> > > > > > > > reloads
> > > > > > > > > > the
> > > > > > > > > > > > cache from the database.
> > > > > > > > > > > >
> > > > > > > > > > > > What's happening is that without MySQL we see EJB
> > > > exceptions
> > > > > > that
> > > > > > > > > they
> > > > > > > > > > > > cannot be created and thus we are dead.
> > > > > > > > > > > >
> > > > > > > > > > > > I've just tried adding autoReconnect=true inside a
> > > > <Resource>
> > > > > > but
> > > > > > > > > that
> > > > > > > > > > > made
> > > > > > > > > > > > no difference. I also tried adding
> ,autoReconnect=true
> > to
> > > > > > > > > > > > ConnectionProperties and ConnectionFactoryProperties
> > > > without
> > > > > > any
> > > > > > > > > change
> > > > > > > > > > > but
> > > > > > > > > > > > I'm not convinced that would have fixed the problem
> > here.
> > > > > > > > > > > >
> > > > > > > > > > > > Is it instead the case that within the EJB I should
> be
> > > > > trapping
> > > > > > > > > > > > connectivity problems such as PersistenceException
> and
> > > > > allowing
> > > > > > > the
> > > > > > > > > > > > containing to gracefully start up and naturally keep
> > > trying
> > > > > > > anyway?
> > > > > > > > > > > >
> > > > > > > > > > > > James
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > On 28 June 2013 17:10, José Luis Cetina <
> > > > > maxtorzito@gmail.com>
> > > > > > > > > wrote:
> > > > > > > > > > > >
> > > > > > > > > > > > > I had a similar problem and what i did was set the
> > > > > > > autoReconnect
> > > > > > > > > > > > attribute
> > > > > > > > > > > > > to true en my tomee.xml datasource.
> > > > > > > > > > > > > What do you mean with retry until the connection
> > > springs
> > > > to
> > > > > > > life?
> > > > > > > > > do
> > > > > > > > > > > you
> > > > > > > > > > > > > have some schedules or jobs running and want to
> retry
> > > > again
> > > > > > > when
> > > > > > > > > the
> > > > > > > > > > > > > connection is available again? or just want when
> > > somebody
> > > > > > click
> > > > > > > > any
> > > > > > > > > > > > button
> > > > > > > > > > > > > the app can connect again (this was my case)??
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > > 2013/6/28 Romain Manni-Bucau <
> rmannibucau@gmail.com>
> > > > > > > > > > > > >
> > > > > > > > > > > > > > With an ejb timer?
> > > > > > > > > > > > > > Le 28 juin 2013 17:46, "James Green" <
> > > > > > > james.mk.green@gmail.com
> > > > > > > > >
> > > > > > > > > a
> > > > > > > > > > > > écrit
> > > > > > > > > > > > > :
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > > Hopefully a quick one.
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > On boot our application attempts to read data
> > > > through a
> > > > > > JPA
> > > > > > > > > > > > > > EntityManager.
> > > > > > > > > > > > > > > If the database connection fails at this point
> > the
> > > > > entire
> > > > > > > > > > > application
> > > > > > > > > > > > > is
> > > > > > > > > > > > > > > effectively dead.
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > Is there a way to essentially ask the database
> > > layer
> > > > to
> > > > > > > retry
> > > > > > > > > > until
> > > > > > > > > > > > the
> > > > > > > > > > > > > > > connection springs to life?
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > Thanks,
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > James
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > > --
> > > > > > > > > > > > >
> > > > > > > >
> > > -------------------------------------------------------------------
> > > > > > > > > > > > > *SCJA. José Luis Cetina*
> > > > > > > > > > > > >
> > > > > > > >
> > > -------------------------------------------------------------------
> > > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > --
> > > > > > >
> > -------------------------------------------------------------------
> > > > > > > *SCJA. José Luis Cetina*
> > > > > > >
> > -------------------------------------------------------------------
> > > > > > >
> > > > > >
> > > > >
> > > > >
> > > > >
> > > > > --
> > > > > -------------------------------------------------------------------
> > > > > *SCJA. José Luis Cetina*
> > > > > -------------------------------------------------------------------
> > > > >
> > > >
> > >
> >
> >
> >
> > --
> > -------------------------------------------------------------------
> > *SCJA. José Luis Cetina*
> > -------------------------------------------------------------------
> >
>

Re: Reconnect if JPA fails at boot?

Posted by James Green <ja...@gmail.com>.
That's exactly what I want. All I have are EJBs with entity managers
injected via @PersistenceContext (exactly as we are taught in the
"Beginning Java EE 6 Platform with Glassfish 3" book which is how this
application began life.

So what's the difference I wonder? Romain talks about adding a dictionary
but I didn't spot anything spectacularly obvious in a browse of the OpenJPA
user guide yesterday (indeed on the subject of injection it told me to
refer to my application server documentation...).



On 1 July 2013 18:05, José Luis Cetina <ma...@gmail.com> wrote:

> I did this test:
>
> 1. Stop TomEE
> 2. Shutdown my database server
> 3. Start TomEE
> 4. Try to access to my app, i could access but when i hit my login button
> for example then i get this error:
> com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException:
> Could not create connection to database server. Attempted reconnect 3
> times. Giving up.
> 5. Start up my database server
> 6. Wait for my database to be ready, i refresh the page then hit again at
> the login button, then my app run without problem (in this point i DONT
> stop/start TomEE again).
>
> Is this the behavior that you need/want it??
>
>
> *Remeber that i have tomee and database in separate server's
>
>
> 2013/7/1 Howard W. Smith, Jr. <sm...@gmail.com>
>
> > Will you be trying the magic that Romain recommended?
> >  On Jul 1, 2013 10:34 AM, "James Green" <ja...@gmail.com>
> wrote:
> >
> > > I was asking about cold boot, specifically. It is when the application
> > > server begins that the JPA implementation performs the Entity mapping,
> so
> > > if the database is not available presumably it remains dead until the
> > > application server itself is restarted?
> > >
> > > Unless you already have the magic installed that Romain refers to.
> > >
> > >
> > > On 1 July 2013 15:24, José Luis Cetina <ma...@gmail.com> wrote:
> > >
> > > > My entire app use database and of course the app doesnt work if the
> > > > database is unavailable, but when the database server is available
> > again
> > > > the webapp can use the database again without restarting TomEE.
> > > >
> > > > I dont know if i response your question.
> > > >
> > > >
> > > > 2013/7/1 James Green <ja...@gmail.com>
> > > >
> > > > > Are you saying your application starts from cold without the
> > database,
> > > > the
> > > > > operates fine without intervention once the database becomes
> > available?
> > > > >
> > > > >
> > > > > On 1 July 2013 14:26, José Luis Cetina <ma...@gmail.com>
> wrote:
> > > > >
> > > > > > I have also differents server, 1 one database and 2 for TomEE
> > (using
> > > > > > memcached + cluster) and with autoReconnect=true i dont have any
> > > issue
> > > > > when
> > > > > > the database server reboot, i set this attribute (autoReconnect)
> > > after
> > > > i
> > > > > > experiment your same problems, when the database server rebooted
> my
> > > > apps
> > > > > > cant connect anymore to the database server, i had to stop and
> > start
> > > > > tomee
> > > > > > again for work. But then, i add that option and now i work with
> any
> > > > > > problem.
> > > > > >
> > > > > > Here is a example of my Resource:
> > > > > >
> > > > > > <Resource id="ANY_NAME" type="DataSource">
> > > > > >   JdbcDriver com.mysql.jdbc.Driver
> > > > > >   JdbcUrl
> > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> jdbc:mysql://any_ip:3306/any_database?zeroDateTimeBehavior=convertToNull&amp;rewriteBatchedStatements=true&amp;autoReconnect=true
> > > > > >   UserName any_user
> > > > > >   Password any_password
> > > > > >   JtaManaged true
> > > > > >   InitialSize=3
> > > > > >   MaxActive=100
> > > > > >   ValidationQuery=SELECT 1
> > > > > >   TestOnBorrow=true
> > > > > > </Resource>
> > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > > 2013/7/1 James Green <ja...@gmail.com>
> > > > > >
> > > > > > > This now sounds substantially more complex than my design
> (which
> > > uses
> > > > > > > @PersistenceContext(unitName="accounts")) caters for. Is there
> an
> > > > > example
> > > > > > > of what you mean somewhere so I can scope the work out?
> > > > > > >
> > > > > > > Thanks
> > > > > > > James
> > > > > > >
> > > > > > >
> > > > > > > On 1 July 2013 12:44, Romain Manni-Bucau <
> rmannibucau@gmail.com>
> > > > > wrote:
> > > > > > >
> > > > > > > > Hi
> > > > > > > >
> > > > > > > > it depends your config and that's probably more an openjpa
> > > question
> > > > > but
> > > > > > > > basically you'll need to provide the dictionnary to use since
> > > > openjpa
> > > > > > > will
> > > > > > > > not be able to read database metadata (at least).
> > > > > > > >
> > > > > > > > *Romain Manni-Bucau*
> > > > > > > > *Twitter: @rmannibucau <https://twitter.com/rmannibucau>*
> > > > > > > > *Blog: **http://rmannibucau.wordpress.com/*<
> > > > > > > > http://rmannibucau.wordpress.com/>
> > > > > > > > *LinkedIn: **http://fr.linkedin.com/in/rmannibucau*
> > > > > > > > *Github: https://github.com/rmannibucau*
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > 2013/7/1 James Green <ja...@gmail.com>
> > > > > > > >
> > > > > > > > > I've suppressed the RuntimeExceptions encountered as EJBs
> > fire
> > > > and
> > > > > > > access
> > > > > > > > > JPA, however I have a new problem now:
> > > > > > > > >
> > > > > > > > > Caused by: <openjpa-2.2.0-r422266:1244990 nonfatal user
> > error>
> > > > > > > > > org.apache.openjpa.persistence.ArgumentException: An error
> > > > occurred
> > > > > > > while
> > > > > > > > > parsing the query filter "SELECT a FROM Account a". Error
> > > > message:
> > > > > > The
> > > > > > > > name
> > > > > > > > > "Account" is not a recognized entity or identifier. Known
> > > entity
> > > > > > names:
> > > > > > > > []
> > > > > > > > >
> > > > > > > > > It seems the JPA component was unable to map my @Entity
> > classes
> > > > > > because
> > > > > > > > the
> > > > > > > > > connection did not exist at startup. What do I need to do
> to
> > > work
> > > > > > > around
> > > > > > > > > this?
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > On 1 July 2013 12:07, Romain Manni-Bucau <
> > > rmannibucau@gmail.com>
> > > > > > > wrote:
> > > > > > > > >
> > > > > > > > > > yep
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > basically get injected the timerservice (
> > > > > > > > > >
> > > > http://docs.oracle.com/javaee/6/api/javax/ejb/TimerService.html
> > > > > ),
> > > > > > in
> > > > > > > > > your
> > > > > > > > > > init method you try to get your data, if not trigger a
> > later
> > > > > > > > > > invocation (
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> http://docs.oracle.com/javaee/6/api/javax/ejb/TimerService.html#createSingleActionTimer(java.util.Date
> > > > > > > > > > ,
> > > > > > > > > > javax.ejb.TimerConfig)). While it fails trigger another
> one
> > > > when
> > > > > > > > invoked.
> > > > > > > > > > When it succeeds you are done.
> > > > > > > > > >
> > > > > > > > > > *Romain Manni-Bucau*
> > > > > > > > > > *Twitter: @rmannibucau <https://twitter.com/rmannibucau
> >*
> > > > > > > > > > *Blog: **http://rmannibucau.wordpress.com/*<
> > > > > > > > > > http://rmannibucau.wordpress.com/>
> > > > > > > > > > *LinkedIn: **http://fr.linkedin.com/in/rmannibucau*
> > > > > > > > > > *Github: https://github.com/rmannibucau*
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > 2013/7/1 James Green <ja...@gmail.com>
> > > > > > > > > >
> > > > > > > > > > > In our case we have two EJBs, both @Singleton and
> > @Startup,
> > > > one
> > > > > > > > depends
> > > > > > > > > > on
> > > > > > > > > > > the other. One is a cache façade and the other loads
> data
> > > via
> > > > > JPA
> > > > > > > and
> > > > > > > > > > feeds
> > > > > > > > > > > it into the cache. An external schedule fires a servlet
> > > that
> > > > > > > reloads
> > > > > > > > > the
> > > > > > > > > > > cache from the database.
> > > > > > > > > > >
> > > > > > > > > > > What's happening is that without MySQL we see EJB
> > > exceptions
> > > > > that
> > > > > > > > they
> > > > > > > > > > > cannot be created and thus we are dead.
> > > > > > > > > > >
> > > > > > > > > > > I've just tried adding autoReconnect=true inside a
> > > <Resource>
> > > > > but
> > > > > > > > that
> > > > > > > > > > made
> > > > > > > > > > > no difference. I also tried adding ,autoReconnect=true
> to
> > > > > > > > > > > ConnectionProperties and ConnectionFactoryProperties
> > > without
> > > > > any
> > > > > > > > change
> > > > > > > > > > but
> > > > > > > > > > > I'm not convinced that would have fixed the problem
> here.
> > > > > > > > > > >
> > > > > > > > > > > Is it instead the case that within the EJB I should be
> > > > trapping
> > > > > > > > > > > connectivity problems such as PersistenceException and
> > > > allowing
> > > > > > the
> > > > > > > > > > > containing to gracefully start up and naturally keep
> > trying
> > > > > > anyway?
> > > > > > > > > > >
> > > > > > > > > > > James
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > On 28 June 2013 17:10, José Luis Cetina <
> > > > maxtorzito@gmail.com>
> > > > > > > > wrote:
> > > > > > > > > > >
> > > > > > > > > > > > I had a similar problem and what i did was set the
> > > > > > autoReconnect
> > > > > > > > > > > attribute
> > > > > > > > > > > > to true en my tomee.xml datasource.
> > > > > > > > > > > > What do you mean with retry until the connection
> > springs
> > > to
> > > > > > life?
> > > > > > > > do
> > > > > > > > > > you
> > > > > > > > > > > > have some schedules or jobs running and want to retry
> > > again
> > > > > > when
> > > > > > > > the
> > > > > > > > > > > > connection is available again? or just want when
> > somebody
> > > > > click
> > > > > > > any
> > > > > > > > > > > button
> > > > > > > > > > > > the app can connect again (this was my case)??
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > 2013/6/28 Romain Manni-Bucau <rm...@gmail.com>
> > > > > > > > > > > >
> > > > > > > > > > > > > With an ejb timer?
> > > > > > > > > > > > > Le 28 juin 2013 17:46, "James Green" <
> > > > > > james.mk.green@gmail.com
> > > > > > > >
> > > > > > > > a
> > > > > > > > > > > écrit
> > > > > > > > > > > > :
> > > > > > > > > > > > >
> > > > > > > > > > > > > > Hopefully a quick one.
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > On boot our application attempts to read data
> > > through a
> > > > > JPA
> > > > > > > > > > > > > EntityManager.
> > > > > > > > > > > > > > If the database connection fails at this point
> the
> > > > entire
> > > > > > > > > > application
> > > > > > > > > > > > is
> > > > > > > > > > > > > > effectively dead.
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > Is there a way to essentially ask the database
> > layer
> > > to
> > > > > > retry
> > > > > > > > > until
> > > > > > > > > > > the
> > > > > > > > > > > > > > connection springs to life?
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > Thanks,
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > James
> > > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > --
> > > > > > > > > > > >
> > > > > > >
> > -------------------------------------------------------------------
> > > > > > > > > > > > *SCJA. José Luis Cetina*
> > > > > > > > > > > >
> > > > > > >
> > -------------------------------------------------------------------
> > > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > > --
> > > > > >
> -------------------------------------------------------------------
> > > > > > *SCJA. José Luis Cetina*
> > > > > >
> -------------------------------------------------------------------
> > > > > >
> > > > >
> > > >
> > > >
> > > >
> > > > --
> > > > -------------------------------------------------------------------
> > > > *SCJA. José Luis Cetina*
> > > > -------------------------------------------------------------------
> > > >
> > >
> >
>
>
>
> --
> -------------------------------------------------------------------
> *SCJA. José Luis Cetina*
> -------------------------------------------------------------------
>

Re: Reconnect if JPA fails at boot?

Posted by "Howard W. Smith, Jr." <sm...@gmail.com>.
+1 Jose, +1!


On Mon, Jul 1, 2013 at 1:05 PM, José Luis Cetina <ma...@gmail.com>wrote:

>
> Is this the behavior that you need/want it??
>
>

RE: @Webservice

Posted by Romain Manni-Bucau <rm...@gmail.com>.
I think cxf removed it for security reasons (would need to check) but it
doesnt affect the webservice itself
Le 1 juil. 2013 22:48, "Patel, Sanjay" <Sa...@nemours.org> a écrit :

> No. ?wsdl will give detail wsdl but in past with tomcat+openejb, without
> ?wsdl it was displaying one line message about webservice.
>
> -----Original Message-----
> From: Romain Manni-Bucau [mailto:rmannibucau@gmail.com]
> Sent: Monday, July 01, 2013 4:41 PM
> To: users@tomee.apache.org
> Subject: Re: @Webservice
>
> Hi,
>
> Didnt you forget ?wsdl ?
>
> Can you reproduce it in a sample?
> Le 1 juil. 2013 22:29, "Patel, Sanjay" <Sa...@nemours.org> a écrit
> :
>
> > Using @Webservice annotation for Stateless EJB and accessing
> > webservice
> > http://localhost:8080/directory/webservices/ws/NemoursDirectoryService
> > gives below output <soap:Envelope
> > xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
> > <soap:Body>
> > <soap:Fault>
> > <faultcode>soap:Server</faultcode>
> > <faultstring>
> >         No such operation: directory (HTTP GET PATH_INFO:
> > /directory/webservices/ws/NemoursDirectoryServicenull)
> > </faultstring>
> > </soap:Fault>
> > </soap:Body>
> > </soap:Envelope>
> >
> > And this is the log
> > WARNING: Interceptor for {
> > http://impl.service.phonedirectory.nemours.org/}NemoursDirectoryServic
> > ehas thrown exception, unwinding now
> > org.apache.cxf.interceptor.Fault: No such operation: directory (HTTP
> > GET
> > PATH_INFO: /directory/webservices/ws/NemoursDirectoryServicenull)
> >         at
> >
> org.apache.cxf.interceptor.URIMappingInterceptor.handleMessage(URIMappingInterceptor.java:93)
> >         at
> >
> org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:262)
> >         at
> >
> org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:121)
> >         at
> >
> org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:236)
> >         at
> >
> org.apache.openejb.server.cxf.CxfWsContainer.onMessage(CxfWsContainer.java:74)
> >         at
> >
> org.apache.openejb.server.webservices.WsServlet.service(WsServlet.java:98)
> >         at
> >
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
> >         at
> >
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
> >         at
> >
> org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
> >         at
> >
> org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:118)
> >         at
> >
> org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:84)
> >         at
> > org.springframework.security.web.FilterChainProxy$VirtualFilterChain.d
> > oFilter(FilterChainProxy.java:342)
> >
> >
> > Before TomEE, when I was using openEJB and Tomcat, I was not getting
> > this error but instead it was giving nice message as below
> >
> > Hi, this is 'NemoursDirectoryWebService' web service.
> >
> > Is something needs to be setup to get this nice message?
> >
> >
>

RE: @Webservice

Posted by "Patel, Sanjay" <Sa...@nemours.org>.
No. ?wsdl will give detail wsdl but in past with tomcat+openejb, without ?wsdl it was displaying one line message about webservice.

-----Original Message-----
From: Romain Manni-Bucau [mailto:rmannibucau@gmail.com] 
Sent: Monday, July 01, 2013 4:41 PM
To: users@tomee.apache.org
Subject: Re: @Webservice

Hi,

Didnt you forget ?wsdl ?

Can you reproduce it in a sample?
Le 1 juil. 2013 22:29, "Patel, Sanjay" <Sa...@nemours.org> a écrit :

> Using @Webservice annotation for Stateless EJB and accessing 
> webservice 
> http://localhost:8080/directory/webservices/ws/NemoursDirectoryService
> gives below output <soap:Envelope 
> xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
> <soap:Body>
> <soap:Fault>
> <faultcode>soap:Server</faultcode>
> <faultstring>
>         No such operation: directory (HTTP GET PATH_INFO:
> /directory/webservices/ws/NemoursDirectoryServicenull)
> </faultstring>
> </soap:Fault>
> </soap:Body>
> </soap:Envelope>
>
> And this is the log
> WARNING: Interceptor for {
> http://impl.service.phonedirectory.nemours.org/}NemoursDirectoryServic
> ehas thrown exception, unwinding now
> org.apache.cxf.interceptor.Fault: No such operation: directory (HTTP 
> GET
> PATH_INFO: /directory/webservices/ws/NemoursDirectoryServicenull)
>         at
> org.apache.cxf.interceptor.URIMappingInterceptor.handleMessage(URIMappingInterceptor.java:93)
>         at
> org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:262)
>         at
> org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:121)
>         at
> org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:236)
>         at
> org.apache.openejb.server.cxf.CxfWsContainer.onMessage(CxfWsContainer.java:74)
>         at
> org.apache.openejb.server.webservices.WsServlet.service(WsServlet.java:98)
>         at
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
>         at
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
>         at
> org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
>         at
> org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:118)
>         at
> org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:84)
>         at
> org.springframework.security.web.FilterChainProxy$VirtualFilterChain.d
> oFilter(FilterChainProxy.java:342)
>
>
> Before TomEE, when I was using openEJB and Tomcat, I was not getting 
> this error but instead it was giving nice message as below
>
> Hi, this is 'NemoursDirectoryWebService' web service.
>
> Is something needs to be setup to get this nice message?
>
>

Re: @Webservice

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Hi,

Didnt you forget ?wsdl ?

Can you reproduce it in a sample?
Le 1 juil. 2013 22:29, "Patel, Sanjay" <Sa...@nemours.org> a écrit :

> Using @Webservice annotation for Stateless EJB and accessing webservice
> http://localhost:8080/directory/webservices/ws/NemoursDirectoryServicegives below output
> <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
> <soap:Body>
> <soap:Fault>
> <faultcode>soap:Server</faultcode>
> <faultstring>
>         No such operation: directory (HTTP GET PATH_INFO:
> /directory/webservices/ws/NemoursDirectoryServicenull)
> </faultstring>
> </soap:Fault>
> </soap:Body>
> </soap:Envelope>
>
> And this is the log
> WARNING: Interceptor for {
> http://impl.service.phonedirectory.nemours.org/}NemoursDirectoryServicehas thrown exception, unwinding now
> org.apache.cxf.interceptor.Fault: No such operation: directory (HTTP GET
> PATH_INFO: /directory/webservices/ws/NemoursDirectoryServicenull)
>         at
> org.apache.cxf.interceptor.URIMappingInterceptor.handleMessage(URIMappingInterceptor.java:93)
>         at
> org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:262)
>         at
> org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:121)
>         at
> org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:236)
>         at
> org.apache.openejb.server.cxf.CxfWsContainer.onMessage(CxfWsContainer.java:74)
>         at
> org.apache.openejb.server.webservices.WsServlet.service(WsServlet.java:98)
>         at
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
>         at
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
>         at
> org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
>         at
> org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:118)
>         at
> org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:84)
>         at
> org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
>
>
> Before TomEE, when I was using openEJB and Tomcat, I was not getting this
> error but instead it was giving nice message as below
>
> Hi, this is 'NemoursDirectoryWebService' web service.
>
> Is something needs to be setup to get this nice message?
>
>

@Webservice

Posted by "Patel, Sanjay" <Sa...@nemours.org>.
Using @Webservice annotation for Stateless EJB and accessing webservice
http://localhost:8080/directory/webservices/ws/NemoursDirectoryService gives below output
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<soap:Fault>
<faultcode>soap:Server</faultcode>
<faultstring>
	No such operation: directory (HTTP GET PATH_INFO: /directory/webservices/ws/NemoursDirectoryServicenull)
</faultstring>
</soap:Fault>
</soap:Body>
</soap:Envelope>

And this is the log
WARNING: Interceptor for {http://impl.service.phonedirectory.nemours.org/}NemoursDirectoryService has thrown exception, unwinding now
org.apache.cxf.interceptor.Fault: No such operation: directory (HTTP GET PATH_INFO: /directory/webservices/ws/NemoursDirectoryServicenull)
        at org.apache.cxf.interceptor.URIMappingInterceptor.handleMessage(URIMappingInterceptor.java:93)
        at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:262)
        at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:121)
        at org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:236)
        at org.apache.openejb.server.cxf.CxfWsContainer.onMessage(CxfWsContainer.java:74)
        at org.apache.openejb.server.webservices.WsServlet.service(WsServlet.java:98)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
        at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
        at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:118)
        at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:84)
        at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)


Before TomEE, when I was using openEJB and Tomcat, I was not getting this error but instead it was giving nice message as below

Hi, this is 'NemoursDirectoryWebService' web service.

Is something needs to be setup to get this nice message?


Re: Reconnect if JPA fails at boot?

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Once pooled a connection stays in the pool t seconds. If the db is no more
accessible the connection will throw exceptions. See interval validation
and validation query params
Le 1 juil. 2013 20:31, "José Luis Cetina" <ma...@gmail.com> a écrit :

> @Romain Why you say that?
>
> This is my resource
> <Resource id="ANY_NAME" type="DataSource">
>   JdbcDriver com.mysql.jdbc.Driver
>   JdbcUrl
>
> jdbc:mysql://any_ip:3306/any_database?zeroDateTimeBehavior=convertToNull&amp;rewriteBatchedStatements=true&amp;autoReconnect=true
>   UserName any_user
>   Password any_password
>   JtaManaged true
>   InitialSize=3
>   MaxActive=100
>   ValidationQuery=SELECT 1
>   TestOnBorrow=true
> </Resource>
>
>
> 2013/7/1 Romain Manni-Bucau <rm...@gmail.com>
>
> > Depends the conf of the pool but sounds ok
> > Le 1 juil. 2013 19:06, "José Luis Cetina" <ma...@gmail.com> a
> écrit :
> >
> > > I did this test:
> > >
> > > 1. Stop TomEE
> > > 2. Shutdown my database server
> > > 3. Start TomEE
> > > 4. Try to access to my app, i could access but when i hit my login
> button
> > > for example then i get this error:
> > > com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException:
> > > Could not create connection to database server. Attempted reconnect 3
> > > times. Giving up.
> > > 5. Start up my database server
> > > 6. Wait for my database to be ready, i refresh the page then hit again
> at
> > > the login button, then my app run without problem (in this point i DONT
> > > stop/start TomEE again).
> > >
> > > Is this the behavior that you need/want it??
> > >
> > >
> > > *Remeber that i have tomee and database in separate server's
> > >
> > >
> > > 2013/7/1 Howard W. Smith, Jr. <sm...@gmail.com>
> > >
> > > > Will you be trying the magic that Romain recommended?
> > > >  On Jul 1, 2013 10:34 AM, "James Green" <ja...@gmail.com>
> > > wrote:
> > > >
> > > > > I was asking about cold boot, specifically. It is when the
> > application
> > > > > server begins that the JPA implementation performs the Entity
> > mapping,
> > > so
> > > > > if the database is not available presumably it remains dead until
> the
> > > > > application server itself is restarted?
> > > > >
> > > > > Unless you already have the magic installed that Romain refers to.
> > > > >
> > > > >
> > > > > On 1 July 2013 15:24, José Luis Cetina <ma...@gmail.com>
> wrote:
> > > > >
> > > > > > My entire app use database and of course the app doesnt work if
> the
> > > > > > database is unavailable, but when the database server is
> available
> > > > again
> > > > > > the webapp can use the database again without restarting TomEE.
> > > > > >
> > > > > > I dont know if i response your question.
> > > > > >
> > > > > >
> > > > > > 2013/7/1 James Green <ja...@gmail.com>
> > > > > >
> > > > > > > Are you saying your application starts from cold without the
> > > > database,
> > > > > > the
> > > > > > > operates fine without intervention once the database becomes
> > > > available?
> > > > > > >
> > > > > > >
> > > > > > > On 1 July 2013 14:26, José Luis Cetina <ma...@gmail.com>
> > > wrote:
> > > > > > >
> > > > > > > > I have also differents server, 1 one database and 2 for TomEE
> > > > (using
> > > > > > > > memcached + cluster) and with autoReconnect=true i dont have
> > any
> > > > > issue
> > > > > > > when
> > > > > > > > the database server reboot, i set this attribute
> > (autoReconnect)
> > > > > after
> > > > > > i
> > > > > > > > experiment your same problems, when the database server
> > rebooted
> > > my
> > > > > > apps
> > > > > > > > cant connect anymore to the database server, i had to stop
> and
> > > > start
> > > > > > > tomee
> > > > > > > > again for work. But then, i add that option and now i work
> with
> > > any
> > > > > > > > problem.
> > > > > > > >
> > > > > > > > Here is a example of my Resource:
> > > > > > > >
> > > > > > > > <Resource id="ANY_NAME" type="DataSource">
> > > > > > > >   JdbcDriver com.mysql.jdbc.Driver
> > > > > > > >   JdbcUrl
> > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> jdbc:mysql://any_ip:3306/any_database?zeroDateTimeBehavior=convertToNull&amp;rewriteBatchedStatements=true&amp;autoReconnect=true
> > > > > > > >   UserName any_user
> > > > > > > >   Password any_password
> > > > > > > >   JtaManaged true
> > > > > > > >   InitialSize=3
> > > > > > > >   MaxActive=100
> > > > > > > >   ValidationQuery=SELECT 1
> > > > > > > >   TestOnBorrow=true
> > > > > > > > </Resource>
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > 2013/7/1 James Green <ja...@gmail.com>
> > > > > > > >
> > > > > > > > > This now sounds substantially more complex than my design
> > > (which
> > > > > uses
> > > > > > > > > @PersistenceContext(unitName="accounts")) caters for. Is
> > there
> > > an
> > > > > > > example
> > > > > > > > > of what you mean somewhere so I can scope the work out?
> > > > > > > > >
> > > > > > > > > Thanks
> > > > > > > > > James
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > On 1 July 2013 12:44, Romain Manni-Bucau <
> > > rmannibucau@gmail.com>
> > > > > > > wrote:
> > > > > > > > >
> > > > > > > > > > Hi
> > > > > > > > > >
> > > > > > > > > > it depends your config and that's probably more an
> openjpa
> > > > > question
> > > > > > > but
> > > > > > > > > > basically you'll need to provide the dictionnary to use
> > since
> > > > > > openjpa
> > > > > > > > > will
> > > > > > > > > > not be able to read database metadata (at least).
> > > > > > > > > >
> > > > > > > > > > *Romain Manni-Bucau*
> > > > > > > > > > *Twitter: @rmannibucau <https://twitter.com/rmannibucau
> >*
> > > > > > > > > > *Blog: **http://rmannibucau.wordpress.com/*<
> > > > > > > > > > http://rmannibucau.wordpress.com/>
> > > > > > > > > > *LinkedIn: **http://fr.linkedin.com/in/rmannibucau*
> > > > > > > > > > *Github: https://github.com/rmannibucau*
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > 2013/7/1 James Green <ja...@gmail.com>
> > > > > > > > > >
> > > > > > > > > > > I've suppressed the RuntimeExceptions encountered as
> EJBs
> > > > fire
> > > > > > and
> > > > > > > > > access
> > > > > > > > > > > JPA, however I have a new problem now:
> > > > > > > > > > >
> > > > > > > > > > > Caused by: <openjpa-2.2.0-r422266:1244990 nonfatal user
> > > > error>
> > > > > > > > > > > org.apache.openjpa.persistence.ArgumentException: An
> > error
> > > > > > occurred
> > > > > > > > > while
> > > > > > > > > > > parsing the query filter "SELECT a FROM Account a".
> Error
> > > > > > message:
> > > > > > > > The
> > > > > > > > > > name
> > > > > > > > > > > "Account" is not a recognized entity or identifier.
> Known
> > > > > entity
> > > > > > > > names:
> > > > > > > > > > []
> > > > > > > > > > >
> > > > > > > > > > > It seems the JPA component was unable to map my @Entity
> > > > classes
> > > > > > > > because
> > > > > > > > > > the
> > > > > > > > > > > connection did not exist at startup. What do I need to
> do
> > > to
> > > > > work
> > > > > > > > > around
> > > > > > > > > > > this?
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > On 1 July 2013 12:07, Romain Manni-Bucau <
> > > > > rmannibucau@gmail.com>
> > > > > > > > > wrote:
> > > > > > > > > > >
> > > > > > > > > > > > yep
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > basically get injected the timerservice (
> > > > > > > > > > > >
> > > > > > http://docs.oracle.com/javaee/6/api/javax/ejb/TimerService.html
> > > > > > > ),
> > > > > > > > in
> > > > > > > > > > > your
> > > > > > > > > > > > init method you try to get your data, if not trigger
> a
> > > > later
> > > > > > > > > > > > invocation (
> > > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> http://docs.oracle.com/javaee/6/api/javax/ejb/TimerService.html#createSingleActionTimer(java.util.Date
> > > > > > > > > > > > ,
> > > > > > > > > > > > javax.ejb.TimerConfig)). While it fails trigger
> another
> > > one
> > > > > > when
> > > > > > > > > > invoked.
> > > > > > > > > > > > When it succeeds you are done.
> > > > > > > > > > > >
> > > > > > > > > > > > *Romain Manni-Bucau*
> > > > > > > > > > > > *Twitter: @rmannibucau <
> > https://twitter.com/rmannibucau
> > > >*
> > > > > > > > > > > > *Blog: **http://rmannibucau.wordpress.com/*<
> > > > > > > > > > > > http://rmannibucau.wordpress.com/>
> > > > > > > > > > > > *LinkedIn: **http://fr.linkedin.com/in/rmannibucau*
> > > > > > > > > > > > *Github: https://github.com/rmannibucau*
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > 2013/7/1 James Green <ja...@gmail.com>
> > > > > > > > > > > >
> > > > > > > > > > > > > In our case we have two EJBs, both @Singleton and
> > > > @Startup,
> > > > > > one
> > > > > > > > > > depends
> > > > > > > > > > > > on
> > > > > > > > > > > > > the other. One is a cache façade and the other
> loads
> > > data
> > > > > via
> > > > > > > JPA
> > > > > > > > > and
> > > > > > > > > > > > feeds
> > > > > > > > > > > > > it into the cache. An external schedule fires a
> > servlet
> > > > > that
> > > > > > > > > reloads
> > > > > > > > > > > the
> > > > > > > > > > > > > cache from the database.
> > > > > > > > > > > > >
> > > > > > > > > > > > > What's happening is that without MySQL we see EJB
> > > > > exceptions
> > > > > > > that
> > > > > > > > > > they
> > > > > > > > > > > > > cannot be created and thus we are dead.
> > > > > > > > > > > > >
> > > > > > > > > > > > > I've just tried adding autoReconnect=true inside a
> > > > > <Resource>
> > > > > > > but
> > > > > > > > > > that
> > > > > > > > > > > > made
> > > > > > > > > > > > > no difference. I also tried adding
> > ,autoReconnect=true
> > > to
> > > > > > > > > > > > > ConnectionProperties and
> ConnectionFactoryProperties
> > > > > without
> > > > > > > any
> > > > > > > > > > change
> > > > > > > > > > > > but
> > > > > > > > > > > > > I'm not convinced that would have fixed the problem
> > > here.
> > > > > > > > > > > > >
> > > > > > > > > > > > > Is it instead the case that within the EJB I should
> > be
> > > > > > trapping
> > > > > > > > > > > > > connectivity problems such as PersistenceException
> > and
> > > > > > allowing
> > > > > > > > the
> > > > > > > > > > > > > containing to gracefully start up and naturally
> keep
> > > > trying
> > > > > > > > anyway?
> > > > > > > > > > > > >
> > > > > > > > > > > > > James
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > > On 28 June 2013 17:10, José Luis Cetina <
> > > > > > maxtorzito@gmail.com>
> > > > > > > > > > wrote:
> > > > > > > > > > > > >
> > > > > > > > > > > > > > I had a similar problem and what i did was set
> the
> > > > > > > > autoReconnect
> > > > > > > > > > > > > attribute
> > > > > > > > > > > > > > to true en my tomee.xml datasource.
> > > > > > > > > > > > > > What do you mean with retry until the connection
> > > > springs
> > > > > to
> > > > > > > > life?
> > > > > > > > > > do
> > > > > > > > > > > > you
> > > > > > > > > > > > > > have some schedules or jobs running and want to
> > retry
> > > > > again
> > > > > > > > when
> > > > > > > > > > the
> > > > > > > > > > > > > > connection is available again? or just want when
> > > > somebody
> > > > > > > click
> > > > > > > > > any
> > > > > > > > > > > > > button
> > > > > > > > > > > > > > the app can connect again (this was my case)??
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > 2013/6/28 Romain Manni-Bucau <
> > rmannibucau@gmail.com>
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > > With an ejb timer?
> > > > > > > > > > > > > > > Le 28 juin 2013 17:46, "James Green" <
> > > > > > > > james.mk.green@gmail.com
> > > > > > > > > >
> > > > > > > > > > a
> > > > > > > > > > > > > écrit
> > > > > > > > > > > > > > :
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > Hopefully a quick one.
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > On boot our application attempts to read data
> > > > > through a
> > > > > > > JPA
> > > > > > > > > > > > > > > EntityManager.
> > > > > > > > > > > > > > > > If the database connection fails at this
> point
> > > the
> > > > > > entire
> > > > > > > > > > > > application
> > > > > > > > > > > > > > is
> > > > > > > > > > > > > > > > effectively dead.
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > Is there a way to essentially ask the
> database
> > > > layer
> > > > > to
> > > > > > > > retry
> > > > > > > > > > > until
> > > > > > > > > > > > > the
> > > > > > > > > > > > > > > > connection springs to life?
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > Thanks,
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > James
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > --
> > > > > > > > > > > > > >
> > > > > > > > >
> > > > -------------------------------------------------------------------
> > > > > > > > > > > > > > *SCJA. José Luis Cetina*
> > > > > > > > > > > > > >
> > > > > > > > >
> > > > -------------------------------------------------------------------
> > > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > --
> > > > > > > >
> > > -------------------------------------------------------------------
> > > > > > > > *SCJA. José Luis Cetina*
> > > > > > > >
> > > -------------------------------------------------------------------
> > > > > > > >
> > > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > > --
> > > > > >
> -------------------------------------------------------------------
> > > > > > *SCJA. José Luis Cetina*
> > > > > >
> -------------------------------------------------------------------
> > > > > >
> > > > >
> > > >
> > >
> > >
> > >
> > > --
> > > -------------------------------------------------------------------
> > > *SCJA. José Luis Cetina*
> > > -------------------------------------------------------------------
> > >
> >
>
>
>
> --
> -------------------------------------------------------------------
> *SCJA. José Luis Cetina*
> -------------------------------------------------------------------
>

Re: Reconnect if JPA fails at boot?

Posted by José Luis Cetina <ma...@gmail.com>.
@Romain Why you say that?

This is my resource
<Resource id="ANY_NAME" type="DataSource">
  JdbcDriver com.mysql.jdbc.Driver
  JdbcUrl
jdbc:mysql://any_ip:3306/any_database?zeroDateTimeBehavior=convertToNull&amp;rewriteBatchedStatements=true&amp;autoReconnect=true
  UserName any_user
  Password any_password
  JtaManaged true
  InitialSize=3
  MaxActive=100
  ValidationQuery=SELECT 1
  TestOnBorrow=true
</Resource>


2013/7/1 Romain Manni-Bucau <rm...@gmail.com>

> Depends the conf of the pool but sounds ok
> Le 1 juil. 2013 19:06, "José Luis Cetina" <ma...@gmail.com> a écrit :
>
> > I did this test:
> >
> > 1. Stop TomEE
> > 2. Shutdown my database server
> > 3. Start TomEE
> > 4. Try to access to my app, i could access but when i hit my login button
> > for example then i get this error:
> > com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException:
> > Could not create connection to database server. Attempted reconnect 3
> > times. Giving up.
> > 5. Start up my database server
> > 6. Wait for my database to be ready, i refresh the page then hit again at
> > the login button, then my app run without problem (in this point i DONT
> > stop/start TomEE again).
> >
> > Is this the behavior that you need/want it??
> >
> >
> > *Remeber that i have tomee and database in separate server's
> >
> >
> > 2013/7/1 Howard W. Smith, Jr. <sm...@gmail.com>
> >
> > > Will you be trying the magic that Romain recommended?
> > >  On Jul 1, 2013 10:34 AM, "James Green" <ja...@gmail.com>
> > wrote:
> > >
> > > > I was asking about cold boot, specifically. It is when the
> application
> > > > server begins that the JPA implementation performs the Entity
> mapping,
> > so
> > > > if the database is not available presumably it remains dead until the
> > > > application server itself is restarted?
> > > >
> > > > Unless you already have the magic installed that Romain refers to.
> > > >
> > > >
> > > > On 1 July 2013 15:24, José Luis Cetina <ma...@gmail.com> wrote:
> > > >
> > > > > My entire app use database and of course the app doesnt work if the
> > > > > database is unavailable, but when the database server is available
> > > again
> > > > > the webapp can use the database again without restarting TomEE.
> > > > >
> > > > > I dont know if i response your question.
> > > > >
> > > > >
> > > > > 2013/7/1 James Green <ja...@gmail.com>
> > > > >
> > > > > > Are you saying your application starts from cold without the
> > > database,
> > > > > the
> > > > > > operates fine without intervention once the database becomes
> > > available?
> > > > > >
> > > > > >
> > > > > > On 1 July 2013 14:26, José Luis Cetina <ma...@gmail.com>
> > wrote:
> > > > > >
> > > > > > > I have also differents server, 1 one database and 2 for TomEE
> > > (using
> > > > > > > memcached + cluster) and with autoReconnect=true i dont have
> any
> > > > issue
> > > > > > when
> > > > > > > the database server reboot, i set this attribute
> (autoReconnect)
> > > > after
> > > > > i
> > > > > > > experiment your same problems, when the database server
> rebooted
> > my
> > > > > apps
> > > > > > > cant connect anymore to the database server, i had to stop and
> > > start
> > > > > > tomee
> > > > > > > again for work. But then, i add that option and now i work with
> > any
> > > > > > > problem.
> > > > > > >
> > > > > > > Here is a example of my Resource:
> > > > > > >
> > > > > > > <Resource id="ANY_NAME" type="DataSource">
> > > > > > >   JdbcDriver com.mysql.jdbc.Driver
> > > > > > >   JdbcUrl
> > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> jdbc:mysql://any_ip:3306/any_database?zeroDateTimeBehavior=convertToNull&amp;rewriteBatchedStatements=true&amp;autoReconnect=true
> > > > > > >   UserName any_user
> > > > > > >   Password any_password
> > > > > > >   JtaManaged true
> > > > > > >   InitialSize=3
> > > > > > >   MaxActive=100
> > > > > > >   ValidationQuery=SELECT 1
> > > > > > >   TestOnBorrow=true
> > > > > > > </Resource>
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > 2013/7/1 James Green <ja...@gmail.com>
> > > > > > >
> > > > > > > > This now sounds substantially more complex than my design
> > (which
> > > > uses
> > > > > > > > @PersistenceContext(unitName="accounts")) caters for. Is
> there
> > an
> > > > > > example
> > > > > > > > of what you mean somewhere so I can scope the work out?
> > > > > > > >
> > > > > > > > Thanks
> > > > > > > > James
> > > > > > > >
> > > > > > > >
> > > > > > > > On 1 July 2013 12:44, Romain Manni-Bucau <
> > rmannibucau@gmail.com>
> > > > > > wrote:
> > > > > > > >
> > > > > > > > > Hi
> > > > > > > > >
> > > > > > > > > it depends your config and that's probably more an openjpa
> > > > question
> > > > > > but
> > > > > > > > > basically you'll need to provide the dictionnary to use
> since
> > > > > openjpa
> > > > > > > > will
> > > > > > > > > not be able to read database metadata (at least).
> > > > > > > > >
> > > > > > > > > *Romain Manni-Bucau*
> > > > > > > > > *Twitter: @rmannibucau <https://twitter.com/rmannibucau>*
> > > > > > > > > *Blog: **http://rmannibucau.wordpress.com/*<
> > > > > > > > > http://rmannibucau.wordpress.com/>
> > > > > > > > > *LinkedIn: **http://fr.linkedin.com/in/rmannibucau*
> > > > > > > > > *Github: https://github.com/rmannibucau*
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > 2013/7/1 James Green <ja...@gmail.com>
> > > > > > > > >
> > > > > > > > > > I've suppressed the RuntimeExceptions encountered as EJBs
> > > fire
> > > > > and
> > > > > > > > access
> > > > > > > > > > JPA, however I have a new problem now:
> > > > > > > > > >
> > > > > > > > > > Caused by: <openjpa-2.2.0-r422266:1244990 nonfatal user
> > > error>
> > > > > > > > > > org.apache.openjpa.persistence.ArgumentException: An
> error
> > > > > occurred
> > > > > > > > while
> > > > > > > > > > parsing the query filter "SELECT a FROM Account a". Error
> > > > > message:
> > > > > > > The
> > > > > > > > > name
> > > > > > > > > > "Account" is not a recognized entity or identifier. Known
> > > > entity
> > > > > > > names:
> > > > > > > > > []
> > > > > > > > > >
> > > > > > > > > > It seems the JPA component was unable to map my @Entity
> > > classes
> > > > > > > because
> > > > > > > > > the
> > > > > > > > > > connection did not exist at startup. What do I need to do
> > to
> > > > work
> > > > > > > > around
> > > > > > > > > > this?
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > On 1 July 2013 12:07, Romain Manni-Bucau <
> > > > rmannibucau@gmail.com>
> > > > > > > > wrote:
> > > > > > > > > >
> > > > > > > > > > > yep
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > basically get injected the timerservice (
> > > > > > > > > > >
> > > > > http://docs.oracle.com/javaee/6/api/javax/ejb/TimerService.html
> > > > > > ),
> > > > > > > in
> > > > > > > > > > your
> > > > > > > > > > > init method you try to get your data, if not trigger a
> > > later
> > > > > > > > > > > invocation (
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> http://docs.oracle.com/javaee/6/api/javax/ejb/TimerService.html#createSingleActionTimer(java.util.Date
> > > > > > > > > > > ,
> > > > > > > > > > > javax.ejb.TimerConfig)). While it fails trigger another
> > one
> > > > > when
> > > > > > > > > invoked.
> > > > > > > > > > > When it succeeds you are done.
> > > > > > > > > > >
> > > > > > > > > > > *Romain Manni-Bucau*
> > > > > > > > > > > *Twitter: @rmannibucau <
> https://twitter.com/rmannibucau
> > >*
> > > > > > > > > > > *Blog: **http://rmannibucau.wordpress.com/*<
> > > > > > > > > > > http://rmannibucau.wordpress.com/>
> > > > > > > > > > > *LinkedIn: **http://fr.linkedin.com/in/rmannibucau*
> > > > > > > > > > > *Github: https://github.com/rmannibucau*
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > 2013/7/1 James Green <ja...@gmail.com>
> > > > > > > > > > >
> > > > > > > > > > > > In our case we have two EJBs, both @Singleton and
> > > @Startup,
> > > > > one
> > > > > > > > > depends
> > > > > > > > > > > on
> > > > > > > > > > > > the other. One is a cache façade and the other loads
> > data
> > > > via
> > > > > > JPA
> > > > > > > > and
> > > > > > > > > > > feeds
> > > > > > > > > > > > it into the cache. An external schedule fires a
> servlet
> > > > that
> > > > > > > > reloads
> > > > > > > > > > the
> > > > > > > > > > > > cache from the database.
> > > > > > > > > > > >
> > > > > > > > > > > > What's happening is that without MySQL we see EJB
> > > > exceptions
> > > > > > that
> > > > > > > > > they
> > > > > > > > > > > > cannot be created and thus we are dead.
> > > > > > > > > > > >
> > > > > > > > > > > > I've just tried adding autoReconnect=true inside a
> > > > <Resource>
> > > > > > but
> > > > > > > > > that
> > > > > > > > > > > made
> > > > > > > > > > > > no difference. I also tried adding
> ,autoReconnect=true
> > to
> > > > > > > > > > > > ConnectionProperties and ConnectionFactoryProperties
> > > > without
> > > > > > any
> > > > > > > > > change
> > > > > > > > > > > but
> > > > > > > > > > > > I'm not convinced that would have fixed the problem
> > here.
> > > > > > > > > > > >
> > > > > > > > > > > > Is it instead the case that within the EJB I should
> be
> > > > > trapping
> > > > > > > > > > > > connectivity problems such as PersistenceException
> and
> > > > > allowing
> > > > > > > the
> > > > > > > > > > > > containing to gracefully start up and naturally keep
> > > trying
> > > > > > > anyway?
> > > > > > > > > > > >
> > > > > > > > > > > > James
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > On 28 June 2013 17:10, José Luis Cetina <
> > > > > maxtorzito@gmail.com>
> > > > > > > > > wrote:
> > > > > > > > > > > >
> > > > > > > > > > > > > I had a similar problem and what i did was set the
> > > > > > > autoReconnect
> > > > > > > > > > > > attribute
> > > > > > > > > > > > > to true en my tomee.xml datasource.
> > > > > > > > > > > > > What do you mean with retry until the connection
> > > springs
> > > > to
> > > > > > > life?
> > > > > > > > > do
> > > > > > > > > > > you
> > > > > > > > > > > > > have some schedules or jobs running and want to
> retry
> > > > again
> > > > > > > when
> > > > > > > > > the
> > > > > > > > > > > > > connection is available again? or just want when
> > > somebody
> > > > > > click
> > > > > > > > any
> > > > > > > > > > > > button
> > > > > > > > > > > > > the app can connect again (this was my case)??
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > > 2013/6/28 Romain Manni-Bucau <
> rmannibucau@gmail.com>
> > > > > > > > > > > > >
> > > > > > > > > > > > > > With an ejb timer?
> > > > > > > > > > > > > > Le 28 juin 2013 17:46, "James Green" <
> > > > > > > james.mk.green@gmail.com
> > > > > > > > >
> > > > > > > > > a
> > > > > > > > > > > > écrit
> > > > > > > > > > > > > :
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > > Hopefully a quick one.
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > On boot our application attempts to read data
> > > > through a
> > > > > > JPA
> > > > > > > > > > > > > > EntityManager.
> > > > > > > > > > > > > > > If the database connection fails at this point
> > the
> > > > > entire
> > > > > > > > > > > application
> > > > > > > > > > > > > is
> > > > > > > > > > > > > > > effectively dead.
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > Is there a way to essentially ask the database
> > > layer
> > > > to
> > > > > > > retry
> > > > > > > > > > until
> > > > > > > > > > > > the
> > > > > > > > > > > > > > > connection springs to life?
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > Thanks,
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > James
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > > --
> > > > > > > > > > > > >
> > > > > > > >
> > > -------------------------------------------------------------------
> > > > > > > > > > > > > *SCJA. José Luis Cetina*
> > > > > > > > > > > > >
> > > > > > > >
> > > -------------------------------------------------------------------
> > > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > --
> > > > > > >
> > -------------------------------------------------------------------
> > > > > > > *SCJA. José Luis Cetina*
> > > > > > >
> > -------------------------------------------------------------------
> > > > > > >
> > > > > >
> > > > >
> > > > >
> > > > >
> > > > > --
> > > > > -------------------------------------------------------------------
> > > > > *SCJA. José Luis Cetina*
> > > > > -------------------------------------------------------------------
> > > > >
> > > >
> > >
> >
> >
> >
> > --
> > -------------------------------------------------------------------
> > *SCJA. José Luis Cetina*
> > -------------------------------------------------------------------
> >
>



-- 
-------------------------------------------------------------------
*SCJA. José Luis Cetina*
-------------------------------------------------------------------

Re: Reconnect if JPA fails at boot?

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Depends the conf of the pool but sounds ok
Le 1 juil. 2013 19:06, "José Luis Cetina" <ma...@gmail.com> a écrit :

> I did this test:
>
> 1. Stop TomEE
> 2. Shutdown my database server
> 3. Start TomEE
> 4. Try to access to my app, i could access but when i hit my login button
> for example then i get this error:
> com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException:
> Could not create connection to database server. Attempted reconnect 3
> times. Giving up.
> 5. Start up my database server
> 6. Wait for my database to be ready, i refresh the page then hit again at
> the login button, then my app run without problem (in this point i DONT
> stop/start TomEE again).
>
> Is this the behavior that you need/want it??
>
>
> *Remeber that i have tomee and database in separate server's
>
>
> 2013/7/1 Howard W. Smith, Jr. <sm...@gmail.com>
>
> > Will you be trying the magic that Romain recommended?
> >  On Jul 1, 2013 10:34 AM, "James Green" <ja...@gmail.com>
> wrote:
> >
> > > I was asking about cold boot, specifically. It is when the application
> > > server begins that the JPA implementation performs the Entity mapping,
> so
> > > if the database is not available presumably it remains dead until the
> > > application server itself is restarted?
> > >
> > > Unless you already have the magic installed that Romain refers to.
> > >
> > >
> > > On 1 July 2013 15:24, José Luis Cetina <ma...@gmail.com> wrote:
> > >
> > > > My entire app use database and of course the app doesnt work if the
> > > > database is unavailable, but when the database server is available
> > again
> > > > the webapp can use the database again without restarting TomEE.
> > > >
> > > > I dont know if i response your question.
> > > >
> > > >
> > > > 2013/7/1 James Green <ja...@gmail.com>
> > > >
> > > > > Are you saying your application starts from cold without the
> > database,
> > > > the
> > > > > operates fine without intervention once the database becomes
> > available?
> > > > >
> > > > >
> > > > > On 1 July 2013 14:26, José Luis Cetina <ma...@gmail.com>
> wrote:
> > > > >
> > > > > > I have also differents server, 1 one database and 2 for TomEE
> > (using
> > > > > > memcached + cluster) and with autoReconnect=true i dont have any
> > > issue
> > > > > when
> > > > > > the database server reboot, i set this attribute (autoReconnect)
> > > after
> > > > i
> > > > > > experiment your same problems, when the database server rebooted
> my
> > > > apps
> > > > > > cant connect anymore to the database server, i had to stop and
> > start
> > > > > tomee
> > > > > > again for work. But then, i add that option and now i work with
> any
> > > > > > problem.
> > > > > >
> > > > > > Here is a example of my Resource:
> > > > > >
> > > > > > <Resource id="ANY_NAME" type="DataSource">
> > > > > >   JdbcDriver com.mysql.jdbc.Driver
> > > > > >   JdbcUrl
> > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> jdbc:mysql://any_ip:3306/any_database?zeroDateTimeBehavior=convertToNull&amp;rewriteBatchedStatements=true&amp;autoReconnect=true
> > > > > >   UserName any_user
> > > > > >   Password any_password
> > > > > >   JtaManaged true
> > > > > >   InitialSize=3
> > > > > >   MaxActive=100
> > > > > >   ValidationQuery=SELECT 1
> > > > > >   TestOnBorrow=true
> > > > > > </Resource>
> > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > > 2013/7/1 James Green <ja...@gmail.com>
> > > > > >
> > > > > > > This now sounds substantially more complex than my design
> (which
> > > uses
> > > > > > > @PersistenceContext(unitName="accounts")) caters for. Is there
> an
> > > > > example
> > > > > > > of what you mean somewhere so I can scope the work out?
> > > > > > >
> > > > > > > Thanks
> > > > > > > James
> > > > > > >
> > > > > > >
> > > > > > > On 1 July 2013 12:44, Romain Manni-Bucau <
> rmannibucau@gmail.com>
> > > > > wrote:
> > > > > > >
> > > > > > > > Hi
> > > > > > > >
> > > > > > > > it depends your config and that's probably more an openjpa
> > > question
> > > > > but
> > > > > > > > basically you'll need to provide the dictionnary to use since
> > > > openjpa
> > > > > > > will
> > > > > > > > not be able to read database metadata (at least).
> > > > > > > >
> > > > > > > > *Romain Manni-Bucau*
> > > > > > > > *Twitter: @rmannibucau <https://twitter.com/rmannibucau>*
> > > > > > > > *Blog: **http://rmannibucau.wordpress.com/*<
> > > > > > > > http://rmannibucau.wordpress.com/>
> > > > > > > > *LinkedIn: **http://fr.linkedin.com/in/rmannibucau*
> > > > > > > > *Github: https://github.com/rmannibucau*
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > 2013/7/1 James Green <ja...@gmail.com>
> > > > > > > >
> > > > > > > > > I've suppressed the RuntimeExceptions encountered as EJBs
> > fire
> > > > and
> > > > > > > access
> > > > > > > > > JPA, however I have a new problem now:
> > > > > > > > >
> > > > > > > > > Caused by: <openjpa-2.2.0-r422266:1244990 nonfatal user
> > error>
> > > > > > > > > org.apache.openjpa.persistence.ArgumentException: An error
> > > > occurred
> > > > > > > while
> > > > > > > > > parsing the query filter "SELECT a FROM Account a". Error
> > > > message:
> > > > > > The
> > > > > > > > name
> > > > > > > > > "Account" is not a recognized entity or identifier. Known
> > > entity
> > > > > > names:
> > > > > > > > []
> > > > > > > > >
> > > > > > > > > It seems the JPA component was unable to map my @Entity
> > classes
> > > > > > because
> > > > > > > > the
> > > > > > > > > connection did not exist at startup. What do I need to do
> to
> > > work
> > > > > > > around
> > > > > > > > > this?
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > On 1 July 2013 12:07, Romain Manni-Bucau <
> > > rmannibucau@gmail.com>
> > > > > > > wrote:
> > > > > > > > >
> > > > > > > > > > yep
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > basically get injected the timerservice (
> > > > > > > > > >
> > > > http://docs.oracle.com/javaee/6/api/javax/ejb/TimerService.html
> > > > > ),
> > > > > > in
> > > > > > > > > your
> > > > > > > > > > init method you try to get your data, if not trigger a
> > later
> > > > > > > > > > invocation (
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> http://docs.oracle.com/javaee/6/api/javax/ejb/TimerService.html#createSingleActionTimer(java.util.Date
> > > > > > > > > > ,
> > > > > > > > > > javax.ejb.TimerConfig)). While it fails trigger another
> one
> > > > when
> > > > > > > > invoked.
> > > > > > > > > > When it succeeds you are done.
> > > > > > > > > >
> > > > > > > > > > *Romain Manni-Bucau*
> > > > > > > > > > *Twitter: @rmannibucau <https://twitter.com/rmannibucau
> >*
> > > > > > > > > > *Blog: **http://rmannibucau.wordpress.com/*<
> > > > > > > > > > http://rmannibucau.wordpress.com/>
> > > > > > > > > > *LinkedIn: **http://fr.linkedin.com/in/rmannibucau*
> > > > > > > > > > *Github: https://github.com/rmannibucau*
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > 2013/7/1 James Green <ja...@gmail.com>
> > > > > > > > > >
> > > > > > > > > > > In our case we have two EJBs, both @Singleton and
> > @Startup,
> > > > one
> > > > > > > > depends
> > > > > > > > > > on
> > > > > > > > > > > the other. One is a cache façade and the other loads
> data
> > > via
> > > > > JPA
> > > > > > > and
> > > > > > > > > > feeds
> > > > > > > > > > > it into the cache. An external schedule fires a servlet
> > > that
> > > > > > > reloads
> > > > > > > > > the
> > > > > > > > > > > cache from the database.
> > > > > > > > > > >
> > > > > > > > > > > What's happening is that without MySQL we see EJB
> > > exceptions
> > > > > that
> > > > > > > > they
> > > > > > > > > > > cannot be created and thus we are dead.
> > > > > > > > > > >
> > > > > > > > > > > I've just tried adding autoReconnect=true inside a
> > > <Resource>
> > > > > but
> > > > > > > > that
> > > > > > > > > > made
> > > > > > > > > > > no difference. I also tried adding ,autoReconnect=true
> to
> > > > > > > > > > > ConnectionProperties and ConnectionFactoryProperties
> > > without
> > > > > any
> > > > > > > > change
> > > > > > > > > > but
> > > > > > > > > > > I'm not convinced that would have fixed the problem
> here.
> > > > > > > > > > >
> > > > > > > > > > > Is it instead the case that within the EJB I should be
> > > > trapping
> > > > > > > > > > > connectivity problems such as PersistenceException and
> > > > allowing
> > > > > > the
> > > > > > > > > > > containing to gracefully start up and naturally keep
> > trying
> > > > > > anyway?
> > > > > > > > > > >
> > > > > > > > > > > James
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > On 28 June 2013 17:10, José Luis Cetina <
> > > > maxtorzito@gmail.com>
> > > > > > > > wrote:
> > > > > > > > > > >
> > > > > > > > > > > > I had a similar problem and what i did was set the
> > > > > > autoReconnect
> > > > > > > > > > > attribute
> > > > > > > > > > > > to true en my tomee.xml datasource.
> > > > > > > > > > > > What do you mean with retry until the connection
> > springs
> > > to
> > > > > > life?
> > > > > > > > do
> > > > > > > > > > you
> > > > > > > > > > > > have some schedules or jobs running and want to retry
> > > again
> > > > > > when
> > > > > > > > the
> > > > > > > > > > > > connection is available again? or just want when
> > somebody
> > > > > click
> > > > > > > any
> > > > > > > > > > > button
> > > > > > > > > > > > the app can connect again (this was my case)??
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > 2013/6/28 Romain Manni-Bucau <rm...@gmail.com>
> > > > > > > > > > > >
> > > > > > > > > > > > > With an ejb timer?
> > > > > > > > > > > > > Le 28 juin 2013 17:46, "James Green" <
> > > > > > james.mk.green@gmail.com
> > > > > > > >
> > > > > > > > a
> > > > > > > > > > > écrit
> > > > > > > > > > > > :
> > > > > > > > > > > > >
> > > > > > > > > > > > > > Hopefully a quick one.
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > On boot our application attempts to read data
> > > through a
> > > > > JPA
> > > > > > > > > > > > > EntityManager.
> > > > > > > > > > > > > > If the database connection fails at this point
> the
> > > > entire
> > > > > > > > > > application
> > > > > > > > > > > > is
> > > > > > > > > > > > > > effectively dead.
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > Is there a way to essentially ask the database
> > layer
> > > to
> > > > > > retry
> > > > > > > > > until
> > > > > > > > > > > the
> > > > > > > > > > > > > > connection springs to life?
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > Thanks,
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > James
> > > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > --
> > > > > > > > > > > >
> > > > > > >
> > -------------------------------------------------------------------
> > > > > > > > > > > > *SCJA. José Luis Cetina*
> > > > > > > > > > > >
> > > > > > >
> > -------------------------------------------------------------------
> > > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > > --
> > > > > >
> -------------------------------------------------------------------
> > > > > > *SCJA. José Luis Cetina*
> > > > > >
> -------------------------------------------------------------------
> > > > > >
> > > > >
> > > >
> > > >
> > > >
> > > > --
> > > > -------------------------------------------------------------------
> > > > *SCJA. José Luis Cetina*
> > > > -------------------------------------------------------------------
> > > >
> > >
> >
>
>
>
> --
> -------------------------------------------------------------------
> *SCJA. José Luis Cetina*
> -------------------------------------------------------------------
>

Re: Reconnect if JPA fails at boot?

Posted by José Luis Cetina <ma...@gmail.com>.
I did this test:

1. Stop TomEE
2. Shutdown my database server
3. Start TomEE
4. Try to access to my app, i could access but when i hit my login button
for example then i get this error:
com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException:
Could not create connection to database server. Attempted reconnect 3
times. Giving up.
5. Start up my database server
6. Wait for my database to be ready, i refresh the page then hit again at
the login button, then my app run without problem (in this point i DONT
stop/start TomEE again).

Is this the behavior that you need/want it??


*Remeber that i have tomee and database in separate server's


2013/7/1 Howard W. Smith, Jr. <sm...@gmail.com>

> Will you be trying the magic that Romain recommended?
>  On Jul 1, 2013 10:34 AM, "James Green" <ja...@gmail.com> wrote:
>
> > I was asking about cold boot, specifically. It is when the application
> > server begins that the JPA implementation performs the Entity mapping, so
> > if the database is not available presumably it remains dead until the
> > application server itself is restarted?
> >
> > Unless you already have the magic installed that Romain refers to.
> >
> >
> > On 1 July 2013 15:24, José Luis Cetina <ma...@gmail.com> wrote:
> >
> > > My entire app use database and of course the app doesnt work if the
> > > database is unavailable, but when the database server is available
> again
> > > the webapp can use the database again without restarting TomEE.
> > >
> > > I dont know if i response your question.
> > >
> > >
> > > 2013/7/1 James Green <ja...@gmail.com>
> > >
> > > > Are you saying your application starts from cold without the
> database,
> > > the
> > > > operates fine without intervention once the database becomes
> available?
> > > >
> > > >
> > > > On 1 July 2013 14:26, José Luis Cetina <ma...@gmail.com> wrote:
> > > >
> > > > > I have also differents server, 1 one database and 2 for TomEE
> (using
> > > > > memcached + cluster) and with autoReconnect=true i dont have any
> > issue
> > > > when
> > > > > the database server reboot, i set this attribute (autoReconnect)
> > after
> > > i
> > > > > experiment your same problems, when the database server rebooted my
> > > apps
> > > > > cant connect anymore to the database server, i had to stop and
> start
> > > > tomee
> > > > > again for work. But then, i add that option and now i work with any
> > > > > problem.
> > > > >
> > > > > Here is a example of my Resource:
> > > > >
> > > > > <Resource id="ANY_NAME" type="DataSource">
> > > > >   JdbcDriver com.mysql.jdbc.Driver
> > > > >   JdbcUrl
> > > > >
> > > > >
> > > >
> > >
> >
> jdbc:mysql://any_ip:3306/any_database?zeroDateTimeBehavior=convertToNull&amp;rewriteBatchedStatements=true&amp;autoReconnect=true
> > > > >   UserName any_user
> > > > >   Password any_password
> > > > >   JtaManaged true
> > > > >   InitialSize=3
> > > > >   MaxActive=100
> > > > >   ValidationQuery=SELECT 1
> > > > >   TestOnBorrow=true
> > > > > </Resource>
> > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > > > 2013/7/1 James Green <ja...@gmail.com>
> > > > >
> > > > > > This now sounds substantially more complex than my design (which
> > uses
> > > > > > @PersistenceContext(unitName="accounts")) caters for. Is there an
> > > > example
> > > > > > of what you mean somewhere so I can scope the work out?
> > > > > >
> > > > > > Thanks
> > > > > > James
> > > > > >
> > > > > >
> > > > > > On 1 July 2013 12:44, Romain Manni-Bucau <rm...@gmail.com>
> > > > wrote:
> > > > > >
> > > > > > > Hi
> > > > > > >
> > > > > > > it depends your config and that's probably more an openjpa
> > question
> > > > but
> > > > > > > basically you'll need to provide the dictionnary to use since
> > > openjpa
> > > > > > will
> > > > > > > not be able to read database metadata (at least).
> > > > > > >
> > > > > > > *Romain Manni-Bucau*
> > > > > > > *Twitter: @rmannibucau <https://twitter.com/rmannibucau>*
> > > > > > > *Blog: **http://rmannibucau.wordpress.com/*<
> > > > > > > http://rmannibucau.wordpress.com/>
> > > > > > > *LinkedIn: **http://fr.linkedin.com/in/rmannibucau*
> > > > > > > *Github: https://github.com/rmannibucau*
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > 2013/7/1 James Green <ja...@gmail.com>
> > > > > > >
> > > > > > > > I've suppressed the RuntimeExceptions encountered as EJBs
> fire
> > > and
> > > > > > access
> > > > > > > > JPA, however I have a new problem now:
> > > > > > > >
> > > > > > > > Caused by: <openjpa-2.2.0-r422266:1244990 nonfatal user
> error>
> > > > > > > > org.apache.openjpa.persistence.ArgumentException: An error
> > > occurred
> > > > > > while
> > > > > > > > parsing the query filter "SELECT a FROM Account a". Error
> > > message:
> > > > > The
> > > > > > > name
> > > > > > > > "Account" is not a recognized entity or identifier. Known
> > entity
> > > > > names:
> > > > > > > []
> > > > > > > >
> > > > > > > > It seems the JPA component was unable to map my @Entity
> classes
> > > > > because
> > > > > > > the
> > > > > > > > connection did not exist at startup. What do I need to do to
> > work
> > > > > > around
> > > > > > > > this?
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > On 1 July 2013 12:07, Romain Manni-Bucau <
> > rmannibucau@gmail.com>
> > > > > > wrote:
> > > > > > > >
> > > > > > > > > yep
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > basically get injected the timerservice (
> > > > > > > > >
> > > http://docs.oracle.com/javaee/6/api/javax/ejb/TimerService.html
> > > > ),
> > > > > in
> > > > > > > > your
> > > > > > > > > init method you try to get your data, if not trigger a
> later
> > > > > > > > > invocation (
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> http://docs.oracle.com/javaee/6/api/javax/ejb/TimerService.html#createSingleActionTimer(java.util.Date
> > > > > > > > > ,
> > > > > > > > > javax.ejb.TimerConfig)). While it fails trigger another one
> > > when
> > > > > > > invoked.
> > > > > > > > > When it succeeds you are done.
> > > > > > > > >
> > > > > > > > > *Romain Manni-Bucau*
> > > > > > > > > *Twitter: @rmannibucau <https://twitter.com/rmannibucau>*
> > > > > > > > > *Blog: **http://rmannibucau.wordpress.com/*<
> > > > > > > > > http://rmannibucau.wordpress.com/>
> > > > > > > > > *LinkedIn: **http://fr.linkedin.com/in/rmannibucau*
> > > > > > > > > *Github: https://github.com/rmannibucau*
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > 2013/7/1 James Green <ja...@gmail.com>
> > > > > > > > >
> > > > > > > > > > In our case we have two EJBs, both @Singleton and
> @Startup,
> > > one
> > > > > > > depends
> > > > > > > > > on
> > > > > > > > > > the other. One is a cache façade and the other loads data
> > via
> > > > JPA
> > > > > > and
> > > > > > > > > feeds
> > > > > > > > > > it into the cache. An external schedule fires a servlet
> > that
> > > > > > reloads
> > > > > > > > the
> > > > > > > > > > cache from the database.
> > > > > > > > > >
> > > > > > > > > > What's happening is that without MySQL we see EJB
> > exceptions
> > > > that
> > > > > > > they
> > > > > > > > > > cannot be created and thus we are dead.
> > > > > > > > > >
> > > > > > > > > > I've just tried adding autoReconnect=true inside a
> > <Resource>
> > > > but
> > > > > > > that
> > > > > > > > > made
> > > > > > > > > > no difference. I also tried adding ,autoReconnect=true to
> > > > > > > > > > ConnectionProperties and ConnectionFactoryProperties
> > without
> > > > any
> > > > > > > change
> > > > > > > > > but
> > > > > > > > > > I'm not convinced that would have fixed the problem here.
> > > > > > > > > >
> > > > > > > > > > Is it instead the case that within the EJB I should be
> > > trapping
> > > > > > > > > > connectivity problems such as PersistenceException and
> > > allowing
> > > > > the
> > > > > > > > > > containing to gracefully start up and naturally keep
> trying
> > > > > anyway?
> > > > > > > > > >
> > > > > > > > > > James
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > On 28 June 2013 17:10, José Luis Cetina <
> > > maxtorzito@gmail.com>
> > > > > > > wrote:
> > > > > > > > > >
> > > > > > > > > > > I had a similar problem and what i did was set the
> > > > > autoReconnect
> > > > > > > > > > attribute
> > > > > > > > > > > to true en my tomee.xml datasource.
> > > > > > > > > > > What do you mean with retry until the connection
> springs
> > to
> > > > > life?
> > > > > > > do
> > > > > > > > > you
> > > > > > > > > > > have some schedules or jobs running and want to retry
> > again
> > > > > when
> > > > > > > the
> > > > > > > > > > > connection is available again? or just want when
> somebody
> > > > click
> > > > > > any
> > > > > > > > > > button
> > > > > > > > > > > the app can connect again (this was my case)??
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > 2013/6/28 Romain Manni-Bucau <rm...@gmail.com>
> > > > > > > > > > >
> > > > > > > > > > > > With an ejb timer?
> > > > > > > > > > > > Le 28 juin 2013 17:46, "James Green" <
> > > > > james.mk.green@gmail.com
> > > > > > >
> > > > > > > a
> > > > > > > > > > écrit
> > > > > > > > > > > :
> > > > > > > > > > > >
> > > > > > > > > > > > > Hopefully a quick one.
> > > > > > > > > > > > >
> > > > > > > > > > > > > On boot our application attempts to read data
> > through a
> > > > JPA
> > > > > > > > > > > > EntityManager.
> > > > > > > > > > > > > If the database connection fails at this point the
> > > entire
> > > > > > > > > application
> > > > > > > > > > > is
> > > > > > > > > > > > > effectively dead.
> > > > > > > > > > > > >
> > > > > > > > > > > > > Is there a way to essentially ask the database
> layer
> > to
> > > > > retry
> > > > > > > > until
> > > > > > > > > > the
> > > > > > > > > > > > > connection springs to life?
> > > > > > > > > > > > >
> > > > > > > > > > > > > Thanks,
> > > > > > > > > > > > >
> > > > > > > > > > > > > James
> > > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > --
> > > > > > > > > > >
> > > > > >
> -------------------------------------------------------------------
> > > > > > > > > > > *SCJA. José Luis Cetina*
> > > > > > > > > > >
> > > > > >
> -------------------------------------------------------------------
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > > >
> > > > >
> > > > > --
> > > > > -------------------------------------------------------------------
> > > > > *SCJA. José Luis Cetina*
> > > > > -------------------------------------------------------------------
> > > > >
> > > >
> > >
> > >
> > >
> > > --
> > > -------------------------------------------------------------------
> > > *SCJA. José Luis Cetina*
> > > -------------------------------------------------------------------
> > >
> >
>



-- 
-------------------------------------------------------------------
*SCJA. José Luis Cetina*
-------------------------------------------------------------------

Re: Reconnect if JPA fails at boot?

Posted by "Howard W. Smith, Jr." <sm...@gmail.com>.
Will you be trying the magic that Romain recommended?
 On Jul 1, 2013 10:34 AM, "James Green" <ja...@gmail.com> wrote:

> I was asking about cold boot, specifically. It is when the application
> server begins that the JPA implementation performs the Entity mapping, so
> if the database is not available presumably it remains dead until the
> application server itself is restarted?
>
> Unless you already have the magic installed that Romain refers to.
>
>
> On 1 July 2013 15:24, José Luis Cetina <ma...@gmail.com> wrote:
>
> > My entire app use database and of course the app doesnt work if the
> > database is unavailable, but when the database server is available again
> > the webapp can use the database again without restarting TomEE.
> >
> > I dont know if i response your question.
> >
> >
> > 2013/7/1 James Green <ja...@gmail.com>
> >
> > > Are you saying your application starts from cold without the database,
> > the
> > > operates fine without intervention once the database becomes available?
> > >
> > >
> > > On 1 July 2013 14:26, José Luis Cetina <ma...@gmail.com> wrote:
> > >
> > > > I have also differents server, 1 one database and 2 for TomEE (using
> > > > memcached + cluster) and with autoReconnect=true i dont have any
> issue
> > > when
> > > > the database server reboot, i set this attribute (autoReconnect)
> after
> > i
> > > > experiment your same problems, when the database server rebooted my
> > apps
> > > > cant connect anymore to the database server, i had to stop and start
> > > tomee
> > > > again for work. But then, i add that option and now i work with any
> > > > problem.
> > > >
> > > > Here is a example of my Resource:
> > > >
> > > > <Resource id="ANY_NAME" type="DataSource">
> > > >   JdbcDriver com.mysql.jdbc.Driver
> > > >   JdbcUrl
> > > >
> > > >
> > >
> >
> jdbc:mysql://any_ip:3306/any_database?zeroDateTimeBehavior=convertToNull&amp;rewriteBatchedStatements=true&amp;autoReconnect=true
> > > >   UserName any_user
> > > >   Password any_password
> > > >   JtaManaged true
> > > >   InitialSize=3
> > > >   MaxActive=100
> > > >   ValidationQuery=SELECT 1
> > > >   TestOnBorrow=true
> > > > </Resource>
> > > >
> > > >
> > > >
> > > >
> > > >
> > > > 2013/7/1 James Green <ja...@gmail.com>
> > > >
> > > > > This now sounds substantially more complex than my design (which
> uses
> > > > > @PersistenceContext(unitName="accounts")) caters for. Is there an
> > > example
> > > > > of what you mean somewhere so I can scope the work out?
> > > > >
> > > > > Thanks
> > > > > James
> > > > >
> > > > >
> > > > > On 1 July 2013 12:44, Romain Manni-Bucau <rm...@gmail.com>
> > > wrote:
> > > > >
> > > > > > Hi
> > > > > >
> > > > > > it depends your config and that's probably more an openjpa
> question
> > > but
> > > > > > basically you'll need to provide the dictionnary to use since
> > openjpa
> > > > > will
> > > > > > not be able to read database metadata (at least).
> > > > > >
> > > > > > *Romain Manni-Bucau*
> > > > > > *Twitter: @rmannibucau <https://twitter.com/rmannibucau>*
> > > > > > *Blog: **http://rmannibucau.wordpress.com/*<
> > > > > > http://rmannibucau.wordpress.com/>
> > > > > > *LinkedIn: **http://fr.linkedin.com/in/rmannibucau*
> > > > > > *Github: https://github.com/rmannibucau*
> > > > > >
> > > > > >
> > > > > >
> > > > > > 2013/7/1 James Green <ja...@gmail.com>
> > > > > >
> > > > > > > I've suppressed the RuntimeExceptions encountered as EJBs fire
> > and
> > > > > access
> > > > > > > JPA, however I have a new problem now:
> > > > > > >
> > > > > > > Caused by: <openjpa-2.2.0-r422266:1244990 nonfatal user error>
> > > > > > > org.apache.openjpa.persistence.ArgumentException: An error
> > occurred
> > > > > while
> > > > > > > parsing the query filter "SELECT a FROM Account a". Error
> > message:
> > > > The
> > > > > > name
> > > > > > > "Account" is not a recognized entity or identifier. Known
> entity
> > > > names:
> > > > > > []
> > > > > > >
> > > > > > > It seems the JPA component was unable to map my @Entity classes
> > > > because
> > > > > > the
> > > > > > > connection did not exist at startup. What do I need to do to
> work
> > > > > around
> > > > > > > this?
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > On 1 July 2013 12:07, Romain Manni-Bucau <
> rmannibucau@gmail.com>
> > > > > wrote:
> > > > > > >
> > > > > > > > yep
> > > > > > > >
> > > > > > > >
> > > > > > > > basically get injected the timerservice (
> > > > > > > >
> > http://docs.oracle.com/javaee/6/api/javax/ejb/TimerService.html
> > > ),
> > > > in
> > > > > > > your
> > > > > > > > init method you try to get your data, if not trigger a later
> > > > > > > > invocation (
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> http://docs.oracle.com/javaee/6/api/javax/ejb/TimerService.html#createSingleActionTimer(java.util.Date
> > > > > > > > ,
> > > > > > > > javax.ejb.TimerConfig)). While it fails trigger another one
> > when
> > > > > > invoked.
> > > > > > > > When it succeeds you are done.
> > > > > > > >
> > > > > > > > *Romain Manni-Bucau*
> > > > > > > > *Twitter: @rmannibucau <https://twitter.com/rmannibucau>*
> > > > > > > > *Blog: **http://rmannibucau.wordpress.com/*<
> > > > > > > > http://rmannibucau.wordpress.com/>
> > > > > > > > *LinkedIn: **http://fr.linkedin.com/in/rmannibucau*
> > > > > > > > *Github: https://github.com/rmannibucau*
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > 2013/7/1 James Green <ja...@gmail.com>
> > > > > > > >
> > > > > > > > > In our case we have two EJBs, both @Singleton and @Startup,
> > one
> > > > > > depends
> > > > > > > > on
> > > > > > > > > the other. One is a cache façade and the other loads data
> via
> > > JPA
> > > > > and
> > > > > > > > feeds
> > > > > > > > > it into the cache. An external schedule fires a servlet
> that
> > > > > reloads
> > > > > > > the
> > > > > > > > > cache from the database.
> > > > > > > > >
> > > > > > > > > What's happening is that without MySQL we see EJB
> exceptions
> > > that
> > > > > > they
> > > > > > > > > cannot be created and thus we are dead.
> > > > > > > > >
> > > > > > > > > I've just tried adding autoReconnect=true inside a
> <Resource>
> > > but
> > > > > > that
> > > > > > > > made
> > > > > > > > > no difference. I also tried adding ,autoReconnect=true to
> > > > > > > > > ConnectionProperties and ConnectionFactoryProperties
> without
> > > any
> > > > > > change
> > > > > > > > but
> > > > > > > > > I'm not convinced that would have fixed the problem here.
> > > > > > > > >
> > > > > > > > > Is it instead the case that within the EJB I should be
> > trapping
> > > > > > > > > connectivity problems such as PersistenceException and
> > allowing
> > > > the
> > > > > > > > > containing to gracefully start up and naturally keep trying
> > > > anyway?
> > > > > > > > >
> > > > > > > > > James
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > On 28 June 2013 17:10, José Luis Cetina <
> > maxtorzito@gmail.com>
> > > > > > wrote:
> > > > > > > > >
> > > > > > > > > > I had a similar problem and what i did was set the
> > > > autoReconnect
> > > > > > > > > attribute
> > > > > > > > > > to true en my tomee.xml datasource.
> > > > > > > > > > What do you mean with retry until the connection springs
> to
> > > > life?
> > > > > > do
> > > > > > > > you
> > > > > > > > > > have some schedules or jobs running and want to retry
> again
> > > > when
> > > > > > the
> > > > > > > > > > connection is available again? or just want when somebody
> > > click
> > > > > any
> > > > > > > > > button
> > > > > > > > > > the app can connect again (this was my case)??
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > 2013/6/28 Romain Manni-Bucau <rm...@gmail.com>
> > > > > > > > > >
> > > > > > > > > > > With an ejb timer?
> > > > > > > > > > > Le 28 juin 2013 17:46, "James Green" <
> > > > james.mk.green@gmail.com
> > > > > >
> > > > > > a
> > > > > > > > > écrit
> > > > > > > > > > :
> > > > > > > > > > >
> > > > > > > > > > > > Hopefully a quick one.
> > > > > > > > > > > >
> > > > > > > > > > > > On boot our application attempts to read data
> through a
> > > JPA
> > > > > > > > > > > EntityManager.
> > > > > > > > > > > > If the database connection fails at this point the
> > entire
> > > > > > > > application
> > > > > > > > > > is
> > > > > > > > > > > > effectively dead.
> > > > > > > > > > > >
> > > > > > > > > > > > Is there a way to essentially ask the database layer
> to
> > > > retry
> > > > > > > until
> > > > > > > > > the
> > > > > > > > > > > > connection springs to life?
> > > > > > > > > > > >
> > > > > > > > > > > > Thanks,
> > > > > > > > > > > >
> > > > > > > > > > > > James
> > > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > --
> > > > > > > > > >
> > > > > -------------------------------------------------------------------
> > > > > > > > > > *SCJA. José Luis Cetina*
> > > > > > > > > >
> > > > > -------------------------------------------------------------------
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > > >
> > > >
> > > > --
> > > > -------------------------------------------------------------------
> > > > *SCJA. José Luis Cetina*
> > > > -------------------------------------------------------------------
> > > >
> > >
> >
> >
> >
> > --
> > -------------------------------------------------------------------
> > *SCJA. José Luis Cetina*
> > -------------------------------------------------------------------
> >
>

Re: Reconnect if JPA fails at boot?

Posted by James Green <ja...@gmail.com>.
I was asking about cold boot, specifically. It is when the application
server begins that the JPA implementation performs the Entity mapping, so
if the database is not available presumably it remains dead until the
application server itself is restarted?

Unless you already have the magic installed that Romain refers to.


On 1 July 2013 15:24, José Luis Cetina <ma...@gmail.com> wrote:

> My entire app use database and of course the app doesnt work if the
> database is unavailable, but when the database server is available again
> the webapp can use the database again without restarting TomEE.
>
> I dont know if i response your question.
>
>
> 2013/7/1 James Green <ja...@gmail.com>
>
> > Are you saying your application starts from cold without the database,
> the
> > operates fine without intervention once the database becomes available?
> >
> >
> > On 1 July 2013 14:26, José Luis Cetina <ma...@gmail.com> wrote:
> >
> > > I have also differents server, 1 one database and 2 for TomEE (using
> > > memcached + cluster) and with autoReconnect=true i dont have any issue
> > when
> > > the database server reboot, i set this attribute (autoReconnect) after
> i
> > > experiment your same problems, when the database server rebooted my
> apps
> > > cant connect anymore to the database server, i had to stop and start
> > tomee
> > > again for work. But then, i add that option and now i work with any
> > > problem.
> > >
> > > Here is a example of my Resource:
> > >
> > > <Resource id="ANY_NAME" type="DataSource">
> > >   JdbcDriver com.mysql.jdbc.Driver
> > >   JdbcUrl
> > >
> > >
> >
> jdbc:mysql://any_ip:3306/any_database?zeroDateTimeBehavior=convertToNull&amp;rewriteBatchedStatements=true&amp;autoReconnect=true
> > >   UserName any_user
> > >   Password any_password
> > >   JtaManaged true
> > >   InitialSize=3
> > >   MaxActive=100
> > >   ValidationQuery=SELECT 1
> > >   TestOnBorrow=true
> > > </Resource>
> > >
> > >
> > >
> > >
> > >
> > > 2013/7/1 James Green <ja...@gmail.com>
> > >
> > > > This now sounds substantially more complex than my design (which uses
> > > > @PersistenceContext(unitName="accounts")) caters for. Is there an
> > example
> > > > of what you mean somewhere so I can scope the work out?
> > > >
> > > > Thanks
> > > > James
> > > >
> > > >
> > > > On 1 July 2013 12:44, Romain Manni-Bucau <rm...@gmail.com>
> > wrote:
> > > >
> > > > > Hi
> > > > >
> > > > > it depends your config and that's probably more an openjpa question
> > but
> > > > > basically you'll need to provide the dictionnary to use since
> openjpa
> > > > will
> > > > > not be able to read database metadata (at least).
> > > > >
> > > > > *Romain Manni-Bucau*
> > > > > *Twitter: @rmannibucau <https://twitter.com/rmannibucau>*
> > > > > *Blog: **http://rmannibucau.wordpress.com/*<
> > > > > http://rmannibucau.wordpress.com/>
> > > > > *LinkedIn: **http://fr.linkedin.com/in/rmannibucau*
> > > > > *Github: https://github.com/rmannibucau*
> > > > >
> > > > >
> > > > >
> > > > > 2013/7/1 James Green <ja...@gmail.com>
> > > > >
> > > > > > I've suppressed the RuntimeExceptions encountered as EJBs fire
> and
> > > > access
> > > > > > JPA, however I have a new problem now:
> > > > > >
> > > > > > Caused by: <openjpa-2.2.0-r422266:1244990 nonfatal user error>
> > > > > > org.apache.openjpa.persistence.ArgumentException: An error
> occurred
> > > > while
> > > > > > parsing the query filter "SELECT a FROM Account a". Error
> message:
> > > The
> > > > > name
> > > > > > "Account" is not a recognized entity or identifier. Known entity
> > > names:
> > > > > []
> > > > > >
> > > > > > It seems the JPA component was unable to map my @Entity classes
> > > because
> > > > > the
> > > > > > connection did not exist at startup. What do I need to do to work
> > > > around
> > > > > > this?
> > > > > >
> > > > > >
> > > > > >
> > > > > > On 1 July 2013 12:07, Romain Manni-Bucau <rm...@gmail.com>
> > > > wrote:
> > > > > >
> > > > > > > yep
> > > > > > >
> > > > > > >
> > > > > > > basically get injected the timerservice (
> > > > > > >
> http://docs.oracle.com/javaee/6/api/javax/ejb/TimerService.html
> > ),
> > > in
> > > > > > your
> > > > > > > init method you try to get your data, if not trigger a later
> > > > > > > invocation (
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> http://docs.oracle.com/javaee/6/api/javax/ejb/TimerService.html#createSingleActionTimer(java.util.Date
> > > > > > > ,
> > > > > > > javax.ejb.TimerConfig)). While it fails trigger another one
> when
> > > > > invoked.
> > > > > > > When it succeeds you are done.
> > > > > > >
> > > > > > > *Romain Manni-Bucau*
> > > > > > > *Twitter: @rmannibucau <https://twitter.com/rmannibucau>*
> > > > > > > *Blog: **http://rmannibucau.wordpress.com/*<
> > > > > > > http://rmannibucau.wordpress.com/>
> > > > > > > *LinkedIn: **http://fr.linkedin.com/in/rmannibucau*
> > > > > > > *Github: https://github.com/rmannibucau*
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > 2013/7/1 James Green <ja...@gmail.com>
> > > > > > >
> > > > > > > > In our case we have two EJBs, both @Singleton and @Startup,
> one
> > > > > depends
> > > > > > > on
> > > > > > > > the other. One is a cache façade and the other loads data via
> > JPA
> > > > and
> > > > > > > feeds
> > > > > > > > it into the cache. An external schedule fires a servlet that
> > > > reloads
> > > > > > the
> > > > > > > > cache from the database.
> > > > > > > >
> > > > > > > > What's happening is that without MySQL we see EJB exceptions
> > that
> > > > > they
> > > > > > > > cannot be created and thus we are dead.
> > > > > > > >
> > > > > > > > I've just tried adding autoReconnect=true inside a <Resource>
> > but
> > > > > that
> > > > > > > made
> > > > > > > > no difference. I also tried adding ,autoReconnect=true to
> > > > > > > > ConnectionProperties and ConnectionFactoryProperties without
> > any
> > > > > change
> > > > > > > but
> > > > > > > > I'm not convinced that would have fixed the problem here.
> > > > > > > >
> > > > > > > > Is it instead the case that within the EJB I should be
> trapping
> > > > > > > > connectivity problems such as PersistenceException and
> allowing
> > > the
> > > > > > > > containing to gracefully start up and naturally keep trying
> > > anyway?
> > > > > > > >
> > > > > > > > James
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > On 28 June 2013 17:10, José Luis Cetina <
> maxtorzito@gmail.com>
> > > > > wrote:
> > > > > > > >
> > > > > > > > > I had a similar problem and what i did was set the
> > > autoReconnect
> > > > > > > > attribute
> > > > > > > > > to true en my tomee.xml datasource.
> > > > > > > > > What do you mean with retry until the connection springs to
> > > life?
> > > > > do
> > > > > > > you
> > > > > > > > > have some schedules or jobs running and want to retry again
> > > when
> > > > > the
> > > > > > > > > connection is available again? or just want when somebody
> > click
> > > > any
> > > > > > > > button
> > > > > > > > > the app can connect again (this was my case)??
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > 2013/6/28 Romain Manni-Bucau <rm...@gmail.com>
> > > > > > > > >
> > > > > > > > > > With an ejb timer?
> > > > > > > > > > Le 28 juin 2013 17:46, "James Green" <
> > > james.mk.green@gmail.com
> > > > >
> > > > > a
> > > > > > > > écrit
> > > > > > > > > :
> > > > > > > > > >
> > > > > > > > > > > Hopefully a quick one.
> > > > > > > > > > >
> > > > > > > > > > > On boot our application attempts to read data through a
> > JPA
> > > > > > > > > > EntityManager.
> > > > > > > > > > > If the database connection fails at this point the
> entire
> > > > > > > application
> > > > > > > > > is
> > > > > > > > > > > effectively dead.
> > > > > > > > > > >
> > > > > > > > > > > Is there a way to essentially ask the database layer to
> > > retry
> > > > > > until
> > > > > > > > the
> > > > > > > > > > > connection springs to life?
> > > > > > > > > > >
> > > > > > > > > > > Thanks,
> > > > > > > > > > >
> > > > > > > > > > > James
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > --
> > > > > > > > >
> > > > -------------------------------------------------------------------
> > > > > > > > > *SCJA. José Luis Cetina*
> > > > > > > > >
> > > > -------------------------------------------------------------------
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> > >
> > >
> > > --
> > > -------------------------------------------------------------------
> > > *SCJA. José Luis Cetina*
> > > -------------------------------------------------------------------
> > >
> >
>
>
>
> --
> -------------------------------------------------------------------
> *SCJA. José Luis Cetina*
> -------------------------------------------------------------------
>

Re: Reconnect if JPA fails at boot?

Posted by José Luis Cetina <ma...@gmail.com>.
My entire app use database and of course the app doesnt work if the
database is unavailable, but when the database server is available again
the webapp can use the database again without restarting TomEE.

I dont know if i response your question.


2013/7/1 James Green <ja...@gmail.com>

> Are you saying your application starts from cold without the database, the
> operates fine without intervention once the database becomes available?
>
>
> On 1 July 2013 14:26, José Luis Cetina <ma...@gmail.com> wrote:
>
> > I have also differents server, 1 one database and 2 for TomEE (using
> > memcached + cluster) and with autoReconnect=true i dont have any issue
> when
> > the database server reboot, i set this attribute (autoReconnect) after i
> > experiment your same problems, when the database server rebooted my apps
> > cant connect anymore to the database server, i had to stop and start
> tomee
> > again for work. But then, i add that option and now i work with any
> > problem.
> >
> > Here is a example of my Resource:
> >
> > <Resource id="ANY_NAME" type="DataSource">
> >   JdbcDriver com.mysql.jdbc.Driver
> >   JdbcUrl
> >
> >
> jdbc:mysql://any_ip:3306/any_database?zeroDateTimeBehavior=convertToNull&amp;rewriteBatchedStatements=true&amp;autoReconnect=true
> >   UserName any_user
> >   Password any_password
> >   JtaManaged true
> >   InitialSize=3
> >   MaxActive=100
> >   ValidationQuery=SELECT 1
> >   TestOnBorrow=true
> > </Resource>
> >
> >
> >
> >
> >
> > 2013/7/1 James Green <ja...@gmail.com>
> >
> > > This now sounds substantially more complex than my design (which uses
> > > @PersistenceContext(unitName="accounts")) caters for. Is there an
> example
> > > of what you mean somewhere so I can scope the work out?
> > >
> > > Thanks
> > > James
> > >
> > >
> > > On 1 July 2013 12:44, Romain Manni-Bucau <rm...@gmail.com>
> wrote:
> > >
> > > > Hi
> > > >
> > > > it depends your config and that's probably more an openjpa question
> but
> > > > basically you'll need to provide the dictionnary to use since openjpa
> > > will
> > > > not be able to read database metadata (at least).
> > > >
> > > > *Romain Manni-Bucau*
> > > > *Twitter: @rmannibucau <https://twitter.com/rmannibucau>*
> > > > *Blog: **http://rmannibucau.wordpress.com/*<
> > > > http://rmannibucau.wordpress.com/>
> > > > *LinkedIn: **http://fr.linkedin.com/in/rmannibucau*
> > > > *Github: https://github.com/rmannibucau*
> > > >
> > > >
> > > >
> > > > 2013/7/1 James Green <ja...@gmail.com>
> > > >
> > > > > I've suppressed the RuntimeExceptions encountered as EJBs fire and
> > > access
> > > > > JPA, however I have a new problem now:
> > > > >
> > > > > Caused by: <openjpa-2.2.0-r422266:1244990 nonfatal user error>
> > > > > org.apache.openjpa.persistence.ArgumentException: An error occurred
> > > while
> > > > > parsing the query filter "SELECT a FROM Account a". Error message:
> > The
> > > > name
> > > > > "Account" is not a recognized entity or identifier. Known entity
> > names:
> > > > []
> > > > >
> > > > > It seems the JPA component was unable to map my @Entity classes
> > because
> > > > the
> > > > > connection did not exist at startup. What do I need to do to work
> > > around
> > > > > this?
> > > > >
> > > > >
> > > > >
> > > > > On 1 July 2013 12:07, Romain Manni-Bucau <rm...@gmail.com>
> > > wrote:
> > > > >
> > > > > > yep
> > > > > >
> > > > > >
> > > > > > basically get injected the timerservice (
> > > > > > http://docs.oracle.com/javaee/6/api/javax/ejb/TimerService.html
> ),
> > in
> > > > > your
> > > > > > init method you try to get your data, if not trigger a later
> > > > > > invocation (
> > > > > >
> > > > >
> > > >
> > >
> >
> http://docs.oracle.com/javaee/6/api/javax/ejb/TimerService.html#createSingleActionTimer(java.util.Date
> > > > > > ,
> > > > > > javax.ejb.TimerConfig)). While it fails trigger another one when
> > > > invoked.
> > > > > > When it succeeds you are done.
> > > > > >
> > > > > > *Romain Manni-Bucau*
> > > > > > *Twitter: @rmannibucau <https://twitter.com/rmannibucau>*
> > > > > > *Blog: **http://rmannibucau.wordpress.com/*<
> > > > > > http://rmannibucau.wordpress.com/>
> > > > > > *LinkedIn: **http://fr.linkedin.com/in/rmannibucau*
> > > > > > *Github: https://github.com/rmannibucau*
> > > > > >
> > > > > >
> > > > > >
> > > > > > 2013/7/1 James Green <ja...@gmail.com>
> > > > > >
> > > > > > > In our case we have two EJBs, both @Singleton and @Startup, one
> > > > depends
> > > > > > on
> > > > > > > the other. One is a cache façade and the other loads data via
> JPA
> > > and
> > > > > > feeds
> > > > > > > it into the cache. An external schedule fires a servlet that
> > > reloads
> > > > > the
> > > > > > > cache from the database.
> > > > > > >
> > > > > > > What's happening is that without MySQL we see EJB exceptions
> that
> > > > they
> > > > > > > cannot be created and thus we are dead.
> > > > > > >
> > > > > > > I've just tried adding autoReconnect=true inside a <Resource>
> but
> > > > that
> > > > > > made
> > > > > > > no difference. I also tried adding ,autoReconnect=true to
> > > > > > > ConnectionProperties and ConnectionFactoryProperties without
> any
> > > > change
> > > > > > but
> > > > > > > I'm not convinced that would have fixed the problem here.
> > > > > > >
> > > > > > > Is it instead the case that within the EJB I should be trapping
> > > > > > > connectivity problems such as PersistenceException and allowing
> > the
> > > > > > > containing to gracefully start up and naturally keep trying
> > anyway?
> > > > > > >
> > > > > > > James
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > On 28 June 2013 17:10, José Luis Cetina <ma...@gmail.com>
> > > > wrote:
> > > > > > >
> > > > > > > > I had a similar problem and what i did was set the
> > autoReconnect
> > > > > > > attribute
> > > > > > > > to true en my tomee.xml datasource.
> > > > > > > > What do you mean with retry until the connection springs to
> > life?
> > > > do
> > > > > > you
> > > > > > > > have some schedules or jobs running and want to retry again
> > when
> > > > the
> > > > > > > > connection is available again? or just want when somebody
> click
> > > any
> > > > > > > button
> > > > > > > > the app can connect again (this was my case)??
> > > > > > > >
> > > > > > > >
> > > > > > > > 2013/6/28 Romain Manni-Bucau <rm...@gmail.com>
> > > > > > > >
> > > > > > > > > With an ejb timer?
> > > > > > > > > Le 28 juin 2013 17:46, "James Green" <
> > james.mk.green@gmail.com
> > > >
> > > > a
> > > > > > > écrit
> > > > > > > > :
> > > > > > > > >
> > > > > > > > > > Hopefully a quick one.
> > > > > > > > > >
> > > > > > > > > > On boot our application attempts to read data through a
> JPA
> > > > > > > > > EntityManager.
> > > > > > > > > > If the database connection fails at this point the entire
> > > > > > application
> > > > > > > > is
> > > > > > > > > > effectively dead.
> > > > > > > > > >
> > > > > > > > > > Is there a way to essentially ask the database layer to
> > retry
> > > > > until
> > > > > > > the
> > > > > > > > > > connection springs to life?
> > > > > > > > > >
> > > > > > > > > > Thanks,
> > > > > > > > > >
> > > > > > > > > > James
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > --
> > > > > > > >
> > > -------------------------------------------------------------------
> > > > > > > > *SCJA. José Luis Cetina*
> > > > > > > >
> > > -------------------------------------------------------------------
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> >
> >
> > --
> > -------------------------------------------------------------------
> > *SCJA. José Luis Cetina*
> > -------------------------------------------------------------------
> >
>



-- 
-------------------------------------------------------------------
*SCJA. José Luis Cetina*
-------------------------------------------------------------------

Re: Reconnect if JPA fails at boot?

Posted by James Green <ja...@gmail.com>.
Are you saying your application starts from cold without the database, the
operates fine without intervention once the database becomes available?


On 1 July 2013 14:26, José Luis Cetina <ma...@gmail.com> wrote:

> I have also differents server, 1 one database and 2 for TomEE (using
> memcached + cluster) and with autoReconnect=true i dont have any issue when
> the database server reboot, i set this attribute (autoReconnect) after i
> experiment your same problems, when the database server rebooted my apps
> cant connect anymore to the database server, i had to stop and start tomee
> again for work. But then, i add that option and now i work with any
> problem.
>
> Here is a example of my Resource:
>
> <Resource id="ANY_NAME" type="DataSource">
>   JdbcDriver com.mysql.jdbc.Driver
>   JdbcUrl
>
> jdbc:mysql://any_ip:3306/any_database?zeroDateTimeBehavior=convertToNull&amp;rewriteBatchedStatements=true&amp;autoReconnect=true
>   UserName any_user
>   Password any_password
>   JtaManaged true
>   InitialSize=3
>   MaxActive=100
>   ValidationQuery=SELECT 1
>   TestOnBorrow=true
> </Resource>
>
>
>
>
>
> 2013/7/1 James Green <ja...@gmail.com>
>
> > This now sounds substantially more complex than my design (which uses
> > @PersistenceContext(unitName="accounts")) caters for. Is there an example
> > of what you mean somewhere so I can scope the work out?
> >
> > Thanks
> > James
> >
> >
> > On 1 July 2013 12:44, Romain Manni-Bucau <rm...@gmail.com> wrote:
> >
> > > Hi
> > >
> > > it depends your config and that's probably more an openjpa question but
> > > basically you'll need to provide the dictionnary to use since openjpa
> > will
> > > not be able to read database metadata (at least).
> > >
> > > *Romain Manni-Bucau*
> > > *Twitter: @rmannibucau <https://twitter.com/rmannibucau>*
> > > *Blog: **http://rmannibucau.wordpress.com/*<
> > > http://rmannibucau.wordpress.com/>
> > > *LinkedIn: **http://fr.linkedin.com/in/rmannibucau*
> > > *Github: https://github.com/rmannibucau*
> > >
> > >
> > >
> > > 2013/7/1 James Green <ja...@gmail.com>
> > >
> > > > I've suppressed the RuntimeExceptions encountered as EJBs fire and
> > access
> > > > JPA, however I have a new problem now:
> > > >
> > > > Caused by: <openjpa-2.2.0-r422266:1244990 nonfatal user error>
> > > > org.apache.openjpa.persistence.ArgumentException: An error occurred
> > while
> > > > parsing the query filter "SELECT a FROM Account a". Error message:
> The
> > > name
> > > > "Account" is not a recognized entity or identifier. Known entity
> names:
> > > []
> > > >
> > > > It seems the JPA component was unable to map my @Entity classes
> because
> > > the
> > > > connection did not exist at startup. What do I need to do to work
> > around
> > > > this?
> > > >
> > > >
> > > >
> > > > On 1 July 2013 12:07, Romain Manni-Bucau <rm...@gmail.com>
> > wrote:
> > > >
> > > > > yep
> > > > >
> > > > >
> > > > > basically get injected the timerservice (
> > > > > http://docs.oracle.com/javaee/6/api/javax/ejb/TimerService.html),
> in
> > > > your
> > > > > init method you try to get your data, if not trigger a later
> > > > > invocation (
> > > > >
> > > >
> > >
> >
> http://docs.oracle.com/javaee/6/api/javax/ejb/TimerService.html#createSingleActionTimer(java.util.Date
> > > > > ,
> > > > > javax.ejb.TimerConfig)). While it fails trigger another one when
> > > invoked.
> > > > > When it succeeds you are done.
> > > > >
> > > > > *Romain Manni-Bucau*
> > > > > *Twitter: @rmannibucau <https://twitter.com/rmannibucau>*
> > > > > *Blog: **http://rmannibucau.wordpress.com/*<
> > > > > http://rmannibucau.wordpress.com/>
> > > > > *LinkedIn: **http://fr.linkedin.com/in/rmannibucau*
> > > > > *Github: https://github.com/rmannibucau*
> > > > >
> > > > >
> > > > >
> > > > > 2013/7/1 James Green <ja...@gmail.com>
> > > > >
> > > > > > In our case we have two EJBs, both @Singleton and @Startup, one
> > > depends
> > > > > on
> > > > > > the other. One is a cache façade and the other loads data via JPA
> > and
> > > > > feeds
> > > > > > it into the cache. An external schedule fires a servlet that
> > reloads
> > > > the
> > > > > > cache from the database.
> > > > > >
> > > > > > What's happening is that without MySQL we see EJB exceptions that
> > > they
> > > > > > cannot be created and thus we are dead.
> > > > > >
> > > > > > I've just tried adding autoReconnect=true inside a <Resource> but
> > > that
> > > > > made
> > > > > > no difference. I also tried adding ,autoReconnect=true to
> > > > > > ConnectionProperties and ConnectionFactoryProperties without any
> > > change
> > > > > but
> > > > > > I'm not convinced that would have fixed the problem here.
> > > > > >
> > > > > > Is it instead the case that within the EJB I should be trapping
> > > > > > connectivity problems such as PersistenceException and allowing
> the
> > > > > > containing to gracefully start up and naturally keep trying
> anyway?
> > > > > >
> > > > > > James
> > > > > >
> > > > > >
> > > > > >
> > > > > > On 28 June 2013 17:10, José Luis Cetina <ma...@gmail.com>
> > > wrote:
> > > > > >
> > > > > > > I had a similar problem and what i did was set the
> autoReconnect
> > > > > > attribute
> > > > > > > to true en my tomee.xml datasource.
> > > > > > > What do you mean with retry until the connection springs to
> life?
> > > do
> > > > > you
> > > > > > > have some schedules or jobs running and want to retry again
> when
> > > the
> > > > > > > connection is available again? or just want when somebody click
> > any
> > > > > > button
> > > > > > > the app can connect again (this was my case)??
> > > > > > >
> > > > > > >
> > > > > > > 2013/6/28 Romain Manni-Bucau <rm...@gmail.com>
> > > > > > >
> > > > > > > > With an ejb timer?
> > > > > > > > Le 28 juin 2013 17:46, "James Green" <
> james.mk.green@gmail.com
> > >
> > > a
> > > > > > écrit
> > > > > > > :
> > > > > > > >
> > > > > > > > > Hopefully a quick one.
> > > > > > > > >
> > > > > > > > > On boot our application attempts to read data through a JPA
> > > > > > > > EntityManager.
> > > > > > > > > If the database connection fails at this point the entire
> > > > > application
> > > > > > > is
> > > > > > > > > effectively dead.
> > > > > > > > >
> > > > > > > > > Is there a way to essentially ask the database layer to
> retry
> > > > until
> > > > > > the
> > > > > > > > > connection springs to life?
> > > > > > > > >
> > > > > > > > > Thanks,
> > > > > > > > >
> > > > > > > > > James
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > --
> > > > > > >
> > -------------------------------------------------------------------
> > > > > > > *SCJA. José Luis Cetina*
> > > > > > >
> > -------------------------------------------------------------------
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
>
>
>
> --
> -------------------------------------------------------------------
> *SCJA. José Luis Cetina*
> -------------------------------------------------------------------
>

Re: Reconnect if JPA fails at boot?

Posted by José Luis Cetina <ma...@gmail.com>.
I have also differents server, 1 one database and 2 for TomEE (using
memcached + cluster) and with autoReconnect=true i dont have any issue when
the database server reboot, i set this attribute (autoReconnect) after i
experiment your same problems, when the database server rebooted my apps
cant connect anymore to the database server, i had to stop and start tomee
again for work. But then, i add that option and now i work with any problem.

Here is a example of my Resource:

<Resource id="ANY_NAME" type="DataSource">
  JdbcDriver com.mysql.jdbc.Driver
  JdbcUrl
jdbc:mysql://any_ip:3306/any_database?zeroDateTimeBehavior=convertToNull&amp;rewriteBatchedStatements=true&amp;autoReconnect=true
  UserName any_user
  Password any_password
  JtaManaged true
  InitialSize=3
  MaxActive=100
  ValidationQuery=SELECT 1
  TestOnBorrow=true
</Resource>





2013/7/1 James Green <ja...@gmail.com>

> This now sounds substantially more complex than my design (which uses
> @PersistenceContext(unitName="accounts")) caters for. Is there an example
> of what you mean somewhere so I can scope the work out?
>
> Thanks
> James
>
>
> On 1 July 2013 12:44, Romain Manni-Bucau <rm...@gmail.com> wrote:
>
> > Hi
> >
> > it depends your config and that's probably more an openjpa question but
> > basically you'll need to provide the dictionnary to use since openjpa
> will
> > not be able to read database metadata (at least).
> >
> > *Romain Manni-Bucau*
> > *Twitter: @rmannibucau <https://twitter.com/rmannibucau>*
> > *Blog: **http://rmannibucau.wordpress.com/*<
> > http://rmannibucau.wordpress.com/>
> > *LinkedIn: **http://fr.linkedin.com/in/rmannibucau*
> > *Github: https://github.com/rmannibucau*
> >
> >
> >
> > 2013/7/1 James Green <ja...@gmail.com>
> >
> > > I've suppressed the RuntimeExceptions encountered as EJBs fire and
> access
> > > JPA, however I have a new problem now:
> > >
> > > Caused by: <openjpa-2.2.0-r422266:1244990 nonfatal user error>
> > > org.apache.openjpa.persistence.ArgumentException: An error occurred
> while
> > > parsing the query filter "SELECT a FROM Account a". Error message: The
> > name
> > > "Account" is not a recognized entity or identifier. Known entity names:
> > []
> > >
> > > It seems the JPA component was unable to map my @Entity classes because
> > the
> > > connection did not exist at startup. What do I need to do to work
> around
> > > this?
> > >
> > >
> > >
> > > On 1 July 2013 12:07, Romain Manni-Bucau <rm...@gmail.com>
> wrote:
> > >
> > > > yep
> > > >
> > > >
> > > > basically get injected the timerservice (
> > > > http://docs.oracle.com/javaee/6/api/javax/ejb/TimerService.html), in
> > > your
> > > > init method you try to get your data, if not trigger a later
> > > > invocation (
> > > >
> > >
> >
> http://docs.oracle.com/javaee/6/api/javax/ejb/TimerService.html#createSingleActionTimer(java.util.Date
> > > > ,
> > > > javax.ejb.TimerConfig)). While it fails trigger another one when
> > invoked.
> > > > When it succeeds you are done.
> > > >
> > > > *Romain Manni-Bucau*
> > > > *Twitter: @rmannibucau <https://twitter.com/rmannibucau>*
> > > > *Blog: **http://rmannibucau.wordpress.com/*<
> > > > http://rmannibucau.wordpress.com/>
> > > > *LinkedIn: **http://fr.linkedin.com/in/rmannibucau*
> > > > *Github: https://github.com/rmannibucau*
> > > >
> > > >
> > > >
> > > > 2013/7/1 James Green <ja...@gmail.com>
> > > >
> > > > > In our case we have two EJBs, both @Singleton and @Startup, one
> > depends
> > > > on
> > > > > the other. One is a cache façade and the other loads data via JPA
> and
> > > > feeds
> > > > > it into the cache. An external schedule fires a servlet that
> reloads
> > > the
> > > > > cache from the database.
> > > > >
> > > > > What's happening is that without MySQL we see EJB exceptions that
> > they
> > > > > cannot be created and thus we are dead.
> > > > >
> > > > > I've just tried adding autoReconnect=true inside a <Resource> but
> > that
> > > > made
> > > > > no difference. I also tried adding ,autoReconnect=true to
> > > > > ConnectionProperties and ConnectionFactoryProperties without any
> > change
> > > > but
> > > > > I'm not convinced that would have fixed the problem here.
> > > > >
> > > > > Is it instead the case that within the EJB I should be trapping
> > > > > connectivity problems such as PersistenceException and allowing the
> > > > > containing to gracefully start up and naturally keep trying anyway?
> > > > >
> > > > > James
> > > > >
> > > > >
> > > > >
> > > > > On 28 June 2013 17:10, José Luis Cetina <ma...@gmail.com>
> > wrote:
> > > > >
> > > > > > I had a similar problem and what i did was set the autoReconnect
> > > > > attribute
> > > > > > to true en my tomee.xml datasource.
> > > > > > What do you mean with retry until the connection springs to life?
> > do
> > > > you
> > > > > > have some schedules or jobs running and want to retry again when
> > the
> > > > > > connection is available again? or just want when somebody click
> any
> > > > > button
> > > > > > the app can connect again (this was my case)??
> > > > > >
> > > > > >
> > > > > > 2013/6/28 Romain Manni-Bucau <rm...@gmail.com>
> > > > > >
> > > > > > > With an ejb timer?
> > > > > > > Le 28 juin 2013 17:46, "James Green" <james.mk.green@gmail.com
> >
> > a
> > > > > écrit
> > > > > > :
> > > > > > >
> > > > > > > > Hopefully a quick one.
> > > > > > > >
> > > > > > > > On boot our application attempts to read data through a JPA
> > > > > > > EntityManager.
> > > > > > > > If the database connection fails at this point the entire
> > > > application
> > > > > > is
> > > > > > > > effectively dead.
> > > > > > > >
> > > > > > > > Is there a way to essentially ask the database layer to retry
> > > until
> > > > > the
> > > > > > > > connection springs to life?
> > > > > > > >
> > > > > > > > Thanks,
> > > > > > > >
> > > > > > > > James
> > > > > > > >
> > > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > > --
> > > > > >
> -------------------------------------------------------------------
> > > > > > *SCJA. José Luis Cetina*
> > > > > >
> -------------------------------------------------------------------
> > > > > >
> > > > >
> > > >
> > >
> >
>



-- 
-------------------------------------------------------------------
*SCJA. José Luis Cetina*
-------------------------------------------------------------------

Re: Reconnect if JPA fails at boot?

Posted by James Green <ja...@gmail.com>.
This now sounds substantially more complex than my design (which uses
@PersistenceContext(unitName="accounts")) caters for. Is there an example
of what you mean somewhere so I can scope the work out?

Thanks
James


On 1 July 2013 12:44, Romain Manni-Bucau <rm...@gmail.com> wrote:

> Hi
>
> it depends your config and that's probably more an openjpa question but
> basically you'll need to provide the dictionnary to use since openjpa will
> not be able to read database metadata (at least).
>
> *Romain Manni-Bucau*
> *Twitter: @rmannibucau <https://twitter.com/rmannibucau>*
> *Blog: **http://rmannibucau.wordpress.com/*<
> http://rmannibucau.wordpress.com/>
> *LinkedIn: **http://fr.linkedin.com/in/rmannibucau*
> *Github: https://github.com/rmannibucau*
>
>
>
> 2013/7/1 James Green <ja...@gmail.com>
>
> > I've suppressed the RuntimeExceptions encountered as EJBs fire and access
> > JPA, however I have a new problem now:
> >
> > Caused by: <openjpa-2.2.0-r422266:1244990 nonfatal user error>
> > org.apache.openjpa.persistence.ArgumentException: An error occurred while
> > parsing the query filter "SELECT a FROM Account a". Error message: The
> name
> > "Account" is not a recognized entity or identifier. Known entity names:
> []
> >
> > It seems the JPA component was unable to map my @Entity classes because
> the
> > connection did not exist at startup. What do I need to do to work around
> > this?
> >
> >
> >
> > On 1 July 2013 12:07, Romain Manni-Bucau <rm...@gmail.com> wrote:
> >
> > > yep
> > >
> > >
> > > basically get injected the timerservice (
> > > http://docs.oracle.com/javaee/6/api/javax/ejb/TimerService.html), in
> > your
> > > init method you try to get your data, if not trigger a later
> > > invocation (
> > >
> >
> http://docs.oracle.com/javaee/6/api/javax/ejb/TimerService.html#createSingleActionTimer(java.util.Date
> > > ,
> > > javax.ejb.TimerConfig)). While it fails trigger another one when
> invoked.
> > > When it succeeds you are done.
> > >
> > > *Romain Manni-Bucau*
> > > *Twitter: @rmannibucau <https://twitter.com/rmannibucau>*
> > > *Blog: **http://rmannibucau.wordpress.com/*<
> > > http://rmannibucau.wordpress.com/>
> > > *LinkedIn: **http://fr.linkedin.com/in/rmannibucau*
> > > *Github: https://github.com/rmannibucau*
> > >
> > >
> > >
> > > 2013/7/1 James Green <ja...@gmail.com>
> > >
> > > > In our case we have two EJBs, both @Singleton and @Startup, one
> depends
> > > on
> > > > the other. One is a cache façade and the other loads data via JPA and
> > > feeds
> > > > it into the cache. An external schedule fires a servlet that reloads
> > the
> > > > cache from the database.
> > > >
> > > > What's happening is that without MySQL we see EJB exceptions that
> they
> > > > cannot be created and thus we are dead.
> > > >
> > > > I've just tried adding autoReconnect=true inside a <Resource> but
> that
> > > made
> > > > no difference. I also tried adding ,autoReconnect=true to
> > > > ConnectionProperties and ConnectionFactoryProperties without any
> change
> > > but
> > > > I'm not convinced that would have fixed the problem here.
> > > >
> > > > Is it instead the case that within the EJB I should be trapping
> > > > connectivity problems such as PersistenceException and allowing the
> > > > containing to gracefully start up and naturally keep trying anyway?
> > > >
> > > > James
> > > >
> > > >
> > > >
> > > > On 28 June 2013 17:10, José Luis Cetina <ma...@gmail.com>
> wrote:
> > > >
> > > > > I had a similar problem and what i did was set the autoReconnect
> > > > attribute
> > > > > to true en my tomee.xml datasource.
> > > > > What do you mean with retry until the connection springs to life?
> do
> > > you
> > > > > have some schedules or jobs running and want to retry again when
> the
> > > > > connection is available again? or just want when somebody click any
> > > > button
> > > > > the app can connect again (this was my case)??
> > > > >
> > > > >
> > > > > 2013/6/28 Romain Manni-Bucau <rm...@gmail.com>
> > > > >
> > > > > > With an ejb timer?
> > > > > > Le 28 juin 2013 17:46, "James Green" <ja...@gmail.com>
> a
> > > > écrit
> > > > > :
> > > > > >
> > > > > > > Hopefully a quick one.
> > > > > > >
> > > > > > > On boot our application attempts to read data through a JPA
> > > > > > EntityManager.
> > > > > > > If the database connection fails at this point the entire
> > > application
> > > > > is
> > > > > > > effectively dead.
> > > > > > >
> > > > > > > Is there a way to essentially ask the database layer to retry
> > until
> > > > the
> > > > > > > connection springs to life?
> > > > > > >
> > > > > > > Thanks,
> > > > > > >
> > > > > > > James
> > > > > > >
> > > > > >
> > > > >
> > > > >
> > > > >
> > > > > --
> > > > > -------------------------------------------------------------------
> > > > > *SCJA. José Luis Cetina*
> > > > > -------------------------------------------------------------------
> > > > >
> > > >
> > >
> >
>

Re: Reconnect if JPA fails at boot?

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Hi

it depends your config and that's probably more an openjpa question but
basically you'll need to provide the dictionnary to use since openjpa will
not be able to read database metadata (at least).

*Romain Manni-Bucau*
*Twitter: @rmannibucau <https://twitter.com/rmannibucau>*
*Blog: **http://rmannibucau.wordpress.com/*<http://rmannibucau.wordpress.com/>
*LinkedIn: **http://fr.linkedin.com/in/rmannibucau*
*Github: https://github.com/rmannibucau*



2013/7/1 James Green <ja...@gmail.com>

> I've suppressed the RuntimeExceptions encountered as EJBs fire and access
> JPA, however I have a new problem now:
>
> Caused by: <openjpa-2.2.0-r422266:1244990 nonfatal user error>
> org.apache.openjpa.persistence.ArgumentException: An error occurred while
> parsing the query filter "SELECT a FROM Account a". Error message: The name
> "Account" is not a recognized entity or identifier. Known entity names: []
>
> It seems the JPA component was unable to map my @Entity classes because the
> connection did not exist at startup. What do I need to do to work around
> this?
>
>
>
> On 1 July 2013 12:07, Romain Manni-Bucau <rm...@gmail.com> wrote:
>
> > yep
> >
> >
> > basically get injected the timerservice (
> > http://docs.oracle.com/javaee/6/api/javax/ejb/TimerService.html), in
> your
> > init method you try to get your data, if not trigger a later
> > invocation (
> >
> http://docs.oracle.com/javaee/6/api/javax/ejb/TimerService.html#createSingleActionTimer(java.util.Date
> > ,
> > javax.ejb.TimerConfig)). While it fails trigger another one when invoked.
> > When it succeeds you are done.
> >
> > *Romain Manni-Bucau*
> > *Twitter: @rmannibucau <https://twitter.com/rmannibucau>*
> > *Blog: **http://rmannibucau.wordpress.com/*<
> > http://rmannibucau.wordpress.com/>
> > *LinkedIn: **http://fr.linkedin.com/in/rmannibucau*
> > *Github: https://github.com/rmannibucau*
> >
> >
> >
> > 2013/7/1 James Green <ja...@gmail.com>
> >
> > > In our case we have two EJBs, both @Singleton and @Startup, one depends
> > on
> > > the other. One is a cache façade and the other loads data via JPA and
> > feeds
> > > it into the cache. An external schedule fires a servlet that reloads
> the
> > > cache from the database.
> > >
> > > What's happening is that without MySQL we see EJB exceptions that they
> > > cannot be created and thus we are dead.
> > >
> > > I've just tried adding autoReconnect=true inside a <Resource> but that
> > made
> > > no difference. I also tried adding ,autoReconnect=true to
> > > ConnectionProperties and ConnectionFactoryProperties without any change
> > but
> > > I'm not convinced that would have fixed the problem here.
> > >
> > > Is it instead the case that within the EJB I should be trapping
> > > connectivity problems such as PersistenceException and allowing the
> > > containing to gracefully start up and naturally keep trying anyway?
> > >
> > > James
> > >
> > >
> > >
> > > On 28 June 2013 17:10, José Luis Cetina <ma...@gmail.com> wrote:
> > >
> > > > I had a similar problem and what i did was set the autoReconnect
> > > attribute
> > > > to true en my tomee.xml datasource.
> > > > What do you mean with retry until the connection springs to life? do
> > you
> > > > have some schedules or jobs running and want to retry again when the
> > > > connection is available again? or just want when somebody click any
> > > button
> > > > the app can connect again (this was my case)??
> > > >
> > > >
> > > > 2013/6/28 Romain Manni-Bucau <rm...@gmail.com>
> > > >
> > > > > With an ejb timer?
> > > > > Le 28 juin 2013 17:46, "James Green" <ja...@gmail.com> a
> > > écrit
> > > > :
> > > > >
> > > > > > Hopefully a quick one.
> > > > > >
> > > > > > On boot our application attempts to read data through a JPA
> > > > > EntityManager.
> > > > > > If the database connection fails at this point the entire
> > application
> > > > is
> > > > > > effectively dead.
> > > > > >
> > > > > > Is there a way to essentially ask the database layer to retry
> until
> > > the
> > > > > > connection springs to life?
> > > > > >
> > > > > > Thanks,
> > > > > >
> > > > > > James
> > > > > >
> > > > >
> > > >
> > > >
> > > >
> > > > --
> > > > -------------------------------------------------------------------
> > > > *SCJA. José Luis Cetina*
> > > > -------------------------------------------------------------------
> > > >
> > >
> >
>

Re: Reconnect if JPA fails at boot?

Posted by James Green <ja...@gmail.com>.
I've suppressed the RuntimeExceptions encountered as EJBs fire and access
JPA, however I have a new problem now:

Caused by: <openjpa-2.2.0-r422266:1244990 nonfatal user error>
org.apache.openjpa.persistence.ArgumentException: An error occurred while
parsing the query filter "SELECT a FROM Account a". Error message: The name
"Account" is not a recognized entity or identifier. Known entity names: []

It seems the JPA component was unable to map my @Entity classes because the
connection did not exist at startup. What do I need to do to work around
this?



On 1 July 2013 12:07, Romain Manni-Bucau <rm...@gmail.com> wrote:

> yep
>
>
> basically get injected the timerservice (
> http://docs.oracle.com/javaee/6/api/javax/ejb/TimerService.html), in your
> init method you try to get your data, if not trigger a later
> invocation (
> http://docs.oracle.com/javaee/6/api/javax/ejb/TimerService.html#createSingleActionTimer(java.util.Date
> ,
> javax.ejb.TimerConfig)). While it fails trigger another one when invoked.
> When it succeeds you are done.
>
> *Romain Manni-Bucau*
> *Twitter: @rmannibucau <https://twitter.com/rmannibucau>*
> *Blog: **http://rmannibucau.wordpress.com/*<
> http://rmannibucau.wordpress.com/>
> *LinkedIn: **http://fr.linkedin.com/in/rmannibucau*
> *Github: https://github.com/rmannibucau*
>
>
>
> 2013/7/1 James Green <ja...@gmail.com>
>
> > In our case we have two EJBs, both @Singleton and @Startup, one depends
> on
> > the other. One is a cache façade and the other loads data via JPA and
> feeds
> > it into the cache. An external schedule fires a servlet that reloads the
> > cache from the database.
> >
> > What's happening is that without MySQL we see EJB exceptions that they
> > cannot be created and thus we are dead.
> >
> > I've just tried adding autoReconnect=true inside a <Resource> but that
> made
> > no difference. I also tried adding ,autoReconnect=true to
> > ConnectionProperties and ConnectionFactoryProperties without any change
> but
> > I'm not convinced that would have fixed the problem here.
> >
> > Is it instead the case that within the EJB I should be trapping
> > connectivity problems such as PersistenceException and allowing the
> > containing to gracefully start up and naturally keep trying anyway?
> >
> > James
> >
> >
> >
> > On 28 June 2013 17:10, José Luis Cetina <ma...@gmail.com> wrote:
> >
> > > I had a similar problem and what i did was set the autoReconnect
> > attribute
> > > to true en my tomee.xml datasource.
> > > What do you mean with retry until the connection springs to life? do
> you
> > > have some schedules or jobs running and want to retry again when the
> > > connection is available again? or just want when somebody click any
> > button
> > > the app can connect again (this was my case)??
> > >
> > >
> > > 2013/6/28 Romain Manni-Bucau <rm...@gmail.com>
> > >
> > > > With an ejb timer?
> > > > Le 28 juin 2013 17:46, "James Green" <ja...@gmail.com> a
> > écrit
> > > :
> > > >
> > > > > Hopefully a quick one.
> > > > >
> > > > > On boot our application attempts to read data through a JPA
> > > > EntityManager.
> > > > > If the database connection fails at this point the entire
> application
> > > is
> > > > > effectively dead.
> > > > >
> > > > > Is there a way to essentially ask the database layer to retry until
> > the
> > > > > connection springs to life?
> > > > >
> > > > > Thanks,
> > > > >
> > > > > James
> > > > >
> > > >
> > >
> > >
> > >
> > > --
> > > -------------------------------------------------------------------
> > > *SCJA. José Luis Cetina*
> > > -------------------------------------------------------------------
> > >
> >
>

Re: Reconnect if JPA fails at boot?

Posted by Romain Manni-Bucau <rm...@gmail.com>.
yep


basically get injected the timerservice (
http://docs.oracle.com/javaee/6/api/javax/ejb/TimerService.html), in your
init method you try to get your data, if not trigger a later
invocation (http://docs.oracle.com/javaee/6/api/javax/ejb/TimerService.html#createSingleActionTimer(java.util.Date,
javax.ejb.TimerConfig)). While it fails trigger another one when invoked.
When it succeeds you are done.

*Romain Manni-Bucau*
*Twitter: @rmannibucau <https://twitter.com/rmannibucau>*
*Blog: **http://rmannibucau.wordpress.com/*<http://rmannibucau.wordpress.com/>
*LinkedIn: **http://fr.linkedin.com/in/rmannibucau*
*Github: https://github.com/rmannibucau*



2013/7/1 James Green <ja...@gmail.com>

> In our case we have two EJBs, both @Singleton and @Startup, one depends on
> the other. One is a cache façade and the other loads data via JPA and feeds
> it into the cache. An external schedule fires a servlet that reloads the
> cache from the database.
>
> What's happening is that without MySQL we see EJB exceptions that they
> cannot be created and thus we are dead.
>
> I've just tried adding autoReconnect=true inside a <Resource> but that made
> no difference. I also tried adding ,autoReconnect=true to
> ConnectionProperties and ConnectionFactoryProperties without any change but
> I'm not convinced that would have fixed the problem here.
>
> Is it instead the case that within the EJB I should be trapping
> connectivity problems such as PersistenceException and allowing the
> containing to gracefully start up and naturally keep trying anyway?
>
> James
>
>
>
> On 28 June 2013 17:10, José Luis Cetina <ma...@gmail.com> wrote:
>
> > I had a similar problem and what i did was set the autoReconnect
> attribute
> > to true en my tomee.xml datasource.
> > What do you mean with retry until the connection springs to life? do you
> > have some schedules or jobs running and want to retry again when the
> > connection is available again? or just want when somebody click any
> button
> > the app can connect again (this was my case)??
> >
> >
> > 2013/6/28 Romain Manni-Bucau <rm...@gmail.com>
> >
> > > With an ejb timer?
> > > Le 28 juin 2013 17:46, "James Green" <ja...@gmail.com> a
> écrit
> > :
> > >
> > > > Hopefully a quick one.
> > > >
> > > > On boot our application attempts to read data through a JPA
> > > EntityManager.
> > > > If the database connection fails at this point the entire application
> > is
> > > > effectively dead.
> > > >
> > > > Is there a way to essentially ask the database layer to retry until
> the
> > > > connection springs to life?
> > > >
> > > > Thanks,
> > > >
> > > > James
> > > >
> > >
> >
> >
> >
> > --
> > -------------------------------------------------------------------
> > *SCJA. José Luis Cetina*
> > -------------------------------------------------------------------
> >
>