Git Product home page Git Product logo

java-sdk's People

Contributors

jsimone avatar jwetzler avatar mleonardsfdc avatar niqbal avatar ryanbrainard avatar tkral avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

java-sdk's Issues

force.com/jdk

Problem - I created java entities using maven for force.com objects. When I try to use entities it shows fields type mismatches Geogerian calendar/Boolean types. In case if I comment all the fields it still shows

java.lang.IllegalArgumentException: out of field index :7
at com.force.sdk.jpa.model.BaseForceObject.jdoReplaceField(BaseForceObject.java)

I'm using following version:
Java-version - 1.6
org.springframework-version-3.0.5.RELEASE
org.aspectj-version-1.6.9
org.slf4j-version-1.6.1
force.sdk.version-22.0.7-BETA
dependency - javax.jdo
artifactId-jdo2-api
version-2.3-eb

My entity code:
@javax.annotation.Generated(value="com.force.sdk.codegen.ForceJPAClassGenerator")
@table(name="detail__c")
@entity(name="Detail")
@com.force.sdk.jpa.annotation.CustomObject(readOnlySchema=true)
public class Detail extends com.force.sdk.jpa.model.BaseForceCustomObject {

  public static final String KEY_PREFIX = "a17";
  protected User createdBy;
  protected User lastModifiedBy;
  protected Event eventId;
  protected Account studentAccountId;
  protected java.util.Calendar lastExecutionDate;
  protected boolean sloan;
  @ManyToOne
  @Basic(fetch=FetchType.LAZY)
  @Column(name="LastModifiedById")
  public User getLastModifiedBy() {
     return this.lastModifiedBy;
  }
  public void setLastModifiedBy(User lastModifiedBy) {
    this.lastModifiedBy = lastModifiedBy;
  }
 @ManyToOne
 @Basic(fetch=FetchType.LAZY)
 @Column(name="event_id__c")
 public Event getEventId() {
    return this.eventId;
  }
 @Basic(optional=false)
 public void setEventId(Event eventId) {
    this.eventId = eventId;
  }
 @ManyToOne
 @Basic(fetch=FetchType.LAZY)
 @Column(name="student_account_id__c")
 public Account getStudentAccountId() {
    return this.studentAccountId;
  }
 @Basic(optional=false)
 public void setStudentAccountId(Account studentAccountId) {
    this.studentAccountId = studentAccountId;
  }
 @Temporal(TemporalType.TIMESTAMP)
 @Column(name="last_execution_date__c")
 public java.util.Calendar getLastExecutionDate() {
    return this.lastExecutionDate;
  }
 public void setLastExecutionDate(java.util.Calendar lastExecutionDate) {
    this.lastExecutionDate = lastExecutionDate;
  }
@Column(name="sloan__c")
public boolean getSloan() {
    return this.sloan;
  }
public void setSloan(boolean sloan) {
    this.sloan = sloan;
  }

Please someone help me with this.

spring roo addon

Hi:
I read, in the blog post, that the source contains code for an add-on to SpringRoo....can someone point it out to me? Can't seem to find it.
Thanks

Unable to convert date field

I followed the instructions in http://forcedotcom.github.io/java-sdk/quick-start

I used the maven plugin to auto generate my classes.

When I try to retrieve an object, I'm hit with a conversion exception from String to double (java.lang.NumberFormatException: For input string: "2013-05-21T06:19:04.000Z") . I think the problem is in the mapping of createdDate to java.util.Calendar, and not java.util.Date (mapping is in com.force.sdk.jpa.model.BaseForceStandardObject).

javax.persistence.PersistenceException: For input string: "2013-05-21T06:19:04.000Z"
at org.datanucleus.jpa.NucleusJPAHelper.getJPAExceptionForNucleusException(NucleusJPAHelper.java:244)
at com.force.sdk.jpa.ForceEntityManager.find(ForceEntityManager.java:296)
at org.datanucleus.jpa.EntityManagerImpl.find(EntityManagerImpl.java:236)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.springframework.orm.jpa.SharedEntityManagerCreator$SharedEntityManagerInvocationHandler.invoke(SharedEntityManagerCreator.java:240)
at $Proxy32.find(Unknown Source)
at com.zazma.risk.service.EntityService.findAccount(EntityService.java:66)
at com.zazma.risk.service.EntityService$$FastClassByCGLIB$$e08a81ee.invoke()
at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:191)
at org.springframework.aop.framework.Cglib2AopProxy$CglibMethodInvocation.invokeJoinpoint(Cglib2AopProxy.java:688)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:621)
at com.zazma.risk.service.EntityService$$EnhancerByCGLIB$$a57e3333.findAccount()
at com.zazma.risk.BasicCRUDIT.testAccountCRUD(BasicCRUDIT.java:117)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:74)
at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:82)
at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:72)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:240)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:180)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: java.lang.NumberFormatException: For input string: "2013-05-21T06:19:04.000Z"
at sun.misc.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:1222)
at java.lang.Double.parseDouble(Double.java:510)
at com.force.sdk.jpa.ForceFetchFieldManager.fetchDoubleField(ForceFetchFieldManager.java:185)
at org.datanucleus.state.AbstractStateManager.replacingDoubleField(AbstractStateManager.java:1106)
at com.zazma.risk.model.Account.jdoReplaceField(Account.java)
at com.force.sdk.jpa.model.BaseForceObject.jdoReplaceFields(BaseForceObject.java)
at org.datanucleus.jdo.state.JDOStateManagerImpl.replaceFields(JDOStateManagerImpl.java:2983)
at org.datanucleus.jdo.state.JDOStateManagerImpl.replaceFields(JDOStateManagerImpl.java:3003)
at org.datanucleus.state.ObjectProviderImpl.replaceFields(ObjectProviderImpl.java:70)
at com.force.sdk.jpa.ForcePersistenceHandler.fetchObject(ForcePersistenceHandler.java:136)
at org.datanucleus.jdo.state.JDOStateManagerImpl.loadFieldsFromDatastore(JDOStateManagerImpl.java:2028)
at org.datanucleus.jdo.state.JDOStateManagerImpl.validate(JDOStateManagerImpl.java:4528)
at org.datanucleus.ObjectManagerImpl.findObject(ObjectManagerImpl.java:2809)
at org.datanucleus.jpa.EntityManagerImpl.find(EntityManagerImpl.java:305)
at com.force.sdk.jpa.ForceEntityManager.find(ForceEntityManager.java:294)

OAuth ForceServiceConnector shares 1 connection for all users

