• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Error while deploying JPA

 
BalajiNityaa Varadharajan
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

i am trying to get my first EJB3 JPA up and running and finding it a bit difficult. I am using Sun Java Application Server to deploy my beans.

Following is my entity POJO class.

package sample.entity.account;

import java.io.Serializable;

//import javax.persistence.AccessType;
import javax.persistence.Entity;
import javax.persistence.EntityListeners;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.NamedQuery;
import javax.persistence.PreUpdate;
import javax.persistence.PrePersist;
import javax.persistence.PreUpdate;
import javax.persistence.PostUpdate;
import javax.persistence.PostLoad;
import javax.persistence.Version;

@Entity //(access = AccessType.FIELD)
@Table (name="Account")
@EntityListeners(MyListener.class)
@NamedQuery(name="findThem", query="SELECT a FROM ACCOUNT a")
public class Account implements Serializable
{
@Id
public int accountNumber;
public String ownerName;
public int balance;

@Version
public int version;

public Account()
{
accountNumber = (int) System.nanoTime();
}

public String toString()
{
return "Acc# "+accountNumber+" , ownerName= "+ownerName+", balance="+balance+"$";
}

@PrePersist
public void prePersist()
{
System.out.println("prePersist()");
}

@PreUpdate
public void preUpdate()
{
System.out.println("preUpdate()");
}

@PostUpdate
public void postUpdate()
{
System.out.println("postUpdate()");
}

@PostLoad
public void postLoad()
{
System.out.println("postLoad()");
}
}

I am trying to access this entity class from a session bean called Bank.

Following is my sun-ejb-jar.xml;

<?xml version="1.0" encoding="UTF-8"?>
<sun-ejb-jar>
<enterprise-beans>
<name>AccountBean</name>
<ejb>
<ejb-name>BankBean</ejb-name>
<jndi-name>Bank</jndi-name>
</ejb>
<ejb>
<ejb-name>Account</ejb-name>
<jndi-name>Account</jndi-name>
</ejb>
</enterprise-beans>
</sun-ejb-jar>

Following is my sun-cmp-mappings.xml.

<?xml version="1.0" encoding="UTF-8"?>
<sun-cmp-mappings>
<sun-cmp-mapping>
<schema>olga_twe48_lease</schema>
<entity-mapping>
<ejb-name>Account</ejb-name>
<table-name>Account</table-name>
<cmp-field-mapping>
<field-name>accountNumber</field-name>
<column-name>Account.AccountNumber</column-name>
</cmp-field-mapping>
<cmp-field-mapping>
<field-name>ownerName</field-name>
<column-name>Account.OwnerName</column-name>
</cmp-field-mapping>
<cmp-field-mapping>
<field-name>balance</field-name>
<column-name>Account.Balance</column-name>
</cmp-field-mapping>
</entity-mapping>
</sun-cmp-mapping>
</sun-cmp-mappings>

Follwing is my 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" version="1.0">
<persistence-unit name="persistence_sample">
<provider>oracle.toplink.essentials.ejb.cmp3.EntityManagerFactoryProvider</provider>
<jta-data-source>TweDS</jta-data-source>
</persistence-unit>
</persistence>


When i try to deploy the jar file i get the following error:

Caused by: java.lang.IllegalArgumentException: Referencing error: This bundle has no bean of name [AccountBean]
at com.sun.enterprise.deployment.EjbBundleDescriptor.getEjbByName(EjbBundleDescriptor.java:258)
at com.sun.enterprise.deployment.node.runtime.EjbNode.setElementValue(EjbNode.java:128)
at com.sun.enterprise.deployment.node.SaxParserHandler.endElement(SaxParserHandler.java:408)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endElement(AbstractSAXParser.java:633)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanEndElement(XMLNSDocumentScannerImpl.java:719)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(XMLDocumentFragmentScannerImpl.java:1685)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:368)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:834)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:764)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:148)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1242)
at javax.xml.parsers.SAXParser.parse(SAXParser.java:375)
at com.sun.enterprise.deployment.io.DeploymentDescriptorFile.read(DeploymentDescriptorFile.java:279)
at com.sun.enterprise.deployment.archivist.Archivist.readRuntimeDeploymentDescriptor(Archivist.java:514)
at com.sun.enterprise.deployment.archivist.ApplicationArchivist.openArchive(ApplicationArchivist.java:773)
at com.sun.enterprise.deployment.archivist.ApplicationArchivist.openArchive(ApplicationArchivist.java:731)
at com.sun.enterprise.deployment.backend.Deployer.loadDescriptors(Deployer.java:327)


If anyone of guys have any idea about the error please let me know.

Thanks in Advance,
Balaji
[ August 15, 2006: Message edited by: Bear Bibeault ]
 
Mike Keith
author
Ranch Hand
Posts: 304
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It looks like you have a <name>AccountBean</name> element in your sun-ejb-jar.xml file that doesn't belong. There are other issues as well, though. For example, you should not be using the cmp mapping file.
 
BalajiNityaa Varadharajan
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

If I dont use a cmp file how can I map my fields to the database columns. Do I need an ejb-jar.xml? I understand that I may have to provide the getter and setter methods for the fields.

Can you please let me know some of the other problems that are there in deploying this entity as I am very new EJB.

Thanks,
Balaji
 
Mike Keith
author
Ranch Hand
Posts: 304
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You seem to be mixing up EJB 2.1 CMP and JPA. (This is one of the reasons why we steered away from going over EJB 2.1 in the book. It can confuse people more than it helps them.) I think in this instance it would be best for you to start fresh with EJB 3.0.

