ejb 2 FinderException table or view does not exist - jboss

I'm working with an existing database and EJB 2.x application.
My task is to migrate the app from WebSphere 8 over to JBOSS EAP 6.4
After many days of fighting with this thing, everything seemed to be working until we started trying to use some of the beans. There are beans that end with "Mgr". For example, there is a SiteMgr bean and a Site bean. Right now, all of the Mgr beans work, but not the rest.
If you couldn't tell already, I'm not an EJB 2 Guru. Here is code that errors out:
/**
* getSessionContext
*/
public SiteVO getSite(int siteId) {
SiteLocal siteLocal;
try {
siteLocal = getSiteHome().findByPrimaryKey(new SiteKey(siteId));
} catch (FinderException e) {
throw new EJBException(e);
}
return siteLocal.getSiteVO();
}
So, when I try to findByPrimaryKey I get javax.ejb.FinderException, with the following cause:
java.sql.SQLSyntaxErrorException: ORA-00942: table or view does not exist
Drilling into that a bit more, here is the cause:
Error : 942, Position : 27, Sql = SELECT t0_Site.siteId FROM SITE t0_Site WHERE t0_Site.siteId=:1 , OriginalSql = SELECT t0_Site.siteId FROM SITE t0_Site WHERE t0_Site.siteId=?, Error Msg = ORA-00942: table or view does not exist
The database contains a table named APP_SITES and the WebSphere app probably figures that out using some files that appear to be specific to WebSphere.
There is appdb70.dbm and Map.mapxmi
These files are very long. I will provide some example text that is specific to the above example.
ejb-jar.xml
<entity id="Site">
<ejb-name>Site</ejb-name>
<local-home>com.app.site.entity.SiteLocalHome</local-home>
<local>com.app.site.entity.SiteLocal</local>
<ejb-class>com.app.site.entity.SiteBean</ejb-class>
<persistence-type>Container</persistence-type>
<prim-key-class>com.app.site.entity.SiteKey</prim-key-class>
<reentrant>false</reentrant>
<cmp-version>2.x</cmp-version>
<abstract-schema-name>Site</abstract-schema-name>
<cmp-field id="CMPAttribute_1087249279390">
<field-name>siteId</field-name>
</cmp-field>
<cmp-field id="CMPAttribute_1087249281781">
<field-name>siteName</field-name>
</cmp-field>
...
Map.mapxmi
<ejbrdbmapping:EjbRdbDocumentRoot xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI"
xmlns:OracleModel="http:///com/ibm/db/models/oracle/oracle.ecore"
xmlns:SQLConstraints="http:///org/eclipse/datatools/modelbase/sql/constraints.ecore"
xmlns:SQLTables="http:///org/eclipse/datatools/modelbase/sql/tables.ecore" xmlns:ejb="ejb.xmi"
xmlns:ejbrdbmapping="ejbrdbmapping.xmi" xmlns:Mapping="Mapping.xmi" xmi:id="EjbRdbDocumentRoot_1289312938455" topToBottom="true" commandStack="">
<helper xmi:type="ejbrdbmapping:RdbSchemaProperies" xmi:id="RdbSchemaProperies_1289312938455" primitivesDocument="ORACLE_V11"/>
<nested xmi:type="ejbrdbmapping:RDBEjbMapper" xmi:id="RDBEjbMapper_1289313262395">
<helper xmi:type="ejbrdbmapping:PrimaryTableStrategy" xmi:id="PrimaryTableStrategy_1289313262395">
<table xmi:type="OracleModel:OracleTable" href="META-INF/backends/ORACLE_V11_3/acapdb70.dbm#_q0x58OwNEd-LtOpsZa3J5w"/>
</helper>
<nested xmi:type="ejbrdbmapping:RDBEjbFieldMapper" xmi:id="RDBEjbFieldMapper_1289315290408">
<inputs xmi:type="ejb:CMPAttribute" href="META-INF/ejb-jar.xml#CMPAttribute_1087249279390"/>
<outputs xmi:type="SQLTables:Column" href="META-INF/backends/ORACLE_V11_3/acapdb70.dbm#_q0x58ewNEd-LtOpsZa3J5w"/>
<typeMapping xmi:type="ejbrdbmapping:RDBEjbFieldMapper" href="JavatoORACLE_V11TypeMaps.V7.xmi#int-NUMBER"/>
</nested>
<nested xmi:type="ejbrdbmapping:RDBEjbFieldMapper" xmi:id="RDBEjbFieldMapper_1289315290409">
<inputs xmi:type="ejb:CMPAttribute" href="META-INF/ejb-jar.xml#CMPAttribute_1087249285656"/>
<outputs xmi:type="SQLTables:Column" href="META-INF/backends/ORACLE_V11_3/acapdb70.dbm#_q0x5-ewNEd-LtOpsZa3J5w"/>
<typeMapping xmi:type="ejbrdbmapping:RDBEjbFieldMapper" href="JavatoORACLE_V11TypeMaps.V7.xmi#String-VARCHAR"/>
</nested>
appdb70.dbm (contains WAY too much data to post...)
<?xml version="1.0" encoding="UTF-8"?>
<!--xtools2_universal_type_manager-->
<xmi:XMI xmlns:datamodelversion="http://www.ibm.com/com.ibm.datatools.core/model/7.5.1.1" xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:OracleModel="http:///com/ibm/db/models/oracle/oracle.ecore" xmlns:SQLConstraints="http:///org/eclipse/datatools/modelbase/sql/constraints.ecore" xmlns:SQLDataTypes="http:///org/eclipse/datatools/modelbase/sql/datatypes.ecore" xmlns:SQLExpressions="http:///org/eclipse/datatools/modelbase/sql/expressions.ecore" xmlns:SQLSchema="http:///org/eclipse/datatools/modelbase/sql/schema.ecore" xmlns:SQLStatements="http:///org/eclipse/datatools/modelbase/sql/statements.ecore" xmlns:SQLTables="http:///org/eclipse/datatools/modelbase/sql/tables.ecore">
<OracleModel:OracleDatabase xmi:id="_WPDywewNEd-LtOpsZa3J5w" name="APPdb70" vendor="Oracle" version="11" schemas="_WQG7oOwNEd-LtOpsZa3J5w"/>
<SQLSchema:Schema xmi:id="_WQG7oOwNEd-LtOpsZa3J5w" name="APPWDB" triggers="_q0VNoOwNEd-LtOpsZa3J5w ..." database="_WPDywewNEd-LtOpsZa3J5w"/>
<SQLTables:Trigger xmi:id="_q0VNoOwNEd-LtOpsZa3J5w" name="APP_APPOINTMENT_D_TRG" schema="_WQG7oOwNEd-LtOpsZa3J5w" subjectTable="_q0VNpuwNEd-LtOpsZa3J5w" ...>
<dependencies xmi:id="_q0VNoewNEd-LtOpsZa3J5w" targetEnd="_q07ry-wNEd-LtOpsZa3J5w"/>
<dependencies xmi:id="_q0VNouwNEd-LtOpsZa3J5w" targetEnd="_q0e_b-wNEd-LtOpsZa3J5w"/>
<dependencies xmi:id="_q0VNo-wNEd-LtOpsZa3J5w" targetEnd="_q0VNpuwNEd-LtOpsZa3J5w"/>
<dependencies xmi:id="_q0VNpOwNEd-LtOpsZa3J5w" targetEnd="_q0VN_OwNEd-LtOpsZa3J5w"/>
<actionStatement xsi:type="SQLStatements:SQLStatementDefault" ..."/>
</SQLTables:Trigger>
<OracleModel:OracleTable xmi:id="_q0VNpuwNEd-LtOpsZa3J5w" name="APP_APPOINTMENT" schema="_WQG7oOwNEd-LtOpsZa3J5w" triggers="_q0VNoOwNEd-LtOpsZa3J5w ...>
<columns xmi:id="_q0VNp-wNEd-LtOpsZa3J5w" name="APPT_ID" nullable="false">
<containedType xsi:type="SQLDataTypes:FixedPrecisionDataType" xmi:id="_q0VNqOwNEd-LtOpsZa3J5w" name="NUMBER" primitiveType="NUMERIC"/>
</columns>
<columns xmi:id="_q0VNqewNEd-LtOpsZa3J5w" name="RMKS_TX">
<containedType xsi:type="SQLDataTypes:CharacterStringDataType" xmi:id="_q0VNquwNEd-LtOpsZa3J5w" name="VARCHAR2" primitiveType="CHARACTER_VARYING" length="200"/>
</columns>
Notice that you can find "CMPAttribute_1087249279390" in multiple files. JBOSS does not seem to make use of these extra files.
I'm not sure what to do at this point. I figured out everything else, but I can't seem to get around this. Any fix that gets the beans to work would be appreciated!

