- This topic has 8 replies, 5 voices, and was last updated 6 years, 4 months ago by support-swapna.
-
AuthorPosts
-
robinsinghMemberENVIRONMENT DETAILS:
I have configured myEclipse with jboss 4.0 RC1 version
on windows XP professional(SP2) using Java[TM] 2 Platform,
Eclipse Platform
Version: 3.0.0
Build id: 200406251208
jdk version(build 1.4.2_05-b04)
myEclipse 3.8.2hi
i am deploying a simple entity bean -has 3 filesbonusbean.java(entity bean definition)
bonus.java (remote interface)
bonushome.java(home interface)i am doing everything right .
myEclipse doesnt show any compiler error whatsoever in the files.(no red crosses etc.)
but when i deploy the application jboss 4.0 RC1 throws exceptions
saying a particular container managed persistent field -“socsec” doesnt have the accessor methods in the bonusbean.javaThough i have those methods in bonusbean.java
and the corresponding declarations are present in the remote interface bonus.java as well.i dont understand why is this happening.
bonusbean.java
public abstract class BonusBean implements javax.ejb.EntityBean { public double bonus; public String socsec; public abstract String getSocSec(); public abstract void setSocSec(String socsec); public abstract double getBonus(); public abstract void setBonus(double bonus);
bonus.java (bonus remote interface)
public interface Bonus extends EJBObject { public String getSocSec() throws RemoteException; public void setSocSec(String socsec) throws RemoteException; public double getBonus() throws RemoteException; public void setBonus(double bonus) throws RemoteException; }
ejb-jar.xml listing
<enterprise-beans> <entity> <ejb-name>BonusBean</ejb-name> <home>Beans.BonusHome</home> <remote>Beans.Bonus</remote> <ejb-class>Beans.BonusBean</ejb-class> <persistence-type>Container</persistence-type> <prim-key-class>java.lang.String</prim-key-class> <reentrant>false</reentrant> <cmp-version>2.x</cmp-version> <abstract-schema-name>bonustable</abstract-schema-name> <cmp-field><field-name>bonus</field-name></cmp-field> <cmp-field><field-name>socsec</field-name></cmp-field> <primkey-field>socsec</primkey-field> <security-identity><use-caller-identity/></security-identity> </entity>
jboss error output
14:09:11,696 INFO [EARDeployer] Init J2EE application: file:/E:/jboss4/server/default/deploy/BonusApp.ear/ 14:09:12,077 WARN [verifier] EJB spec violation: Bean : BonusBean Section: 10.6.2 Warning: The entity bean class must define a get accessor for each CMP field. Info : Field: socsec 14:09:12,077 WARN [verifier] EJB spec violation: Bean : BonusBean Section: 10.6.2 Warning: The entity bean class must define a set accessor for each CMP field. Info : Field: socsec 14:09:12,107 ERROR [MainDeployer] could not create deployment: file:/E:/jboss4/server/default/deploy/BonusApp.ear/BonusAppEJB. org.jboss.deployment.DeploymentException: Verification of Enterprise Beans failed, see above for error messages.
Any help with this will be appreciated.
thanks .
regards
robin
Scott AndersonParticipantRobin,
i am doing everything right
Well, not everything. 😉
The problem is that you’re violating the javabean spec on the expected names of the accessors. They should be ‘getSocsec’ and ‘setSocsec’. The container doesn’t know that SocSec is a camel-cased shortening of Social Security. So, your versions have the wrong names and thus are not recognized.
robinsinghMemberthanks that worked.
Now i am stuck in another weird problem
kindly help with this .In the following listing(bonusservlet.java).
my field “socsec” is told by the Server to have the null value
though i have made sure (by all means) that it doenst have null valuefor create(double bonus, String socsec)
i call create(bonus, “1234”) ; //hardcoding socsec with non-null value
in the bonusservlet.java codestill the jboss a.S throws the following exception at the bonusbean.create()method;;
16:55:52,347 ERROR [BonusBean] Could not create entity java.sql.SQLException: General error message from server: "Column 'socsec' cannot be null" --- ------ at $Proxy64.create(Unknown Source) at BonusServlet.doGet(BonusServlet.java:59) ---- ------- ---- 16:55:52,397 INFO [STDOUT] javax.ejb.CreateException: Could not create entity:java.sql.SQLException: General error message from server: "Column 'socsec' cannot be null"
when i submit the values from my html page to this servlet
wich further calls an entity bean bonusbean.create() method
to create records in to the back-end database called bonusstable.(i have already created an empty bonustable in the database by
create table bonustable(bonus double,socsec char(20))If you dont see an immediate error in this . kindly tell me how do i go about debugging this using myEclipse debugging tool .
though i have tried doing some out.println() statements just before the
bonusbean.create() method and it shows me non-null values for socsec
variable. (that’s why i am confused ..as to If i am not sending a null value
how come server tells me that a null value cannt be put in the socsec column in the backend. )bonusServlet.java listing
- public void doGet (HttpServletRequest request, HttpServletResponse response
) throws ServletException, IOException {
String socsec = “1890”, retsocsec = “1891”;
PrintWriter out;
response.setContentType(“text/html”);
String title = “EJB Example”;
out = response.getWriter();
out.println(“<HTML><HEAD><TITLE>”);
out.println(title);
out.println(“</TITLE></HEAD><BODY>”);try {
//Retrieve Bonus and Social Security Information
String strMult = request.getParameter(“MULTIPLIER”);
Integer integerMult = new Integer(strMult);
multiplier = integerMult.intValue();
socsec = request.getParameter(“SOCSEC”);
out.println(“socialsecurity”+socsec);//BROWSER PRINTS THIS non-null value for socsec
//Calculate bonus
double bonus = 100.00;theCalculation = homecalc.create();
calc = theCalculation.calcBonus(multiplier, bonus);
try {
//Create row in table
out.println(“socialsecurity ::calc==>”+socsec+”::”+calc);//BROWSER PRINTS THIS non-null value for socsec
theBonus = homebonus.create(calc,”1234″);
out.println(“socialsecurity 2::calc==>”+socsec+”::”+calc);
//browser doesnt print this line coz Exception gets thrown a line before
//Display data
out.println(“<H1>Bonus Calculation</H1>”);
out.println(“<P>Soc Sec passed in: ” + theBonus.getSocsec() + “<P>”);
out.println(“<P>Multiplier passed in: ” + multiplier + “<P>”);
out.println(“<P>Bonus Amount calculated: ” +
theBonus.getBonus() + “<P>”);
out.println(“</BODY></HTML>”);
//Catch duplicate key error
} catch (javax.ejb.DuplicateKeyException e) {
——————–
}
} catch (Exception CreateException) {
CreateException.printStackTrace();
}I tried looking around for debug tools but they only debug the standard JAva applications/applets etc. not the servlets .
this is iimportant for me to know so that i know
how to go about debugging such Servlet applications in future.
rather than sending u the code listing.
(but this time pretty please .. help me ;-))
robinsinghMemberi saw another table bonusbean automatically made by the Entity EJB on the backend
i deleted my table bonustable and bean’s automatically generated bonusbean table.then i created another table bonusbean
create table bonusbean (bonus double not null default 0, socsec varchar(250) primary key default "333");
to cover for any other dumb possibilities.
now the bean while being deployed says…Table bonusbean already exists. j2ee application gets started.
but the servlet still throws the same CreateException at the same point .
this is really confusing.
kindly help.
brizola777ParticipantHi, I know the post is a little old, and I’m doing maintenance on an old system with the same problem. I’m going to put my ejb-jar.xml and Bean if anyone can help me …
I also use struts2 and XDoclet. Thank you!<entity > <description><![CDATA[Business object persistence Bean for OrganizationUnit]]></description> <display-name>OrganizationUnit CMP Bean</display-name> <ejb-name>OrganizationUnit</ejb-name> <local-home>br.com.certisign.certificatemanager.interfaces.OrganizationUnitLocalHome</local-home> <local>br.com.certisign.certificatemanager.interfaces.OrganizationUnitLocal</local> <ejb-class>br.com.certisign.certificatemanager.core.template.cmp.OrganizationUnitBean</ejb-class> <persistence-type>Container</persistence-type> <prim-key-class>java.lang.String</prim-key-class> <reentrant>False</reentrant> <cmp-version>2.x</cmp-version> <abstract-schema-name>OrganizationUnitSchema</abstract-schema-name> <cmp-field > <description><![CDATA[Obtém o código de <i>hash</i> representando o identificador do campo de formatação.]]></description> <field-name>idOu</field-name> </cmp-field> <cmp-field > <description><![CDATA[Obtém a descrição do campo de formatação.]]></description> <field-name>descricaoOu</field-name> </cmp-field> <cmp-field > <description><![CDATA[Obtém o código de <i>hash</i> representando o identificador do campo de formatação.]]></description> <field-name>crtId</field-name> </cmp-field> <cmp-field > <description><![CDATA[Obtém o código de <i>hash</i> representando o identificador do campo de formatação.]]></description> <field-name>ordemOu</field-name> </cmp-field> <primkey-field>idOu</primkey-field> <query> <query-method> <method-name>findAll</method-name> <method-params> </method-params> </query-method> <ejb-ql><![CDATA[SELECT OBJECT(o) FROM OrganizationUnitSchema o]]></ejb-ql> </query> <query> <query-method> <method-name>findByDescription</method-name> <method-params> <method-param>java.lang.String</method-param> </method-params> </query-method> <ejb-ql><![CDATA[SELECT OBJECT(o) FROM OrganizationUnitSchema o WHERE o.descricaoOU = ?1]]></ejb-ql> </query> <!-- Write a file named ejb-finders-OrganizationUnitBean.xml if you want to define extra finders. --> </entity>
package br.com.certisign.certificatemanager.core.template.cmp; import java.rmi.RemoteException; import java.util.Collection; import javax.ejb.EJBException; import javax.ejb.EntityBean; import javax.ejb.EntityContext; import javax.ejb.RemoveException; import br.com.certisign.certificatemanager.support.IdGenerator; /** * Classe EJB que faz a representação dos dados da tabela ORGANIZATIONUNIT * junto ao banco de dados para a forma orientada a objetos. Tais dados são a * representação do OrganizationUnit. * * * @since 26 de junho de 2018 * @version 0.1 * @see EntityBean * * @ejb.bean name="OrganizationUnit" display-name="OrganizationUnit CMP Bean" * description * ="Business object persistence Bean for OrganizationUnit" * jndi-name="ejb/OrganizationUnit" schema="OrganizationUnitSchema" * type="CMP" cmp-version="2.x" view-type="local" * primkey-field="idOu" * @ejb.persistence table-name="OrganizationUnit" * @ejb.finder query="SELECT OBJECT(o) FROM OrganizationUnitSchema o" * signature="java.util.Collection findAll()" * @ejb.finder query="SELECT OBJECT(o) FROM OrganizationUnitSchema o WHERE * o.descricaoOU = ?1" signature= * "br.com.certisign.certificatemanager.interfaces.OrganizationUnitLocal findByDescription(java.lang.String descricaoOU)" */ public abstract class OrganizationUnitBean implements EntityBean { /** * Método sobrescrito. Consulte a API * {@link EntityBean#setEntityContext(EntityContext)} para a compreensão. */ public void setEntityContext(EntityContext ctx) throws EJBException, RemoteException { } /** * Método sobrescrito. Consulte a API * {@link EntityBean#unsetEntityContext()} para a compreensão. */ public void unsetEntityContext() throws EJBException, RemoteException { } /** * Método sobrescrito. Consulte a API {@link EntityBean#ejbRemove()} para a * compreensão. */ public void ejbRemove() throws RemoveException, EJBException, RemoteException { } /** * Método sobrescrito. Consulte a API {@link EntityBean#ejbActivate()} para * a compreensão. */ public void ejbActivate() throws EJBException, RemoteException { } /** * Método sobrescrito. Consulte a API {@link EntityBean#ejbPassivate()} para * a compreensão. */ public void ejbPassivate() throws EJBException, RemoteException { } /** * Método sobrescrito. Consulte a API {@link EntityBean#ejbLoad()} para a * compreensão. */ public void ejbLoad() throws EJBException, RemoteException { } /** * Método sobrescrito. Consulte a API {@link EntityBean#ejbStore()} para a * compreensão. */ public void ejbStore() throws EJBException, RemoteException { } /** * Inicializa os atributos da instância. * * @param idOu * id OrganizationUnit. * @param crtId * id crtId. * @param descricaoOu * campo descrição. * @param ordemOu * id ordemOU. * @return o idOu do campo de formatação. * @throws javax.ejb.CreateException * Erro ao criar o EJB. * @ejb.create-method view-type = "local" */ public String ejbCreate(String idOu, String crtId, String descricaoOu, Long ordemOu) throws javax.ejb.CreateException { idOu = IdGenerator.generateGUID( this ); this.setidOu(idOu); this.setCrtId( crtId ); this.setDescricaoOu( descricaoOu ); this.setOrdemOu( ordemOu ); return String.valueOf(idOu); } /** * Método executado após a criação do registro na base de dados. * * @param idOu * id OrganizationUnit. * @param crtId * id crtId. * @param descricaoOu * campo descrição. * @param ordemOu * id ordemOU. * @return o identificador do campo de formatação. * @throws javax.ejb.CreateException * Erro ao criar o EJB. * @ejb.create-method view-type = "local" */ public void ejbPostCreate(String idOu, String crtId, String descricaoOu, Long ordemOu) throws javax.ejb.CreateException { } /** * Obtém o código de <i>hash</i> representando o identificador do campo de * formatação. * @ejb.pk-field * @return o identificador do campo de formatação. * @ejb.interface-method view-type="local" * @ejb.persistence column-name="IDOU" jdbc-type="VARCHAR" * sql-type="VARCHAR(129)" */ public abstract String getIdOu(); /** * Seta o código de <i>hash</i> representando o identificador do campo de * formatação. * @ejb.pk-field * @return o identificador do campo de formatação. * @ejb.interface-method view-type="local" * @ejb.persistence column-name="IDOU" jdbc-type="VARCHAR" * sql-type="VARCHAR(129)" */ public abstract void setidOu(String idOu); /** * Obtém a descrição do campo de formatação. * * @return a descrição do campo de formatação. * @ejb.persistent-field * @ejb.interface-method view-type="local" * @ejb.persistence column-name="DESCRICAOOU" jdbc-type="VARCHAR" * sql-type="VARCHAR(129)" * @jboss.persistence not-null="false" */ public abstract String getDescricaoOu(); /** * Atribui a descrição do campo de formatação. * * @param value * a descrição do campo de formatação. * @ejb.interface-method view-type="local" */ public abstract void setDescricaoOu(String value); /** * Obtém o código de <i>hash</i> representando o identificador do campo de * formatação. * @return o identificador do campo de formatação. * @ejb.interface-method view-type="local" * @ejb.persistence column-name="CRTID" jdbc-type="INTEGER" * sql-type="INTEGER" */ public abstract String getCrtId(); /** * Atribui o identificador do campo de formatação. * * @param value * o identificador. * @ejb.interface-method view-type="local" */ public abstract void setCrtId(String value); /** * Obtém o código de <i>hash</i> representando o identificador do campo de * formatação. * @return o identificador do campo de formatação. * @ejb.interface-method view-type="local" * @ejb.persistence column-name="ORDEMOU" jdbc-type="NUMBER" * sql-type="NUMBER" */ public abstract Long getOrdemOu(); /** * Atribui o identificador do campo de formatação. * * @param value * o identificador. * @ejb.interface-method view-type="local" */ public abstract void setOrdemOu(Long value); }
14:19:02,461 WARN [verifier] EJB spec violation:
Bean : OrganizationUnit
Section: 10.6.2
Warning: The entity bean class must define a set accessor for each CMP field.
Info : Field: idOu- This reply was modified 6 years, 4 months ago by brizola777.
brizola777ParticipantSorry forgot the error:
14:19:02,461 WARN [verifier] EJB spec violation:
Bean : OrganizationUnit
Section: 10.6.2
Warning: The entity bean class must define a set accessor for each CMP field.
Info : Field: idOu
Brian FernandesModeratorHi, I know the post is a little old,
At only 14 years old, probably a record 😉
So we’re on the same page, can you let us know:
1) What version of MyEclipse you are using
2) Where exactly do you see this error – I’m assuming it’s during deployment, and not in the IDE?
3) What server/version are you deploying to?
brizola777Participantkkkkkkkkkkkk
sorry my english its mean, im brazilian and this post is only i find on google talking about that.Well, I was able to fix the problem (I hope) by changing the name of the variable everywhere idOu to id, not a good practice I know change only to id however was the way I found …
now the mistake is another ….
Bean : OrganizationUnit
Method : public abstract OrganizationUnitLocal postCreate(String, String, String, Long) throws CreateException
Section: 12.2.11
Warning: Each local home method must match a method defined in the entity bean class.Follows my Local Home class, Local and Bean … I could not understand the error
public abstract class OrganizationUnitBean implements EntityBean { /** * Método sobrescrito. Consulte a API * {@link EntityBean#setEntityContext(EntityContext)} para a compreensão. */ public void setEntityContext(EntityContext ctx) throws EJBException, RemoteException { } /** * Método sobrescrito. Consulte a API * {@link EntityBean#unsetEntityContext()} para a compreensão. */ public void unsetEntityContext() throws EJBException, RemoteException { } /** * Método sobrescrito. Consulte a API {@link EntityBean#ejbRemove()} para a * compreensão. */ public void ejbRemove() throws RemoveException, EJBException, RemoteException { } /** * Método sobrescrito. Consulte a API {@link EntityBean#ejbActivate()} para * a compreensão. */ public void ejbActivate() throws EJBException, RemoteException { } /** * Método sobrescrito. Consulte a API {@link EntityBean#ejbPassivate()} para * a compreensão. */ public void ejbPassivate() throws EJBException, RemoteException { } /** * Método sobrescrito. Consulte a API {@link EntityBean#ejbLoad()} para a * compreensão. */ public void ejbLoad() throws EJBException, RemoteException { } /** * Método sobrescrito. Consulte a API {@link EntityBean#ejbStore()} para a * compreensão. */ public void ejbStore() throws EJBException, RemoteException { } /** * Inicializa os atributos da instância. * * @param idOu * id OrganizationUnit. * @param crtId * id crtId. * @param descricaoOu * campo descrição. * @param ordemOu * id ordemOU. * @return o idOu do campo de formatação. * @throws javax.ejb.CreateException * Erro ao criar o EJB. * @ejb.create-method view-type = "local" */ public String ejbCreate(String id, String crtId, String descricaoOu, Long ordemOu) throws javax.ejb.CreateException { id = IdGenerator.generateGUID( this ); this.setId(id); this.setCrtId( crtId ); this.setDescricaoOu( descricaoOu ); this.setOrdemOu( ordemOu ); return String.valueOf(id); } /** * Método executado após a criação do registro na base de dados. * * @param idOu * id OrganizationUnit. * @param crtId * id crtId. * @param descricaoOu * campo descrição. * @param ordemOu * id ordemOU. * @return o identificador do campo de formatação. * @throws javax.ejb.CreateException * Erro ao criar o EJB. * @ejb.create-method view-type = "local" */ public void ejbPostCreate(String id, String crtId, String descricaoOu, Long ordemOu) throws javax.ejb.CreateException { } /** * Obtém o código de <i>hash</i> representando o identificador do campo de * formatação. * @ejb.pk-field * @return o identificador do campo de formatação. * @ejb.interface-method view-type="local" * @ejb.persistence column-name="IDOU" jdbc-type="VARCHAR" * sql-type="VARCHAR(129)" */ public abstract String getId(); /** * Seta o código de <i>hash</i> representando o identificador do campo de * formatação. * @ejb.pk-field * @return o identificador do campo de formatação. * @ejb.interface-method view-type="local" * @ejb.persistence column-name="IDOU" jdbc-type="VARCHAR" * sql-type="VARCHAR(129)" */ public abstract void setId(String id); /** * Obtém a descrição do campo de formatação. * * @return a descrição do campo de formatação. * @ejb.persistent-field * @ejb.interface-method view-type="local" * @ejb.persistence column-name="DESCRICAOOU" jdbc-type="VARCHAR" * sql-type="VARCHAR(129)" * @jboss.persistence not-null="false" */ public abstract String getDescricaoOu(); /** * Atribui a descrição do campo de formatação. * * @param value * a descrição do campo de formatação. * @ejb.interface-method view-type="local" */ public abstract void setDescricaoOu(String value); /** * Obtém o código de <i>hash</i> representando o identificador do campo de * formatação. * @return o identificador do campo de formatação. * @ejb.interface-method view-type="local" * @ejb.persistence column-name="CRTID" jdbc-type="INTEGER" * sql-type="INTEGER" */ public abstract String getCrtId(); /** * Atribui o identificador do campo de formatação. * * @param value * o identificador. * @ejb.interface-method view-type="local" */ public abstract void setCrtId(String value); /** * Obtém o código de <i>hash</i> representando o identificador do campo de * formatação. * @return o identificador do campo de formatação. * @ejb.interface-method view-type="local" * @ejb.persistence column-name="ORDEMOU" jdbc-type="NUMBER" * sql-type="NUMBER" */ public abstract Long getOrdemOu(); /** * Atribui o identificador do campo de formatação. * * @param value * o identificador. * @ejb.interface-method view-type="local" */ public abstract void setOrdemOu(Long value); }
public interface OrganizationUnitLocal extends javax.ejb.EJBLocalObject { /** * Obtém o código de <i>hash</i> representando o identificador do campo de formatação. * @return o identificador do campo de formatação. */ public java.lang.String getId( ) ; /** * Seta o código de <i>hash</i> representando o identificador do campo de formatação. * @return o identificador do campo de formatação. */ public void setId( java.lang.String id ) ; /** * Obtém a descrição do campo de formatação. * @return a descrição do campo de formatação. */ public java.lang.String getDescricaoOu( ) ; /** * Atribui a descrição do campo de formatação. * @param value a descrição do campo de formatação. */ public void setDescricaoOu( java.lang.String value ) ; /** * Obtém o código de <i>hash</i> representando o identificador do campo de formatação. * @return o identificador do campo de formatação. */ public java.lang.String getCrtId( ) ; /** * Atribui o identificador do campo de formatação. * @param value o identificador. */ public void setCrtId( java.lang.String value ) ; /** * Obtém o código de <i>hash</i> representando o identificador do campo de formatação. * @return o identificador do campo de formatação. */ public java.lang.Long getOrdemOu( ) ; /** * Atribui o identificador do campo de formatação. * @param value o identificador. */ public void setOrdemOu( java.lang.Long value ) ; }
public interface OrganizationUnitLocalHome extends javax.ejb.EJBLocalHome { public static final String COMP_NAME="java:comp/env/ejb/OrganizationUnitLocal"; public static final String JNDI_NAME="OrganizationUnitLocal"; public br.com.certisign.certificatemanager.interfaces.OrganizationUnitLocal create(java.lang.String id , java.lang.String crtId , java.lang.String descricaoOu , java.lang.Long ordemOu) throws javax.ejb.CreateException; public br.com.certisign.certificatemanager.interfaces.OrganizationUnitLocal postCreate(java.lang.String id , java.lang.String crtId , java.lang.String descricaoOu , java.lang.Long ordemOu) throws javax.ejb.CreateException; public java.util.Collection findAll() throws javax.ejb.FinderException; public br.com.certisign.certificatemanager.interfaces.OrganizationUnitLocal findByDescription(java.lang.String descricaoOU) throws javax.ejb.FinderException; public br.com.certisign.certificatemanager.interfaces.OrganizationUnitLocal findByPrimaryKey(java.lang.String pk) throws javax.ejb.FinderException; }
You asked me:
What version of MyEclipse you are using : Neon
Where exactly do you see this error – I’m assuming it’s during deployment, and not in the IDE – On Console when up Jboss 5.1,
I do not know if you will understand what I mean by upjboss, I mean when I upload the project in jboss, I’m going to insert an image.What server/version are you deploying to – Jboss 5.1
thank you so much!!!!!!!!!!!!
- This reply was modified 6 years, 4 months ago by brizola777.
Attachments:
You must be logged in to view attached files.
support-swapnaModeratorbrizola777,
Thank you for the details. I am afraid we cannot provide support for Eclipse as this forum is specifically for MyEclipse IDE and other Genuitec related product issues. Also the problem you are seeing is an EJB development related question and it is better to post in development forums like stackoverflow.com for suggestions from the developer community.
Sorry that we couldn’t assist further.
–Swapna
Genuitec Support -
AuthorPosts