function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Shoby Abdi.ax1151Shoby Abdi.ax1151 

Issues syncing a standard object with Database.com JDK

I've been running through the following Database.com Java SDK quickstart

 

http://forcedotcom.github.com/java-sdk/quick-start <-- The Hello Cloud example

 

To extend the application, I generated a POJO for the Task object, which is basically the following

 

package org.docsample.model;

import javax.persistence.*;
import com.force.sdk.*;

@javax.annotation.Generated(value="com.force.sdk.codegen.ForceJPAClassGenerator")
@Table(name="Task")
@Entity(name="Task")
@com.force.sdk.jpa.annotation.CustomObject(readOnlySchema=true)
public class Task extends com.force.sdk.jpa.model.BaseForceObject {

    public static final String KEY_PREFIX = "00T";


    // whoId possible references:
    // Contact
    // Lead
    protected String whoId;
    // whatId possible references:
    // Account
    // Asset
    // Campaign
    // Case
    // Contract
    // Opportunity
    // Product2
    // Solution
    protected String whatId;
    protected boolean subject;
    protected java.util.Date activityDate;
    protected String status;
    protected String priority;
    //protected User owner;
    protected String description;
    protected boolean isDeleted;
    //protected Account account;
    protected boolean isClosed;
    protected java.util.Calendar createdDate;
    //protected User createdBy;
    protected java.util.Calendar lastModifiedDate;
    //protected User lastModifiedBy;
    protected java.util.Calendar systemModstamp;
    protected boolean isArchived;
    protected int callDurationInSeconds;
    protected CallTypeEnum callType;
    protected String callDisposition;
    protected String callObject;
    protected java.util.Calendar reminderDateTime;
    protected boolean isReminderSet;
    protected Task recurrenceActivityId;
    protected boolean isRecurrence;
    protected java.util.Date recurrenceStartDateOnly;
    protected java.util.Date recurrenceEndDateOnly;
    protected RecurrenceTimeZoneSidKeyEnum recurrenceTimeZoneSidKey;
    protected RecurrenceTypeEnum recurrenceType;
    protected int recurrenceInterval;
    protected int recurrenceDayOfWeekMask;
    protected int recurrenceDayOfMonth;
    protected RecurrenceInstanceEnum recurrenceInstance;
    protected RecurrenceMonthOfYearEnum recurrenceMonthOfYear;
    
...

}

 I am currently trying to add this object, but its not uploading properly. I get the following exception:

 

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityController': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: org.docsample.service.EntityService org.docsample.controller.EntityController.entityService; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityService': Injection of persistence dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [app-context.xml]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: Explicit persistence provider error(s) occurred for "forceDatabase" after trying the following discovered implementations: org.datanucleus.jpa.PersistenceProviderImpl, com.force.sdk.jpa.PersistenceProviderImpl from provider: com.force.sdk.jpa.PersistenceProviderImpl
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:285)
When I take off the following annotation from the entity
@Entity(name="Task")

@Table(name="Task")

It generates a custom object, but with it I get the exceptions above. I can't see the correlation between setting up a standard object in the JPA and BeanGeneration not working. 

 

The settings on the hellocloud app are exactly the same as the demo. The app is working, its just when I add the Task POJO to the Model Bean generation fails. Am I missing a setting somewhere?

elukaweskielukaweski

Hi:

 

I spent a bit of time looking at this one...to get some experience with the SDK.

 

Seems to me this exception is caused by the 'subject' field in the Task standard object. When the Task object is generated bu the build plugin, the subject field is defined as 'boolean' . It is, in fact, a 'combobox' and, if one looks at the generated Java code, there is an Enum class generated. 

 

When I try to save a Task entity, I get a similar exception with a root cause of a NullPointerException. This exception comes from the datanucleus JPA handler processing the metadata for the 'subject' field. 

 

I think this is a 'bug'  in the generation plugin and could be reported on the Github site, here: https://github.com/forcedotcom/java-sdk/issues?sort=created&direction=desc&state=open&page=1

 

If you wish, go ahead and report this. If not, then I might.

 

Thanks

Edwin

 

Shoby Abdi.ax1151Shoby Abdi.ax1151

Great catch elukaweski 

 

Yeah it looks like a bug not only on subject but also on the status and priority fields instead. The code generator generated enumerator classes for those attributes but did not reference it which also looks like a bug. 

 

I am still getting an error, but a different one similar to yours

 

[ERROR] --------------------[ERROR]  Standard error from the DataNucleus tool + org.datanucleus.enhancer.DataNucleusEnhancer :[ERROR] --------------------[ERROR] Oct 24, 2011 10:49:06 AM org.datanucleus.enhancer.DataNucleusEnhancer <init>INFO: DataNucleus Enhancer : Using ClassEnhancer "ASM" for API "JPA"Oct 24, 2011 10:49:07 AM org.datanucleus.enhancer.DataNucleusEnhancer mainINFO: DataNucleus Enhancer (version 2.1.0-release) : Enhancement of classesOct 24, 2011 10:49:07 AM org.datanucleus.metadata.MetaDataManager loadClassesINFO: Class "org.docsample.controller.EntityController" has no MetaData or annotations.Oct 24, 2011 10:49:07 AM org.datanucleus.metadata.MetaDataManager loadClassesINFO: Class "org.docsample.controller.HomeController" has no MetaData or annotations.Oct 24, 2011 10:49:07 AM org.datanucleus.metadata.MetaDataManager loadClassesINFO: Class "org.docsample.controller.TaskController" has no MetaData or annotations.Oct 24, 2011 10:49:07 AM org.datanucleus.jpa.metadata.JPAAnnotationReader processClassAnnotationsINFO: Class "org.docsample.model.MyEntity" has been specified with JPA annotations so using those.Oct 24, 2011 10:49:07 AM org.datanucleus.metadata.MetaDataManager loadClassesINFO: Class "org.docsample.model.Task$CallTypeEnum" has no MetaData or annotations.Oct 24, 2011 10:49:07 AM org.datanucleus.metadata.MetaDataManager loadClassesINFO: Class "org.docsample.model.Task$PriorityEnum" has no MetaData or annotations.Oct 24, 2011 10:49:07 AM org.datanucleus.metadata.MetaDataManager loadClassesINFO: Class "org.docsample.model.Task$RecurrenceInstanceEnum" has no MetaData or annotations.Oct 24, 2011 10:49:07 AM org.datanucleus.metadata.MetaDataManager loadClassesINFO: Class "org.docsample.model.Task$RecurrenceMonthOfYearEnum" has no MetaData or annotations.Oct 24, 2011 10:49:07 AM org.datanucleus.metadata.MetaDataManager loadClassesINFO: Class "org.docsample.model.Task$RecurrenceTimeZoneSidKeyEnum" has no MetaData or annotations.Oct 24, 2011 10:49:07 AM org.datanucleus.metadata.MetaDataManager loadClassesINFO: Class "org.docsample.model.Task$RecurrenceTypeEnum" has no MetaData or annotations.Oct 24, 2011 10:49:07 AM org.datanucleus.metadata.MetaDataManager loadClassesINFO: Class "org.docsample.model.Task$StatusEnum" has no MetaData or annotations.Oct 24, 2011 10:49:07 AM org.datanucleus.metadata.MetaDataManager loadClassesINFO: Class "org.docsample.model.Task$SubjectEnum" has no MetaData or annotations.Oct 24, 2011 10:49:07 AM org.datanucleus.jpa.metadata.JPAAnnotationReader processClassAnnotationsINFO: Class "org.docsample.model.Task" has been specified with JPA annotations so using those.Oct 24, 2011 10:49:07 AM org.datanucleus.metadata.MetaDataManager loadClassesINFO: Class "org.docsample.service.EntityService" has no MetaData or annotations.Oct 24, 2011 10:49:07 AM org.datanucleus.metadata.MetaDataManager loadClassesINFO: Class "org.docsample.service.TaskService" has no MetaData or annotations.Oct 24, 2011 10:49:07 AM org.datanucleus.enhancer.DataNucleusEnhancer mainSEVERE: DataNucleus Enhancer completed with an error. Please review the enhancer log for full details. Some classes may have been enhanced but some caused errorsErrors were encountered when loading the specified MetaData files and classes. See the nested exceptions for detailsorg.datanucleus.exceptions.NucleusUserException: Errors were encountered when loading the specified MetaData files and classes. See the nested exceptions for detailsat org.datanucleus.metadata.MetaDataManager.loadClasses(MetaDataManager.java:482)at org.datanucleus.enhancer.DataNucleusEnhancer.getFileMetadataForInput(DataNucleusEnhancer.java:791)at org.datanucleus.enhancer.DataNucleusEnhancer.enhance(DataNucleusEnhancer.java:582)at org.datanucleus.enhancer.DataNucleusEnhancer.main(DataNucleusEnhancer.java:1316)Caused by: java.lang.NullPointerExceptionat org.datanucleus.jpa.metadata.JPAAnnotationReader.newColumnMetaData(JPAAnnotationReader.java:2076)at org.datanucleus.jpa.metadata.JPAAnnotationReader.processMemberAnnotations(JPAAnnotationReader.java:1330)at org.datanucleus.metadata.annotations.AbstractAnnotationReader.getMetaDataForClass(AbstractAnnotationReader.java:161)at org.datanucleus.metadata.annotations.AnnotationManagerImpl.getMetaDataForClass(AnnotationManagerImpl.java:135)at org.datanucleus.metadata.MetaDataManager.loadAnnotationsForClass(MetaDataManager.java:2354)at org.datanucleus.metadata.MetaDataManager.loadClasses(MetaDataManager.java:442)... 3 moreNested Throwables StackTrace:java.lang.NullPointerExceptionat org.datanucleus.jpa.metadata.JPAAnnotationReader.newColumnMetaData(JPAAnnotationReader.java:2076)at org.datanucleus.jpa.metadata.JPAAnnotationReader.processMemberAnnotations(JPAAnnotationReader.java:1330)at org.datanucleus.metadata.annotations.AbstractAnnotationReader.getMetaDataForClass(AbstractAnnotationReader.java:161)at org.datanucleus.metadata.annotations.AnnotationManagerImpl.getMetaDataForClass(AnnotationManagerImpl.java:135)at org.datanucleus.metadata.MetaDataManager.loadAnnotationsForClass(MetaDataManager.java:2354)at org.datanucleus.metadata.MetaDataManager.loadClasses(MetaDataManager.java:442)at org.datanucleus.enhancer.DataNucleusEnhancer.getFileMetadataForInput(DataNucleusEnhancer.java:791)at org.datanucleus.enhancer.DataNucleusEnhancer.enhance(DataNucleusEnhancer.java:582)at org.datanucleus.enhancer.DataNucleusEnhancer.main(DataNucleusEnhancer.java:1316)
[ERROR] --------------------[INFO] ------------------------------------------------------------------------[INFO] BUILD FAILURE[INFO] ------------------------------------------------------------------------[INFO] Total time: 3.202s[INFO] Finished at: Mon Oct 24 10:49:07 CDT 2011[INFO] Final Memory: 7M/81M[INFO] ------------------------------------------------------------------------[ERROR] Failed to execute goal org.datanucleus:maven-datanucleus-plugin:2.1.0-release:enhance (default) on project hellocloud: The DataNucleus tool org.datanucleus.enhancer.DataNucleusEnhancer exited with a non-null exit code. -> [Help 1]

 

How were you able to resolve the issue above? 

 

I'll log a bug

Hari Krishna SAGHari Krishna SAG

Hi Edwin,

 

Very Good Morning,

 

I am working with Spring Roo sample & JDK 1.6.0_17

 

and Maven 3.0.3 with Jetty server.

 

Could you please tell me what is the solution for the following problem. 

 

>>  D:\maven-3.0.3\boot\plexus-classworlds-2.4.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 53.643s
[INFO] Finished at: Thu Nov 24 12:29:30 IST 2011
[INFO] Final Memory: 7M/13M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.datanucleus:maven-datanucleus-plugin:2.1.0-re
lease:enhance (default) on project rootest: Error executing enhancer: Invocation
TargetException: com/cts/rootest/model/AlbumRoo : Unsupported major.minor versio
n 51.0 -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e swit
ch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please rea
d the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionE
xception

 

Thanks & Regards,

Hari krishna.