Home > Java, JBoss, Seam, WebLogic > Error loading element EntityTransaction with component name null and component class null

Error loading element EntityTransaction with component name null and component class null

The exception java.lang.RuntimeException: Error loading element EntityTransaction with component name null and component class null is caused by this line

<transaction:entity-transaction entity-manager="#{entityManager}"/>

in the components.xml file. In order to fix the error you have to replace the

   <persistence:managed-persistence-context name="entityManager" auto-create="true" persistence-unit-jndi-name="java:/myManagerFactory"/>

with

   <persistence:entity-manager-factory name="entityManagerFactory" persistence-unit-name="myPersistenceUnit"/>
   <persistence:managed-persistence-context name="entityManager" auto-create="true" entity-manager-factory="#{entityManagerFactory}" />

and remove the

<transaction:entity-transaction entity-manager="#{entityManager}"/>

line.

The myPersistenceUnit is the name of the persistence unit in persistence.xml

<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence" 
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd" 
             version="1.0">
             
   <persistence-unit name="myPersistenceUnit" transaction-type="RESOURCE_LOCAL">
      <provider>org.hibernate.ejb.HibernatePersistence</provider>

      <jta-data-source>myDatasource</jta-data-source>

      <properties>
         <property name="hibernate.connection.provider_class" value="org.hibernate.connection.DatasourceConnectionProvider"/>
	   <property name="hibernate.connection.datasource" value="myDatasource"/>
	   <property name="transaction.factory_class" value="org.hibernate.transaction.JTATransactionFactory"/>
	   <property name="hibernate.cache.provider_class" value="org.hibernate.cache.HashtableCacheProvider"/>
	   <property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.WeblogicTransactionManagerLookup"/>
         <property name="hibernate.dialect" value="gr.my.company.util.MyAS400Dialect"/>
         <property name="hibernate.hbm2ddl.auto" value="validate"/>
         <property name="hibernate.show_sql" value="true"/>
         <property name="hibernate.format_sql" value="true"/>
         <property name="hibernate.default_schema" value="MYSCHEMA"/>
      </properties>
   </persistence-unit>  
    
</persistence>
Advertisements
  1. Nicolas
    11 February 2011 at 3:05 pm

    Hi,

    Trying this modification I have the following exception on weblogic 10.3.3:
    Would you know what i’m missing ?

    Caused By: org.dom4j.DocumentException: Error on line 55 of document : The prefix “persistence” for element “persistence:entity-manager-factory” is not bound. Nested exception: The prefix “persistence” for element “persistence:entity-manager-factory” is not bound.
    at org.dom4j.io.SAXReader.read(SAXReader.java:482)
    at org.dom4j.io.SAXReader.read(SAXReader.java:343)
    at org.jboss.seam.util.XML.getRootElement(XML.java:24)
    at org.jboss.seam.init.Initialization.initComponentsFromXmlDocument(Initialization.java:226)
    at org.jboss.seam.init.Initialization.create(Initialization.java:132)
    at org.jboss.seam.servlet.SeamListener.contextInitialized(SeamListener.java:36)
    at weblogic.servlet.internal.EventsManager$FireContextListenerAction.run(EventsManager.java:481)
    at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
    at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121)
    at weblogic.servlet.internal.EventsManager.notifyContextCreatedEvent(EventsManager.java:181)
    at weblogic.servlet.internal.WebAppServletContext.preloadResources(WebAppServletContext.java:1863)
    at weblogic.servlet.internal.WebAppServletContext.start(WebAppServletContext.java:3126)
    at weblogic.servlet.internal.WebAppModule.startContexts(WebAppModule.java:1512)
    at weblogic.servlet.internal.WebAppModule.start(WebAppModule.java:486)
    at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:425)
    at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:41)
    at weblogic.application.internal.flow.ModuleStateDriver.start(ModuleStateDriver.java:119)
    at weblogic.application.internal.flow.ScopedModuleDriver.start(ScopedModuleDriver.java:200)
    at weblogic.application.internal.flow.ModuleListenerInvoker.start(ModuleListenerInvoker.java:247)
    at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:425)
    at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:41)
    at weblogic.application.internal.flow.ModuleStateDriver.start(ModuleStateDriver.java:119)
    at weblogic.application.internal.flow.StartModulesFlow.activate(StartModulesFlow.java:27)
    at weblogic.application.internal.BaseDeployment$2.next(BaseDeployment.java:1267)
    at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:41)
    at weblogic.application.internal.BaseDeployment.activate(BaseDeployment.java:409)
    at weblogic.application.internal.EarDeployment.activate(EarDeployment.java:58)
    at weblogic.application.internal.DeploymentStateChecker.activate(DeploymentStateChecker.java:161)
    at weblogic.deploy.internal.targetserver.AppContainerInvoker.activate(AppContainerInvoker.java:79)
    at weblogic.deploy.internal.targetserver.operations.AbstractOperation.activate(AbstractOperation.java:569)
    at weblogic.deploy.internal.targetserver.operations.ActivateOperation.activateDeployment(ActivateOperation.java:150)
    at weblogic.deploy.internal.targetserver.operations.ActivateOperation.doCommit(ActivateOperation.java:116)
    at weblogic.deploy.internal.targetserver.operations.AbstractOperation.commit(AbstractOperation.java:323)
    at weblogic.deploy.internal.targetserver.DeploymentManager.handleDeploymentCommit(DeploymentManager.java:844)
    at weblogic.deploy.internal.targetserver.DeploymentManager.activateDeploymentList(DeploymentManager.java:1253)
    at weblogic.deploy.internal.targetserver.DeploymentManager.handleCommit(DeploymentManager.java:440)
    at weblogic.deploy.internal.targetserver.DeploymentServiceDispatcher.commit(DeploymentServiceDispatcher.java:163)
    at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.doCommitCallback(DeploymentReceiverCallbackDeliverer.java:195)
    at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.access$100(DeploymentReceiverCallbackDeliverer.java:13)
    at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer$2.run(DeploymentReceiverCallbackDeliverer.java:68)
    at weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:528)
    at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
    at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)

  2. 12 February 2011 at 7:48 pm

    Hi, can you post your components.xml file?

  3. Nicolas
    14 February 2011 at 10:26 am

    Hi. I’ve been trying several times to post a new comment with the components.xml file without any success… 😦 I guess the xml tags mess the editor.

  4. 14 February 2011 at 12:36 pm

    Can you try putting the code inside the [ code language=”XML” ][ /code ] without spaces between [ and code.

  5. Nicolas
    14 February 2011 at 2:41 pm

    Still not working 😦 is there a description somewhere of the available syntax allowed in the blog ?

  6. 15 February 2011 at 8:05 am

    Ok, never mind, I can guess where the problem is but I just wanted to be sure. What the error means is that you’re mising the namespace. For instance in my components.xml file I have defined this

    xmlns:persistence=”http://jboss.com/products/seam/persistence”

    so I can do persistence:entity-manager-factory.

    Check your components.xml and see if the url http://jboss.com/products/seam/persistence is mapped to another namespace. If not then add it, if yes then change the persistence:entity-manager-factory to use your own namespace, like mynamespacedefined:entity-manager-factory for example.

  7. Nicolas
    15 February 2011 at 1:58 pm

    Thank you, it was indeed the issue !

  8. 16 February 2011 at 8:02 am

    Nice, glad you got it solved.

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: