junit glassfish v3 oracle db

时间:2014-04-11 15:21:35

标签: oracle junit glassfish

尝试在netbeans8上编写ejb3 junit 我们使用weblogic 12c,但我无法获得他们的嵌入式容器,因此放弃并尝试使用glassfish

它更进一步,但有一点是bizzar,即使我的持久性xml使用oracle设置,它会触发derby并说我的架构/表不在那里

尝试使用derby

  

<?xml version="1.0" encoding="UTF-8"?> <persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"> <persistence-unit name="ACP-warPU" transaction-type="JTA"> <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider> <exclude-unlisted-classes>false</exclude-unlisted-classes> <shared-cache-mode>ALL</shared-cache-mode> <properties> <property name="eclipselink.logging.level" value="FINE"/> <property name="eclipselink.logging.logger" value="ServerLogger"/> <property name="javax.persistence.jdbc.url" value="jdbc:oracle:thin:@localhost:1521:db11g"/> <property name="javax.persistence.jdbc.password" value="spa"/> <property name="javax.persistence.jdbc.driver" value="oracle.jdbc.OracleDriver"/> <property name="javax.persistence.jdbc.user" value="spa"/> </properties> </persistence-unit> </persistence>

Map<String, Object> p = new HashMap<String, Object>();

    File[] modules = {
        new File("target/test-classes"),
        new File("target/classes")

    };
    p.put(EJBContainer.MODULES, modules);
    p.put("org.glassfish.ejb.embedded.glassfish.installation.root", "/target/gfv3");

    ejbContainer = EJBContainer.createEJBContainer(p);
    ctx = ejbContainer.getContext();
    ejbFacade = (AllocnGrpFacade) ctx.lookup("java:global/classes/AllocnGrpFacade");


Caused by: ERROR 42Y07: Schema 'SPA' does not exist
at org.apache.derby.iapi.error.StandardException.newException(Unknown Source)
at org.apache.derby.impl.sql.catalog.DataDictionaryImpl.getSchemaDescriptor(Unknown Source)
at org.apache.derby.impl.sql.compile.QueryTreeNode.getSchemaDescriptor(Unknown Source)
at org.apache.derby.impl.sql.compile.QueryTreeNode.getSchemaDescriptor(Unknown Source)
at org.apache.derby.impl.sql.compile.FromBaseTable.bindTableDescriptor(Unknown Source)
at org.apache.derby.impl.sql.compile.FromBaseTable.bindNonVTITables(Unknown Source)
at org.apache.derby.impl.sql.compile.FromList.bindTables(Unknown Source)
at org.apache.derby.impl.sql.compile.SelectNode.bindNonVTITables(Unknown Source)
at org.apache.derby.impl.sql.compile.DMLStatementNode.bindTables(Unknown Source)
at org.apache.derby.impl.sql.compile.DMLStatementNode.bind(Unknown Source)
at org.apache.derby.impl.sql.compile.CursorNode.bindStatement(Unknown Source)
at org.apache.derby.impl.sql.GenericStatement.prepMinion(Unknown Source)
at org.apache.derby.impl.sql.GenericStatement.prepare(Unknown Source)
at org.apache.derby.impl.sql.conn.GenericLanguageConnectionContext.prepareInternalStatement(Unknown Source)

1 个答案:

答案 0 :(得分:0)

基本上你需要使用glassfish域设置,即使是嵌入式容器

我希望我可以使用代码执行此操作,而不是使用生成的垃圾,但是现在我就是这样做了

解决了看

Caused by: javax.naming.NameNotFoundException: pools