Best way to inject EJB's in Struts 2

Hi all,
I'd like to ask you what do you think is the best way to inject EJB's in Struts 2 Actions (and perhaps other struts classes such as type converters).
I've read and implemented both a Struts 2 Interceptor and used CDI. About CDI I've read there's a discussion whether the injected resource should be a private field or injected through the constructor which would help testing.
Personally I seem to prefer CDI as it looks a bit simpler after you are familiar a bit with the technology.
What is your preferred solution and why?

Make sure you are using JDeveloper with a "regular Oracle DB" and not Oracle XE - Oracle XE doesn't have support for JPublisher.
And make sure you are trying to invoke this from the database navigator window and not from the connection manager of your application.
Anton - I think you are mixing JPublisher with something else - maybe with Java stored procedures?
JPublisher just creates a JDBC wrapper that calls the functions in the DB - it doesn't run inside the DB so I don't get your point about the mini JVM?
So it basically does exactly what you recommended: "access PL/SQL procedures from java directly?"

Similar Messages

  • Best way to call EJB - Servlet or Tag Library

    Hi,
    What is the best way to call an EJB from a JSP? We are using Weblogic 7.0(moving to 8.1 beta). WE have a form on a JSP that needs to get data from an EJB. Our flow goes from JSP --> Controller servlet or tag library -->EJB "Bean" Controller ---> EJB. The specfic EJB we need to populate drop downs and fields will be called by a bean controller. Is it better to call the bean controller using a tag library in the jsp or go to the controller servlet to get the data? If servlet is the answer, where do I lookup the EJB Home and call the create from within the servlet? Any help would be greatly appreciated!!
    Thanks!

    IMO, if you are following some design patterns, like the MVC framework, the best thing is to populate the model(entities that contain the business data) and call the respective getXX methods from the model on the JSP page. The reason for doing so is to keep JSP pages away from any other work other than to just display the business data contained in the respective business entities.
    The model can be populated in the servlet and either set in the request or session attribute as per the requirement.
    The EJB can be looked up in the servlet as and when required. I would suggest to make use of the Service Locator Pattern to do a look up for the EJB Remote Interface and accordingly make the business calls.
    Hopefully this answers some of your questions.

  • What is the best way to use EJB modules with JAX-WS?

    Hi.
    I am doing a project that returns EAN13 encoded data to external java clients.
    I think I need to use a webservice that send response, a webservice client that send the request, and other project that transforms a data to an EAN encoded data, returns it and store it in MySql database.
    It is possible that I need to authenticate users for every request made.
    -I have created a EJB module contained into Glassfish for the webservice
    -I have created a Common Java project with 3 layers: Entities, bussines and data access layer for mysql database
    -I have a project for the webservice client with JAX-WS ( is the best choice? or Would be better JAX-RPC? )
    **How would you suggest me create the structure of the project with all the java power?*
    **Could you help me with goods tutorial of design patterns about webservices using EJB and the best way for use databases for this kind of projects ( I have heard about JNDI, Hibernate, Session EJB, ... )?*
    **Would be better use other EJB module instead of a Common java project that has classes?*
    h3. {color:#333399}I shall be pleased with your help{color}

    Kappy is dead on correct about Bridge Mode as a requirement for the Time Capsule.
    Do you know how to check to see if the Time Capsule is configured this way?
    Next question.....you really should not try to have two wireless networks....one Arris and another Time Capsule.....unless it is absolutely necessary. Two wireless routers in close proximity can create wireless interference effects that can cause problems with either...or both...networks.
    Best to turn off the wireless on one router to keep the chances of wireless interference between routers minimized.
    Are both the Arris and Time Capsule providing wireless signals?

  • Best way to call EJBs from JavaBeans/JSP

    Does anyone have a favorite way for getting EJB data from a JavaBean into
              your JSPs?
              I'm looking for a way of caching the EJBHome references so the beans don't
              have to do a lookup on each page, each time they are called.
              Thanks,
              -TB
              

    How does this HelperClass keep the references cached after it looks them up?
              Is it a singleton object, or does it keep the references in static fields?
              "Argyn Kuketayev" <[email protected]> wrote in message
              news:3b1e468b$[email protected]..
              > make a HelperClass, which will have a method getXXXHome()
              > inside the Helper class you may implement cashing.
              >
              > thanks,
              > Argyn
              >
              > T. Bailey wrote in message <[email protected]>...
              > >Does anyone have a favorite way for getting EJB data from a JavaBean into
              > >your JSPs?
              > >
              > >I'm looking for a way of caching the EJBHome references so the beans
              don't
              > >have to do a lookup on each page, each time they are called.
              > >
              > >Thanks,
              > >-TB
              > >
              > >
              >
              >
              

  • Best way of keeping property files in struts 2 in an application

    Actually we are 5 people working on an application . Now the problem is everyone is using their own properties files for internationalization and now the problem is that message are conflicting with each others properties file even i only have 4 properties files and my own messages are conflicting .
    So can please tell me the right way for handling internationalization..
    if we'll keep only one properties file for internationalization then it become really really huge .
    So what can be the alternate....
    Please Please tell me the solution..
    Thanks.....

    I believe a Referenced file system would accomplish what you are describing.
    In a Referenced file system:
    * Your files are not stored in the Aperture Library, but are externally referenced from folders on a hard drive (either internal or external).
    * You Aperture Library can hold Previews of any or all of your Referenced images.
    * You can disconnect an external drive with the Referenced files if you wish.
    * The Vault only backs up project/folder/album, keyword/metadata, and adjustment data, not the images.
    You can easily move your images from being Managed in your Aperture Library to being Referenced by using File>Relocate Master.
    You can find out more about a Referenced file system on Page 135 of the User Manual available from the Help menu in Aperture. There is also good into here: http://homepage.mac.com/bagelturf/aparticles/ref/ref.html
    -Karen

  • Best way to include javascript-script into different struts-pages

    Hi,
    I'm running a struts-based webapplication using the tiles-templates for my layout. Now I have to use some javascript-code for a pop-up window and another javascript for tracing on multiple pages but in different combinations. As I do n't want to copy-paste it on every page, but put it on a single place for better maintenance I'm wondering what would be the best way to do this together with the struts-logic.
    I thought about the following options:
    1.) Using the "template:put" feature like this:
    <template:put name='js' content="/myJavascripts.jsp"> I don't think this would be a good option, as I always have to include the whole javascript and I cannot distinguish between my two different javascripts
    2.) Using the template:insert feature like this:
    <template:insert template="/myJavascripts.jsp"/>. This is a lot better, as I can split my two javascripts into two different files and can always decide, which one to include with the template:insert tag. But I'm not sure, if this is conforming with the struts-concept, as I do not use any template:put or template:set tags
    3.) Using simple jsp:include or <%@ include ... %> tags.
    This would be the easiest way to include my pages with <%@ include file='/myJavascripts.jsp' %>. Same advantages like template:insert but I don't need the additionally features of the template:insert-tag. But still the same question: is this the concept of struts? Or will I become any difficulties with this concept later??
    Any recommendations or further ideas are greatly appriciated.
    Thanx for your help
    Thomas

    Getting PDFs to download is fairly easy and the method is described here.....
    http://www.iwebformusicians.com/WebMusic/PDFs.html
    To get multi page docs to display in the browser requires the use of Google Docs viewer, ISSUU or some such thing....
    http://www.iwebformusicians.com/PromoPage/ISSUU.html
    Safari is the only browser I know of that will display PDFs in an iFrame without a plugin.

  • What is the best  way for using a  C++ in the EJB?

    What is the best way for using C++ in the EJB ie
    either 1. Socket programming
    2. JNI

    To what purpose?
    To use C++ in the client you could generate IDL from your remote interfaces and run that through your vendor's IDL-to-C++ processor.

  • Best way of avoiding SQL injection?

    Hey,
    I was wondering what you guys would recommend to prevent SQL injections. Now, I know that you can use the PreparedStatement and setString for cases like this:
    String userName  = request.getParameter("username");
    String sqlString = "SELECT * FROM UserTable WHERE USERNAME='" + userName ;but what can you do when you have cases like these:
    String userdef_table  = request.getParameter("userdef_table");
    String userName  = request.getParameter("username");
    String sqlString = "SELECT * FROM "+ userdef_table +" WHERE USERNAME='" + userName ;Note: userdef_table can be created by the admin so I wont know what tables are around.
    thanks,
    domet

    For Your First Question
    1) using PreparedStatement is the best way, but yes you will have to catch the Table Not Found Exception very well in case the passed table deso not exist... Thats The Only Logical Answer For your Query
    For Your Second Query
    1) Create a String variable which will have the required reflex string ie the text you would liketo have after LIKE keyword and then pass the variable to the prepare statement
    this
    ?% will not work for its wrong SQL query
    String likeThis = "%Bill%"; <or what ever>
    the Query part will be like this ".......like ?"
    setString(....,likeThis);
    Hope This Works
    Bhaskar

  • Best way for an applet to contact EJB ?

    Which is the best way for an applet to connect EJB?
    1) Applet --> servlet --> EJB
    2) Applet --> EJB
    What is the pros and cons of both approach?
    Thanks

    Hi there,
    This is a tricky question and it would be interesting to hear what others think.
    Probably the key factor is what is available to you in terms of communications between the EJB and the applet. If you are on an intranet then having the applet talk directly to the EJB looks favourable as you will almost certainly be able to use RMI/IIOP for communications between the applet and the EJB. If you are forced to use HTTP as the communications protocol then you can't talk directly from the applet to the EJB but there again talking to a Servlet from an applet throws up complications of it's own. In this case you should consider not using an applet at all and instead use a JSP page or pages to handle the presentation.
    There is another issue that you need to consider when the applet talks directly to the EJB. If the App server that contains the EJB is on a different system to the one that runs the Web Server you'll have to address some security issues and will have to either have local policy files for the systems running the applet or you'll have to sign the applet and have the clients trust it.
    Hope this helps
    Amanda
    Developer Technical Support
    Sun Microsystems
    http://www.sun.com/developers

  • What is the best way of integrating rules to a J2EE (EJB 3) application ?

    We are working in a J2EE(EJB3) project which we plan to validate business logic using rule engine(JBoss rule). What is the best way of integrating the rule engine to the application ?
    Does rule engine good for validating a large no of data volume ? (asserted as an objects)

    I don't see a big switch construct. How about trying the following:
    Call this method from your original method by passing the resultset obtained.
    public String[] convert(ResultSet rs) {
         int col = ((ResultSetMetaData) rs.getMetaData()).getColumnCount();
         String[] record = new String[col];
         int i=0;
         while(rs.next()) {
              if(rs.wasNull()) record[i] = new String();
              else record[i] = rs.getString(i);
              i++;
         return record;
    iDriZ

  • The best way for moving from Java To JSP....

    Hello Guys ,
    Actually i am New to Java Technology and i Love it very much , i am trying to do my best ...
    i Understand it , it`s Logical for me , as you told you i`m New to Java Technology and i wanna learn JSP as soon as i can , because i have to do the commercial Project "Website" for my Univ... And Sure i wanna Continue With Jsp .. For Enterprise Commercial Projects .Sure i will Continue with Java Too ..
    The Question is .. , What is the Best way i MUST follow to achive my target ?
    i mean if i can start with Jsp Directly , or i have to focus on special Topics in Java Before Strat JSP ...
    i have just 6 monthes to Perform my Commercial Project "Payment On line ..etc"
    So Please i really want your Help
    I`d be really thankfull for you guys
    thanx for your time
    Java son

    Enterprise Applications != JSP. JSP is just a
    front-end. For enterprise apps you'd probably rather
    need EJBs...Argh... not true. I see what you are getting at, as JSP is merely presentation layer stuff; however, EJBs are certainly not ever required per se, altho they may offer some services that may be useful. I suggest OP takes a look at Struts in order to separate the webapp in an MVC style so that the decision for what to use at the back is decoupled from everything else. If it is a simple webapp, and for a University then I don't think a complex back-end will be required. In any case webapps are not enterprise systems, but they may act as views on them in some cases.

  • What is the best way to find and apply the samples in the sap library

    I am a fresh man in the process of learning sap .
    Mainly aim at the MM and SD model .
    They all say that the best way to accomplish the task is to follow the sap on-line help.
    because i don`t know the struts of the library , so to find what i need in the library becomes impossible for me as the library includes a lot of files .
    so please some one help me to direct the struts of the library and teach me the way how to find what i want ?
    thanks

    Hi,
    This forum is for BPX. Post Solution related quries in SAP Solution Forums.
    You can access MM and SD help at:
    http://help.sap.com/erp2005_ehp_02/helpdata/en/80/ea89395eb58c4f9d0c3e837cf0909d/frameset.htm under Logistics
    or http://help.sap.com/ -> SAP ERP -> Choose Release (for example SAP enhancement package 2 for SAP ERP 6.0) -> SAP ERP Central Compoennt (MM and SD under Logistics)
    From Materials Management Link you can navigate further to Purchasing, Inventory Management etc. From Sales and Distribution you can naviate further: Sales, Billing etc.
    For example to see help regarding Purchase Orders:
    You would first expand Logistics and choose Materials Management in Help Link for ERP Central Component. Here, choose Purchasing Node which will take you Purchasing Help screen -> Click and Purchase Orders Node and Expand the same for more information regarding Purchase Orders.
    You should be comfortable with SAP help link.
    Regards,
    Naveen.
    Search the forum with keywords before posting the query.

  • What's the best way to handle this?

    I'm not sure what APIs/setup to use for this situation:
    A company wants to store data projects they do for clients. Each year, the data fields are set (as a result of gov't requirements) and they won't change for any client project for that year. however, the fields required can (and usually do) change every year. So things they require this year, might not be needed the next year and new fields might be introduced.
    While there are likely to be many common fields from year to year, there's no way to guarantee which ones will remain consistent. They also want to be able to do searches on the data and fields, for projects within a year and across years.
    What's the best framework/API/configuration to handle this? EJB? Simple JDBC? If so, how should the database be handled? Won't it have to constantly create new fields in a table? Or is there another way to handle this?
    What's the best way from a "clean architecture" standpoint?

    dang, I really have to start over? I finally got all this stuff working again.  well, hopefully it won't be as big a pain this time since the data won't be coming from a different machine.   After completing the Migration Assistant process, I had to reinput a bunch of serial numbers for apps, reinstall print and mouse drivers, etc...  I've finally got the new machine up and running smoothly and now I gotta start over? Sigh.
    I was hoping that either I could rename the current account after deleting the other one, or just move everything from one account to the other and then delete the 'RJM' account.
    ok, so it sounds like here are the steps I need to take:
    - make another full cloned backup of this current machine in Super Duper
    - reboot this machine using the advice in the first post, wipe everything clean and reinstall the OS
    - create a new account like 'user1' and re-do software update (which is like 2.5 gig worth of stuff) and takes like an hour even on a high speed connection
    - then re-do the migration assistant process to the properly named account
    - then delete the 'user1' account
    does that sound right?

  • What is the best way to deploy application that uses web services?

    Hi all,
    I'm having some problems figuring out the best way to deploy our app now that we've switched over to using web services.
    I'm fairly new to Java and web services. From what I understand, JNLP and WebStart are methods to deploy Java clients to users and not for creating war files and the like.
    Here's a little background:
    We have a large PowerBuilder/Oracle application. The db consists of over 500 tables and the client consists of several thousand PB components. A user creates "transactions" which contain a series of "sub-transactions" within. Most of the data is collected and stored locally in the client in a series of datastores. When the "finalize" happens, the records are validated and sent to the database.
    We are in the process of moving each of the subtransactions (currently in the PB client) into subPROCESSES on a java project. We are using the JAX-WS framework to develop the web services in Netbeans. These web services aren't much more than remote xml as the messaging technology. For writing data back to the database, we are using the Java Persistence API to function outside of an EJB container but will shortly be migrating to the Glassfish application server to use several of the EJB container frameworks including the EntityManager.
    We haven't attempted any type of deployment and are unsure of where to start. Any suggestions would be so helpful and appreciated!
    Thanks!
    Edited by: doubleEspresso on Jan 10, 2008 8:06 AM

    >
    I'm fairly new to Java and web services. From what I understand, JNLP and WebStart are methods to deploy Java clients to users and not for creating war files and the like. >Correct, while Java Web Start has 'web' in the name, it has little if anything to do with web applications - certainly not providing much toward their installation. It is for launching rich client GUI based (AWT, Swing, SWT..) applications onto the end-user's desktop.
    There are some parts of JWS that might seem peripherally useful to the installation of a web-app., but it is really not a 'good fit'.
    >
    ..Any suggestions would be so helpful and appreciated!>You might try the forums for the 'web tier' APIs.
    <http://forum.java.sun.com/category.jspa?categoryID=20>
    Or perhaps the forum 'Java Technologies for Web Services' (under 'enterprise technologies')
    <http://forum.java.sun.com/forum.jspa?forumID=331>
    This one in 'BigAdmin' seems particularly relevant, 'Set up and Deploy'
    <http://forum.java.sun.com/forum.jspa?forumID=550>

  • What's the best way for a web app to handle logins and sessions?

    I'm deploying in JBoss, using JSF. As is often the case, I keep User information in an entity bean. My question is, what's the best way to handle this bean?
    My inclination is to create a login page with a LoginBackingBean atached to it. When the user attempts to log in, it will see if there is a User entity bean that corresponds to the given name and password. If there is no User bean that matches, obviously we show an informative error screen.
    But what happens if there is a valid user?
    In the plain old Servlet world (without EJB / J2EE) I would just put the User object (it's an object, not an EJB) into the HttpSession, and I would create a Filter that would check for the presence of that User object, and I would map the filter to something like /members/*, and that would be it. I would use Hibernate to persist the User object, and there would also be a filter that creates a Hibernate session and stores it in the Request so that the User object would work and persist.
    How do I do this within the J2EE / EJB world?
    My first thought would be to just do the same thing. Install the User bean into the HttpSession, and create a filter and do all the same stuff. Is that the right way to do it? It would work pretty well with JSF because I could just access things in the normal JSF way: #{user.firstName} would find the "user" object in the HttpSession scope. So that's good.
    One question that comes up from that is if the user makes some change to the User object that is in the Session scope, will the EJB automatically do the right thing and make those changes persistent? Is there anything else I need to do?
    I'm new to the EJB world, but from what I can see so far, it seems like it's the best way to think about a web application.
    Thanks

    hi ,
    i think the best way is to create java beans ,in that bean call your EJB ,
    and check the validation over there.
    and make that bean scope to session.
    in each and everypage try to check the session ,if it is not valid then forward to your login page...
    otherwise continue to give access to him like guest
    Regards,
    AfTaB

Maybe you are looking for