Based on piece at http://wiki.apache.org/jakarta-hivemind/CayenneIntegration, I implemented the following to attempt access to the Cayenne DataContext (DC) from a non Tapestry class (any class). I get my Visit object from HiveMind, so I know HiveMind is working. I am using Tapestry 4.0-beta-11, Cayenne 1.2M7, and HiveMind 1.1-rc-1 running on Jetty 5.1.5. My app starts up with no problems, then I get an exception on calling to get a DC. I called for a DC from my WebApp and with a JUnit test to see if either would work, neither did.
Will someone suggest what I can do to get this service working, or at least make it accessible first? Will this approach work when calling from non Tapestry classes? Do you have a good example of getting a service to work? I can just use that instead. Thanks, Joseph Caller: Registry hivemindRegistry = RegistryBuilder.constructDefaultRegistry() ; DataContextService dcs = (DataContextService) hivemindRegistry.getService( DataContextService.class) ; WebApp exception: org.apache.hivemind.ApplicationRuntimeException: There is no service point for interface org.code.hivemind.DataContextService. at org.apache.hivemind.impl.RegistryInfrastructureImpl.getService( RegistryInfrastructureImpl.java:236) at org.apache.hivemind.impl.RegistryImpl.getService(RegistryImpl.java:84) at org.code.utility.Utility.fetchDataContext(Utility.java:82) ... JUnit Test exception: org.apache.hivemind.ApplicationRuntimeException: Service point DataContextService does not exist. at org.apache.hivemind.impl.RegistryInfrastructureImpl.getServicePoint( RegistryInfrastructureImpl.java:179) at org.apache.hivemind.impl.RegistryInfrastructureImpl.getService( RegistryInfrastructureImpl.java:205) at org.apache.hivemind.impl.RegistryImpl.getService(RegistryImpl.java:79) at org.code.utility.UtilityTest.testHiveMindDataContext(UtilityTest.java:80) ... web.xml: <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version="2.4"> <display-name>........</display-name> <distributable/> <filter> .... </filter> <filter-mapping> ... </filter-mapping> <listener> <listener-class>org.objectstyle.cayenne.conf.WebApplicationContextProvider </listener-class> </listener> <servlet> ... </servlet> <servlet-mapping> ... </servlet-mapping> </web-app> hivemodule.xml: <?xml version="1.0" encoding="utf-8"?> <module id="org.code.hivemind" version="1.0.0"> <contribution configuration-id="tapestry.state.ApplicationObjects"> ... </contribution> <service-point id="dataContextService" interface=" org.code.hivemind.DataContextService"/> <implementation service-id="dataContextService"> <invoke-factory> <construct class="org.code.hivemind.DataContextServiceImpl"/> </invoke-factory> </implementation> </module> Interface: package org.code.hivemind; import org.objectstyle.cayenne.access.DataContext; public interface DataContextService { public DataContext getDataContext () ; } Implementation: package org.code.hivemind; import org.objectstyle.cayenne.access.DataContext; public class DataContextServiceImpl implements DataContextService { public DataContext getDataContext() { DataContext dataContext = DataContext.getThreadDataContext() ; if (dataContext == null) { dataContext = DataContext.createDataContext() ; DataContext.bindThreadDataContext(dataContext) ; } return dataContext ; } }
