Bug 779971 (SOA-2331) - It is not possible to use JpaSource using JCR API inside container
Summary: It is not possible to use JpaSource using JCR API inside container
Keywords:
Status: CLOSED NOTABUG
Alias: SOA-2331
Product: JBoss Enterprise SOA Platform 5
Classification: JBoss
Component: EDS
Version: 5.1.0.ER1
Hardware: Unspecified
OS: Unspecified
urgent
urgent
Target Milestone: ---
: ---
Assignee: Default User
QA Contact:
URL: http://jira.jboss.org/jira/browse/SOA...
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2010-09-20 12:43 UTC by Jiri Pechanec
Modified: 2010-09-21 14:16 UTC (History)
0 users

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2010-09-21 14:16:39 UTC
Type: Bug


Attachments (Terms of Use)
modeshape-config.xml (11.94 KB, text/xml)
2010-09-20 12:44 UTC, Jiri Pechanec
no flags Details


Links
System ID Private Priority Status Summary Last Updated
Red Hat Issue Tracker SOA-2331 0 None None None Never

Description Jiri Pechanec 2010-09-20 12:43:19 UTC
project_key: SOA

The following code used to access JCR repository ends with exception when configured to use JpaSource
	public static Repository getServerRepository(String repositoryName) {
		try {
			InitialContext ctx = new InitialContext();
			Repositories repositories = (Repositories) ctx.lookup("jcr/local");
			return repositories.getRepository(repositoryName);
		} catch (Exception e) {
			throw new RuntimeException(e);
		}
	}

-------------------------------------------
javax.persistence.PersistenceException: org.hibernate.PropertyAccessException: could not get a field value by reflection getter of org.modeshape.connector.store.jpa.util.StoreOptionEntity.name
org.jboss.soa.modeshape.jcr.client.RepositoryReferenceFactory.getServerRepository(RepositoryReferenceFactory.java:69) 
at org.jboss.soa.modeshape.jcr.client.RepositoryReferenceFactory.getRepository(RepositoryReferenceFactory.java:27) 
at org.jboss.soa.modeshape.qa.tests.MultiThreadTest.createRepositories(MultiThreadTest.java:40) 
24 lines not shown 

Caused by org.hibernate.PropertyAccessException: could not get a field value by reflection getter of org.modeshape.connector.store.jpa.util.StoreOptionEntity.name
org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException(AbstractEntityManagerImpl.java:614) 
at org.hibernate.ejb.AbstractEntityManagerImpl.persist(AbstractEntityManagerImpl.java:226) 
at org.modeshape.connector.store.jpa.util.StoreOptions.setOption(StoreOptions.java:120) 
at org.modeshape.connector.store.jpa.util.StoreOptions.setRootNodeUuid(StoreOptions.java:68) 
at org.modeshape.connector.store.jpa.JpaSource.getConnection(JpaSource.java:1137) 
at org.modeshape.graph.connector.RepositoryConnectionPool.newWrappedConnection(RepositoryConnectionPool.java:980) 
at org.modeshape.graph.connector.RepositoryConnectionPool.getConnection(RepositoryConnectionPool.java:831) 
at org.modeshape.repository.RepositoryLibrary.createConnection(RepositoryLibrary.java:558) 
at org.modeshape.graph.Graph.execute(Graph.java:278) 
at org.modeshape.graph.Graph$5.process(Graph.java:226) 
at org.modeshape.graph.request.RequestBuilder.verifyWorkspace(RequestBuilder.java:72) 
at org.modeshape.graph.Graph.useWorkspace(Graph.java:377) 
at org.modeshape.graph.Graph.getCurrentWorkspace(Graph.java:352) 
at org.modeshape.graph.Graph.getCurrentWorkspaceName(Graph.java:337) 
at org.modeshape.jcr.JcrRepository.<init>(JcrRepository.java:591) 
at org.modeshape.jcr.JcrEngine.doCreateJcrRepository(JcrEngine.java:304) 
at org.modeshape.jcr.JcrEngine.getRepository(JcrEngine.java:209) 
at org.modeshape.jboss.managed.JNDIManagedRepositories.getRepository(JNDIManagedRepositories.java:87) 
at org.jboss.soa.modeshape.jcr.client.RepositoryReferenceFactory.getServerRepository(RepositoryReferenceFactory.java:67) 
at org.jboss.soa.modeshape.jcr.client.RepositoryReferenceFactory.getRepository(RepositoryReferenceFactory.java:27) 
at org.jboss.soa.modeshape.qa.tests.MultiThreadTest.createRepositories(MultiThreadTest.java:40) 
24 lines not shown 

