Google App Engine 上的 Quercus:类未加载
致命错误:没有匹配的类连接
index.php
<?php
import database.connection;
$connection = connection::get()->getPersistenceManager(); // ***ERROR HERE***
?>
connection.java
package database;
import javax.jdo.JDOHelper;
import javax.jdo.PersistenceManagerFactory;
public final class connection {
private static final PersistenceManagerFactory pmfInstance =
JDOHelper.getPersistenceManagerFactory("transactions-optional");
private connection() {}
public static PersistenceManagerFactory get() {
return pmfInstance;
}
}
Quercus 在其他方面配置良好,PHP 实现在 GAE 上运行顺利。但是当我尝试初始化类时,PHP 找不到它们。我做错了什么?
Fatal Error: no matching class connection
index.php
<?php
import database.connection;
$connection = connection::get()->getPersistenceManager(); // ***ERROR HERE***
?>
connection.java
package database;
import javax.jdo.JDOHelper;
import javax.jdo.PersistenceManagerFactory;
public final class connection {
private static final PersistenceManagerFactory pmfInstance =
JDOHelper.getPersistenceManagerFactory("transactions-optional");
private connection() {}
public static PersistenceManagerFactory get() {
return pmfInstance;
}
}
Quercus is otherwise configured fine, PHP implementation works smoothly on GAE. But when I try to initialize classes, PHP can't find them. What am I doing wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我是因为你发布这个问题才发现Quercus的存在!
我的猜测是 Quercus 无法实例化该对象,因为“连接”类有一个私有构造函数。
查看文档,类似 java_class("database.connection") 之类的东西可用于访问无法实例化的类中的静态方法。
I only discovered that Quercus existed due to you posting this question!
My guess would be that Quercus cannot instantiate the object because the class "connection" has a private constructor.
Looking at the documentation, something like java_class("database.connection") can be used to access static methods in classes which cannot be instantiated.
您的类
connection
需要扩展AbstractQuercusModule
,如此处Your class
connection
needs to extendsAbstractQuercusModule
as explained here