Is this a bad J2EE design?

Hi, I've implemented a bulletin board system with JSPs and Stateless session beans. The JSP assigns 1 Stateless Session EJB to each client's HttpSession. And if the session times out, a new session is created and a new reference to a Stateless Session EJB is obtained.
I've seen an example that uses 1 Session EJB per JSP page (rather than 1 per client's session). But it seems to me if you do it with 1 Session EJB per JSP, then you'd have to synchronize access to this shared Session EJB, since the JSP is executed by multiple threads at the same time. Since the majority of the work is done in my Session EJB (accessing the entity beans), it seems like having to synchronize access to it would defeat the whole purpose of having multithreaded JSP execution in the first place.
Any thoughts?

Yes could you please explain how its different for
Session Facade Session Beans (SFSB)? SFSB means StateFul Session Bean. You cannot call stateful session beans conccurently. It will cause container to throw an exception.
If you use stateless beans (doesnt matter if it's a facade or not) than you dont have to worry about this.
Because thats
actually my setup. I have 1 Session Bean per Client
and each session bean calls methods on the entity
beans that map to the database tables.

Similar Messages

  • JavaBean Models, Command Bean and J2EE Design Pattern

    Hello,
    I have read the available "How To", “Using EJBs in Web Dynpro Applications” where the author mentions that one should use a Command Bean (according to J2EE Design Patterns) so that one can invoke business methods in a Session Bean from our Web Dynpro Application. Well, although, I have read some available articles in the internet about J2EE design patterns, I still have some questions about command beans and its usage in Web Dynpro applications.
    I have developed a WD App which uses EJBs to read data from the DB.
    Let's suppose I only have two tables: BOOKS and AUTHORS.
    Let’s also suppose I have to Entity Beans (one for each table) and a Session Bean with two methods: Book[] getAllBooks() and Author[] getAllAuthors();
    I also have a Command Bean which I imported in my WD App.
    My questions are:
    How should I design my Command Bean?
    Can I have only one Command Bean with two methods each calling one of the methods of the Session Bean?
    Or instead should I design two Command Beans, one for each call?
    In the last case do the methods must be named <b>execute</b> or can I name them whatever I want?
    Furthermore, how should I store the data in my command bean? In instance variables?
    If so, can I use array of a class representing a record in the database table (for instance, classes Book and Author) or do I have to store the data in a generic collection (such as ArrayList for instance)?
    I ask this last question because if I try to store the data in an array when I am importing the Command Bean as a JavaBean model I always get an error.
    One last question: Can the Command Bean execute method directly return the data or should I always store the data in an instance variable an then get it using getter methods?
    I know this questions are more about J2EE Design Patterns and JavaBeans specification than they are about Web Dynpro but I also have doubts about the rules that the command bean must obey in order to accomplish a successful JavaBean model import in WD.
    Some guidance or tips would be highly appreciated.
    King Regards

    I have the same problem.
    Does anyone know the solution?
    Thanks
    Davide

  • J2EE design

    Will this tool support the design / build of EJBs or is it only aimed at webApps

    Based on the following quote from there news article on java.sun.com I believe it is primarily a tool for RAD web applications.
    Sun Java Studio Creator (formerly known as Project RAVE) delivers these benefits and helps you to create two-tier web applications that conform to the Java 2 Platform, Enterprise Edition (J2EE) BluePrints.
    Regards,
    Mark Wolfe
    http://www.hsd.com.au

  • Bad MBA design

    I've had my MBA for a while now but had never taken it with me to travel. I had the opportunity to take it this weekend and discovered a major design flaw!
    It look like the trackpad button touches the area of the screen right below the isight and, when the MBA is moved around with the lid closed, the two are in contact and rub against each other creating dark scratches on the edge of the screen!!!
    This is really bad. I guess it doesn't show until you lug it around without the foamy paper thing that comes when the MBA ships! I guess I will start using it to prevent such problem.
    Anybody noticed the same thing?

    Looks like I'm not the only one then.
    If you are going to transport it around without the foam thingy between the screen and the keyboard, I suggest that you try to put the least amount of pressure towards the central edge part of the MBA (right above and below the trackpad when the lid is closed) to avoid this problem!
    I had my MBA in my messenger bag and the fact that the top part was being compressed created this problem. Also, the fact that I was picking up the MBA by holding on the central edge of the MBA to take it out of my messenger bag probably aggravated the issue!
    Be careful guys, this is obviously a design flaw. The rubber part around the screen should have been thicker or the trackpad should sit a little lower....
    Cheers...

  • Bad OOP design?

    I have to access some data before my program starts (to prevent a slow down while the program is running). The thing is, I need to init some objects before my program loads. It works fine now, but when I do the thing that I need the objects for, it hangs for a very short time (while it creates them, you see, right now I can only create them when the action they are needed for is called; it is to detailed to explain). The problem is it just looks unprofessional. Anyway, java.awt.component has a method that would make it possible for me to do the object creation before the program starts. Would it be bad to make a class that extends Component, and then define a method in there that get the information I need to makes it possible for me to create my object before the program starts? Is this bad OOP design?
    Thank you!
    Joshua

    Of course you can't really initialize stuff "before your program loads" since the initialization is part of your program, just before you program tells the user it's loaded.
    Probably the way to intialise stuff early is to do it in static, which will happen as soon as the class loads.
    Mostly you can do it with static object variables initialised to new objects.
    But you can get fancy and put a static code block in the class. Just a piece of code under
    static {
      .. do some initialization

  • J2EE Design Questions

    Please forgive me, I am just getting into J2EE and, despite having a mountain of manuals on my desk, I'm having a little trouble figuring out how everything fits together...
    Question 1.
    Is there any standard application entry point for an EJB container... kind of like main() in a plain old java application, or the contextInitialized() method for a ServletContextListener in a web container?
    Question 2.
    Is there any kind of an analog to web.xml for EJB containers? If not, is there some kind of standard way to set initialization parameters for EJBs?
    Question 3.
    Is there any kind of JNDI service provider created for me by my EJB container? For example, the (rather old) article here:
    http://java.sun.com/products/jndi/tutorial/getStarted/examples/naming.html
    suggests the following code:
    import javax.naming.Context;
    import javax.naming.InitialContext;
    import javax.naming.NamingException;
    Hashtable env = new Hashtable();
    env.put(Context.INITIAL_CONTEXT_FACTORY,
        "com.sun.jndi.fscontext.RefFSContextFactory");
    Context ctx = new InitialContext(env);specifically 'Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.fscontext.RefFSContextFactory"' looks like a bunch of voodoo to me, and also mentions something about the file system... I don't want my JNDI to have anything to do with my filesystem. Do I need to install some kind of JNDI server or LDAP server or something? Sorry... I'm really confused.
    Question 4.
    In my test application, I'm trying to centralize logging. I have a stateless EJB that implements logging capability. When instantiated, (in theory) it should register it's logging element to JNDI, so that further instantiations of the logging EJB should all direct their calls to the same element.
    I fully realize that this would imply (at best), in a distributed environment, the rather strange behavior of logging calls bouncing around to the first machine that happend to instantiate a logging bean...
    regardless, I have the following broken code:
    import javax.ejb.Stateless;
    import javax.naming.Context;
    import javax.naming.InitialContext;
    import javax.naming.NamingException;
    @Stateless
    public class LogEJB implements VCMarkWeb.log.LogEJBRemote {
        private transient Context context;
        private transient Log     log;
        private transient boolean logMaster = false;
        private int logLevel;
        public
        LogEJB() {               
            try {
                context = new InitialContext();
                Log     globLog = (Log) context.lookup("log");           
                if (log != null){
                    this.log = globLog;
                    return;
                log = new LogWindow(800, 600, "LogBean", 5);
                log.out("Logging born.");
                context.bind("log", log);
                this.logMaster = true;           
            catch (Exception exception) {
                System.out.println("LogEJB: Exception while instantiating.");
                System.out.println(exception.getMessage());
        public void
        finalize() {
            if (!logMaster)
                return;
            try {
                context.unbind("log");
            catch (Exception exception) {
                System.out.println("LogEJB.finalize(): Exception unbinding log.");
                System.out.println(exception.getMessage());
    } Obviously, this code is broken, because my EJB has overridden finalize(), which is apparently not allowed. In this case (since I'm going to have to delete that finalize() method), how could I assure that my reference to a logging element will be unbound once the owner of that logging element is garbage-collected?
    ..or.. if I'm asking Question #5 in too convoluted of a way...
    Question 5'. Say, when my EJB container is kicked off, I want to create a single class containing a swing window, which will exist for the lifetime of the container, to which I can pass a handle to, such that any EJB's can invoke its methods? How would I do that, and how would I pass to my EJBs a handle to said class the 'right way'(tm)?
    Thanks so much for your assistance, J2EE design gurus :)

    singletons are counter to the very concept of distributed computing, which EJB is of course liable to do.
    So while you may have a class that behaves like a singleton inside its own enterprise application context, there is no guarantee it will behave like a singleton when seen from the perspective of a client.
    In fact, when the enterprise application is run in a distributed environment it's guaranteed to not be a singleton anymore as each JVM instance will have its own instance of the class loaded.
    It can get even worse depending on application server architecture, and you may end up having several instances of your "singleton" running inside the same server (possibly the same application) though that is more rare.
    So the best thing to do with singletons is forget all about them.

  • I am trying to change my Apple ID. Try to do this I keep getting an error message saying 'This email address is designated as your rescue email address and cannot be used as your Apple ID or Primary email address. Please choose another.' The email address

    I am trying to change my Apple ID. Try to do this I keep getting an error message saying ‘This email address is designated as your rescue email address and cannot be used as your Apple ID or Primary email address. Please choose another.’ The email address that I want to use did use to be my recovery email but I have changed it, so that address is no lonegr associated with my account. I do not understand why I cannot use it as my Apple ID now.  Can anyone help?

    Contact iTunes customer support for assistance.

  • Vizio 26" LCD - Is this a bad choice?

    I am pretty used to working on my 3 year old MacBook Pro 17" laptop and recently bought a MacPro (2008) I've been looking at different monitors and originally didn't like the "glossy" display coating that the new laptops had... BUT for my MacPro I'm in a dark room with no windows so I've changed my mind. I do professional graphics and photography but just can't afford a 30" Apple Display...
    I recently bought the Vizio 26" LCD at this link for $350 to "try it out"
    http://tinyurl.com/n9p2qx
    I was surprised that I kind of like the size and quality of the image...
    SO... I really don't understand all of the TN TFT jargon. Is this a bad monitor for any reason and I just don't know it because I'm used to working on my "dull and small" laptop monitor.
    1. WHAT ARE the BEST bang for the buck monitors above 24" that I should consider and why?
    2. WHAT is the "technical term" for the difference that I see when I look at this Vizio monitor vs it's duller LCD counterparts?
    Thanks!

    If you are doing pro graphics then I assume you make a living doing this and also have your work printed professionally - ie, on a Heidelberg or other offset printers. If so, you will see how the Vizio is useless for this work.
    I deal with many top class printers and if you visit their production department like I do, you see many 23-24 inch Apple displays (not the new LED backlits). These displays can be calibrated with 3rd party hardware-software color calibrators (I use a Kodak method because my main printers uses this). I produce magazines from start to finish and I soft-proof the pages on my 23 inch Apple display - it is perfect. What I see on my display (the digital proof from my printer) matches what will be printed and most important, matches the display at my printer. We are on the same page so to speak.
    You may also see other expensive displays - Barco monitors for example, used for graphics work.
    These are all calibrated. Simple calibration starts with Apple's Colorsync set up.
    Apple's 30 inch display cannot be calibrated by our Kodak system - it is not in their tables or list of approved displays - thats why we are using 23 inch displays.
    Also why are you in a dark room? This is not good for graphic work. A dull room fine - no harsh lighting and no flourescents, no spots, etc.
    This still applies if your work is only with websites, because these are usually seen on computersa nd still need to be within the correct gamut and Luts. I would read up on Colorsynch and color gamut for the particluar work you do.
    Now if you are working only in video or entertainment that is different.

  • J2EE Design Question -- Am I On The Right Track?

    There are multiple tables in my database. Each table has a primary key, and the table that relates to other tables has foreign keys. I have to match the primary key and foreign key to go from one table to another. The specifics are spelled out below:
    The first table has login, pwd, and a primary key as fields, the second table contains completely different fields plus a primary key and foreign keys. The fields in the third table are different from those in the first and second tables plus its primary key. Queries to the third table can be made only if the user login and pwd are found in the first table, and through the second table's relation to the first table and the third table�s relation to the second table.
    The fields of all those tables may be accessed concurrently, but the fields are read-only (for the time being).
    I have a servlet to handle browser interactions. And I have a session bean to handle the workflow and business logic. However, I am confused with the choices between VO and entity beans.
    I first thought that I should use value objects to represent the data fields of the specific rows I looked for in those tables. Here is what I read about Value Object:
    "If a business object merely represents a structure to hold data fields, and the only behavior it provides are get and set method for the fields, then it would be wasteful of system resources to implement it as an enterprise bean. To avoid expensive remote methods calls (system resources and network bandwidth) to get the value of entity object fields, a value object is used to represent the details of the entity object. Only one remote call is required to retrieve the value object and then a client�s request to query the state of the object can then be met via local get methods on this details object."
    On my second thought, I think I should use entity beans to represent the specific rows I am looking for in those tables because I must use primary key and foreign key relations to go from one table to another.
    I do not use DAO because I am using CMP. The first call is within the session bean. It is a remote call to look for a specific row in the first table in my database. Subsequently, the mapping of the row in the first table to the second table, and the mapping of the row in the second table to the third table are all invoked on the �local" interfaces of those entity beans.
    client(browser)-->front controller(servlet)-->session facade(session ejb)-->entity ejb-->entity ejb -- > entity ejb
    Please advise if this is the right design. Am I on the right track? Is there improvement to be made?

    I might not explain my question well in my previous post -- there is no business logic involved in what I am doing to go from the first entity bean to the second entity bean and to go from the second entity bean to the third entity bean.
    Based on the login information, I have to go through those entity beans to find the very specific row in the third table in order to get the data field I need. That is to say, only thing involved is searching for rows.
    In my view, session bean -- > 1st entity bean -- > 2nd entity bean -- > 3rd entity bean
    1. session bean -- > 1st entity bean: remote call and returns the key to the 1st entity bean for locating the 2nd entity bean
    2. 1st entity bean -- > 2nd entity bean: local call and returns the key to the 2nd entity bean for locating the 3rd entity bean
    3. 2nd entity bean -- > 3rd entity bean: local call and then returns the value of the specific field to the session bean
    The alternative approach is:
    session bean
    |
    + + +
    1st entity bean 2nd entity bean 3rd entity bean
    1. session bean -- > 1st entity bean: remote call and returns the key to the session bean for locating the 2nd entity bean
    2. session bean -- > 2nd entity bean: remote call
    and returns the key to the session bean for locating the 3rd entity bean
    3. session bean -- > 3rd entity bean: remote call and the session bean can get the value of the specific field from the 3rd entity bean
    I do not know which approach to go for. Please provide guidance. Thanks.

  • Failed to load this workflow. To correct this problem, restart Sharepoint Designer

    I installed Sharepoint Server 2013 SP1, Workflow Manager 1.0 Refresh, 
    Service Bus 1.1, Sharepoint Designer 2013 SP1 (15.0.4569.1503).
    Than I install sandbox solution which contain workflow 2013. This workflow I can open in SPD2013 SP1. But
    after than I publish this workflow it can't open more. Appearing error: "Failed to load this workflow. To correct this problem, restart Sharepoint Designer". After restart SPD error appers again. Clearing SPD cache not help me
    It seems me a bug of SPD2013 SP1?!

    Did you try this?
    http://support.microsoft.com/kb/2768343

  • Suggest good book for J2EE Design Pattern.

    Is there any good book for J2EE Design pattern? I know Head First Design Pattern book, but is focuses oncore java. I want to learn in detail with examples J2EE design pattern.
    Please suggest good books.
    Thanks in advance.
    Rahul.

    most j2ee patterns are discredited now. they were mostly workarounds for deficiencies in ejb 1 & 2 specs.
    "core j2ee patterns" is your best bet, but take it with a grain of salt.
    better to learn spring, IMO:
    springframework.org
    %

  • Personal hotspot missing and music volume not working and lots of other problem after updated 4s to ios8 ? Apple disappointed this time badly.

    Personal hotspot missing and music volume not working and lots of other problem after updated 4s to ios8 ? Apple disappointed this time badly.

    GO to Setting > Cellar Data > VPN Settings > Add any user and password under Personal Hotspot, then you will see it's activated again as usual

  • If i unplug my iphone while its "updating software" will it restore the old software? or is this a bad idea?

    if i unplug my iphone while its "updating software" will it restore the old software? or is this a bad idea?

    It's a bad idea. It *ought* to recover OK, but there are too many cases where it hasn't to be safe assuming that it will.
    If, as Changren Yong says, you have a good backup, you always have the safety net of a restore, but it's a silly thing to do,
    My advice when doing software updates is to download separately then update (you're always offered an option to download only). You can do what you like during the download, which is always the ling part of the process for me. The update usually (for me) only takes about 5 minutes.
    One further point - in case you didn't know, you can initiate a backup by right-clicking the phone in iTunes and choosing Backup from the drop-down. That should always be part of your update process

  • ABOUT ADOBE MUSE Does this software have responsive design? Do I pay...

    Does this software have responsive design? Do I pay a fee to use the software and another fee to host the web site? How much does it cost to have ONE website edited in Muse and published by Adobe server?

    Hi Leonardo,
    Muse does not offer responsive design at this stage.
    You need to pay the subscription fees to be able to use the software. As far as the hosting fees in concerned, if you opt for subscription to creative cloud that you get 5 free sites hosted on business catalyst for free on the webBasics/webHostings plan. If you choose to opt for single app subscription for Muse then you get one free site.
    This free site offer is not available for the students and the teachers edition.
    You can check different site plans that are available with business catalyst here, US Monthly Pricing | Adobe Business Catalyst
    - Abhishek Maurya

  • The "This Accessory is Not Designed for iPhone" Nag

    "This Accessory is Not Designed for iPhone"
    I guess that's the oldest (bug?) in the iPhone. What I have noticed in going from the (highly coveted) firmware 3.0.1 to firmware 4.2.1 is that after you press “dismiss”, the "This Accessory is Not Designed for iPhone" nag reappears in 5-6 Mins.
    With my old firmware the nag would only show up once, with firmware 4.2.1 it nags over and over again. (And of course, all of the accessories involved work perfectly in every way.)
    Others tell me, jail breaking is required to stop the nagging. I am not jailbreaking my phone. Please tell me there's another way.

    It's not quite a bug.
    The only reason it would reappear is if it loses the connection and then reestablishes it. It should never show up after appearing once and maintaining that connection. Presumably it i showing up because there is an incompatibility. If there is then I suppose it would make sense that it is struggling to maintain that connection.
    In terms of getting rid of it there really is no way besides using an accessory that is compatible on Apple's terms. The same thing happens to me when I use my car dock. Do I really need to be told every time I get in my car that the same dock I have used for months is incompatible (yet still works 100% fine)? Absolutely not. But it's not something that can be disabled.
    -SM

Maybe you are looking for

  • Different chart for each level hierarchy in report designer

    Is there a way to display a different chart for each level of the hierarchy in a report designer? I want a different chart for each level. That is, if there are 5 nodes in level 4, I want 5 different nodes. Is there a way to do this? I tried to inser

  • Mapping constant block parameters in simulink to a Veristand control block

    Hello, I am trying to take a simple model of a RL circuit in simulink (built a dll file) and add control of constant blocks in Veristand to dynamically change the value of R and L constant thru the Veristand Slider or Numerical indicator. I can see t

  • Cannot create CO of type Composite App Service in SP9

    Hi All, We have recently upgrade our system to SP9, from then I am not able to create CO of type Composite Application Service. Did anybody come acros this issue? It gives an error "an error "Invalid component: componentName=com.sap.caf.core.gp.ui.ba

  • Dynamic Prouct Proposal

    Hi Friends, All the configuration has been setup properly for dynamic product proposal like: u2022     Define the customer pricing procedure for the product proposal u2022     Define the document pricing procedure for the product proposal u2022     A

  • Can I sync with a smart phone

    Am I able to sync my smart phone to my iPad