You do not need getter or setter methods at all. The easiest way to start mapping is to annotate the entity. Take a look at the simple examples for chapters 2 and 4, or here for a general how-to on defining an entity.

-Mike
 
BalajiNityaa Varadharajan
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Mike,

Can you please tell me which version of Oracle Application Server I should download to execute the samples given in your Pro EJB3 Book.
 
Michele Smith
Ranch Hand
Posts: 421
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am having a similar problem.

Here is a description of the error while trying to register an EJB file:

Deploying application in domain failed; Error loading deployment descriptors for module [AdapterPolicyEngineProxyEJB] -- Referencing error: This bundle has no bean of name [AdapterPolicyEngine] Error loading deployment descriptors for module [AdapterPolicyEngineProxyEJB] -- Referencing error: This bundle has no bean of name [AdapterPolicyEngine]

the server log says this:


[#|2010-11-15T08:50:44.855-0500|WARNING|sun-appserver2.1|org.apache.coyote.tomcat5.CoyoteRequest|_ThreadID=14;_ThreadName=httpWorkerThread-4848-1;_RequestID=3b60f892-5327-45cd-94dd-85b5f5c39f01;|PWC4011: Unable to set request character encoding to UTF-8 from context , because request parameters have already been read, or ServletRequest.getReader() has already been called|#]

[#|2010-11-15T08:51:00.792-0500|WARNING|sun-appserver2.1|javax.enterprise.system.tools.deployment|_ThreadID=16;_ThreadName=Thread-75;_RequestID=a2e12e6e-e0b1-4e7e-a0af-7404e453264e;|Error in annotation processing: java.lang.NoClassDefFoundError: gov/hhs/fha/nhinc/adapterpolicyengine/AdapterPolicyEnginePortType|#]

[#|2010-11-15T08:51:00.886-0500|SEVERE|sun-appserver2.1|javax.enterprise.system.tools.deployment|_ThreadID=16;_ThreadName=Thread-75;_RequestID=a2e12e6e-e0b1-4e7e-a0af-7404e453264e;|Exception occured in J2EEC Phasejava.lang.IllegalArgumentException: Referencing error: This bundle has no bean of name [AdapterPolicyEngine]
com.sun.enterprise.deployment.backend.IASDeploymentException: Error loading deployment descriptors for module [AdapterPolicyEngineProxyEJB] -- Referencing error: This bundle has no bean of name [AdapterPolicyEngine]
at com.sun.enterprise.deployment.backend.Deployer.loadDescriptors(Deployer.java:406)
at com.sun.enterprise.deployment.backend.ModuleDeployer.loadDescriptors(ModuleDeployer.java:426)
at com.sun.enterprise.deployment.backend.EjbModuleDeployer.deploy(EjbModuleDeployer.java:141)
at com.sun.enterprise.deployment.backend.ModuleDeployer.doRequestFinish(ModuleDeployer.java:182)
at com.sun.enterprise.deployment.phasing.J2EECPhase.runPhase(J2EECPhase.java:208)
at com.sun.enterprise.deployment.phasing.DeploymentPhase.executePhase(DeploymentPhase.java:108)
at com.sun.enterprise.deployment.phasing.PEDeploymentService.executePhases(PEDeploymentService.java:966)
at com.sun.enterprise.deployment.phasing.PEDeploymentService.deploy(PEDeploymentService.java:283)
at com.sun.enterprise.deployment.phasing.PEDeploymentService.deploy(PEDeploymentService.java:835)
at com.sun.enterprise.management.deploy.DeployThread.deploy(DeployThread.java:187)
at com.sun.enterprise.management.deploy.DeployThread.run(DeployThread.java:225)
Caused by: java.lang.IllegalArgumentException: Referencing error: This bundle has no bean of name [AdapterPolicyEngine]
at com.sun.enterprise.deployment.EjbBundleDescriptor.getEjbByName(EjbBundleDescriptor.java:283)
at com.sun.enterprise.deployment.EjbBundleDescriptor.getEjbByName(EjbBundleDescriptor.java:266)
at com.sun.enterprise.deployment.node.runtime.EjbNode.setElementValue(EjbNode.java:141)
at com.sun.enterprise.deployment.node.SaxParserHandler.endElement(SaxParserHandler.java:469)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endElement(AbstractSAXParser.java:601)
at com.sun.org.apache.xerces.internal.impl.dtd.XMLNSDTDValidator.endNamespaceScope(XMLNSDTDValidator.java:263)
at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.handleEndElement(XMLDTDValidator.java:2028)
at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.endElement(XMLDTDValidator.java:901)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanEndElement(XMLDocumentFragmentScannerImpl.java:1774)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2930)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:648)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:140)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:510)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:807)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:737)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:107)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1205)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:522)
at javax.xml.parsers.SAXParser.parse(SAXParser.java:395)
at com.sun.enterprise.deployment.io.DeploymentDescriptorFile.read(DeploymentDescriptorFile.java:298)
at com.sun.enterprise.deployment.archivist.Archivist.readRuntimeDeploymentDescriptor(Archivist.java:527)
at com.sun.enterprise.deployment.archivist.ApplicationArchivist.openArchive(ApplicationArchivist.java:836)
at com.sun.enterprise.deployment.archivist.ApplicationArchivist.openArchive(ApplicationArchivist.java:794)
at com.sun.enterprise.deployment.backend.Deployer.loadDescriptors(Deployer.java:365)
... 10 more
|#]

Can you steer me in the correct directions?

Thanks,
Midani
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic