Dimitry,

that's a nice mystery...

"final" on PMF doesn't seem to make a difference here. "static"
members are implicitly "final" too, by the way ("static" and "static
final" is equivalent). Class type inititialization (and thus static
field initialization) is implicitly synchronized, so no worry there
either (see http://en.wikipedia.org/wiki/Singleton_pattern).

With lazy initialization you could at least intercept and log a stack
trace... maybe that would give you a hint.


On Aug 7, 11:49 pm, dimi <dimitri.beck...@gmail.com> wrote:
> Hello guys,
>
> I've got an app running for 1.3 months now, without any problem...
>
> Until today, just before 3PM (GMT+2) my app stopped serving all queries from
> kind A.
> All the other kinds (B, C, D,...) still worked.
>
> When I looked it up in the logs, I found this error multiple times when
> querying kind A.
>
> javax.jdo.JDOFatalUserException: Application code attempted to create a
> PersistenceManagerFactory named transactions-optional, but one with this
> name already exists!  Instances of PersistenceManagerFactory are extremely
> slow to create and it is usually not necessary to create one with a given
> name more than once.  Instead, create a singleton and share it throughout
> your code.  If you really do need to create a duplicate
> PersistenceManagerFactory (such as for a unittest suite), set the
> appengine.orm.disable.duplicate.pmf.exception system property to avoid this
> error.
>
> The problem is obvious you say?
> It would be, but I already use a Singleton. (And I searched my source
> files.. I never create more than one instance!)
>
> I'm using this code (it comes out of the JDO Google documentation):
>
> import javax.jdo.JDOHelper;
> import javax.jdo.PersistenceManagerFactory;
>
> public final class PMF {
>     private static final PersistenceManagerFactory pmfInstance =
>         JDOHelper.getPersistenceManagerFactory("transactions-optional");
>
>     private PMF() {}
>
>     public static PersistenceManagerFactory get() {
>         return pmfInstance;
>     }
>
> }
>
> I did define my app as <threadsafe>true</threadsafe> so could I be a lucky
> lottery winner? Meaning that the pmfInstance was set twice on exactly the
> same moment? Should I put it in a synchronised block? Or should I use this
> code?
>
> public class PMF
> {
> private static final PersistenceManagerFactory pmfInstance =
> JDOHelper.getPersistenceManagerFactory("transactions-optional");
>
>     private PMF() {}
>
>     public static PersistenceManagerFactory getInstance()
>     {
>         return pmfInstance;
>     }
>
> }
>
> But, it does not explain why I only had problems while executing queries of
> kind A.. The other queries over other kinds still worked.
>
> Unfortunately, I discovered the problem 4 hours later and the problem was
> still accurate. Only disabling the app killed all running java instances and
> solved my problem.
>
> Any ideas what could have caused this?
>
> Thnx!
>
> Dimitri

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine for Java" group.
To post to this group, send email to google-appengine-java@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.

Reply via email to