This seem like a major problem with OAuth implementation or the Sample Spring app with SDK setup is wrong.
In simple web app I want to use SDK and SF as identity provider, let users login to the app using their existing Salesforce user.
For the 1st user it works perfectly well he gets OAuth and connection to the org all works normal, that is great!
Now the PROBLEM! Get 2nd browser session and try login to the same app with different User on different ORG, the OAuth works again and let 2nd user into the app BUT this user now also has same connection as user #1 so they share same connection given by SDK even though they are from totally different ORG, is this working correctly by OAuth standard? I must be missing something simple in Spring or Security config and need help. I try many different settings nothing seem to work, ForceServiceConnector always returns the connection for the 1st initial authenticated user to all incoming sessions regardless where they come or what browser it is or what user it is. So anyone with Salesforce USER ID always get the same #1 user connection instead of their own ORG connection based on their user authentication.

I did try several versions of SDK same result, most recent I use 22.0.8-BETA SDK same auth problem need help finding a solution or correct configuration.

Here is my security parms in Spring, I did try session and cookie store:

securityContextStorageMethod
cookie



secure-key-file



storeUsername
true

This may be related to the Spring context being singleton for single app I try to switch that around NO GO!
The demo app from SDK does same effect with multi user login #1 user connection always given to all other users who login after the 1st user.

Any ideas or fixes, settings to resolve this or it is part of OAuth SDK design to get one connection and pass that to any user?

PostLoad not always called

I am working with a slightly more advanced object that requires a @PostLoad method. I found that the JPA adapter is not reliably calling the method annotated with @PostLoad. The method gets called if the object is explicitly loaded but not if the object is implicitly loaded.

This works:

author = entityManager.find(Author.class, authorId);  // The @PostLoad method gets called for author

This does NOT work:

book = entityManager.find(Book.class, bookId);
author = book.getAuthor(); // The @PostLoad is NOT called for author

P.S. - Yes, the Book and Author class have a relationship defined between them.

java.lang.IllegalArgumentException: Illegal connection url (force://[email protected]&password=passwordToKeN). Illegal value ([email protected]&password=passwordTOKEN) for ForceConnectionProperty (endpoint)

I am using the maven archetype plugin to generate a sample spring MVC app connecting to force.com database that uses the java-sdk. I have signed up for an account at database.com and created the properties file to point to a URL as follows:

force://login.salesforce.com?user=[email protected]&password=passwordTOKEN

where my email address/password/TOKEN are substituted with the values for my account.

I am very new to force/database.com so I am almost certainly not setting my account up correctly or using the wrong host. Please could some kind of pointer be given to help me know what is invalid with my url or account and how I can change this.

My stacktrace is pasted below

Thanks
Adrian

Caused by: 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: com.force.sdk.jpa.PersistenceProviderImpl, org.datanucleus.jpa.PersistenceProviderImpl from provider: com.force.sdk.jpa.PersistenceProviderImpl
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1420)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.findDefaultEntityManagerFactory(PersistenceAnnotationBeanPostProcessor.java:529)
at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.findEntityManagerFactory(PersistenceAnnotationBeanPostProcessor.java:495)
at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor$PersistenceElement.resolveEntityManager(PersistenceAnnotationBeanPostProcessor.java:656)
at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor$PersistenceElement.getResourceToInject(PersistenceAnnotationBeanPostProcessor.java:629)
at org.springframework.beans.factory.annotation.InjectionMetadata$InjectedElement.inject(InjectionMetadata.java:147)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:84)
at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.postProcessPropertyValues(PersistenceAnnotationBeanPostProcessor.java:338)
... 57 more
Caused by: javax.persistence.PersistenceException: Explicit persistence provider error(s) occurred for "forceDatabase" after trying the following discovered implementations: com.force.sdk.jpa.PersistenceProviderImpl, org.datanucleus.jpa.PersistenceProviderImpl from provider: com.force.sdk.jpa.PersistenceProviderImpl
at javax.persistence.Persistence.createPersistenceException(Persistence.java:242)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:184)
at org.springframework.orm.jpa.LocalEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalEntityManagerFactoryBean.java:92)
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:308)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1477)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1417)
... 70 more
Caused by: java.lang.IllegalArgumentException: Illegal connection url (force://login.salesforce.com?user=[email protected]&password=passwordTOKEN). Illegal value (login.salesforce.com?user=[email protected]&password=passwordTOKEN) for ForceConnectionProperty (endpoint)
at com.force.sdk.connector.ForceConnectionProperty.validateValue(ForceConnectionProperty.java:163)
at com.force.sdk.connector.ForceConnectorUtils.loadConnectorPropsFromUrl(ForceConnectorUtils.java:295)
at com.force.sdk.connector.ForceConnectorUtils.loadConnectorPropsFromFile(ForceConnectorUtils.java:236)
at com.force.sdk.connector.ForceConnectorUtils.loadConnectorPropsFromName(ForceConnectorUtils.java:197)
at com.force.sdk.connector.ForceConnectorConfig.loadFromName(ForceConnectorConfig.java:72)
at com.force.sdk.connector.ForceServiceConnector.getConfig(ForceServiceConnector.java:299)
at com.force.sdk.connector.ForceServiceConnector.initConnection(ForceServiceConnector.java:255)
at com.force.sdk.connector.ForceServiceConnector.initMetadataConnection(ForceServiceConnector.java:416)
at com.force.sdk.connector.ForceServiceConnector.getNamespace(ForceServiceConnector.java:492)
at com.force.sdk.jpa.ForceManagedConnection.getNamespace(ForceManagedConnection.java:111)
at com.force.sdk.jpa.schema.ForceStoreSchemaHandler.cacheDescribeSObjects(ForceStoreSchemaHandler.java:124)
at com.force.sdk.jpa.ForceStoreManager.preInitialiseFileMetaData(ForceStoreManager.java:309)
at com.force.sdk.jpa.ForceMetaDataManager.initialiseFileMetaDataForUse(ForceMetaDataManager.java:262)
at org.datanucleus.metadata.MetaDataManager.loadPersistenceUnit(MetaDataManager.java:854)
at com.force.sdk.jpa.ForceMetaDataManager.loadPersistenceUnit(ForceMetaDataManager.java:113)
at org.datanucleus.jpa.EntityManagerFactoryImpl.initialisePMF(EntityManagerFactoryImpl.java:598)
at org.datanucleus.jpa.EntityManagerFactoryImpl.(EntityManagerFactoryImpl.java:380)
at com.force.sdk.jpa.ForceEntityManagerFactory.(ForceEntityManagerFactory.java:63)
at com.force.sdk.jpa.PersistenceProviderImpl.createEntityManagerFactory(PersistenceProviderImpl.java:79)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:150)
... 74 more

Would really like "OFFSET" support

I was trying to work with a very large dataset by using paging techniques (query.setFirstResult() & query.setMaxResults()). I discovered that it didn't really work. A little more research and I found that there is a new SOQL option called "OFFSET" that DOES work for me through the REST interface.

It would be really nice if the JPA adapter could be updated to use the new SOQL "OFFSET" option to make query.setFirstResult() work correctly. Until that happens it looks like I am unable to use JPA for large datasets.

It is not a show stopper for me right now because I am temporarily switching over to the REST interface. I think this is something that will need to be addressed, however, before others try to use JPA for production applications.

Can't Start tc Server

Following the Quick Start from the docs I am able to successfully build and run the hellocloud application. However, with a fresh install of STS I am unable to start tc Server after importing the project. It looks like the server config is looking in the wrong directory for tomcat. See http://jeffdouglas.com/spring-error.png. Any ideas?

Thanks
Jeff

Oddities in HTTPS vs. HTTP for force:// URLs

I was having some difficulties making the connections for JPA work in my test environment. I discovered that the JPA adapter is playing funny tricks when choosing between HTTP and HTTPS protocols. The JPA adapter uses HTTPS to talk to my public Dev org and uses HTTP to talk to my local development build. It was a surprise to me.

I looked at the JPA code and discovered that there is special code to do this. Unfortunately the special logic is messing me up. I am losing control to select the protocol I want. I want the same protocol for all my test environments but right now I get different protocols depending on my hostname.

I am working around the problem now but I think this special logic in JPA is a problem and is likely to mess customers up. If a customer accidentally has a DNS host name that includes the "internal" word then the customer will start getting the wrong kinds of connections. I suggest we remove the special logic from the JPA adapter and not base the HTTP protocol on the host name. It is risky.

Illegal connection URL

Version built from git (pulled yesterday) 22.0.6 throws an exception with a connection URL which seems to work fine in 22.0.3 (Which is in the current maven repo)

Exception is:

Caused by: java.lang.IllegalArgumentException: Illegal connection url (force://test.salesforce.com;user=[email protected];password=CHANGEDJJ3eZki3
gEZORCFrOZNz7eaSs;oauth_key=5MV442mZZZnmM6mzLV39eLlSuWQgNB2Z2R9kScjg_Xs58q7Jm9zgz5ERs5ZEZ78oA606pOSoeHQABAKW3cWc;oauth_secret=123456916284780867). The ForceCo
nnectionProperty (endpoint) must have a value

My persistence xml is:

<persistence-unit name="forceDatabase">
    <provider>com.force.sdk.jpa.PersistenceProviderImpl</provider>
    <!-- In a single module web application, no need to specify classes. Classes 
        will be autodiscovered based on @Entity annotation -->
    <properties>
        <property name="datanucleus.storeManagerType" value="force" />
        <property name="datanucleus.autoCreateSchema" value="false" />
        <property name="datanucleus.autoCreateWarnOnError" value="false" />
        <property name="datanucleus.validateTables" value="false" />
        <property name="datanucleus.ConnectionURL" value="force://test.salesforce.com;[email protected];password=CHANGEDJJ3eZki3gEZORCFrOZNz7eaSs;oauth_key=5MV442mZZZnmM6mzLV39eLlSuWQgNB2Z2R9kScjg_Xs58q7Jm9zgz5ERs5ZEZ78oA606pOSoeHQABAKW3cWc;oauth_secret=123456916284780867"/>
        <property name="datanucleus.validateConstraints" value="false" />
        <property name="datanucleus.Optimistic" value="false" />
        <property name="datanucleus.datastoreTransactionDelayOperations" value="true" />
        <property name="datanucleus.jpa.addClassTransformer" value="false" />
        <property name="datanucleus.cache.level2.type" value="none" />
        <property name="datanucleus.detachAllOnCommit" value="true" />
        <property name="datanucleus.copyOnAttach" value="false" />

    </properties>
</persistence-unit>

DataNucleus JDOFatalUserException: No metadata has been registered for class

I generated entities for my force.com application using the maven-force-plugin.

Then I created a simple main program to connect to my org and load a Contact entity:

    public static void main(String[] args) {
        EntityManager em = 
            Persistence
                .createEntityManagerFactory(PERSISTENCE_UNIT_NAME)
                .createEntityManager();
        try {
            System.out.println("Contact: " + em.find(Contact.class, CONTACT_ID));
        }
        finally {
            em.close();
        }
    }

When I run this I get the following exception:

    Exception in thread "main" javax.jdo.JDOFatalUserException: No metadata has been registered for class com.claimvantagecorp.model.Contact.
        at javax.jdo.spi.JDOImplHelper.getMeta(JDOImplHelper.java:493)
        at javax.jdo.spi.JDOImplHelper.newInstance(JDOImplHelper.java:227)
        at org.datanucleus.jdo.state.JDOStateManagerImpl.initialiseForHollow(JDOStateManagerImpl.java:253)
        at org.datanucleus.state.StateManagerFactory.newStateManagerForHollow(StateManagerFactory.java:56)
        at org.datanucleus.ObjectManagerImpl.findObject(ObjectManagerImpl.java:2772)
        at org.datanucleus.jpa.EntityManagerImpl.find(EntityManagerImpl.java:305)
        at com.force.sdk.jpa.ForceEntityManager.find(ForceEntityManager.java:294)
        at org.datanucleus.jpa.EntityManagerImpl.find(EntityManagerImpl.java:236)

When I breakpoint the line that registers a classes jdo metadata, JDOImplHelper.java:364, I can see that the mapped superclasses of the entities are being added but not the entities them selves.

Btw, this is the debug output:

    17:02:58 INFO  [Persistence] - Property datanucleus.rdbms.stringDefaultLength unknown - will be ignored
    17:02:58 INFO  [Persistence] - ================= Persistence Configuration ===============
    17:02:58 INFO  [Persistence] - DataNucleus Persistence Factory - Vendor: "DataNucleus"  Version: "2.2.3"
    17:02:58 INFO  [Persistence] - DataNucleus Persistence Factory initialised for datastore URL="" driver="" userName=""
    17:02:58 INFO  [Persistence] - ===========================================================
    17:02:58 INFO  [Persistence] - Property force.ConnectionName unknown - will be ignored
    17:02:58 INFO  [MetaData] - Not found any metadata mapping files for resource name META-INF/orm.xml in CLASSPATH
    17:02:59 INFO  [MetaData] - Class "com.example.model.Account" has been specified with JPA annotations so using those.
    17:02:59 INFO  [MetaData] - Class "com.example.model.Contact" has been specified with JPA annotations so using those.
    17:02:59 INFO  [MetaData] - Class "com.example.model.UserRole" has been specified with JPA annotations so using those.
    17:02:59 INFO  [MetaData] - Class "com.example.model.BusinessProcess" has been specified with JPA annotations so using those.
    17:02:59 INFO  [MetaData] - Class "com.example.model.Organization" has been specified with JPA annotations so using those.
    17:02:59 INFO  [MetaData] - Class "com.example.model.RecordType" has been specified with JPA annotations so using those.
    17:02:59 INFO  [MetaData] - Class "com.force.sdk.jpa.model.ForceOwner" has been specified with JPA annotations so using those.
    17:02:59 INFO  [MetaData] - Class "com.example.model.CallCenter" has been specified with JPA annotations so using those.
    17:02:59 INFO  [MetaData] - Class "com.example.model.Profile" has been specified with JPA annotations so using those.
    17:02:59 INFO  [MetaData] - Class "com.example.model.Dates" has been specified with JPA annotations so using those.
    17:02:59 INFO  [MetaData] - Class "com.example.model.Group" has been specified with JPA annotations so using those.
    17:02:59 INFO  [MetaData] - Class "com.example.model.UserLicense" has been specified with JPA annotations so using those.
    17:02:59 INFO  [MetaData] - Class "com.example.model.User" has been specified with JPA annotations so using those.
    17:02:59 INFO  [MetaData] - Class "com.force.sdk.jpa.model.BaseForceStandardObject" has been specified with JPA annotations so using those.
    17:02:59 INFO  [MetaData] - Class "com.force.sdk.jpa.model.BaseForceObject" has been specified with JPA annotations so using those.
    17:02:59 INFO  [MetaData] - Class "com.force.sdk.jpa.model.BaseForceCustomObject" has been specified with JPA annotations so using those.
    17:02:59 INFO  [connector] - Connection : Creating AbsenceJpaTest from environment variable: FORCE_JPATEST_URL
    17:03:13 INFO  [Persistence] - Managing Persistence of Class : com.force.sdk.jpa.model.BaseForceObject [Table : (none), InheritanceStrategy : subclass-table]
    17:03:13 INFO  [Persistence] - Managing Persistence of Class : com.example.model.CallCenter [Table : (none), InheritanceStrategy : new-table]
    17:03:13 INFO  [Persistence] - Managing Persistence of Class : com.example.model.UserLicense [Table : (none), InheritanceStrategy : new-table]
    17:03:13 INFO  [Persistence] - Managing Persistence of Class : com.example.model.Profile [Table : (none), InheritanceStrategy : new-table]
    17:03:13 INFO  [Persistence] - Managing Persistence of Class : com.example.model.UserRole [Table : (none), InheritanceStrategy : new-table]
    17:03:13 INFO  [Persistence] - Managing Persistence of Class : com.example.model.User [Table : (none), InheritanceStrategy : new-table]
    17:03:13 INFO  [Persistence] - Managing Persistence of Class : com.force.sdk.jpa.model.ForceOwner [Table : (none), InheritanceStrategy : new-table]
    17:03:13 INFO  [Persistence] - Managing Persistence of Class : com.force.sdk.jpa.model.BaseForceStandardObject [Table : (none), InheritanceStrategy : subclass-table]
    17:03:13 INFO  [Persistence] - Managing Persistence of Class : com.example.model.Account [Table : (none), InheritanceStrategy : new-table]
    17:03:13 INFO  [Persistence] - Managing Persistence of Class : com.example.model.BusinessProcess [Table : (none), InheritanceStrategy : new-table]
    17:03:13 INFO  [Persistence] - Managing Persistence of Class : com.example.model.RecordType [Table : (none), InheritanceStrategy : new-table]
    17:03:13 INFO  [Persistence] - Managing Persistence of Class : com.force.sdk.jpa.model.BaseForceCustomObject [Table : (none), InheritanceStrategy : subclass-table]
    17:03:13 INFO  [Persistence] - Managing Persistence of Class : com.example.model.Contact [Table : (none), InheritanceStrategy : new-table]
    Exception in thread "main" javax.jdo.JDOFatalUserException: No metadata has been registered for class com.example.model.Contact.

Btw, I tried posting this as a question on stackoverflow but the tag database.com hasn't been created yet and (I'm ashamed to say :(), I don't have the reputation to create one. Any help or pointers would be much appreciated.

ForceMappingConfigurationStrategy doesn't pick up the identity field

The library doesn't correctly identify the identity field for a generated JPA class. The JpaMappingConfigurationStrategy seems to looks up the @id annotation based on the field on line ~130 of this class. I'm not sure why the JpaMappingConfigurationStrategy is looking up the annotations against the fields instead of using a bean wrapper, but as a result it doesn't see the annotations (@id is important in my case). My hack is to override the JpaMappingConfigurationStrategy (and change the provider in ForceMappingContext) and add this method:

public PersistentProperty getIdentity(Class javaClass, MappingContext context) {
    if ( !identities.containsKey(javaClass) ){
        final ClassPropertyFetcher cpf = ClassPropertyFetcher.forClass(javaClass);
        PropertyDescriptor propertyDescriptor = cpf.getPropertyDescriptor("id");
        final PersistentEntity owner = context.getPersistentEntity(javaClass.getName());
        identities.put(javaClass, propertyFactory.createIdentity(owner, context, propertyDescriptor));
    }
    return identities.get(javaClass);
}

Unable to handshake using forcedotcom jetstream

Hi,

I am facing some issues starting up jetstream. I have followed the instructions for Java webapp. I am using embedded Jetty. Following is the execution log. Would appreciate any help in debugging this issue. Thanks.

Regards,

Shashi

D:\Cloudspokes\MavenTest\jetstream>.\target\bin\webapp
Drive already SUBSTed
31 [main] INFO org.eclipse.jetty.util.log - jetty-7.4.0.v20110414
203 [main] INFO org.eclipse.jetty.util.log - started o.e.j.w.WebAppContext{/,file:/D:/Cloudspokes/MavenTest/jetstream/sr
c/main/webapp/}
405 [main] INFO com.force.sdk.streaming.server.ForceStreamingService - Creating bayeux service at /service/force
639 [main] INFO com.force.sdk.streaming.client.ForceStreamingClientModule - Providing http client for connection name fo
rceDatabase
639 [main] INFO com.force.sdk.connector - Connection : Creating forceDatabase from environment variable: FORCE_FORCEDATA
BASE_URL
639 [main] INFO com.force.sdk.connector - Connection : loading forceDatabase from cache
log4j:WARN No appenders could be found for logger (DataNucleus.ClassLoading).
log4j:WARN Please initialize the log4j system properly.
201776 [main] INFO org.eclipse.jetty.util.log - Started [email protected]:8080 STARTING
201776 [main] INFO org.eclipse.jetty.util.log - Started [email protected]:8443 STARTING
Connecting to push topic topic
204364 [HttpClient-16] INFO org.cometd.client.BayeuxClient@20910958 - Messages failed [{"id":"1","supportedConnectionTyp
es":["long-polling"],"channel":"/meta/handshake","version":"1.0"}]
java.net.ProtocolException: Unexpected response 400: TransportExchange@24333128=POST//login.salesforce.com:443/cometd/23
.0/handshake#7
at org.cometd.client.BayeuxClient$PublishTransportListener.onProtocolError(BayeuxClient.java:1106)
at org.cometd.client.transport.LongPollingTransport$TransportExchange.onResponseComplete(LongPollingTransport.ja
va:304)
at org.eclipse.jetty.client.HttpExchange$Listener.onResponseComplete(HttpExchange.java:968)
at org.eclipse.jetty.client.HttpExchange.setStatus(HttpExchange.java:279)
at org.eclipse.jetty.client.HttpConnection$Handler.messageComplete(HttpConnection.java:619)
at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:862)
at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:214)
at org.eclipse.jetty.client.HttpConnection.handle(HttpConnection.java:275)
at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:535)
at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:40)
at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:529)
at java.lang.Thread.run(Thread.java:619)
Removing channel /force/topic
205642 [HttpClient-19] INFO org.cometd.client.BayeuxClient@20910958 - Messages failed [{"id":"2","supportedConnectionTyp
es":["long-polling"],"channel":"/meta/handshake","version":"1.0"}]
java.net.ProtocolException: Unexpected response 400: TransportExchange@26153596=POST//login.salesforce.com:443/cometd/23
.0/handshake#7
at org.cometd.client.BayeuxClient$PublishTransportListener.onProtocolError(BayeuxClient.java:1106)
at org.cometd.client.transport.LongPollingTransport$TransportExchange.onResponseComplete(LongPollingTransport.ja
va:304)
at org.eclipse.jetty.client.HttpExchange$Listener.onResponseComplete(HttpExchange.java:968)
at org.eclipse.jetty.client.HttpExchange.setStatus(HttpExchange.java:279)
at org.eclipse.jetty.client.HttpConnection$Handler.messageComplete(HttpConnection.java:619)
at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:862)
at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:214)
at org.eclipse.jetty.client.HttpConnection.handle(HttpConnection.java:275)
at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:535)
at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:40)
at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:529)
at java.lang.Thread.run(Thread.java:619)
Removing channel /force
207917 [HttpClient-21] INFO org.cometd.client.BayeuxClient@20910958 - Messages failed [{"id":"3","supportedConnectionTyp
es":["long-polling"],"channel":"/meta/handshake","version":"1.0"}]
java.net.ProtocolException: Unexpected response 400: TransportExchange@25847952=POST//login.salesforce.com:443/cometd/23
.0/handshake#7
at org.cometd.client.BayeuxClient$PublishTransportListener.onProtocolError(BayeuxClient.java:1106)
at org.cometd.client.transport.LongPollingTransport$TransportExchange.onResponseComplete(LongPollingTransport.ja
va:304)
at org.eclipse.jetty.client.HttpExchange$Listener.onResponseComplete(HttpExchange.java:968)
at org.eclipse.jetty.client.HttpExchange.setStatus(HttpExchange.java:279)
at org.eclipse.jetty.client.HttpConnection$Handler.messageComplete(HttpConnection.java:619)
at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:862)
at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:214)
at org.eclipse.jetty.client.HttpConnection.handle(HttpConnection.java:275)
at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:535)
at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:40)
at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:529)
at java.lang.Thread.run(Thread.java:619)
211814 [HttpClient-20] INFO org.cometd.client.BayeuxClient@20910958 - Messages failed [{"id":"4","supportedConnectionTyp
es":["long-polling"],"channel":"/meta/handshake","version":"1.0"}]
java.net.ProtocolException: Unexpected response 400: TransportExchange@23449824=POST//login.salesforce.com:443/cometd/23
.0/handshake#7
at org.cometd.client.BayeuxClient$PublishTransportListener.onProtocolError(BayeuxClient.java:1106)
at org.cometd.client.transport.LongPollingTransport$TransportExchange.onResponseComplete(LongPollingTransport.ja
va:304)
at org.eclipse.jetty.client.HttpExchange$Listener.onResponseComplete(HttpExchange.java:968)
at org.eclipse.jetty.client.HttpExchange.setStatus(HttpExchange.java:279)
at org.eclipse.jetty.client.HttpConnection$Handler.messageComplete(HttpConnection.java:619)
at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:862)
at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:214)
at org.eclipse.jetty.client.HttpConnection.handle(HttpConnection.java:275)
at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:535)
at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:40)
at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:529)
at java.lang.Thread.run(Thread.java:619)
213217 [qtp10748354-42] INFO com.force.sdk.streaming.client.ForceBayeuxClient - Unable to complete handshake. Disconnect
ing from service.

Can't load datanucleus on Wildfly 9.x

I'm using Wildfly 9.0.1 application server and trying to use force.com java sdk.
Following javaample-musiclib sample, I updated the file src/main/resources/META-INF/persistence.xml

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">

    <persistence-unit name="forceDatabase">
        <provider>com.force.sdk.jpa.PersistenceProviderImpl</provider>
        <properties>
            <property name="datanucleus.storeManagerType" value="force" />
            <property name="datanucleus.autoCreateSchema" value="true" />
            <property name="datanucleus.validateTables" value="false" />
            <property name="datanucleus.validateConstraints" value="false" />
            <property name="datanucleus.Optimistic" value="false" />
            <property name="datanucleus.datastoreTransactionDelayOperations" value="true" />
            <property name="datanucleus.jpa.addClassTransformer" value="false" />
            <property name="datanucleus.cache.level2.type" value="none" />
            <property name="datanucleus.detachAllOnCommit" value="true" />
            <property name="datanucleus.copyOnAttach" value="false" />
        </properties>
    </persistence-unit>
</persistence>

And my pom.xm file looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
                                            http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>com.artrunners</groupId>
        <artifactId>ar-web-parent</artifactId>
        <version>1.0.0-SNAPSHOT</version>
        <relativePath>../</relativePath>
    </parent>

    <artifactId>ar-web-cli</artifactId>
    <packaging>war</packaging>
    <name>${project.artifactId}</name>
    <description>ArtRunners marketplace web application project</description>


    <properties>
        <force.sdk.version>22.0.9-BETA</force.sdk.version>
    </properties>

    <build>
        <finalName>${project.artifactId}</finalName>
        <plugins>
            <!-- Compiler plugin -->
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.3</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>

            <!-- WAR plugin -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.6</version>
                <configuration>
                    <failOnMissingWebXml>false</failOnMissingWebXml>
                </configuration>
            </plugin>

            <!-- Wildfly deploy plugin -->
            <plugin>
                <groupId>org.wildfly.plugins</groupId>
                <artifactId>wildfly-maven-plugin</artifactId>
                <version>1.1.0.Alpha3</version>
                <executions>
                    <execution>
                        <phase>install</phase>
                        <goals>
                            <goal>deploy</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <name>${project.artifactId}</name>
                    <hostname>${wildfly.hostname}</hostname>
                    <username>${wildfly.username}</username>
                    <password>${wildfly.password}</password>
                    <force>true</force>
                </configuration>
            </plugin>

            <!-- Salesforce plugin -->
            <plugin>
                <groupId>com.force</groupId>
                <artifactId>maven-force-plugin</artifactId>
                <version>22.0.5-BETA</version>
                <configuration>
                    <connectionName>connname</connectionName>
                    <includes>
                        <include>Account</include>
                        <include>Contact</include>
                        <include>Order</include>
                        <include>Quote</include>
                        <include>Shipment__c</include>
                    </includes>
                    <destDir>${basedir}/src/main/java</destDir>
                    <packageName>com.artrunners.model.autogen</packageName>
                </configuration>
                <executions>
                    <execution>
                        <id>generate-force-entities</id>
                        <goals>
                            <goal>codegen</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.wildfly</groupId>
                <artifactId>wildfly-spec-api</artifactId>
                <version>${version.wildfly}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <dependencies>
        <!-- Import Wildfly Spec  -->
        <dependency>
            <groupId>org.wildfly</groupId>
            <artifactId>wildfly-spec-api</artifactId>
            <version>${version.wildfly}</version>
            <type>pom</type>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>org.jboss.spec.javax.servlet</groupId>
            <artifactId>jboss-servlet-api_3.1_spec</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.jboss.spec.javax.ws.rs</groupId>
            <artifactId>jboss-jaxrs-api_2.0_spec</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax.enterprise</groupId>
            <artifactId>cdi-api</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax.annotation</groupId>
            <artifactId>jsr250-api</artifactId>
            <version>1.0</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.hibernate.javax.persistence</groupId>
            <artifactId>hibernate-jpa-2.1-api</artifactId>
            <scope>provided</scope>
        </dependency>

        <!-- Import Resteasy client  -->
        <dependency>
            <groupId>org.jboss.resteasy</groupId>
            <artifactId>resteasy-client</artifactId>
            <scope>provided</scope>
        </dependency>


        <!-- Salesforce Database.com -->
        <dependency>
            <groupId>com.force.sdk</groupId>
            <artifactId>force-jpa</artifactId>
            <version>${force.sdk.version}</version>
        </dependency>
        <dependency>
            <groupId>org.datanucleus</groupId>
            <artifactId>datanucleus-core</artifactId>
            <version>2.2.3</version>
        </dependency>
        <dependency>
            <groupId>org.datanucleus</groupId>
            <artifactId>datanucleus-enhancer</artifactId>
            <version>2.1.0-release</version>
        </dependency>
        <dependency>
            <groupId>org.datanucleus</groupId>
            <artifactId>datanucleus-jpa</artifactId>
            <version>2.1.7</version>
        </dependency>
        <dependency>
            <groupId>javax.jdo</groupId>
            <artifactId>jdo2-api</artifactId>
            <version>2.3-eb</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>1.6.1</version>
        </dependency>

        <!-- JUnit -->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>${version.junit}</version>
            <scope>test</scope>
        </dependency>

    </dependencies>

</project>

Since datanucleus-jpa is an OSGI bundle and Wildfly is not OSGI container, I followed datanucleus guidelines and explicitly defined the persistence provider in file src/main/resources/META-INF/services/javax.persistence.spi.PersistenceProvider:

org.datanucleus.jpa.PersistenceProviderImpl

When running the application server, it fails to load datanucleus, here is the error log:

13:31:13,983 ERROR [org.jboss.msc.service.fail] (ServerService Thread Pool -- 10) MSC000001: Failed to start service jboss.persistenceunit."ar-web-cli.war#forceDatabase": org.jboss.msc.service.StartException in service jboss.persistenceunit."ar-web-cli.war#forceDatabase": javax.jdo.JDOFatalInternalException: Unexpected exception caught.
NestedThrowables:
java.lang.reflect.InvocationTargetException
    at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1$1.run(PersistenceUnitServiceImpl.java:172)
    at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1$1.run(PersistenceUnitServiceImpl.java:117)
    at org.wildfly.security.manager.WildFlySecurityManager.doChecked(WildFlySecurityManager.java:665)
    at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1.run(PersistenceUnitServiceImpl.java:182)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
    at org.jboss.threads.JBossThread.run(JBossThread.java:320)
Caused by: javax.jdo.JDOFatalInternalException: Unexpected exception caught.
NestedThrowables:
java.lang.reflect.InvocationTargetException
    at javax.jdo.JDOHelper.invokeGetPersistenceManagerFactoryOnImplementation(JDOHelper.java:1186)
    at javax.jdo.JDOHelper.getPersistenceManagerFactory(JDOHelper.java:803)
    at javax.jdo.JDOHelper.getPersistenceManagerFactory(JDOHelper.java:698)
    at org.datanucleus.jpa.EntityManagerFactoryImpl.initialisePMF(EntityManagerFactoryImpl.java:592)
    at org.datanucleus.jpa.EntityManagerFactoryImpl.<init>(EntityManagerFactoryImpl.java:282)
    at com.force.sdk.jpa.ForceEntityManagerFactory.<init>(ForceEntityManagerFactory.java:53)
    at com.force.sdk.jpa.PersistenceProviderImpl.createContainerEntityManagerFactory(PersistenceProviderImpl.java:59)
    at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.createContainerEntityManagerFactory(PersistenceUnitServiceImpl.java:318)
    at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.access$1100(PersistenceUnitServiceImpl.java:67)
    at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1$1.run(PersistenceUnitServiceImpl.java:167)
    ... 7 more
Caused by: java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at javax.jdo.JDOHelper$16.run(JDOHelper.java:1956)
    at java.security.AccessController.doPrivileged(Native Method)
    at javax.jdo.JDOHelper.invoke(JDOHelper.java:1951)
    at javax.jdo.JDOHelper.invokeGetPersistenceManagerFactoryOnImplementation(JDOHelper.java:1159)
    ... 16 more
Caused by: org.datanucleus.exceptions.NucleusUserException: Persistence process has been specified to use a ClassLoaderResolver of name "" yet this has not been found by the DataNucleus plugin mechanism. Please check your CLASSPATH and plugin specification.
    at org.datanucleus.OMFContext.getClassLoaderResolver(OMFContext.java:327)
    at org.datanucleus.OMFContext.<init>(OMFContext.java:181)
    at org.datanucleus.OMFContext.<init>(OMFContext.java:149)
    at org.datanucleus.ObjectManagerFactoryImpl.initialiseOMFContext(ObjectManagerFactoryImpl.java:137)
    at org.datanucleus.jdo.JDOPersistenceManagerFactory.initialiseProperties(JDOPersistenceManagerFactory.java:370)
    at org.datanucleus.jdo.JDOPersistenceManagerFactory.<init>(JDOPersistenceManagerFactory.java:314)
    at com.force.sdk.jdo.ForceJDOPersistenceManagerFactory.<init>(ForceJDOPersistenceManagerFactory.java:64)
    at com.force.sdk.jdo.ForceJDOPersistenceManagerFactory.createPersistenceManagerFactory(ForceJDOPersistenceManagerFactory.java:98)
    at com.force.sdk.jdo.ForceJDOPersistenceManagerFactory.getPersistenceManagerFactory(ForceJDOPersistenceManagerFactory.java:87)
    ... 24 more

13:31:13,991 ERROR [org.jboss.as.controller.management-operation] (management-handler-thread - 3) WFLYCTL0013: Operation ("deploy") failed - address: ([("deployment" => "ar-web-cli.war")]) - failure description: {"WFLYCTL0080: Failed services" => {"jboss.persistenceunit.\"ar-web-cli.war#forceDatabase\"" => "org.jboss.msc.service.StartException in service jboss.persistenceunit.\"ar-web-cli.war#forceDatabase\": javax.jdo.JDOFatalInternalException: Unexpected exception caught.
NestedThrowables:
java.lang.reflect.InvocationTargetException
    Caused by: javax.jdo.JDOFatalInternalException: Unexpected exception caught.
NestedThrowables:
java.lang.reflect.InvocationTargetException
    Caused by: java.lang.reflect.InvocationTargetException
    Caused by: org.datanucleus.exceptions.NucleusUserException: Persistence process has been specified to use a ClassLoaderResolver of name \"\" yet this has not been found by the DataNucleus plugin mechanism. Please check your CLASSPATH and plugin specification."}}
13:31:13,994 ERROR [org.jboss.as.server] (management-handler-thread - 3) WFLYSRV0021: Deploy of deployment "ar-web-cli.war" was rolled back with the following failure message: 
{"WFLYCTL0080: Failed services" => {"jboss.persistenceunit.\"ar-web-cli.war#forceDatabase\"" => "org.jboss.msc.service.StartException in service jboss.persistenceunit.\"ar-web-cli.war#forceDatabase\": javax.jdo.JDOFatalInternalException: Unexpected exception caught.
NestedThrowables:
java.lang.reflect.InvocationTargetException
    Caused by: javax.jdo.JDOFatalInternalException: Unexpected exception caught.
NestedThrowables:
java.lang.reflect.InvocationTargetException
    Caused by: java.lang.reflect.InvocationTargetException
    Caused by: org.datanucleus.exceptions.NucleusUserException: Persistence process has been specified to use a ClassLoaderResolver of name \"\" yet this has not been found by the DataNucleus plugin mechanism. Please check your CLASSPATH and plugin specification."}}

Any ideas how to get datanucleus to work with Wildfly?

SOQL queries don't support bind parameters (?)

The documentation says:

String soqlQuery = "SELECT Email, LastName " +
"FROM User WHERE FirstName = :firstName";
Query q = em.createNativeQuery(soqlQuery);
// Bind the named parameter into the query
q.setParameter("firstName", "Bob");

But this results in:

“javax.persistence.PersistenceException: Bind parameters not supported on native SOQL query”.

LogoutSuccessHandler does not clear SDK related cookies

I use SecurityContextCookieStore as security context storage service. Then I set the cookie path as "/" to make the cookies available to the whole site. However after I call the logout endpoint (with SDK LogoutSuccessHandler), those cookies does not clear. User can access the protected resources again without login.

When user logout, LogoutSuccessHandler calls SecurityContextService to clear all related cookies. From source code, clear cookie process does not specifiy the cookie path. From http spec (http://www.w3.org/Protocols/rfc2109/rfc2109), "Path Defaults to the path of the request URL that generated the Set-Cookie response, up to, but not including, the right-most /." If the SDK does not specific the path when clearing cookies, it just clear the cookies under the logout path. In my site login and logout endpoint are at two separate path, so I think this is the root course of the unexpected behaviour. Any suggestions?

Upgrade to use DN3.1+

DataNucleus v2.x hasn't been maintained for some time now (more than a year). DataNucleus 3.0 is also no longer maintained. Strongly suggest that you upgrade your plugin to use something recent (DN3.1, or DN3.2 milestone releases)

Objects loaded from queries don't always connect properly to their related objects

I encountered a problem with the Force JPA and I was hoping to talk to you at some point about it. I’ve tried to reproduce with a small program but have been unsuccessful. I can easily reproduce in my larger program. I thought maybe you or someone might have some ideas if you see the bug in action.

The problem is this:

I’ve got a tree of related objects. When I load the object with a “em.find” everything is built okay. If I load the object with a query instead then the object tree is not built okay. The “DEBUG” statements show the SOQL asking for all the information to build the tree but the tree doesn’t get built completely in the query case. The hierarchy looks something like this:

Subscription -> Application -> Vendor

When I query for Subscription the “Subscription -> Application” link comes out okay but the “Application -> Vendor” link is missing.

If I do “em.refresh(subscription)” after the query then the tree is built correctly. Naturally this is a performance problem so I prefer not to refresh each result of the query every time.

Do you have any ideas of how to proceed? Again, I have been unsuccessful in reproducing in a small program.

oauth cookies

Seems that oauth is depositing cookies on almost every call (I end up with a cookie at every directory level of the website). This should be reduced, but the problem is that the (other) cookies cause the session to be invalidated due to the session id in the session (when using session) not matching the force_sid cookie. This can happen after a logout or an expired session.

I think it's best to set the cookie path to make sure only 1 cookie is set and to avoid having different sid's.

Please have a look at these suggested changes:

ustramooner@9c0185c
ustramooner@444b52a

22.0.3 gets in a circular OAuth loop.

I setup security to use authentication as per the config below:

<security:http entry-point-ref="authenticationProcessingFilterEntryPoint" use-expressions="true">

        <security:intercept-url pattern="/**" access="isAuthenticated()" />

    <!-- sets this as the authentication filter over the default -->
    <security:custom-filter position="FORM_LOGIN_FILTER" ref="authenticationFilter"/>
    <security:custom-filter position="LOGOUT_FILTER" ref="logoutFilter"/>
</security:http>

This correctly results in the request being forward to Salesforce for authentication, back to my app url, then to the _auth handler, then a back to Salesforce (and so on) (continuing until manually stopped).

This seems to be a common problem with Spring Security, but I'm at a loss as to how to fix it, the redirection is back to path on my app which should then be treated as authenticated and not cause another redirect to the _auth filter for authentication with Salesforce.

java-sdk and roo

Hi:

I am testing java-sdk with STS 2.7.2, Roo 1.2.0M1 and java-sdk 22.0.7BETA. I have set up a simple entity with 2 fields (string).

Upon running the integration junit test on the entity, I get a number of errors on the OSGi console. One of them is:

ERROR DataNucleus.Plugin - Bundle "org.eclipse.jdt.junit.core" requires "org.eclipse.core.expressions" but it cannot be resolved.

All the others are similar but specify a different org.eclipse module.

Is this being caused by the java-sdk plugin (using the java-jdk as the database and data-nucleus-2 as the provider).?
Or, should I look elsewhere?

thanks
Edwin

Existing schema.. I have to manually create my Entity classes?

I already have an existing data model in Salesforce I want to interact with.

I assume I have two choices. Use sObject class and 'get()' methods to pull data out by field name or manually create my Entities in my Java project with the appropriate field getters/setters and annotations?

(Just wondering if I've over looked some documentation)

Large number of objects causes long startup times

On heroku, startup times can be significant for more than a few objects. The debug logs show:

Initialising Meta-Data for class XXX

Each call is taking ~500ms and sometimes as high as 3000ms. I believe that this is the bit where the java-sdk is fetching the metadata from force.com. This sometimes causes startup failures due to taking too long to startup on heroku.

If I'm not wrong, Force.com provides an API to allow querying more than one metadata object, so startup times could be significantly reduced by fetching the metadata for all metadata objects that will be required in a single call.

I haven't looked into how this could be achieved yet, but does anyone have any thoughts on this?

Java Spring Security stop working missing Salesforce XML schema

Salesforce Spring Security Schema URL suddenly returns 404 and Java apps built with OAUth on DB.com SDK stop working on Heroku. Any idea where this URL has moved: http://www.salesforce.com/schema/springsecurity?
Error result form Spring web app:
org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 18 in XML document from ServletContext resource [/WEB-INF/spring/security-config.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 18; columnNumber: 49; cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'fss:oauth'.

There is a definition: xmlns:fss="http://www.salesforce.com/schema/springsecurity"

Additional note: Another URL schema: http://media.developerforce.com/schema/force-springsecurity-1.2.xsd also returns Access denied instead of schema file.

Saving Object with OneToMany and un-persisted children

Attempting to save both the parent and children list of a OneToMany relationship fails with an error like:

org.datanucleus.exceptions.NucleusUserException: Field name: childs not found in Force.com object: Parent__c

Happens when we're expecting to insert both the parent and the children in the same transaction.

See more details in Stack Overflow question:

http://stackoverflow.com/questions/9671547/onetomany-returning-not-found-in-force-com-object

ForceOAuthConnector#getAccessToken expecting refresh_token on authorization_code grant

ForceOAuthConnector#getAccessToken is using grant_type=authorization_code, which returns the refresh_token with legacy Remote Access OAuth consumers, but not with the new Connected Apps OAuth consumers. Changing grant_type to refresh_token should do it.

    2013-02-15T18:37:32+00:00 app[web.1]: java.io.IOException: Missing refresh token on response
    2013-02-15T18:37:32+00:00 app[web.1]:     at com.force.sdk.oauth.connector.ForceOAuthConnector.createTokenInternal(ForceOAuthConnector.java:196)
    2013-02-15T18:37:32+00:00 app[web.1]:   at com.force.sdk.oauth.connector.ForceOAuthConnector.getAccessToken(ForceOAuthConnector.java:145)
    2013-02-15T18:37:32+00:00 app[web.1]:   at org.springframework.security.authentication.AbstractAuthenticationManager.authenticate(AbstractAuthenticationManager.java:48)
    2013-02-15T18:37:32+00:00 app[web.1]:   at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355)
    2013-02-15T18:37:32+00:00 app[web.1]:   at com.force.sdk.springsecurity.OAuthAuthenticationProvider.authenticate(OAuthAuthenticationProvider.java:78)
    2013-02-15T18:37:32+00:00 app[web.1]:   at org.springframework.security.authentication.ProviderManager.doAuthentication(ProviderManager.java:130)

Using connectionName in com.force.sdk.oauth.AuthFilter doesn't work

Using the connectionName parameter in the AuthFilter doesn't work, because the ForceOAuthConnectionInfo is filled with the authorisation endpoint (which includes /services/... in the url). This is later used as a prefix for the oauth url which is incorrect.

My solution is to change at line ~176 of AuthFilter to the following.

    } else if (config.getInitParameter("connectionName") != null) {
        connInfo = new ForceOAuthConnectionInfo();
        String connectionName = config.getInitParameter("connectionName");

        Map<ForceConnectionProperty, String> propMap;
        try {
            propMap = ForceConnectorUtils.loadConnectorPropsFromName(connectionName);
        } catch (IOException e1) {
            throw new RuntimeException(e1);
        }
        if (propMap == null){
            throw new IllegalArgumentException("Could not find any connectionName called " + connectionName + ". ");
        }
        String errorMessage = "Could not load valid ForceOAuthConnectionInfo properties from " + connectionName + ".";

        String endpointValue = propMap.get(ForceConnectionProperty.ENDPOINT);
        ForceConnectionProperty.ENDPOINT.validateValue(endpointValue, errorMessage);
        URL endpointUrl;
        try {
            endpointUrl = new URL(endpointValue);
        } catch (MalformedURLException e) {
            throw new IllegalArgumentException(e);
        }
        connInfo.setEndpoint(endpointUrl.getProtocol() + "://" + endpointUrl.getHost());

        String oauthKeyValue = propMap.get(ForceConnectionProperty.OAUTH_KEY);
        ForceConnectionProperty.OAUTH_KEY.validateValue(oauthKeyValue, errorMessage);
        connInfo.setOauthKey(oauthKeyValue);

        String oauthSecretValue = propMap.get(ForceConnectionProperty.OAUTH_SECRET);
        ForceConnectionProperty.OAUTH_SECRET.validateValue(oauthSecretValue, errorMessage);
        connInfo.setOauthSecret(oauthSecretValue);

        oauthConnector.setConnectionInfo(connInfo);

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.