Google App Engine (Java + String + Velocity) Data Access debugging, error Cann

Source: Internet
Author: User

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>

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.