Caused by could not get a field value by reflection getter of org.modeshape.connector.store.jpa.util.StoreOptionEntity.name
org.hibernate.property.DirectPropertyAccessor$DirectGetter.get(DirectPropertyAccessor.java:58) 
at org.hibernate.tuple.entity.AbstractEntityTuplizer.getIdentifier(AbstractEntityTuplizer.java:199) 
at org.hibernate.persister.entity.AbstractEntityPersister.getIdentifier(AbstractEntityPersister.java:3606) 
at org.hibernate.persister.entity.AbstractEntityPersister.isTransient(AbstractEntityPersister.java:3322) 
at org.hibernate.engine.ForeignKeys.isTransient(ForeignKeys.java:204) 
at org.hibernate.event.def.AbstractSaveEventListener.getEntityState(AbstractSaveEventListener.java:535) 
at org.hibernate.event.def.DefaultPersistEventListener.onPersist(DefaultPersistEventListener.java:93) 
at org.hibernate.event.def.DefaultPersistEventListener.onPersist(DefaultPersistEventListener.java:61) 
at org.hibernate.impl.SessionImpl.firePersist(SessionImpl.java:647) 
at org.hibernate.impl.SessionImpl.persist(SessionImpl.java:621) 
at org.hibernate.impl.SessionImpl.persist(SessionImpl.java:625) 
at org.hibernate.ejb.AbstractEntityManagerImpl.persist(AbstractEntityManagerImpl.java:220) 
at org.modeshape.connector.store.jpa.util.StoreOptions.setOption(StoreOptions.java:120) 
at org.modeshape.connector.store.jpa.util.StoreOptions.setRootNodeUuid(StoreOptions.java:68) 
at org.modeshape.connector.store.jpa.JpaSource.getConnection(JpaSource.java:1137) 
at org.modeshape.graph.connector.RepositoryConnectionPool.newWrappedConnection(RepositoryConnectionPool.java:980) 
at org.modeshape.graph.connector.RepositoryConnectionPool.getConnection(RepositoryConnectionPool.java:831) 
at org.modeshape.repository.RepositoryLibrary.createConnection(RepositoryLibrary.java:558) 
at org.modeshape.graph.Graph.execute(Graph.java:278) 
at org.modeshape.graph.Graph$5.process(Graph.java:226) 
at org.modeshape.graph.request.RequestBuilder.verifyWorkspace(RequestBuilder.java:72) 
at org.modeshape.graph.Graph.useWorkspace(Graph.java:377) 
at org.modeshape.graph.Graph.getCurrentWorkspace(Graph.java:352) 
at org.modeshape.graph.Graph.getCurrentWorkspaceName(Graph.java:337) 
at org.modeshape.jcr.JcrRepository.<init>(JcrRepository.java:591) 
at org.modeshape.jcr.JcrEngine.doCreateJcrRepository(JcrEngine.java:304) 
at org.modeshape.jcr.JcrEngine.getRepository(JcrEngine.java:209) 
at org.modeshape.jboss.managed.JNDIManagedRepositories.getRepository(JNDIManagedRepositories.java:87) 
at org.jboss.soa.modeshape.jcr.client.RepositoryReferenceFactory.getServerRepository(RepositoryReferenceFactory.java:67) 
at org.jboss.soa.modeshape.jcr.client.RepositoryReferenceFactory.getRepository(RepositoryReferenceFactory.java:27) 
at org.jboss.soa.modeshape.qa.tests.MultiThreadTest.createRepositories(MultiThreadTest.java:40) 
24 lines not shown 

