Eclipse JEE application

Discussion in 'Java' started by Tim Slattery, May 3, 2011.

  1. Tim Slattery

    Tim Slattery Guest

    I've been a Netbeans user, but the powers that be have dictated that I
    have to use Eclipse.

    I've created a JavaEE "Dynamic Web Project". I've imported my struts
    jars by copying and pasting (but there must be a way to find them from
    within Eclipse). Then I create a Java class. I can use the classes
    defined in the Struts jars, no problem there. But I cannot use things
    like HttpServletRequest, HttpServletResponse, or HttpSession. It
    doesn't know what they are. If I manually write the "import"
    statements, it tells me "the import cannot be resolved".

    It knows that this is a Java EE app, so why in the world can't it
    figure this stuff out?

    --
    Tim Slattery

    http://members.cox.net/slatteryt
    Tim Slattery, May 3, 2011
    #1
    1. Advertising

  2. On 11-05-03 01:34 PM, Tim Slattery wrote:
    > I've been a Netbeans user, but the powers that be have dictated that I
    > have to use Eclipse.
    >
    > I've created a JavaEE "Dynamic Web Project". I've imported my struts
    > jars by copying and pasting (but there must be a way to find them from
    > within Eclipse). Then I create a Java class. I can use the classes
    > defined in the Struts jars, no problem there. But I cannot use things
    > like HttpServletRequest, HttpServletResponse, or HttpSession. It
    > doesn't know what they are. If I manually write the "import"
    > statements, it tells me "the import cannot be resolved".
    >
    > It knows that this is a Java EE app, so why in the world can't it
    > figure this stuff out?
    >

    For something as generic as the JAR for the Servlet API and
    implementation, one usually sets up a runtime (Tomcat, JBoss, WebSphere,
    Oracle oc4j etc) and those libraries are then available to you.

    A right-click under the Servers tab to get New->Server will get you started.

    AHS
    Arved Sandstrom, May 3, 2011
    #2
    1. Advertising

  3. Tim Slattery

    markspace Guest

    On 5/3/2011 1:45 PM, Arved Sandstrom wrote:

    > For something as generic as the JAR for the Servlet API and
    > implementation, one usually sets up a runtime (Tomcat, JBoss, WebSphere,
    > Oracle oc4j etc) and those libraries are then available to you.



    At least in NetBeans, when you set up a type of "project," the base
    libraries are put on your compile path. For example, when you choose
    "Web Application," you don't have to do anything else to extend for
    example HttpServlet.


    > A right-click under the Servers tab to get New->Server will get you started.



    If this is the answer, then it is indeed a bit weird for someone from a
    NetBeans background. Hopefully, you're answering about the compile-time
    environment and not the run-time.

    (NetBeans comes with a server, Glassfish, by default if you get the
    "full Monty" (<-- air quotes), so perhaps that is why you don't have to
    explicitly install one in NB. It always has at least one server to
    compile against.)
    markspace, May 4, 2011
    #3
  4. On 11-05-03 09:56 PM, markspace wrote:
    > On 5/3/2011 1:45 PM, Arved Sandstrom wrote:
    >
    >> For something as generic as the JAR for the Servlet API and
    >> implementation, one usually sets up a runtime (Tomcat, JBoss, WebSphere,
    >> Oracle oc4j etc) and those libraries are then available to you.

    >
    >
    > At least in NetBeans, when you set up a type of "project," the base
    > libraries are put on your compile path. For example, when you choose
    > "Web Application," you don't have to do anything else to extend for
    > example HttpServlet.


    I seem to remember that. I haven't used NetBeans for a couple of years,
    and even then it was for a desktop app (a socket server actually). So
    it's likely been 3 or 4 years since I fired up a web or full J2EE app on NB.

    I do actually keep up with NetBeans dev. I have 6.9 and/or 7 installed
    on two boxes right now, just in case. The reason I barely use it is
    because no clients in the last 3 or 4 years have...it's almost always
    Eclipse. I try to evangelize a bit but it's tough slogging.

    >> A right-click under the Servers tab to get New->Server will get you
    >> started.

    >
    >
    > If this is the answer, then it is indeed a bit weird for someone from a
    > NetBeans background. Hopefully, you're answering about the compile-time
    > environment and not the run-time.


    Well, compile time and run time, it's somewhat indistinguishable. If
    you're writing J2EE/Java EE with a typical app server there's the
    expectation that most of your core stack is going to be supplied by the
    server, not by the WAR/JAR/EAR. So your compile time requirements for
    core Java EE APIs, and for your JSF, and for your persistence, and so
    forth, are supplied by the server libraries - otherwise you are
    maintaining two sets of dependencies.

    > (NetBeans comes with a server, Glassfish, by default if you get the
    > "full Monty" (<-- air quotes), so perhaps that is why you don't have to
    > explicitly install one in NB. It always has at least one server to
    > compile against.)


    That's the difference, and Glassfish (or specific variants thereof) is
    the Java EE reference implementation besides. Eclipse (at least all the
    versions I've used) has elected not to include a server, but it does
    have an easy-to-use server plugin system that handles most of the app
    servers out there - you yourself obtain and unpack the server distro,
    and the Eclipse server plugin for server X simplifies the process of
    making Eclipse aware of it. I can typically set up and configure Eclipse
    for Tomcat or JBoss or oc4j or whatever inside 5 minutes, once the
    server distro is unpacked.

    I have no objections to either approach, NetBeans or Eclipse. The
    Eclipse approach is more realistic for me, as no client my company has,
    has had, or ever will have, uses or will use Glassfish. :) So it's best
    for me to go through the initial upfront setup for OAS or Websphere or
    JBoss first on any given project. YMMV.

    AHS
    --
    Governor Thomas was so pleas'd with the Construction of this Stove, as
    describ'd in it, that he offer'd to give me a Patent for the sole
    Vending of them for a Term of Years; but I declin'd it from a Principle
    which has ever weigh'd with me on such Occasions, viz. That as we enjoy
    great Advantages from the Inventions of Others, we should be glad of an
    Opportunity to serve others by any Invention of ours, and this we should
    do freely and generously.
    -- Benjamin Franklin
    Arved Sandstrom, May 4, 2011
    #4
  5. Tim Slattery

    Tim Slattery Guest

    markspace <-@.> wrote:

    >On 5/3/2011 1:45 PM, Arved Sandstrom wrote:
    >
    >> For something as generic as the JAR for the Servlet API and
    >> implementation, one usually sets up a runtime (Tomcat, JBoss, WebSphere,
    >> Oracle oc4j etc) and those libraries are then available to you.

    >
    >
    >At least in NetBeans, when you set up a type of "project," the base
    >libraries are put on your compile path. For example, when you choose
    >"Web Application," you don't have to do anything else to extend for
    >example HttpServlet.


    Exactly right.
    >
    >
    >> A right-click under the Servers tab to get New->Server will get you started.


    Nogo. I had already done that, before posting. I'd downloaded support
    for Weblogic (our server), I'd created a "server" within eclipse. No
    change.

    If I now bring up project options and choose "Servers", I get a page
    that says "This project is not associated with any servers." The only
    other thing on the page is a "Restore Defaults" button and an "Apply"
    button. Not very helpful.

    There's a pane at the bottom of the Eclipse windows that has four
    tabs" Markers, Servers, Data Source Explorer, and Snippets. CLicking
    the "Servers" tab shows the WL server that I created, and says
    [Started].

    --
    Tim Slattery

    http://members.cox.net/slatteryt
    Tim Slattery, May 4, 2011
    #5
  6. Tim Slattery

    Lew Guest

    On 05/04/2011 09:13 AM, Tim Slattery wrote:
    > markspace<-@.> wrote:
    >
    >> On 5/3/2011 1:45 PM, Arved Sandstrom wrote:
    >>
    >>> For something as generic as the JAR for the Servlet API and
    >>> implementation, one usually sets up a runtime (Tomcat, JBoss, WebSphere,
    >>> Oracle oc4j etc) and those libraries are then available to you.

    >>
    >>
    >> At least in NetBeans, when you set up a type of "project," the base
    >> libraries are put on your compile path. For example, when you choose
    >> "Web Application," you don't have to do anything else to extend for
    >> example HttpServlet.

    >
    > Exactly right.
    >>
    >>
    >>> A right-click under the Servers tab to get New->Server will get you started.

    >
    > Nogo. I had already done that, before posting. I'd downloaded support
    > for Weblogic (our server), I'd created a "server" within eclipse. No
    > change.
    >
    > If I now bring up project options and choose "Servers", I get a page
    > that says "This project is not associated with any servers." The only
    > other thing on the page is a "Restore Defaults" button and an "Apply"
    > button. Not very helpful.
    >
    > There's a pane at the bottom of the Eclipse windows that has four
    > tabs" Markers, Servers, Data Source Explorer, and Snippets. CLicking
    > the "Servers" tab shows the WL server that I created, and says
    > [Started].


    You have to set up "runtimes". Context-menu the project, select "Properties"
    and set up the "Targeted Runtimes".

    --
    Lew
    Honi soit qui mal y pense.
    http://upload.wikimedia.org/wikipedia/commons/c/cf/Friz.jpg
    Lew, May 4, 2011
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Naeem
    Replies:
    1
    Views:
    282
  2. david_marsetty
    Replies:
    0
    Views:
    876
    david_marsetty
    Jan 29, 2008
  3. jonne
    Replies:
    0
    Views:
    1,662
    jonne
    Feb 8, 2009
  4. Arne Vajhøj

    Re: Eclipse, JEE, Hello World

    Arne Vajhøj, Mar 7, 2009, in forum: Java
    Replies:
    3
    Views:
    549
    Arne Vajhøj
    Mar 7, 2009
  5. Arved Sandstrom

    Re: Eclipse, JEE, Hello World

    Arved Sandstrom, Mar 7, 2009, in forum: Java
    Replies:
    7
    Views:
    481
    John B. Matthews
    Mar 9, 2009
Loading...

Share This Page