2017-04-21 64 views
0

我想部署我的servlet来GAE但得到以下错误谷歌应用程序引擎+ StampBarcode + PDF417阿比

HTTP ERROR 500 

问题访问/条形码。原因:

java.awt.Rectangle is a restricted class. Please see the Google App Engine developer's guide for more details. 

引起:

java.lang.NoClassDefFoundError:java.awt.Rectangle中是受限制的类。有关更多详细信息,请参阅Google App Engine开发人员指南。 at com.google.appengine.tools.development.agent.runtime.Runtime.reject(Runtime.java:50) at com.barcodelib.barcode.aba(a.java) at com.barcodelib.barcode.abc( (i.java) at com.barcodelib.barcode.PDF417.a(PDF417.java) at com.barcodelib.barcode.AbstractBarcode.renderBarcode(AbstractBarcode.java) 在PDF417Barcodes.doGet(PDF417Barcodes.java:49) 在javax.servlet.http.HttpServlet.service(HttpServlet.java:617)

servlet 
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException 
     { 
      try { 
       PDF417 barcode = new PDF417(); 
       barcode.setData("PDF417"); 

       ServletOutputStream servletoutputstream = response.getOutputStream(); 

       response.setContentType("image/jpeg"); 
       response.setHeader("Pragma", "no-cache"); 
       response.setHeader("Cache-Control", "no-cache"); 
       response.setDateHeader("Expires", 0); 

       // Generate PDF-417 barcode & output to ServletOutputStream 
       barcode.renderBarcode(servletoutputstream); 

      } catch (Exception e) { 
       throw new ServletException(e); 
      } 
     } 

它工作正常使用Tomcat,但不与GAE的工作,请大家帮忙我。

回答

0

您的条形码库使用java.awt.Rectangle,并且作为错误消息指出,它是一个受限制的类。这个限制只适用于GAE,这不是一个普遍的限制,这就是它在Tomcat中工作的原因。

此页面https://cloud.google.com/appengine/docs/standard/java/jrewhitelist列出了允许的所有 JRE类,所以如果您直接或间接使用未列出的类,它将会失败。

您既不能使用GAE,也不能尝试找到一个宣传为GAE“安全”的库(免责声明:我不知道这样的库是否存在)。

+0

感谢您的建议,如果您知道任何适用于GAE的pdf417条形码API? – dkmaven

+0

我的免责声明说了什么? – Kayaman

1

GAE不支持来自标准JDK的所有类。请参阅以下链接

https://cloud.google.com/appengine/docs/standard/java/jrewhitelist

在这里你会找到允许类的列表。它似乎是你的pdf417 barcodelib库正在使用一个不允许的类。所以你的应用程序将运行在标准和独立的tomcat上,但不在GAE上运行。