Account Options

  1. Sign in
Google Groups Home
« Groups Home
java.lang.RuntimeException: Unable to replace JPACallbackHandler - Unit Testing
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  3 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Thierry Golvanig  
View profile  
 More options Dec 11 2009, 7:29 am
From: Thierry Golvanig <golva...@gmail.com>
Date: Fri, 11 Dec 2009 04:29:42 -0800 (PST)
Local: Fri, Dec 11 2009 7:29 am
Subject: java.lang.RuntimeException: Unable to replace JPACallbackHandler - Unit Testing
Hi All,

I am trying to write a bunch of tests with JUNIT for my JDO classes.

The package works when integrated in a appengine web application, but
I get a RunTimeException when testing in a Junit 'environment'.

I started with the JDODataSourceConfigTest source file in the
appengine test directory.
and It's ok with nothing included.

Then I tried to store some data within the two methods implemented:

 public void testTransactionalPMF() {
    JDOPersistenceManagerFactory pmf = (JDOPersistenceManagerFactory)
JDOHelper
        .getPersistenceManagerFactory("transactional");
    DatastoreManager storeMgr = (DatastoreManager) pmf.getStoreManager
();
    JDOPersistenceManager pm = (JDOPersistenceManager)
pmf.getPersistenceManager();
    // assertTrue(storeMgr.connectionFactoryIsTransactional());

    DomainGAE domain = new DomainGAE("Name", "Description");

    Transaction tx = pm.currentTransaction();
    try {
      tx.begin();
      pm.makePersistent(domain);
      tx.commit();
    } catch (Exception e) {
      System.out.println("Exception e: " + e);
      e.printStackTrace();

      if (tx != null) {
        tx.rollback();
      }
    }

    pm.close();
    pmf.close();
  }

-------------------------------

DomainGAE  is a simple Class

import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;
import com.google.appengine.api.datastore.Key;
import com.google.appengine.api.datastore.KeyFactory;
import ....

@PersistenceCapable(table = "domain", detachable = "true")
public class DomainGAE implements Domain {
  @PrimaryKey
  @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
  private Key id;

  protected String name = null;
  protected String description = null;

  public DomainGAE(String name, String description) {
    this.name = name;
    this.description = description;
  }

.....

}

Here is the error and the stackTrace:
Exception e: java.lang.RuntimeException: Unable to replace
JPACallbackHandler.
java.lang.RuntimeException: Unable to replace JPACallbackHandler.
        at
org.datanucleus.store.appengine.DatastorePluginRegistry.getExtensionPoint
(DatastorePluginRegistry.java:67)
        at org.datanucleus.plugin.PluginManager.getExtensionPoint
(PluginManager.java:65)
        at
org.datanucleus.plugin.PluginManager.getConfigurationElementForExtension
(PluginManager.java:113)
        at org.datanucleus.plugin.PluginManager.getAttributeValueForExtension
(PluginManager.java:230)
        at org.datanucleus.ObjectManagerImpl.getCallbackHandler
(ObjectManagerImpl.java:3804)
        at org.datanucleus.state.AbstractStateManager.getCallbackHandler
(AbstractStateManager.java:160)
        at
org.datanucleus.state.JDOStateManagerImpl.initialiseForPersistentNew
(JDOStateManagerImpl.java:466)
        at
org.datanucleus.state.StateManagerFactory.newStateManagerForPersistentNew
(StateManagerFactory.java:151)
        at org.datanucleus.ObjectManagerImpl.persistObjectInternal
(ObjectManagerImpl.java:1297)
        at org.datanucleus.ObjectManagerImpl.persistObject
(ObjectManagerImpl.java:1175)
        at org.datanucleus.jdo.JDOPersistenceManager.jdoMakePersistent
(JDOPersistenceManager.java:669)
        at org.datanucleus.jdo.JDOPersistenceManager.makePersistent
(JDOPersistenceManager.java:694)
        at
com.golvanig.projteam.JDODataSourceConfigTest.testNonTransactionalPMF
(JDODataSourceConfigTest.java:65)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke
(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke
(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at junit.framework.TestCase.runTest(TestCase.java:168)
        at junit.framework.TestCase.runBare(TestCase.java:134)
        at junit.framework.TestResult$1.protect(TestResult.java:110)
        at junit.framework.TestResult.runProtected(TestResult.java:128)
        at junit.framework.TestResult.run(TestResult.java:113)
        at junit.framework.TestCase.run(TestCase.java:124)
        at junit.framework.TestSuite.runTest(TestSuite.java:232)
        at junit.framework.TestSuite.run(TestSuite.java:227)
        at org.junit.internal.runners.JUnit38ClassRunner.run
(JUnit38ClassRunner.java:83)
        at org.apache.maven.surefire.junit4.JUnit4TestSet.execute
(JUnit4TestSet.java:62)
        at
org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet
(AbstractDirectoryTestSuite.java:140)
        at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute
(AbstractDirectoryTestSuite.java:127)
        at org.apache.maven.surefire.Surefire.run(Surefire.java:177)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke
(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke
(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess
(SurefireBooter.java:345)
        at org.apache.maven.surefire.booter.SurefireBooter.main
(SurefireBooter.java:1009)
Tests run: 2, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.104
sec <<< FAILURE!

I did the test with maven and also directly with junit by providing
the lib from 1.2.8
Results are the same.

I tried to extends JDODataSourceConfigTest from LocalServiceTestCase
or LocalDatastoreTestCase (http://code.google.com/appengine/docs/java/
howto/unittesting.html)
but I got the same error.

I am sure I forgot something, but I can't figure what.

Does anyone has an hint?
Thanks


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Max Ross (Google)  
View profile  
 More options Dec 11 2009, 12:59 pm
From: "Max Ross (Google)" <maxr+appeng...@google.com>
Date: Fri, 11 Dec 2009 09:59:41 -0800
Local: Fri, Dec 11 2009 12:59 pm
Subject: Re: [appengine-java] java.lang.RuntimeException: Unable to replace JPACallbackHandler - Unit Testing

I suspect datanucleus-jpa-1.1.5.jar isn't on your classpath.  Is that
possible?

On Fri, Dec 11, 2009 at 4:29 AM, Thierry Golvanig <golva...@gmail.com>wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Thierry Golvanig  
View profile  
 More options Dec 15 2009, 9:50 am
From: Thierry Golvanig <golva...@gmail.com>
Date: Tue, 15 Dec 2009 06:50:43 -0800 (PST)
Local: Tues, Dec 15 2009 9:50 am
Subject: Re: java.lang.RuntimeException: Unable to replace JPACallbackHandler - Unit Testing
Thank you Max.
Yes, I didn't include correctly datanucleus-jpa-1.1.5.jar in the
classpath.
It works now! That's perfect.

On Dec 11, 6:59 pm, "Max Ross (Google)" <maxr+appeng...@google.com>
wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »