2014-09-16 10 views
7

Mam wiele projektów goe7 maven (uszy z modułami web i ejb) z usługami RestFul, które działają dobrze na Glassfish v 4.0, ale tak szybko, jak staram się uruchomić te projekty na GlassFish v 4.1 usługi spokojny nie działa już i rzucają ten wyjątek.Glassfish 4.1 nie może uruchomić usługi RestFul podczas korzystania z modułu ear/ejb/web

javax.servlet.ServletException: A MultiException has 1 exceptions. They are: 
1. org.glassfish.hk2.api.UnsatisfiedDependencyException: There was no object available for injection at SystemInjecteeImpl(requiredType=TestBean,parent=GenericResource,qualifiers={},position=-1,optional=false,self=false,unqualified=null,82785107) 

ja dwukrotnie sprawdzane problem i ostatecznie GlassFish 4.1 prawdopodobnie ma złamaną bibliotekę (może implementacja cdi?), Glassfish v. 4.0 i Wildfly 8.1.0.Final działają dobrze ...

Nie mogę zrozumieć, w jaki sposób mogę uruchomić moje usługi internetowe RestFul na Glassfish v. 4.1 ...

Czy ktoś może mi pomóc?

Wiele z góry dzięki ...

Tu ślad stosu:

Avvertenza: An instance of EJB class, test.rest.GenericResource, could not be looked up using simple form name. Attempting to look up using the fully-qualified form name. 
javax.naming.NamingException: Lookup failed for 'java:app/TestEjb/GenericResource' in SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, java.naming.factory.url.pkgs=com.sun.enterprise.naming} [Root exception is javax.naming.NameNotFoundException: No object bound to name java:app/TestEjb/GenericResource] 
    at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:491) 
    at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:438) 
    at javax.naming.InitialContext.lookup(InitialContext.java:417) 
    at javax.naming.InitialContext.lookup(InitialContext.java:417) 
    at org.glassfish.jersey.gf.ejb.internal.EjbComponentProvider.lookupSimpleForm(EjbComponentProvider.java:378) 
    at org.glassfish.jersey.gf.ejb.internal.EjbComponentProvider.lookup(EjbComponentProvider.java:360) 
    at org.glassfish.jersey.gf.ejb.internal.EjbComponentProvider.access$000(EjbComponentProvider.java:100) 
    at org.glassfish.jersey.gf.ejb.internal.EjbComponentProvider$EjbFactory.provide(EjbComponentProvider.java:123) 
    at org.jvnet.hk2.internal.FactoryCreator.create(FactoryCreator.java:124) 
    at org.jvnet.hk2.internal.SystemDescriptor.create(SystemDescriptor.java:461) 
    at org.jvnet.hk2.internal.PerLookupContext.findOrCreate(PerLookupContext.java:69) 
    at org.jvnet.hk2.internal.Utilities.createService(Utilities.java:2258) 
    at org.jvnet.hk2.internal.ServiceLocatorImpl.internalGetService(ServiceLocatorImpl.java:690) 
    at org.jvnet.hk2.internal.ServiceLocatorImpl.getService(ServiceLocatorImpl.java:655) 
    at org.glassfish.jersey.internal.inject.Injections.getOrCreate(Injections.java:172) 
    at org.glassfish.jersey.server.model.MethodHandler$ClassBasedMethodHandler.getInstance(MethodHandler.java:185) 
    at org.glassfish.jersey.server.internal.routing.PushMethodHandlerRouter.apply(PushMethodHandlerRouter.java:74) 
    at org.glassfish.jersey.server.internal.routing.RoutingStage._apply(RoutingStage.java:112) 
    at org.glassfish.jersey.server.internal.routing.RoutingStage._apply(RoutingStage.java:115) 
    at org.glassfish.jersey.server.internal.routing.RoutingStage._apply(RoutingStage.java:115) 
    at org.glassfish.jersey.server.internal.routing.RoutingStage._apply(RoutingStage.java:115) 
    at org.glassfish.jersey.server.internal.routing.RoutingStage.apply(RoutingStage.java:94) 
    at org.glassfish.jersey.server.internal.routing.RoutingStage.apply(RoutingStage.java:63) 
    at org.glassfish.jersey.process.internal.Stages.process(Stages.java:197) 
    at org.glassfish.jersey.server.ServerRuntime$1.run(ServerRuntime.java:263) 
    at org.glassfish.jersey.internal.Errors$1.call(Errors.java:271) 
    at org.glassfish.jersey.internal.Errors$1.call(Errors.java:267) 
    at org.glassfish.jersey.internal.Errors.process(Errors.java:315) 
    at org.glassfish.jersey.internal.Errors.process(Errors.java:297) 
    at org.glassfish.jersey.internal.Errors.process(Errors.java:267) 
    at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:297) 
    at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:254) 
    at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:1028) 
    at org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:372) 
    at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:381) 
    at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:344) 
    at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:221) 
    at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1682) 
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:318) 
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:160) 
    at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:734) 
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:673) 
    at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:99) 
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:174) 
    at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:415) 
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:282) 
    at com.sun.enterprise.v3.services.impl.ContainerMapper$HttpHandlerCallable.call(ContainerMapper.java:459) 
    at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:167) 
    at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:201) 
    at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:175) 
    at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:235) 
    at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119) 
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:284) 
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:201) 
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:133) 
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:112) 
    at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77) 
    at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:561) 
    at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:112) 
    at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:117) 
    at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:56) 
    at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:137) 
    at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:565) 
    at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:545) 
    at java.lang.Thread.run(Thread.java:745) 
