1
What is the procedure to be able to inject dependencies using @Inject
of javax.inject
on the Weblogic 12.x. x server? I need to download Weld and place it on project dependencies?
I noticed that Weblogic doesn’t even recognize the annotation
I tested both with my empty Beans.xml (worked on jboss 7.1.1) and with the content below:
<beans></beans>
Within the class I intend to inject my Stateless Session Bean, I simply made the reference like this:
@Inject
private TransFacadeLocal transfacade;
And when trying to use it this always null, resulting in a Nullpointerexception when trying to reference it.
The concrete class of my Stateless Session Bean is as follows:
//imports omitidos
@Stateless(mappedName = "transFacade")
@LocalBean
public class TransFacade implements TransFacadeLocal{
public TransFacade{}
//outros métodos omitidos
}
The local interface I’m using to inject is as follows:
//imports omitidos
@Local
public interface TransFacadeLocal{//... metodos omitidos}
To recognize the libs as @Inject of javax.inject for example I did without referencing the Weld itself, but taking advantage of libs that already came in the distribution along with OEPE/Weblogic. Are they:
- wljarbuilder. ... Oracle Middleware Oracle_home wlserver server lib
- Weblogic.jar ... Oracle Middleware Oracle_home wlserver server lib
Weblogic.server.merged.jar ... Oracle Middleware Oracle_home wlserver modules Features
Error 500-Internal Server Error
org.jboss.weld.exceptions.DeploymentException: WELD-001409 Ambiguous dependencies for type [TesteLocal] with qualifiers [@Default] at injection point [[field] @Inject private br.com.programa.teste.ServletTest.testeLocal]. Possible dependencies [[Managed Bean [class br.com.programa.Teste] with Qualifiers [@Any @Default], Session bean [class br.com.programa.Teste with Qualifiers [@Any @Default]; local interfaces are [Teste, Testelocal], Managed Bean [class br.com.programa.Teste] with Qualifiers [@Any @Default]] at org.jboss.Weld.bootstrap.Validator.validateInjectionPoint(Validator.java:318) at org.jboss.Weld.bootstrap.Validator.validateInjectionPoint(Validator.java:284) at org.jboss.Weld.bootstrap.Validator.validateInjectionTarget(Validator.java:342) at org.jboss.Weld.manager.Injectiontargetvalidator.addInjectionTarget(Injectiontargetvalidator.java:29) at org.jboss.Weld.manager.Beanmanagerimpl.createInjectionTarget(Beanmanagerimpl.java:943) at org.jboss.Weld.manager.Beanmanagerimpl.fireProcessInjectionTarget(Beanmanagerimpl.java:1098) at com.oracle.Injection.provider.Weld.WeldBeanManager.newBeanInstance(Weldbeanmanager.java:135) at com.oracle.Injection.integration.utils.InjectionBeanCreator.newBeanInstance(Injectionbeancreator.java:154) Weblogic.servlet.Internal.InjectionBasedWebComponentCreator.createServletInstance(Injectionbasedwebcomponentcreator.java:66) at Weblogic.servlet.Internal.Stubsecurityhelper$Servletinitaction.newServletInstanceIfNecessary(Stubsecurityhelper.java:358) at Weblogic.servlet.Internal.Stubsecurityhelper$Servletinitaction.run(Stubsecurityhelper.java:311) at Weblogic.servlet.Internal.Stubsecurityhelper$Servletinitaction.run(Stubsecurityhelper.java:288) Weblogic.security.Acl.internal.Authenticatedsubject.doas(Authenticatedsubject.java:321) at Weblogic.security.service.SecurityManager.runas(Securitymanager.java:120) at Weblogic.servlet.Provider.WlsSubjectHandle.run(Wlssubjecthandle.java:57) at Weblogic.servlet.Internal.StubSecurityHelper.initServletInstance(Stubsecurityhelper.java:98) at Weblogic.servlet.Internal.StubSecurityHelper.createServlet(Stubsecurityhelper.java:86) Weblogic.servlet.Internal.StubLifecycleHelper.createOneInstance(Stublifecyclehelper.java:71) at Weblogic.servlet.Internal.StubLifecycleHelper.(Stublifecyclehelper.java:57) at Weblogic.servlet.Internal.StubLifecycleHelper.(Stublifecyclehelper.java:31) at Weblogic.servlet.Internal.ServletStubImpl.initStubLifecycleHelper(Servletstubimpl.java:660) at Weblogic.servlet.Internal.ServletStubImpl.prepareServlet(Servletstubimpl.java:600) at Weblogic.servlet.Internal.ServletStubImpl.getServlet(Servletstubimpl.java:408) at Weblogic.servlet.Internal.ServletStubImpl.execute(Servletstubimpl.java:300) at Weblogic.servlet.Internal.TailFilter.doFilter(Tailfilter.java:25) at Weblogic.servlet.Internal.FilterChainImpl.doFilter(Filterchainimpl.java:79) at org.jboss.Weld.servlet.Conversationpropagationfilter.doFilter(Conversationpropagationfilter.java:62) at Weblogic.servlet.Internal.FilterChainImpl.doFilter(Filterchainimpl.java:79) Weblogic.servlet.Internal.RequestEventsFilter.doFilter(Requesteventsfilter.java:27) at Weblogic.servlet.Internal.FilterChainImpl.doFilter(Filterchainimpl.java:79) at Weblogic.servlet.Internal.Webappservletcontext$Servletinvocationaction.wrapRun(Webappservletcontext.java:3436) at Weblogic.servlet.Internal.Webappservletcontext$Servletinvocationaction.run(Webappservletcontext.java:3402) Weblogic.security.Acl.internal.Authenticatedsubject.doas(Authenticatedsubject.java:321) at Weblogic.security.service.SecurityManager.runas(Securitymanager.java:120) at Weblogic.servlet.Provider.WlsSubjectHandle.run(Wlssubjecthandle.java:57) at Weblogic.servlet.Internal.WebAppServletContext.doSecuredExecute(Webappservletcontext.java:2285) at Weblogic.servlet.Internal.WebAppServletContext.securedExecute(Webappservletcontext.java:2201) at Weblogic.servlet.Internal.WebAppServletContext.execute(Webappservletcontext.java:2179) at Weblogic.servlet.Internal.ServletRequestImpl.run(Servletrequestimpl.java:1572) Weblogic.servlet.Provider.Containersupportproviderimpl$Wlsrequestexecutor.run(Containersupportproviderimpl.java:255) Weblogic.work.Executethread.execute(Executethread.java:311) Weblogic.work.Executethread.run(Executethread.java:263)
Patrick, welcome to [en.so]! Your problem is a little vague. Could you add more details? You have the
bens.xml
in your project? The injected classes have some annotations that make them Beans injectable by the CDI?– utluiz
Another tip specific to Weblogic, it already comes with a CDI implementation, you do not need to include Weld in your project (use the App Server). Take a look at the manual part specific on Icds and in the example in
EXAMPLES_HOME\wl_server\examples\src\examples\javaee6\cdi
. In version 12.1.1 there were some bugs related to CDI, but it seems that came out patches and that in versions 12.1.2+ everything is already working correctly.– Anthony Accioly
@Anthonyaccioly, I haven’t been able to find these examples so far. I even carefully reinstalled OEPE Bundle to ensure that I did a Full Installation as suggested in the documentation, and after finishing the installation the supposed directory that should contain the examples does not appear.
– Patrick Nascimento
According to the documentation: the examples directory should be: EXAMPLES_HOME , i.e.: ORACLE_HOME user_projects Applications However on my ORACLE_HOME there are only the following directories: ORACLE_HOME Coherence, ORACLE_HOME on, ORACLE_HOME\install,
ORACLE_HOME\inventory,
ORACLE_HOME\oepe (eclipse),
ORACLE_HOME\OPatch,
ORACLE_HOME\oracle_common,
ORACLE_HOME\oui,
ORACLE_HOME\wlserver ...

Testei tanto no windows qto no macosx na versão OEPE 12.1.3.
– Patrick Nascimento
Can anyone add tags related to the webserver name? Weblogic, weblogic12c. I don’t have that permission yet. I believe this problem is very specific to the webserver since my injections work in Jboss.
– Patrick Nascimento
Since the test with Weld was not enough for the injection to work (it started to recognize the Annotation but the injected bean remains null), any idea about which jars I would have to put in the build path to enable the injection? I put some libs I found inside the server: wljarbuilder.jar, Weblogic.jar, Weblogic.server.merged.jar in the build path and he started to recognize @Inject as well, but the test is still unsuccessful.
– Patrick Nascimento
Patrick, about the examples: You need to select the complete installation option: In Installation Wizard. http://docs.oracle.com/middleware/1213/wls/INTRO/examples.htm
– Anthony Accioly
In the OEPE installer version 12.1.3 it is not possible to choose between Full or Partial installation. It is all or nothing..
– Patrick Nascimento
Dude, try another version of the installer then. I’m with 12.1.2 (I can’t remember which installer I used but I think it was Generic), it came with all the examples (I can zip for you, but I don’t know if it will work in another version... Nor without the specific testing domain).
– Anthony Accioly
It worked here... I used another installer that I believe to be identical... and made some different Steps in the configuration. I will detail what I did in case anyone finds the same problem. Anyway, very grateful @Anthonyaccioly.
– Patrick Nascimento
Perfect Patrick. I’m glad to have helped and for your initiative to post the answer to help other users with similar problems.
– Anthony Accioly