Related

Alfresco workflow api is loosing a variable

I have an Alfresco community 5.2 installation with a custom workflow. The users needs to specify some actors to be part of this workflow and review the submitted document. The users are divided in 4 groups (co-authors, reviewers, approvers, authorizer) and I start the workflow using Alfresco JS Api passing all variables and actors.
The problem that I have is: a workflow variable of one of those actors group, the reviewers, is correctly passed to wf Params but is received as null when the workflow is started
var wfparams = new Array();
wfparams["mywf:coAuthorsAssignees"] = coAuthorsProp;
wfparams["mywf:reviewersAssignees"] = reviewersProp;
wfparams["mywf:approverAssignee"] = approverProp;
wfparams["mywf:authorizerAssignee"] = authorizerProp;
wfparams["bpm:priority"] = workflowPriorityProp;
wfparams["mywf:taskDueDateDaysNumber"] = workflowTaskDueDateDaysNumberProp;
wfparams["bpm:description"] = workflowMessageProp;
wfparams["bpm:workflowDescription"] = workflowMessageProp;
wfparams["mywf:copyToInitiator"] = copyToInitiator;
wfparams["mywf:previousTaskComments"] = workflowInitiatorComment;
wfparams["_startTaskCompleted"] = new Date();
logger.info("mywf:reviewersAssignees"); // OK, the variable is correct
workflowAction.startWorkflow(package, wfparams);
And here is my start
<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:activiti="http://activiti.org/bpmn" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:omgdc="http://www.omg.org/spec/DD/20100524/DC" xmlns:omgdi="http://www.omg.org/spec/DD/20100524/DI" typeLanguage="http://www.w3.org/2001/XMLSchema" expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="http://alfresco.org">
<process id="DTTPublishWorkflow" name="Parallel Review And Approve Document" isExecutable="true">
<extensionElements>
<activiti:executionListener event="start" class="org.alfresco.repo.workflow.activiti.listener.ScriptExecutionListener">
<activiti:field name="script">
<activiti:string><![CDATA[//checkSingleWFIstance();
// printing the variable inside the workflow (bpmn), I see it null
logger.info(execution.getVariable('mywf_reviewersAssignees')) // null
<!-- ... -->
How it is possible? What am I missing?
Or what can I do to figure out what the problem is? Can I debug somehow that happens under startWorkflow(package, wfparams);
-- EDIT --
Could it be some strange problem in javascript object conversion ?
Look like some prefix mistake.
You are assigning by prefix "mywf" and you are fetching by "eneawf".
Is this your way of fetching or mistake?

terracotta open source not working in ecache.xml - terracotta:clustered-shared

I am migrating from ehcache 2 to ehcache 3.5. I am trying to use terracotta open source for sharing the cache with clusters.
Below is my java code,
final CacheManagerBuilder<PersistentCacheManager> clusteredCacheManagerBuilder =
CacheManagerBuilder.newCacheManagerBuilder()
.with(ClusteringServiceConfigurationBuilder.cluster(URI.create("terracotta://terr.com:9410/clustered")).autoCreate()
.defaultServerResource("default-resource")
.resourcePool("pool3", 28, MemoryUnit.MB))
.withCache("boxMaxFileId", CacheConfigurationBuilder.newCacheConfigurationBuilder(String.class, Integer.class,
ResourcePoolsBuilder.newResourcePoolsBuilder()
.with(ClusteredResourcePoolBuilder.clusteredShared("pool3")))) ;
final PersistentCacheManager cacheManager = clusteredCacheManagerBuilder.build(true);
LOGGER.info(cacheManager.getStatus().toString());
return cacheManager;
Can someone help me in getting converted to ehcache.xml
<ehcache:service>
<terracotta:cluster>
<terracotta:connection url="terracotta://terr.com:9410/clustered"/>
<terracotta:server-side-config auto-create="true">
<terracotta:default-resource from="default-resource"/>
<terracotta:shared-pool name="pool1" unit="MB">2</terracotta:shared-pool>
</terracotta:server-side-config>
</terracotta:cluster>
</ehcache:service>
<ehcache:cache alias="boxMaxFileId">
<ehcache:key-type>java.lang.String</ehcache:key-type>
<ehcache:value-type>java.lang.Integer</ehcache:value-type>
<ehcache:resources>
<ehcache:heap unit="entries">100</ehcache:heap>
<ehcache:offheap unit="MB">1</ehcache:offheap>
<terracotta:clustered-shared sharing="pool1" />
</ehcache:resources>
</ehcache:cache>
tc-config.xml
<plugins>
<config>
<ohr:offheap-resources>
<ohr:resource name="default-resource" unit="MB">512</ohr:resource>
</ohr:offheap-resources>
</config>
</plugins>
I am getting exception like Pool name "pool1" not exists in server.
<?xml version="1.0" encoding="UTF-8"?>
<ehcache:config
xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
xmlns:jsr107='http://www.ehcache.org/v3/jsr107'
xmlns:terracotta='http://www.ehcache.org/v3/clustered'
xmlns:ehcache='http://www.ehcache.org/v3'
xsi:schemaLocation="http://www.ehcache.org/v3 http://www.ehcache.org/schema/ehcache-core-3.1.xsd
http://www.ehcache.org/v3/jsr107 http://www.ehcache.org/schema/ehcache-107-ext-3.5.xsd
http://www.ehcache.org/v3/clustered http://www.ehcache.org/schema/ehcache-clustered-ext-3.1.xsd">
<ehcache:service>
<terracotta:cluster>
<terracotta:connection url="terracotta://terr.com:9410/clustered"/>
<terracotta:server-side-config auto-create="true">
<terracotta:default-resource from="default-resource"/>
<terracotta:shared-pool name="pool1" from="default-resource" unit="MB">2</terracotta:shared-pool>
</terracotta:server-side-config>
</terracotta:cluster>
</ehcache:service>
<ehcache:cache alias="boxMaxFileId">
<ehcache:key-type>java.lang.String</ehcache:key-type>
<ehcache:value-type>java.lang.Integer</ehcache:value-type>
<ehcache:resources>
<ehcache:heap unit="entries">100</ehcache:heap>
<ehcache:offheap unit="MB">1</ehcache:offheap>
<!-- <terracotta:clustered-dedicated unit="MB">5</terracotta:clustered-dedicated>-->
<terracotta:clustered-shared sharing="pool1" />
</ehcache:resources>
</ehcache:cache>
</ehcache:config>
This is the converted xml. For sharing, we need to use the above format.

Magento getEvent()->getOrder empty

I'm trying to get an Observer working to see if a payment has been made via check/cheque, I know the Observer is being used as I have a log record to show. However when I try to access the Order it is either empty or will not print to the log file.
app/etc/modules/Foo_Bar.xml
<?xml version="1.0"?>
<config>
<modules>
<Foo_Bar>
<active>true</active>
<codePool>local</codePool>
</Foo_Bar>
</modules>
</config>
app/code/local/Foo/Bar/etc/config.xml
<?xml version="1.0" encoding="UTF-8" ?>
<config>
<global>
<models>
<foo_bar>
<class>Foo_Bar_Model</class>
</foo_bar>
</models>
<events>
<sales_order_payment_place_end> <!-- event -->
<observers>
<foo_bar> <!-- unique for event -->
<!-- type: singleton | disable | model -->
<class>foo_bar/observer</class>
<method>SalesOrderPaymentPlaceEnd</method>
</foo_bar>
</observers>
</sales_order_payment_place_end>
</events>
</global>
</config>
app/code/local/Foo/Bar/Model/Observer.php
<?php
class Foo_Bar_Model_Observer
{
public function SalesOrderPaymentPlaceEnd(Varien_Event_Observer $observer)
{
Mage::log('Location: SalesOrderPaymentPlaceEnd');
$order = $observer->getEvent()->getOrder();
Mage::log('order: '.$order);
}
}
The first log works as expected, however I'm sure getOrder() isn't working as my second log entry just prints 'order: '.
Thanks
#James has already commented this..I am explaning
The event "sales_order_payment_place_end" located in "app\code\core\Mage\Sales\Model\Order\Payment.php" .
The event have only one parameter that is Payment. So
$order = $observer->getEvent()->getOrder();
will not work. You need to use
$orderPayment = $observer->getEvent()->getPayment();
What worked for me was below:
public function autoInvoiceForOfflinePayment(Varien_Event_Observer $observer)
{
$order = $observer->getEvent()->getPayment()->getOrder();
// In my case I was trying to get the payment method code, e.g.
$order->getPayment()->getMethodInstance()->getCode()
}
I hope this helps (Magento EE 1.14.2)
What I discovered, which I forget and often discover again when creating a hook is to look at the line in the file dispatching the event:
e.g. "app\code\core\Mage\Sales\Model\Order\Payment.php"
Mage::dispatchEvent('sales_order_payment_place_end', array('payment' => $this));
So you want to get the event first, then in the array the payment variable:
$order = $observer->getEvent()->getPayment();
From there you can get any public functions in that file, the same principle seems to apply throughout.

Zend Framework 2 SOAP server WSDL failed to load

I can't get the SOAP server working in Zend Framework 2 module. I am not completely sure, but I believe that the problem is the WSDL file. I try to create the WSDL file via Autodiscover, which is provided by the Zend Framework. Here is the error.log:
[Fri Apr 19 20:39:29 2013] [error] [client 172.23.31.109] PHP Warning: SoapServer::SoapServer(): I/O warning : failed to load external entity "http-LINK/services?wsdl" in /PATH/public_html/vendor/zendframework/zendframework/library/Zend/Soap/Server.php on line 749
[Fri Apr 19 20:39:29 2013] [error] [client 172.23.31.109] PHP Fatal error: SOAP-ERROR: Parsing WSDL: Couldn't load from 'http-LINK/services?wsdl' : failed to load external entity "http-LINK/services?wsdl"\n in /PATH/public_html/vendor/zendframework/zendframework/library/Zend/Soap/Server.php on line 749
I added an own module for this services test, this is the structure, module is called "Services":
-Services
--config
---module.config.php
--src
---Services
----API
-----1.0
------servicesAPI.php
---Controller
----ServicesController.php
--view
---services
----serivces
-Module.php
-autoload_classmap.php
This is my file "servicesAPI.php"
class servicesAPI {
/**
* This method takes a value and gives back the md5 hash of the value
*
* #param String $value
* #return String
*/
public function md5Value($value) {
return md5($value);
}
}
And this is ServicesController.php:
namespace Services\Controller;
ini_set("soap.wsdl_cache_enabled", 0);
use Zend\Mvc\Controller\AbstractActionController;
use Zend\Soap\AutoDiscover;
use Zend\Soap\Server;
require_once __DIR__ . '/../API/1.0/servicesAPI.php';
class ServicesController extends AbstractActionController {
private $_options;
private $_URI = "http-LINK/services";
private $_WSDL_URI = "http-LINK/services?wsdl";
public function indexAction() {
if (isset($_GET['wsdl'])) {
$this->handleWSDL();
} else {
$this->handleSOAP();
}
}
private function handleWSDL() {
$autodiscover = new AutoDiscover();
$autodiscover->setClass('servicesAPI')
->setUri($this->_URI);
$autodiscover->handle();
}
private function handleSOAP() {
$soap = new Server($this->_WSDL_URI);
$soap->setClass('servicesAPI');
$soap->handle();
}
}
So when I deploy this and open http-LINK/services in the browser, it gives me the following:
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Body>
<SOAP-ENV:Fault>
<faultcode>WSDL</faultcode>
<faultstring>
SOAP-ERROR: Parsing WSDL: Couldn't load from 'http-LINK/services?wsdl' : failed to load external entity "http-LINK/services?wsdl"
</faultstring>
<detail/>
</SOAP-ENV:Fault>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
On this call also the PHP error output is written!
If I try to open the services?wsdl in browser, it shows me this (chrome and safari):
This page contains the following errors:
error on line 3 at column 1: Extra content at the end of the document
Below is a rendering of the page up to the first error.
This method takes a value and gives back the md5 hash of the value
But if I inspect the element, it looks completely ok:
<?xml version="1.0" encoding="utf-8"?>
<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http-LINK/services" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap-enc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" name="servicesAPI" targetNamespace="http-LINK/services"><types><xsd:schema targetNamespace="http-LINK/services"/></types><portType name="servicesAPIPort"><operation name="md5Value"><documentation>This method takes a value and gives back the md5 hash of the value</documentation><input message="tns:md5ValueIn"/><output message="tns:md5ValueOut"/></operation></portType><binding name="servicesAPIBinding" type="tns:servicesAPIPort"><soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/><operation name="md5Value"><soap:operation soapAction="http-LINK/services#md5Value"/><input><soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http-LINK/services"/></input><output><soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http-LINK/services"/></output></operation></binding><service name="servicesAPIService"><port name="servicesAPIPort" binding="tns:servicesAPIBinding"><soap:address location="http-LINK/services"/></port></service><message name="md5ValueIn"><part name="value" type="xsd:string"/></message><message name="md5ValueOut"><part name="return" type="xsd:string"/></message></definitions>
I can validate this xml with any xml validator, it seems to be valid.
I read all the posts concerning this on stackoverflow, searched google, but none of the solutions helped me. Here a short list of what else I tried:
According to this: https://bugs.php.net/bug.php?id=48216 I tried to save the wsdl xml to a file and open it from this file when starting the soap server, fail
I tried to run the autodiscover and soapserver statements with try/catch to catch any exceptions, nothing appears
I tried with echo-ing through toXML() and other outputs, fail
Used XMLReader::open and isValid to make sure, that the xml is valid (it is)
Some more information:
PHP Version 5.3.23
Ubuntu server 11.04
php-soap module is loaded
Zend Framework version 2.1.4
Any help or hints are appreciated. Thanks in advance.
Try instantiate the Soap Server class this way:
...
private function handleSOAP() {
$soap = new Server(
null, array(,
'wsdl' => http-LINK/services?wsdl,
)
);
$soap->setClass('servicesAPI');
$soap->handle();
}
....
Also you should add this line to the end of your indexAction()
return $this->getResponse();
.. it disables the layout.

Symfony DIC and Parent Services not working

I'm integrating Symfony DIC in a zend framework application, that's going fine except for parent services.
In my DIC config I have a parent service PC_Service which will be extended by all my services.
The problem is that the entity manager is not available (NULL) in the services that extend PC_Service. When I inject the entitymanager via service.stats the entitymanger is set correctly.
...
<service id="pc.service" class="PC_Service" abstract="true">
<call method="setEntityManager">
<argument type="service" id="doctrine.entitymanager" />
</call>
</service>
...
<service id="service.stats" class="Application_Service_Stats" parent="pc.service" />
...
PC_Service
abstract class PC_Service
{
protected $_em;
public function setEntityManager($entityManager)
{
$this->_em = $entityManager;
}
}
Application_Service_Stats
class Application_Service_Stats extends PC_Service
{
... $this->_em should be set here.
}
I hope someone can tell me what I'm doing wrong.
Don't know if it's a typo but it should be doctrine.orm.default_entity_manager or doctrine.orm.entity_manager (alias of the previuos):
<service id="pc.service" class="PC_Service" abstract="true">
<call method="setEntityManager">
<argument type="service" id="doctrine.orm.default_entity_manager" />
</call>
</service>
The solution is to compile the service container near the end of the ZF bootstrap. This process has a step called ResolveDefinitionTemplatesPass which patches in the calls from parent services.
This is typically done by the Symfony Kernel, but of course it isn't present in a ZF integration.
protected function _initServiceContainerCompilation()
{
// Wait for the SC to get built
$this->bootstrap('Services');
// Doctrine modifies the SC, so we need to wait for it also
$this->bootstrap('Doctrine');
// Compiling the SC allows "ResolveDefinitionTemplatesPass" to run,
// allowing services to inherit method calls from parents
$sc = $this->getResource('Services');
$sc->compile();
}