Announcement Announcement Module
Collapse
No announcement yet.
ClassCastException while registering new node types on JBoss 4.2 Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • ClassCastException while registering new node types on JBoss 4.2

    Hello,

    I have problem with registring custom node types on JBoss with se-jcr and JackRabbit 1.5.6. I get the class cast expection (java.lang.ClassCastException: org.apache.jackrabbit.core.nodetype.NodeTypeManage rImpl cannot be cast to org.apache.jackrabbit.api.JackrabbitNodeTypeManage r - full stack trace below)

    That is what I have done:

    1. I have followed the JackRabbit installation instruction on JBoss (http://wiki.apache.org/jackrabbit/JackrabbitOnJBoss). The repository is installed correctly (for example JCR-Explorer can connect easily).
    2. my sessionFactory configuration with a try to registry a new node:

    Code:
    <bean id="jcrSessionFactory"
    	class="org.springframework.extensions.jcr.jackrabbit.JackrabbitSessionFactory">
    		<property name="repository" ref="repository" />
    		<property name="nodeDefinitions">
    			<list>
    				<value>classpath:/cfg/jcr/newNode.cnd</value>
    			</list>
    		</property>
    
    		<property name="credentials">
    			<bean class="javax.jcr.SimpleCredentials">
    				<constructor-arg index="0" value="zdzislaw" />
    				<constructor-arg index="1">
    					<bean factory-bean="password" factory-method="toCharArray" />
    				</constructor-arg>
    			</bean>
    		</property>
    	</bean>
    	<bean id="password" class="java.lang.String">
    		<constructor-arg index="0" value="Krecina" />
    	</bean>
    3. I access the repository via jndi
    Code:
    <bean id="repository" class="org.springframework.jndi.JndiObjectFactoryBean">
    		<property name="jndiName">
    			<value>java:jcr/local</value>
    		</property>
    	</bean>
    the problem occours only when I try to register new Node types, via configuration or via code:

    Code:
    public class ProductDao extends JcrDaoSupport {
    
    	public void createNodeType() {
    		Session session = getSession();
    
    		if (session == null) {
    			throw new NullPointerException(
    					"Jackrabbit repository session is not accessible");
    		}
    
    		Workspace workspace = session.getWorkspace();
    		if (workspace == null) {
    			throw new NullPointerException(
    					"Jackrabbit repository workspace is not accessible");
    		}
    
    		NodeTypeManager manager = null;
    		try {
    			manager = workspace.getNodeTypeManager();
    			}
    		} catch (RepositoryException e1) {
    			// TODO mm Auto-generated catch block
    			e1.printStackTrace();
    		}
    		 if (!(manager instanceof JackrabbitNodeTypeManager)) {
                     //always thrown!
    		 throw new ClassCastException(
    		 "NodeTypeManager is not JackrabbitNodeTypeManager");
    		 }
             }
    }
    If I start the "local" repository like this:

    Code:
    <bean id="repository"
    	class="org.springframework.extensions.jcr.jackrabbit.RepositoryFactoryBean">
    		<property name="configuration"
    		value="classpath:jackrabbit-repository.xml" /> 
    </bean>
    the problem is gone so I suspect that there is something wrong with the JBoss installation or configuration. Can someone, please, help me?

    Code:
    java.lang.ClassCastException: org.apache.jackrabbit.core.nodetype.NodeTypeManagerImpl cannot be cast to org.apache.jackrabbit.api.JackrabbitNodeTypeManager
    	at org.springframework.extensions.jcr.jackrabbit.JackrabbitSessionFactory.registerNodeTypes(JackrabbitSessionFactory.java:55)
    	at org.springframework.extensions.jcr.JcrSessionFactory.afterPropertiesSet(JcrSessionFactory.java:141)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1369)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1335)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:473)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
    	at java.security.AccessController.doPrivileged(Native Method)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
    	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)
    	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
    	at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:671)
    	at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:610)
    	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredMethodElement.inject(AutowiredAnnotationBeanPostProcessor.java:499)
    	at org.springframework.beans.factory.annotation.InjectionMetadata.injectMethods(InjectionMetadata.java:117)
    	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:253)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:998)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:472)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
    	at java.security.AccessController.doPrivileged(Native Method)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
    	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)
    	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
    	at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:671)
    	at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:610)
    	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:412)
    	at org.springframework.beans.factory.annotation.InjectionMetadata.injectFields(InjectionMetadata.java:105)
    	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessAfterInstantiation(AutowiredAnnotationBeanPostProcessor.java:240)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:959)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:472)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
    	at java.security.AccessController.doPrivileged(Native Method)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
    	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)
    	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
    	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:429)
    	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:728)
    	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:380)
    	at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:402)
    	at [...]

  • #2
    I know this answer is a bit late but I just stumbled on this thread while searching for something different. Anyway I was able to get the NodeTypeManager from the JackRabbit 1.6 repository I deployed in JBoss as described on JackrabbitOnJBoss by modifying the org.apache.jackrabbit.rmi.server.jmx.JCRServer class . The class is located in the jcr-rmi JAR and the only line in modified was in the start() method. Look for the line

    RemoteAdapterFactory factory = new ServerAdapterFactory();

    and change it to

    RemoteAdapterFactory factory = new JackrabbitServerAdapterFactory();

    If your IDE doesn't do it automagically for you then you must also change the import statements so that it imports the org.apache.jackrabbit.rmi.jackrabbit.JackrabbitSer verAdapterFactory class

    After deploying the modified jcr-rmi JAR i was able to add new NodeTypes and invoke other JackRabbit specific stuff.

    I'm not sure this is a good way to solve the problem and if it might cause other problems but it at least it solved my NodeTypeManager problems.

    /PorkLip
    Last edited by PorkLip; Feb 23rd, 2010, 12:17 PM.

    Comment

    Working...
    X