ReportEJB and FieldsEJB
I want to store a set of fields as an attribute in the reportEJB but i am
having problems setting values and consequently i am getting a
nullpointerexception
Stack trade:
| 13:58:02,804 ERROR [LogInterceptor] EJBException in method: public abstract
void
|
com.rgs.ejb.reportdefinitionmanager.ReportDefinitionManagerRemote.createReportD
| efinition(com.rgs.ejb.reportdefinition.ReportDefinitionPOJO) throws
java.rmi.Rem
| oteException, causedBy:
| javax.transaction.TransactionRolledbackException: null; CausedByException
is:
| null; nested exception is:
| javax.ejb.EJBException: null; CausedByException is:
| null
| at
org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInte
| rceptor.java:244)
| at
org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxIntercep
| torCMT.java:316)
| at
org.jboss.ejb.plugins.TxInterceptorCMT.invokeHome(TxInterceptorCMT.ja
| va:129)
| at
org.jboss.ejb.plugins.SecurityInterceptor.invokeHome(SecurityIntercep
|
|
| [/ode]
|
| here is the flow of the code including ejb-jar and jbosscmpjdbc config
files as i think this may be where the problem lies?
|
|
| | </ejb-relation>
| | <ejb-relation>
| |
<ejb-relation-name>ReportMasterFields-ReportDefinition</ejb-relation-name>
| | <ejb-relationship-role>
| | <ejb-relationship-role-name>
| | ReportMasterFields-has-Many-ReportDefinitions
| | </ejb-relationship-role-name>
| | <multiplicity>Many</multiplicity>
| | <relationship-role-source>
| | <ejb-name>ReportMasterFieldsEJB</ejb-name>
| | </relationship-role-source>
| | </ejb-relationship-role>
| |
| | <ejb-relationship-role>
| | <ejb-relationship-role-name>
| | ReportDefinition-has-many-ReportMasterFields
| | </ejb-relationship-role-name>
| | <multiplicity>Many</multiplicity>
| | <relationship-role-source>
| | <ejb-name>ReportDefinitionEJB</ejb-name>
| | </relationship-role-source>
| | <cmr-field>
| | <cmr-field-name>reportFields</cmr-field-name>
| | <cmr-field-type>java.util.Set</cmr-field-type>
| | </cmr-field>
| | </ejb-relationship-role>
| | </ejb-relation>
| |
|
| jbosscmp-jdbc
|
| |
| | <ejb-relation>
| |
<ejb-relation-name>ReportMasterFields-ReportDefinition</ejb-relation-name>
| |
| | <relation-table-mapping>
| | <table-name>report_fields</table-name>
| | <create-table>true</create-table>
| | <remove-table>true</remove-table>
| | </relation-table-mapping>
| |
| | <ejb-relationship-role>
| | <ejb-relationship-role-name>
| | ReportDefinition-has-many-ReportMasterFields
| | </ejb-relationship-role-name>
| | <key-fields>
| | <key-field>
| | <field-name>id</field-name>
| | <column-name>report_definition_id</column-name>
| | </key-field>
| | </key-fields>
| | </ejb-relationship-role>
| |
| | <ejb-relationship-role>
| | <ejb-relationship-role-name>
| | ReportMasterFields-has-Many-ReportDefinitions
| | </ejb-relationship-role-name>
| | <key-fields>
| | <key-field>
| | <field-name>id</field-name>
| | <column-name>masterfield_id</column-name>
| | </key-field>
| | </key-fields>
| | </ejb-relationship-role>
| | </ejb-relation>
| |
| |
|
| Client code
|
| |
| | Set masterfields = new HashSet();
| | ....
| | //create a new ReportDefinition and add set of
reportMasterFields to it
| | ReportDefinitionPOJO r = new ReportDefinitionPOJO();
| | r.setName("Report1");
| | r.setFilterCriteria("Filter");
| | r.setGroupCriteria("group");
| | r.setSortCriteria("sort");
| | r.setDescription("description");
| | r.setDestination("destination");
| | r.setRequester("Fiona");
| | r.setFormat("Text");
| |
| |
//System.out.println(r.getReportFields());//.add(masterfields);
| | r.setReportFields(masterfields);
| |
| | _managerRemote.createReportDefinition(r);
| |
| | ReportDefinitionPOJO po =
_managerRemote.listReportByName("Fiona");
| | Set fields = po.getReportFields(); //null
pointer occurs here
| | Iterator it = fields.iterator();
| | while(it.hasNext())
| | {
| | ReportMasterFieldsPOJO p =
(ReportMasterFieldsPOJO)it.next();
| | System.out.println(p.getName());
| | }
| | }
| | catch(Exception e){e.printStackTrace();}
| |
| |
|
| Session bean
|
| |
| | public void createReportDefinition(ReportDefinitionPOJO pojo)
| | {
| |
| | try{
| | home.create(pojo);
| | }
| | catch(Exception e)
| | {
| | throw new EJBException(e);
| | }
| |
| | }
| |
| Bean...btw im using POJOs
|
| |
| | public Integer ejbCreate(ReportDefinitionPOJO report) throws
CreateException
| | {
| | setId(generatePrimaryKey());
| | System.out.println("ejbcreate");
| | return report.getId();
| | }
| | public void ejbPostCreate(ReportDefinitionPOJO report)
| | {
| |
| | setName(report.getName());
| | System.out.println("fields"
+report.getReportFields());//this is printing to the console
| | setReportFields(report.getReportFields());
| | setFilterCriteria(report.getFilterCriteria());
| | setGroupCriteria(report.getGroupCriteria());
| | setSortCriteria(report.getSortCriteria());
| | setDescription(report.getDescription());
| | setDestination(report.getDestination());
| | setUserId(report.getUserId());
| | setFormat(report.getFormat());
| | setRequester(report.getRequester());
| | System.out.println("postcreate");
| |
| | }
| |
| | public void setValueObject(Object obj)
| | {
| | ReportDefinitionPOJO report = (ReportDefinitionPOJO)obj;
| | //we don't set the ID as its already set
| | setName(report.getName());
| | setReportFields(report.getReportFields());
| | setFilterCriteria(report.getFilterCriteria());
| | setGroupCriteria(report.getGroupCriteria());
| | setSortCriteria(report.getSortCriteria());
| | setDescription(report.getDescription());
| | setDestination(report.getDestination());
| | setUserId(report.getUserId());
| | setFormat(report.getFormat());
| | setRequester(report.getRequester());
| |
| | }
| |
| | public Object getValueObject(){
| |
| | ReportDefinitionPOJO report = new ReportDefinitionPOJO();
| | report.setId(getId());
| | report.setName(getName());
| | //report.setReportFields(getReportFields());
| | report.setFilterCriteria(getFilterCriteria());
| | report.setGroupCriteria(getGroupCriteria());
| | report.setSortCriteria(getSortCriteria());
| | report.setDescription(getDescription());
| | report.setDestination(getDestination());
| | report.setUserId(getUserId());
| | report.setFormat(getFormat());
| | report.setRequester(getRequester());
| | return report;
| | }
| |
| | public abstract void setReportFields(Set fields);
| | public abstract Set getReportFields();
| |
| |
|
|
|
| Please help i have tried everything in solving this problem
View the original post :
http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3867810#3867810
Reply to the post :
http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=3867810
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
JBoss-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jboss-user