OSGi Homework Problem

0 views
Skip to first unread message

Henry Suryawirawan

unread,
Jan 26, 2010, 3:32:53 AM1/26/10
to javaee6-codecamp
Hi all,

I am stucked up with this problem for my homework. Since I'm quite new to OSGi, probably someone could help me pointing out the missing link.

Basically, for the homework, I created examples.services.api.MyComputeService with implementation examples.services.impl.MyComputeServiceImpl.
I've also created mycomputeservice.xml in OSGI-INF directory and name the component "decl-service-2".
MANIFEST.MF has also been updated to include the new mycomputeservice.xml file.

However, when I try to inject the MyComputeService in my servlet using @Resource(mappedName = "decl-service-2"), it prompts me with exception.

Here is the stack trace:

WARNING: StandardWrapperValve[HelloWorld]: PWC1382: Allocate exception for servlet HelloWorld
com.sun.enterprise.container.common.spi.util.InjectionException: Error creating managed object for class examples.services.webclient.HelloWorld
        at com.sun.enterprise.container.common.impl.util.InjectionManagerImpl.createManagedObject(InjectionManagerImpl.java:312)
        at com.sun.enterprise.web.WebContainer.createServletInstance(WebContainer.java:700)
        at com.sun.enterprise.web.WebModule.createServletInstance(WebModule.java:1937)
        at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1252)
        at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:1059)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:187)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:188)
        at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:641)
        at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:97)
        at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:85)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:185)
        at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:332)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:233)
        at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:165)
        at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:791)
        at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:693)
        at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:954)
        at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:170)
        at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:135)
        at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:102)
        at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:88)
        at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:76)
        at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:53)
        at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:57)
        at com.sun.grizzly.ContextTask.run(ContextTask.java:69)
        at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:330)
        at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:309)
        at java.lang.Thread.run(Thread.java:619)
Caused by: com.sun.enterprise.container.common.spi.util.InjectionException: Exception attempting to inject Env-Prop: examples.services.webclient.HelloWorld/myComputeService@Field-Injectable Resource. Class name = examples.services.webclient.HelloWorld Field name=myComput...@java.lang.String@@@ into class examples.services.webclient.HelloWorld
        at com.sun.enterprise.container.common.impl.util.InjectionManagerImpl._inject(InjectionManagerImpl.java:614)
        at com.sun.enterprise.container.common.impl.util.InjectionManagerImpl.inject(InjectionManagerImpl.java:384)
        at com.sun.enterprise.container.common.impl.util.InjectionManagerImpl.injectInstance(InjectionManagerImpl.java:141)
        at com.sun.enterprise.container.common.impl.util.InjectionManagerImpl.injectInstance(InjectionManagerImpl.java:127)
        at com.sun.enterprise.container.common.impl.util.InjectionManagerImpl.createManagedObject(InjectionManagerImpl.java:306)
        ... 27 more
Caused by: java.lang.IllegalArgumentException: Can not set examples.services.api.MyComputeService field examples.services.webclient.HelloWorld.myComputeService to examples.services.impl.MyComputeServiceImpl
        at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:146)
        at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:150)
        at sun.reflect.UnsafeObjectFieldAccessorImpl.set(UnsafeObjectFieldAccessorImpl.java:63)
        at java.lang.reflect.Field.set(Field.java:657)
        at com.sun.enterprise.container.common.impl.util.InjectionManagerImpl._inject(InjectionManagerImpl.java:565)
        ... 31 more

Henry Suryawirawan

unread,
Jan 26, 2010, 3:51:31 AM1/26/10
to javaee6-codecamp
I managed to solve the problem by rebuilding the two projects, undeploy the previous module deployment from glassfish, restart the glassfish, and redeploy the new modules.
Reply all
Reply to author
Forward
0 new messages