升级App Engine至1.9.59后JSON包缺失问题的解决方法咨询
Hey Gal, sorry to hear you ran into this issue after updating your App Engine target version! Let me break down what's happening and how to fix it.
The com.google.appengine.labs.repackaged.org.json package was an internal repackaged version of the standard JSON library that Google App Engine used to include for its own internal operations. Starting around version 1.9.50+, Google removed this internal package from the SDK because it was never intended for public developer use—relying on internal repackaged libraries is always risky since they can be removed or modified without prior notice.
The most sustainable and supported solution is to replace the internal repackaged library with the official, standalone org.json library. Here's how to do it step by step:
Add the official dependency to your
pom.xml
Insert this snippet inside your<dependencies>section:<dependency> <groupId>org.json</groupId> <artifactId>json</artifactId> <version>20230618</version> <!-- Use the latest stable version available --> </dependency>Update your import statement in
ReportServlet.java
Replace the problematic import line:import com.google.appengine.labs.repackaged.org.json.JSONObject;With the standard, supported import:
import org.json.JSONObject;Test your code
Good news— theorg.json.JSONObjectclass has the exact same API as the repackaged version you were using. All your existing code that uses methods likeput(),get(), ortoString()on JSONObject will work without any additional changes.
If you absolutely can't refactor your code right now (e.g., a huge codebase with hundreds of references), you could try manually adding the repackaged JSON JAR to your project. However, this is strongly discouraged because:
- It's an unsupported internal library that may break with future App Engine updates
- It won't receive security patches or bug fixes
- Google could remove access to it entirely in future SDK versions
Sticking with the official org.json library is the safest long-term approach.
内容的提问来源于stack exchange,提问作者Gal Kogman