Caused by Can not set java.lang.String field org.modeshape.connector.store.jpa.util.StoreOptionEntity.name to org.modeshape.connector.store.jpa.util.StoreOptionEntity
sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:146) 
at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:150) 
at sun.reflect.UnsafeFieldAccessorImpl.ensureObj(UnsafeFieldAccessorImpl.java:37) 
at sun.reflect.UnsafeObjectFieldAccessorImpl.get(UnsafeObjectFieldAccessorImpl.java:18) 
at java.lang.reflect.Field.get(Field.java:358) 
at org.hibernate.property.DirectPropertyAccessor$DirectGetter.get(DirectPropertyAccessor.java:55) 
at org.hibernate.tuple.entity.AbstractEntityTuplizer.getIdentifier(AbstractEntityTuplizer.java:199) 
at org.hibernate.persister.entity.AbstractEntityPersister.getIdentifier(AbstractEntityPersister.java:3606) 
at org.hibernate.persister.entity.AbstractEntityPersister.isTransient(AbstractEntityPersister.java:3322) 
at org.hibernate.engine.ForeignKeys.isTransient(ForeignKeys.java:204) 
at org.hibernate.event.def.AbstractSaveEventListener.getEntityState(AbstractSaveEventListener.java:535) 
at org.hibernate.event.def.DefaultPersistEventListener.onPersist(DefaultPersistEventListener.java:93) 
at org.hibernate.event.def.DefaultPersistEventListener.onPersist(DefaultPersistEventListener.java:61) 
at org.hibernate.impl.SessionImpl.firePersist(SessionImpl.java:647) 
at org.hibernate.impl.SessionImpl.persist(SessionImpl.java:621) 
at org.hibernate.impl.SessionImpl.persist(SessionImpl.java:625) 
at org.hibernate.ejb.AbstractEntityManagerImpl.persist(AbstractEntityManagerImpl.java:220) 
at org.modeshape.connector.store.jpa.util.StoreOptions.setOption(StoreOptions.java:120) 
at org.modeshape.connector.store.jpa.util.StoreOptions.setRootNodeUuid(StoreOptions.java:68) 
at org.modeshape.connector.store.jpa.JpaSource.getConnection(JpaSource.java:1137) 
at org.modeshape.graph.connector.RepositoryConnectionPool.newWrappedConnection(RepositoryConnectionPool.java:980) 
at org.modeshape.graph.connector.RepositoryConnectionPool.getConnection(RepositoryConnectionPool.java:831) 
at org.modeshape.repository.RepositoryLibrary.createConnection(RepositoryLibrary.java:558) 
at org.modeshape.graph.Graph.execute(Graph.java:278) 
at org.modeshape.graph.Graph$5.process(Graph.java:226) 
at org.modeshape.graph.request.RequestBuilder.verifyWorkspace(RequestBuilder.java:72) 
at org.modeshape.graph.Graph.useWorkspace(Graph.java:377) 
at org.modeshape.graph.Graph.getCurrentWorkspace(Graph.java:352) 
at org.modeshape.graph.Graph.getCurrentWorkspaceName(Graph.java:337) 
at org.modeshape.jcr.JcrRepository.<init>(JcrRepository.java:591) 
at org.modeshape.jcr.JcrEngine.doCreateJcrRepository(JcrEngine.java:304) 
at org.modeshape.jcr.JcrEngine.getRepository(JcrEngine.java:209) 
at org.modeshape.jboss.managed.JNDIManagedRepositories.getRepository(JNDIManagedRepositories.java:87) 
at org.jboss.soa.modeshape.jcr.client.RepositoryReferenceFactory.getServerRepository(RepositoryReferenceFactory.java:67) 
at org.jboss.soa.modeshape.jcr.client.RepositoryReferenceFactory.getRepository(RepositoryReferenceFactory.java:27) 
at org.jboss.soa.modeshape.qa.tests.MultiThreadTest.createRepositories(MultiThreadTest.java:40)

Repository configuration is attached

Comment 1 Jiri Pechanec 2010-09-20 12:44:21 UTC
Attachment: Added: modeshape-config.xml


Comment 2 Van Halbert 2010-09-20 15:26:45 UTC
see:  http://docs.jboss.org/modeshape/2.2.0.Final/manuals/reference/html_single/reference-guide-en.html

Section 9.2 for a coding example.   And the URL to use should be:   jndi:jcr/local?repositoryName=repository    (section 9.2.2 for details).

Comment 3 Jiri Pechanec 2010-09-20 18:47:01 UTC
I tried code
                        Map parameters = new HashMap();
                        parameters.put("org.modeshape.jcr.URL", "jndi:jcr/local?repositoryName=" + repositoryName);
                        RepositoryFactory factory = new JcrRepositoryFactory();
                        return factory.getRepository(parameters);

The results is same as in description

Comment 4 Van Halbert 2010-09-20 19:04:34 UTC
Need to use the ServiceLoader:

Repository repository = null;

for (RepositoryFactory factory : ServiceLoader.load(RepositoryFactory.class)) {

    repository = factory.getRepository(parameters);

    if (repository != null) break;

}

Comment 5 Jiri Pechanec 2010-09-20 19:14:26 UTC
                        Map<String, String> parameters = new HashMap<String, String>();
                        parameters.put("org.modeshape.jcr.URL", "jndi:jcr/local?repositoryName=" + repositoryName);
                        Repository repository = null;
                        for (RepositoryFactory aFactory : ServiceLoader.load(RepositoryFactory.class)) {
                                repository = aFactory.getRepository(parameters);
                                if (repository != null) {
                                        return repository;
                                }
                        }
                        return null;

Same issue :-(

Comment 6 Van Halbert 2010-09-20 20:16:15 UTC
Found this:  http://jira.codehaus.org/browse/GROOVY-3122    which indicates is could be a class loading issue.   

As for the version, I'm changing ModeShape to use 3.3.2-CP03 and we'll see what happens with the integration tests tonight.

Comment 7 Van Halbert 2010-09-20 20:58:23 UTC
Link: Added: This issue depends MODE-901


Comment 8 Jiri Pechanec 2010-09-21 14:16:21 UTC
Solved as classloading issue with TestNG


Note You need to log in before you can comment on or make changes to this bug.