Injection EJB JDeveloper 12 c

Hello world. I just installed Jdev 12 c

It looks great by the way.

Well in Jdev 11.1.2.3.0 I used the research to connect to my ejb methods.

In jdev12c I know injection EJB can be used, I created my page jsf with auto-linking.

He also created the bean support. In the bean to support I have this:

public class Index implements Serializable{
    @SuppressWarnings("compatibility:-1609217697211604393")
    private static final long serialVersionUID = 1L;
    @EJB
    private transient SessionEJBRemote sessionEJBRemote;
    
    public Index() {
    }
    
    public List getSuggestedItems(String string) {
        List<SelectItem> suggestedItems = new ArrayList<SelectItem>();
        int nidEva = Integer.parseInt(string);
        try {
            Lista ls = new Lista();
            List<Evaluacion> lstEvas = sessionEJBRemote.getEvaluacionByNidEva(nidEva);
            Iterator it = lstEvas.iterator();
            while(it.hasNext()){
                Evaluacion eva = (Evaluacion) it.next();
                suggestedItems.add(new SelectItem(eva.getNidEvaluacion(), eva.getNidEvaluacion()+" "+eva.getFechaHora()));
            }
        } catch (Exception e) {
            System.out.println("BBean");
            e.printStackTrace();
        }
        return suggestedItems;
    }

I get online 15 NPES I think sessionEJBRemote variable is null, so that you do not find the method.

Thank you! to vassionvaEJBRemote

1. I think that the EJB injection is something that was available in Java EE 5.0 - then maybe should work in older versions of JDeveloper too. (However for this thread we just focus instead on 12 c).

2. you shouldn't be prefexing beans with this scope - see 1 here - http://technology.amis.nl/2013/12/16/adf-classic-mistakes-and-worst-practices-abstract-from-ukoug-2013/

3 - for now, it seems that beans that require injection should be entered in the faces - config.xml to work.

That being said - have you considered directly exposing your EJB as data controls? This way you won't need to mess with coding managed beans to access their functionality.

Tags: Java

Similar Questions

  • Need help with the addiction of injection @EJB null pointer

    I have an application in an ear file that contains 2 modules. One is a war of component web and the other is a jar of ejb.
    appname.ear
    +-webclient.war
    +-webbean.jar
    I stated my bean with a @Stateless annotation:
    @Stateless
    public class EchoBean {}
    And added a dependency with @EJB in a servlet in my web module:
    @EJB(lookup="java:app/webbean/EchoBean")
    private EchoBean _echo;
    Everything compiles, but when I run it, this object always returns null. Using a JNDI on the InitialContext research I can successfully get the bean via "java: app/webbean/EchoBean. But use it as the search in the @EJB attribute also fails. What could I do it wrong?

    Meatwad says:

    
    
    
    

    2.4? I venture a guess that this right here is your problem. than 2.5 and try again.

  • EJB injected into the servlet

    Hello
    I injected ejb into my servlet and I have this error in my servlet
    in my if condition that I get this error:
    ................................................................
    ava.lang.ClassCastException:
    swch.api.BaseEntity.Terminal cannot be cast to swch.api.BaseEntity.Terminal

