• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 401
  • Last Modified:

How to deploy a J2EE JAR only application to Glassfish

Hello all,
I am new to Java & J2EE / Glassfish and need some basic help.  I am using NetBeans 7.0.1 w/ Glassfish 3.1.  

I know that this will be superfluous information, but I am running through the path that I have taken to arrive at where I am now.  When I create a new Enterprise Application the EJB and WAR projects are created.  When I deploy the project, Glassfish launches the JSP page.

While I will want a web front end to administer this application, I do not want that to be the entry point.  I want to have the entry point on the launch of the application to be a class within the JAR file created in the EJB project.

I have read about, and tried to implement a singleton session bean with the @Startup, @Singleton, @LocalBean and @PostConstruct annotations, however this class is never called.  I have waded through a sea of documentation, blogs and other musings and data, but I still do not understand how to define the entry point of the application or how GlassFish determines how it will run the application.

I thank you for your guidance.
0
edc
Asked:
edc
  • 4
  • 4
1 Solution
 
for_yanCommented:
I think it will start with index.jsp page in the root of your web application.
But how do you plan the users will start your web application?
0
 
edcAuthor Commented:
Hi for_yan,
Thank you for helping me with this.  The application will take 'messages' from TCP/IP sockets and process them, so the main interface for this application will be plain old TCP sockets.  I would like to have a web interface for administration and statistics on the internals of the server, but it is not the focus of the app.

Thanks again.
0
 
for_yanCommented:
Then maybe you may consider debugging  it separately - as non-web application for sockets and then if necessary as web application for administration.
0
Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

 
edcAuthor Commented:
Thanks for_yan.  Actually, on reflection, I think I need to start the sockets from the WAR rather than the JAR/EJB.  If anyone happens to know how to do this off the top of their head, please post here.  I will be investigating it in the mean time.
0
 
for_yanCommented:
When you say "to start sockets form the WAR rather than form JAR/EJB" do you imply that you want your users to initiate their work
by accessing some page on the web server rather than starting with issuing java command on the command line ?
0
 
edcAuthor Commented:
Hi for_yan, Perhaps the better way to describe this is that there is code that I want to execute when the application starts.  This code will not be started by code in a web page, but needs to start when the server starts.

Thank you again for your help.
0
 
for_yanCommented:
I haven't used Glassfish but I assume that most of the things should be similar with Tomcat.

So on Tomcat in the TOMCAT_HOME/conf folder there is a web.xml file which  names
all servlets which should be started  on the startup of the container

It has codes like below where in   <load-on-startup>1</load-on-startup>
it determines the order in which servlets start executing after startup.



You can also read about it here:
http://stackoverflow.com/questions/809775/what-does-the-servlet-load-on-startup-value-of-0-zero-signify

Perhpas something like that could serve your purpose.
I guess Glassfish should lavbe something similar

<servlet>
        <servlet-name>default</servlet-name>
        <servlet-class>org.apache.catalina.servlets.DefaultServlet</servlet-class>
        <init-param>
            <param-name>debug</param-name>
            <param-value>0</param-value>
        </init-param>
        <init-param>
            <param-name>listings</param-name>
            <param-value>true</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>

Open in new window

0
 
edcAuthor Commented:
Hi for_yan,
I apologize.  I though I had closed this one out.  Thank you for your help.  The link led me to some material that allowed me to solve this one.

Thanks very much.
0

Featured Post

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

  • 4
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now