Caused by: javax.naming.NameNotFoundException: No object bound to name java:app/TestEjb/GenericResource 
    at com.sun.enterprise.naming.impl.GlassfishNamingManagerImpl.lookup(GlassfishNamingManagerImpl.java:741) 
    at com.sun.enterprise.naming.impl.GlassfishNamingManagerImpl.lookup(GlassfishNamingManagerImpl.java:715) 
    at com.sun.enterprise.naming.impl.JavaURLContext.lookup(JavaURLContext.java:167) 
    at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:471) 
    ... 64 more 

Grave: javax.naming.NamingException: Lookup failed for 'java:app/TestEjb/GenericResource!test.rest.GenericResource' in SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, java.naming.factory.url.pkgs=com.sun.enterprise.naming} [Root exception is javax.naming.NameNotFoundException: No object bound to name java:app/TestEjb/GenericResource!test.rest.GenericResource] 
    at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:491) 
    at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:438) 
    at javax.naming.InitialContext.lookup(InitialContext.java:417) 
    at javax.naming.InitialContext.lookup(InitialContext.java:417) 
    at org.glassfish.jersey.gf.ejb.internal.EjbComponentProvider.lookupFullyQualifiedForm(EjbComponentProvider.java:400) 
    at org.glassfish.jersey.gf.ejb.internal.EjbComponentProvider.lookup(EjbComponentProvider.java:364) 
    at org.glassfish.jersey.gf.ejb.internal.EjbComponentProvider.access$000(EjbComponentProvider.java:100) 
    at org.glassfish.jersey.gf.ejb.internal.EjbComponentProvider$EjbFactory.provide(EjbComponentProvider.java:123) 
    at org.jvnet.hk2.internal.FactoryCreator.create(FactoryCreator.java:124) 
    at org.jvnet.hk2.internal.SystemDescriptor.create(SystemDescriptor.java:461) 
    at org.jvnet.hk2.internal.PerLookupContext.findOrCreate(PerLookupContext.java:69) 
    at org.jvnet.hk2.internal.Utilities.createService(Utilities.java:2258) 
    at org.jvnet.hk2.internal.ServiceLocatorImpl.internalGetService(ServiceLocatorImpl.java:690) 
    at org.jvnet.hk2.internal.ServiceLocatorImpl.getService(ServiceLocatorImpl.java:655) 
    at org.glassfish.jersey.internal.inject.Injections.getOrCreate(Injections.java:172) 
    at org.glassfish.jersey.server.model.MethodHandler$ClassBasedMethodHandler.getInstance(MethodHandler.java:185) 
    at org.glassfish.jersey.server.internal.routing.PushMethodHandlerRouter.apply(PushMethodHandlerRouter.java:74) 
    at org.glassfish.jersey.server.internal.routing.RoutingStage._apply(RoutingStage.java:112) 
    at org.glassfish.jersey.server.internal.routing.RoutingStage._apply(RoutingStage.java:115) 
    at org.glassfish.jersey.server.internal.routing.RoutingStage._apply(RoutingStage.java:115) 
    at org.glassfish.jersey.server.internal.routing.RoutingStage._apply(RoutingStage.java:115) 
    at org.glassfish.jersey.server.internal.routing.RoutingStage.apply(RoutingStage.java:94) 
    at org.glassfish.jersey.server.internal.routing.RoutingStage.apply(RoutingStage.java:63) 
    at org.glassfish.jersey.process.internal.Stages.process(Stages.java:197) 
    at org.glassfish.jersey.server.ServerRuntime$1.run(ServerRuntime.java:263) 
    at org.glassfish.jersey.internal.Errors$1.call(Errors.java:271) 
    at org.glassfish.jersey.internal.Errors$1.call(Errors.java:267) 
    at org.glassfish.jersey.internal.Errors.process(Errors.java:315) 
    at org.glassfish.jersey.internal.Errors.process(Errors.java:297) 
    at org.glassfish.jersey.internal.Errors.process(Errors.java:267) 
    at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:297) 
    at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:254) 
    at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:1028) 
    at org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:372) 
    at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:381) 
    at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:344) 
    at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:221) 
    at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1682) 
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:318) 
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:160) 
    at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:734) 
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:673) 
    at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:99) 
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:174) 
    at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:415) 
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:282) 
    at com.sun.enterprise.v3.services.impl.ContainerMapper$HttpHandlerCallable.call(ContainerMapper.java:459) 
    at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:167) 
    at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:201) 
    at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:175) 
    at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:235) 
    at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119) 
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:284) 
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:201) 
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:133) 
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:112) 
    at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77) 
    at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:561) 
    at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:112) 
    at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:117) 
    at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:56) 
    at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:137) 
    at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:565) 
    at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:545) 
    at java.lang.Thread.run(Thread.java:745) 
Caused by: javax.naming.NameNotFoundException: No object bound to name java:app/TestEjb/GenericResource!test.rest.GenericResource 
    at com.sun.enterprise.naming.impl.GlassfishNamingManagerImpl.lookup(GlassfishNamingManagerImpl.java:741) 
    at com.sun.enterprise.naming.impl.GlassfishNamingManagerImpl.lookup(GlassfishNamingManagerImpl.java:715) 
    at com.sun.enterprise.naming.impl.JavaURLContext.lookup(JavaURLContext.java:167) 
    at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:471) 
    ... 64 more 

Avvertenza: StandardWrapperValve[test.rest.ApplicationConfig]: Servlet.service() for servlet test.rest.ApplicationConfig threw exception 
org.glassfish.hk2.api.UnsatisfiedDependencyException: There was no object available for injection at SystemInjecteeImpl(requiredType=TestBean,parent=GenericResource,qualifiers={},position=-1,optional=false,self=false,unqualified=null,734647163) 
    at org.jvnet.hk2.internal.ThreeThirtyResolver.resolve(ThreeThirtyResolver.java:74) 
    at org.jvnet.hk2.internal.Utilities.justInject(Utilities.java:947) 
    at org.jvnet.hk2.internal.ServiceLocatorImpl.inject(ServiceLocatorImpl.java:902) 
    at org.jvnet.hk2.internal.ServiceLocatorImpl.createAndInitialize(ServiceLocatorImpl.java:977) 
    at org.jvnet.hk2.internal.ServiceLocatorImpl.createAndInitialize(ServiceLocatorImpl.java:968) 
    at org.glassfish.jersey.internal.inject.Injections.getOrCreate(Injections.java:173) 
    at org.glassfish.jersey.server.model.MethodHandler$ClassBasedMethodHandler.getInstance(MethodHandler.java:185) 
    at org.glassfish.jersey.server.internal.routing.PushMethodHandlerRouter.apply(PushMethodHandlerRouter.java:74) 
    at org.glassfish.jersey.server.internal.routing.RoutingStage._apply(RoutingStage.java:112) 
    at org.glassfish.jersey.server.internal.routing.RoutingStage._apply(RoutingStage.java:115) 
    at org.glassfish.jersey.server.internal.routing.RoutingStage._apply(RoutingStage.java:115) 
    at org.glassfish.jersey.server.internal.routing.RoutingStage._apply(RoutingStage.java:115) 
    at org.glassfish.jersey.server.internal.routing.RoutingStage.apply(RoutingStage.java:94) 
    at org.glassfish.jersey.server.internal.routing.RoutingStage.apply(RoutingStage.java:63) 
    at org.glassfish.jersey.process.internal.Stages.process(Stages.java:197) 
    at org.glassfish.jersey.server.ServerRuntime$1.run(ServerRuntime.java:263) 
    at org.glassfish.jersey.internal.Errors$1.call(Errors.java:271) 
    at org.glassfish.jersey.internal.Errors$1.call(Errors.java:267) 
    at org.glassfish.jersey.internal.Errors.process(Errors.java:315) 
    at org.glassfish.jersey.internal.Errors.process(Errors.java:297) 
    at org.glassfish.jersey.internal.Errors.process(Errors.java:267) 
    at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:297) 
    at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:254) 
    at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:1028) 
    at org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:372) 
    at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:381) 
    at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:344) 
    at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:221) 
    at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1682) 
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:318) 
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:160) 
    at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:734) 
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:673) 
    at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:99) 
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:174) 
    at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:415) 
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:282) 
    at com.sun.enterprise.v3.services.impl.ContainerMapper$HttpHandlerCallable.call(ContainerMapper.java:459) 
    at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:167) 
    at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:201) 
    at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:175) 
    at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:235) 
    at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119) 
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:284) 
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:201) 
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:133) 
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:112) 
    at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77) 
    at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:561) 
    at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:112) 
    at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:117) 
    at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:56) 
    at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:137) 
    at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:565) 
    at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:545) 
    at java.lang.Thread.run(Thread.java:745) 

