Recently, we are catching up with fashion and have also made a simple cloud development.
On a large number of cloud platforms, I chose Google App Engine, although it is already under the wall ......
Download Elipse and install Google App Engine and Spring STS. Follow the instructions on the official website.
Install the AppEngine documentation, configure ADO data ing, and test locally. Everything works normally. The dependency injection configuration for PersistenceManager using Spring is as follows:
[Html]
<! -- Context bean -->
<Bean id = "persistenceManagerFactory" class = "javax. jdo. JDOHelper" factory-method = "getPersistenceManagerFactory">
<Constructor-arg>
<Value> transactions-optional </value>
</Constructor-arg>
</Bean>
<Bean id = "persistenceManager" factory-bean = "persistenceManagerFactory-method =" getPersistenceManager "scope =" request "destroy-method =" close "> </bean>
Write some simple data operations and test everything locally. And then published to the server. An exception occurs.
View the logs provided by the AppEngine console and find the following errors:
Cannot find class [javax. naming. Context]
There are almost no Chinese materials in this regard. Google found some introductions in English, probably that PersistenceManagerFactory objects cannot be injected using Spring. Therefore, the Factory is encapsulated into a static property according to the Google document method.
[Java]
Public class PMF {
Private static final PersistenceManagerFactory pmfInstance = JDOHelper
. GetPersistenceManagerFactory ("transactions-optional ");
Private PMF (){
}
Public static PersistenceManagerFactory get (){
Return pmfInstance;
}
}
Modify the configuration as follows:
[Html]
<! -- Context bean -->
<Bean id = "persistenceManagerFactory" class = "xxx. PMF" factory-method = "get">
</Bean>
<Bean id = "persistenceManager" factory-bean = "persistenceManagerFactory-method =" getPersistenceManager "scope =" request "destroy-method =" close "> </bean>
After re-upload, the error type is changed:
Cannot find class [javax. naming. Name]
It seems that using Spring to inject PersistenceManager is not acceptable, so Add the following code to PMF:
[Java]
Public static PersistenceManager getPersistenceManager (){
Return get (). getPersistenceManager ();
}
Modify the Spring configuration as follows:
[Html]
<Bean id = "persistenceManager" class = "xxx. PMF"
Factory-method = "getPersistenceManager" scope = "request" destroy-method = "close">
</Bean>