    ..................................................................
    public interface {ITrmnlAuthenticationBL}
    public locate (String serialNo, String password)
    throw GeneralException;

    }
    ..................................................................
    @Stateless
    / public class TrmnlAuthenticationBL implements ITrmnlAuthenticationBL {}
    @EJB IPersistenceManager h;

    public locate (String serialNo, String password)
    get {GeneralException}

    try {}
    Terminal = pm.getEntityManager () .createQuery ("Terminal where password =: pass and serialNo =: series", Terminal.class)
    .setParameter ("pass", password) .setParameter ("serial", serialNo)
    . getSingleResult();
    return terminal;
    } catch (NoResultException e) {}
    e.printStackTrace ();
    Returns a null value.

    }

    catch (Exception e) {}
    e.printStackTrace ();
    Returns a null value.
    }
    }
    ...............................................................
    SerializableAttribute public class EnterLet extends HttpServlet {}

    @EJB
    Private ITrmnlAuthenticationBL trmnlMg;
    @Override
    protected void doPost (HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {}
    Password String = request.getParameter ("ps");

    Terminal = trmnlMg.find (serialNo, password);
    If (terminal == null |! password.equalsIgnoreCase (terminal.getPassword ()))

    I have error in this line if condition when I used 'terminal.getPassword' and can climb no class of setting standby extended to
    Terminal entity in my project...
    Please explain my mistake

    Published by: Marzieh on November 17, 2011 01:13

    You use JBoss 6. That's your problem :-(

    First of all, make sure that your EJB jars are not also included in the WEB-INF/lib directory of the any of your wars. So theoretically, everything should work.

    But this is not guaranteed with JBoss 6. This version introduces a new system of classloader, but never the quality of production.
    At one point we had a similar request, which would fail with ClassCastExceptions on startup time 2 / 3 :-(.

    In JBoss 7, classloading (welding) component seems to be much more stable.

    Welcome, Geert.

  • [jdev 11.1.1.6] Dependency injection

    Hello world


    I want to use with jdev 11.1.1.6 dependency injection, you guys the pointers I can refer? I know it may be through JSF 2.x


    Thank you

    Aerts

    abhinandanpanda.com

    EJB dependency injection may still be used.

    Dependency injection EJB session Bean façade in JSF 1.2 on WebLogic 10.3 (JSF with JPA) - AMIS Technology Blog

  • EJB transactions

    I'm developing a Web Service using an EJB Stateless, which has a single entry point (method). There are 3 steps in this method and I want to step 1 to occur in another transaction that steps 2 and 3 (which should be in the same transaction). These "measures" include vocations EJB Stateless injected. Let me explain with a code:

    @Stateless
    @WebService(...)
    public class MyWebServiceImpl implements MyWebService {
         @EJB
         private UserBusinessBean userBusinessBean;
    
         @EJB
         private EventsBusinessBean eventsBusinessBean;
    
         @WebMethod(...)
         public MyWebServiceResult process(MyWebServiceParam param) {
              // extract data from param
              EventResult createEventResult = eventsBusinessBean.createEvent(data); // step 1
              // do some extra processing
              User user = userBusinessBean.createUser(someData); // step 2
              // do some extra processing
              EventResult updateEventResult = eventsBusinessBean.updateEvent(moreData); // step 3
         }
    }
    

    The injected EJBs 2 themselves are stateless and have injected references to stateless persons DAoC, whose function is to call stored procedures to the database.

    I need to have step 1 running in a transaction and the steps 2 and 3 running in another transaction (because if step 2 or 3 fails, the news of step 1 is already committed).

    I know that I have 2 options to implement this: container-Manager transactions or managed by users. I think that the first approach is more secure than the second, in delegating management to the container (in my case, a Weblogic Server). But I can't understand how can I use Annotations in EJB Transactions to apply this logic. Can I annotate my beans injected Business methods? And what about the BCM, do need to have too many annotations? And what are those which one should I use?

    I hope you can give me a little help in this one. Let me know if you need to know more details of my implementation.

    Basically, you need to apply the attributes of correct transaction but only at the entrance to a string of calls when it is required. If you use 'CREATE_NEW' for example, the EJB invocation will create a transaction nested of its own rather than adopt the transaction that already existed. All work done in this 'inner' transaction will be validated and will not affect the "external" transaction, which was suspended before the end of the 'inner' invocation of EJB

    A tutorial on EJB tech explain what transaction attributes exist and what they do in the world. Applying them properly instead of always just using the default (REQUIRED) can help you create a transactional environment more controlled in which you have the chance of catching transactional errors early on (for example: If you have the code for which you know a transaction MUST exist that he succeed, the 'REQUIRED' attribute is useful). You will find that this bit of micro-management, it's making it a little more difficult to apply in a first time tech EJB, but ultimately when you start to 'see the matrix' it will actually start helping you establish a code clean design. However, that takes experience.

  • Ejb3 remote injection

    Hi all

    I have two weblogic server running on a different machine.

    You have ejb and others have the web client.


    Can I use the web client dependency injection when I access the ejb remote server?

    Regarding.

    Hello

    Please refer to http://stackoverflow.com/questions/1560335/is-it-possible-to-use-ejb-annotation-to-inject-ejbs-through-different-servers

  • NetBeans + EJB3. 0, injection of @EJB in JSFManagedBean does not work.

    Hello

    I developed a business for Oracle 11 g weblogic application using netbeans 6.9.1.

    I called the remote ejb in the same EAR
    @EJB private AcaeServiceRemote acaeService;
    but when I used it in my JSF managed bean methods, acaeService is null and cannot call its methods. Does anyone have an idea about this and how to fix this?

    I use Annotations for the bean managed JSF as well. (@ManagedBean etc.). Then I tried to declare in the faces - config.xml. But the result was the same.

    If I used the same within a Servlet, it works very well and runs the ejb method.

    Published by: Knightbeat on February 21, 2011 12:32

    gDay-

    He should perhaps note here, is that if you want to use in beans controlled with WLS dependency injection, so you must ensure that you are using the shared library of WLS JSF as the JSF for your application runtime.

    The reason is that, in order to fill in the runtime WLS to support controlled beans DI, we provide an implementation of "com.sun.faces.spi.InjectionProvider". This is done in the jsf - xx.war we provide as shared libraries via the file wls.jsf.di.jar we combine:

    sbutton:~/Oracle/middleware/wlserver_10.3/common/deployable-libraries $ jar tf jsf - 2.0.war
    META-INF /.
    META-INF/MANIFEST. MF
    WEB - INF /.
    WEB-INF/lib /.
    META-INF/javadoc.mf
    WEB-INF/lib/glassfish.jsf_1.0.0.0_2-0-4.jar
    WEB-INF/lib/glassfish.jstl_1.2.0.1.jar
    WEB-INF/lib/javax.jsf_1.0.0.0_2-0.jar
    WEB-INF/lib/wls.jsf.di.jar
    WEB-INF/web.xml

    Looking at the contents of wls.jsf.di.jar, you can see the only class that implements the InjectionProviderInterface:

    sbutton:~/Oracle/middleware/wlserver_10.3/common/deployable-libraries $ javap - classpath WEB_INF/lib/wls.jsf.di.jar com.bea.faces.WeblogicInjectionProvider
    Compiled from "WeblogicInjectionProvider.java."
    public class com.bea.faces.WeblogicInjectionProvider extends java.lang.Object implements com.sun.faces.spi.InjectionProvider {}
    com.bea.faces.WeblogicInjectionProvider (public);
    Public Sub inject (java.lang.Object) survey com.sun.faces.spi.InjectionProviderException.
    Public Sub invokePostConstruct (java.lang.Object) survey com.sun.faces.spi.InjectionProviderException.
    Public Sub invokePreDestroy (java.lang.Object) survey com.sun.faces.spi.InjectionProviderException.
    }

    If you are integrating a JSF runtime inside the file. WAR that you deploy, then he won't have this library and so no access to the provider, so DI beans controlled for WLS resources will not work.

    You can follow the doc to deploy and to refer to the shared library in your application, which is here: http://download.oracle.com/docs/cd/E17904_01/web.1111/e13712/configurejsfandjtsl.htm#i163440

    I have also heard people succeed by pulling on the wls.jsf.di.jar of the jsf - xx.war we provide and which the group inside the WAR file. We document this approach, but I think that the JDeveloper tool takes this approach.

    Let us know how it goes.

    * Update: I created a sample with a JSF 2.0 application that uses a ManagedBean wherein an EJB is injected and it shows all work, see: http://bit.ly/wlsjsfejb

    This quick application was built using NetBeans 7.0 B2 and WLS 10.3.4. I've never tried sharing projects like this, so I hope it works. The WLS target domain should have the jsf - 2.0.war - shared library deployed on it, you can see referenced in weblogic.xml as:


    JSF
    2.0
    1.0.0.0_2 - 0-2

    NetBeans is actually pretty cool because when you add a JSF framework to a web application that is referred to in WLS, it will show you the list of the JSF libraries available on the server, and then deploy that you select when you first run the application should deploy.

    -steve-

    Published by: Steve button on February 28, 2011 17:13

  • There is no such thing as JDeveloper gives error - package javax.ejb

    Hi all

    I use JDeveloper Studio Edition Version 11.1.2.1.0.

    When I try to compile and run my jsf file, I get the following error.

    • Error (5,17): javax.ejb package does not exist

    How to fix this error and how to run the application, please note that I use the built-in weblogic server of Jdeveloper. It seems to work for all other files, but somehow the EJB do not work. Help, please.

    Thank you

    Faiz

    You can go to the properties of application - library & Classpath. Add library and select EJB 3.0 ejb all pots and make OK OK. Clean and build again.

    Thank you

  • How to inject some ejb in servlet

    Hi all
    How to inject some ejb in servlet?
    Please explain how config my servlet and my paroject
    I have an ear with two files jar file
    Thanks in advance

    Then why do you provide the mapped name then? Just do:

    @EJB
    private ITrmnlAuthenticationBL trmnlMg;
    
  • Problem using Jdeveloper Tutoriels [JPA, EJB, JSF] &lt; DB connection &gt;

    Hello, I tried to complete tutorials for JDeveloper technology uses and I came with a persistent error message. I have sought for more than a few hours and can not find any relevant information on this error.

    Scenario: Tutorials JDeveloper (http://www.oracle.com/technology/products/jdev/11/cuecards111/index.html)

    Problem: http://www.oracle.com/technology/products/jdev/11/cuecards111/adf_set_12/ccset12_ALL.html
    On the Create Database link.

    We have oracle 10 g deployed, customer installed oracle databases (and some applications apex working on them).
    I want to finish the tutorial above for setting up the example of jsf page to work on our databases not on one sample.
    I created the Java EE Application. I have 2 databases under connections IDE (work on them also with sql) and I want to add to the resources of the Application of the tutorial app.
    However whenever I try, I get the same error message (even on another project):

    Added library "EJB 3.0"to the EJBModel project.
    May 20, 2010 17:13:55 oracle.adf.share.dt.security.providers.jps.CSFDTCredentialStore getURLFromJPSConfigPath
    WARNING: / /OrdersApplication/src/META-INF/jps-config.xml E:/JDeveloper/mywork (test) is not a not valid URL Protocol: /OrdersApplication/src/META-INF/jps-config.xml/E:/JDeveloper/mywork (test)

    JPS config file generated by Jdeveloper:
    ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    <? XML version = "1.0" encoding = "Cp1252"? >
    < jpsConfig xmlns = "http://xmlns.oracle.com/oracleas/schema/11/jps-config-11_1.xsd" xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance" xsi: schemaLocation = "http://xmlns.oracle.com/oracleas/schema/11/jps-config-11_1.xsd" >
    < propertySets / >
    < serviceProviders >
    "< class ="oracle.security.jps.internal.credstore.ssp.SspCredentialStoreProvider serviceProvider"name =" credstore.provider "type ="CREDENTIAL_STORE">
    < description > service provider for the credentials store < / description >
    < / serviceProvider >
    < / serviceProviders >
    < serviceInstances >
    < provider = "credstore.provider serviceInstance" name = "credstore" > "
    < property = value "." "/" name = "location" / >
    < / serviceInstance >
    < / serviceInstances >
    < default jpsContexts = "DBModeling" >
    < jpsContext name = "DBModeling" >
    < serviceInstanceRef ref = "credstore" / >
    < / jpsContext >
    < / jpsContexts >
    < / jpsConfig >
    ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    As I understand it, the project needs a job jps - config.xml and set up somehow to create a link to the database I already added in the Connection Wizard?
    I'm not familiar with jsp-configs (again) and could not find anything here or on other websites.

    I would appreciate help with the configuration of the connection appear under Application resources (not only the IDE) connection so I can continue with the tutorial.

    Thank you in advance.

    Edited by: user9377591 may 20, 2010 07:44

    The problem is the parenthesis in the path of your project: * / E:/JDeveloper/mywork (test) *.

    Nick

  • EJB injection does not not for a class of Jersey

    I have a standard EJB3.0 bean defined as follows:
    @Stateless
    @Local (CustomerService.class)
    / public class CustomerBean implements CustomerService
    ...


    I can reference this EJB successfully using dependency injection to a servlet with the following code:
    SerializableAttribute public class CustomerServlet extends HttpServlet {}
    ...
    @EJB (beanName = "CustomerBean")
    private CustomerService customerService.
    ...
    Public Sub doGet (...) {
    Customer CustomerVO = customerService.getCustomerById (id);
    ...

    However the same code does not a RESTful Jersey service class
    @Path("/{customer}")
    public class CustomerREST {}
    @EJB (beanName = "CustomerBean")
    private CustomerService customerService.
    ...

    @GET
    @Produces("text/plain")
    public String getCustomer (@PathParam ("customer"), String customerId) {}
    Customer CustomerVO = customerService.getCustomerById (customerId);
    ...


    Service class RESTful Jersey will run, but throws a NullPointerException as the customerService entity is null.

    The CustomerServlet and CustomerREST classes are both in the same WebApp, inside the EAR with the EJB.
    They're even in the same package!

    I'd appreciate any help.

    Congratulations. You have reached the major limitation of JEE-based dependency injection. You can only inject resources in servlets, filters, listeners, and managers of the tag. That's why people eventually move in the spring if they really need dependency injection in non - JEE components.

    You can read the manual to WebLogic pages linked to it at [http://download.oracle.com/docs/cd/E12840_01/wls/docs103/pdf/webapp.pdf]. Read Chapter 8, "WebLogic Annotation for Web Components.

  • EJB dependency injection

    Hello

    I am building a Web Application from merger ADF and I model and ViewController modules.

    In the model, I have my session bean that I want to acess for a bean on ViewController, that controls my JSF page.

    So, I have this on my SessionBean:

    Interface:

    @Remote

    public interface SessionFacadeBean {...}

    Implementation:

    @Stateless (name = "SessionFacade", = "Test-model-SessionFacade" mappedName)

    / public class SessionFacadeBeanImpl implements SessionFacadeBean {}

    @Resource

    SessionContext sessionContext;

    @PersistenceContext (unitName = "Model")

    private EntityManager em;

    public SessionFacadeBeanImpl() { }

    ...

    }

    And this on my bean in ViewController module:

    public class TesteSessionBean {}

    @EJB private SessionFacadeBean beanSession;

    }

    But I still have my NULL beanSession...

    Can someone help me please?

    Thank you

    Mafalda

    FIX:

    Faltava add o TesteSessionBean ao faces - config.xml no viewcontroller.

  • EJB with JDeveloper 11.1.1.2 problems?

    Hi people jdev,.

    I am writing an application that uses EJB, datacontrlos, and adf faces components... When the test application is behaving abnormally. the application has many pages with a master detail (master form and detail table), when I insert to the table detail rows and then I still or merge content, the operation is successful, when I change existing lines in the detail table, the operation shows no errors, but the changes are not subject to the database. is it posible? is this a bug.

    Kind regards
    Enrique

    Hi Enrique.

    Please check the response that should be correct than others may be guided and so I can earn points too ;)

    Kind regards

    Pino

  • MySQL w / JDeveloper EJB named query error

    I have named this query:

    @NamedQuery (name = "Node.topParent", query = "select o to o node where o.node is null")

    However, the conversion of a query SQL (connected to MySQL) it shows:

    Select * from 'node' where (parentId IS NULL)

    The 'node' causes MySQL Error but if I remove the quotes manually then it works. Why is the query using "" and how do I set up to by MySQL compatible?

    Thanks in advance,

    Kris

    Looks like you have a problem of annotation entity here (entity is named you name according to your JPQL but it is mapped to the name table). Try to study how you mapped your entity in table first. Try also the forums of TopLink, I see a lot of MySQL questions it.

  • How to adopt the validation of level entity such as BC ADF using EJB/JPA?

    I explore how to implement validation to entity level using the EJB/JPA instead of ADF BC. (Note: I use JDeveloper + ADF 12 c)

    1. I cannot add validation attribute level in the ADF (Data Control) of EJB model layer. but it is not enough. I can just code partial UI validation here.

    2. I googled and find that someone is using jsr-303-bean-validation. What is a unique choice? How the entity-level validation code?

    Validation of the JPA EJB ADF application entity

    3. I want to implement certain business validation and processing business in the layer of business ADF service, as in the EJB method.

    I did a simple test to simulate an exception, but I found the exception has been handled incorrectly in the layer of binding of ADF and error dialog box prompt: DCA-29000: Unexpected exception caught: java.lang.reflect.InvocationTargetException, msg = null.

        public Departments persistDepartments(Departments departments) {
            if(true){
              throw new RuntimeException("persistDepartments");
            }
            em.persist(departments);
            return departments;
        }
    
    
    
    

    Any expert can help? will I have to rewrite the ADF Model layer error handling? How to code the validation in EJB? you will need to take local and manipulate it in class in the ADF error handling model layer? where can I find a demo?

    4. I want to introduce a layer of application service between EJB session façade and JPA entity for the re-use of the company.  but I found JDeveloper helps me to do anything. I do code manually, when I create EJB session façade, it always integrate directly with JPA entity inside.  I expect that my application service is class instead of the EJB POJO.  Session EJB façade summons enforcement and demand serviceshall call JPA entity services.  is this possible? any sugguestion?

    Thank you

    Qn1, the ADF Model layer Validation are supported at the level of the validation attribute. It is confirmed.

    Qn2, it seems that this is a better solution, but is not Explorer so far.

    Qn3 is resloved by creating a custom error handler to extract a validation thrown from EJB exception and at the same time, it cannot be avoided that the thrown exception of service business layer is still dumped at MTS-out.

    Qn4 is reslolved by employment Commission to inject POJO, EJB session faade and inject POJO EntityManager (use JTA transaction).

    Thanks to you all!

Maybe you are looking for