mam ucho z jednego modułu ejb i jednego modułu WWW (moduł Web dodać moduł ejb jako biblioteki) .

Moduł EJB ma taką klasę:

package test.session; 
import javax.ejb.Stateless; 
import javax.inject.Named; 
@Stateless 
@Named 
public class TestBean { 
    public String getValue() { 
    return "value"; 
    } 
} 

Moduł Web ma tej klasy:

package test.rest; 
import java.util.Set; 
import javax.ws.rs.core.Application; 
@javax.ws.rs.ApplicationPath("webresources") 
public class ApplicationConfig extends Application { 
    @Override 
    public Set<Class<?>> getClasses() { 
    Set<Class<?>> resources = new java.util.HashSet<>(); 
    addRestResourceClasses(resources); 
    return resources; 
    } 
    private void addRestResourceClasses(Set<Class<?>> resources) { 
    resources.add(test.rest.GenericResource.class); 
    } 
} 

oraz:

package test.rest; 
import javax.ejb.Stateless; 
import javax.inject.Inject; 
import javax.ws.rs.core.Context; 
import javax.ws.rs.core.UriInfo; 
import javax.ws.rs.Produces; 
import javax.ws.rs.Consumes; 
import javax.ws.rs.GET; 
import javax.ws.rs.Path; 
import javax.ws.rs.PUT; 
import test.session.TestBean; 
@Path("generic") 
@Stateless 
public class GenericResource { 
    @Context 
    private UriInfo context; 
    @Inject 
    TestBean testBean; 
    public GenericResource() { 
    } 
    @GET 
    @Produces("application/json") 
    public String getXml() { 
    //TODO return proper representation object 
    return testBean.getValue(); 
} 
} 

Jeśli staram się poruszać:

http://localhost:8080/TestRest/webresources/generic 

GlassFish 4.1 podbicie wyjątek i GlassFish 4.0 działa dobrze ...

Odpowiedz

9

miałem podobny problem. Jest to błąd wspomniany przez @ user993553, który próbuje utworzyć instancję EJB (GenericResource) Modułu WAR z modułu EJB.

Rozwiązaniem jest konwersja EJB z modułu WAR na CDI. Po prostu zmień @javax.ejb.Stateless na @javax.enterprise.context.RequestScoped lub dowolny inny zakres.

@Path("generic") 
@javax.enterprise.context.RequestScoped 
public class GenericResource 
{ 
    @Context 
    private UriInfo context; 

    @Inject 
    TestBean testBean; 

    public GenericResource() {} 

    @GET 
    @Produces("application/json") 
    public String getXml() { 
     // TODO return proper representation object 
     return testBean.getValue(); 
    } 
} 
+0

Tak, Twoje obejście działa jak urok !!! Wielkie dzięki !!! – giates

+0

Tego typu rzeczy doprowadzają mnie do szału. Jeden dzień zmarnowany na ten błąd !!!! – angelcervera

+0

Pamiętaj, że nie jest to EJB, więc nie ma właściwości publicznych, jeśli nie chcesz błędu "Błąd definicji CDI: WELD-000075: Normalna klasa implementacji bean o ograniczonym zasięgu ma publiczne pole: ..." Ufff !! A po tym błędzie konieczne jest ponowne uruchomienie instancji. To jest szalone! – angelcervera

0

To może brzmieć głupio, ale zmiana nazwy pliku WAR do czegoś kończącym się .jar i przesłać go jako „aplikacji internetowej” pracował dla mnie.

Zobacz także https://java.net/jira/browse/JERSEY-2690

Można zapewne byłaby swoją aplikację, aby wszystkie Stateless zajęcia w słoiku.