USE OF THREADS IN TOMCAT SERVER

hi guys
I am in confused is it safe to use threads in my application which is running on tomcat server.
My application use connection pool and scheduler threads which run through the life time of application.Is it safe to use threads , i heard we should not use threads in application server, so plz anybody have link or resources plz let me know.
thanks in advance.

It's fine to "use threads" because believe it or not you already are, the implementation is simply hidden from you. And next time please don't write the topic title in caps.

Similar Messages

  • How to use toplink in the tomcat server?

    Hi,
    I want to use Toplink in the tomcat server. I am connecting to oracle database using DataSource.
    Can any body help me, what are the setup required to use the toplink in the tomcat?
    Please help me if any body has idea on the same.

    Take a look at this other forum posting: Tomcat acquire dataSource [TOPLINK-7060]
    --Shaun                                                                                                                                                                                                                               

  • Integration  Of Standalone Tomcat Server to JDeveloper 11gR2

    Please tell me how to add & start using external standalone apache tomcat server 7.0.32 with JDeveloper IDE 11gR2.

    For only Tomcat 7 is certified
    http://www.oracle.com/technetwork/developer-tools/jdev/jdev11gr2-cert-405181.html#Application_Servers
    Also in case you want to deploy a ADF app on Tomcat 6.x this should help -
    https://blogs.oracle.com/dana/entry/how_to_deploy_a_11g_adf_applic_1
    Edited by: Sudipto Desmukh on Oct 29, 2012 5:25 PM

  • I want to use hibernate with the tomcat

    I want to use hibernate with the tomcat server can it be possible and if yes then what is the stepwise way.
    Infact I know the java JSF but want to command on Hibernate plz help me.
    I'll be thankful to you.

    To be honest, I wouldn't even know where to start. Do you know what Hibernate does and how it works? Do you know how Tomcat works? All you'd need to do to combine those two would be to let Tomcat provide the DB connections for Hibernate, I suppose. Neither of those products are a topic of this board though.

  • Client/Server in one program (using multiple threads)?

    Is there some examples out there of how to use a client and server in a single program using separate threads? Also, is it possible to start a third thread to control the packets, such as drop a random or specified number of packets (or match on specific data in a packet)?

    Just trying to have a client send udp packets to a server (all on the same machine running from the same program) and want to be able to drop packets coming from the client side to the server side.
    E.g.,
    Here's an example that I found here: http://compnet.epfl.ch/tps/tp5.html
    import java.io.<strong>;
    import java.net.</strong>;
    import java.util.<strong>;
    /</strong>
    * Server to process ping requests over UDP.
    public class PingServer {
         private static double lossRate = 0.3;
         private static int averageDelay = 100; // milliseconds
         private static int port;
         private static DatagramSocket socket;
         public static void main(String[] args) {
              // Get command line arguments.
              try {
                   if (args.length == 0) {
                        throw new Exception("Mandatory parameter missing");
                   port = Integer.parseInt(args[0]);
                   if (args.length > 1) {
                        lossRate = Double.parseDouble(args[1]);
                   if (args.length > 2) {
                        averageDelay = Integer.parseInt(args[2]);
              } catch (Exception e) {
                   System.out.println("UDP Ping Server");
                   System.out.println("Usage: java PingServer port [loss rate] [average delay in miliseconds]");
                   return;
              // Create random number generator for use in simulating
              // packet loss and network delay.
              Random random = new Random();
              // Create a datagram socket for receiving and sending UDP packets
              // through the port specified on the command line.
              try {
                   socket = new DatagramSocket(port);
                   System.out.println("UDP PingSever awaiting echo requests");
              } catch (SocketException e) {
                   System.out.println("Failed to create a socket");
                   System.out.println(e);
                   return;
              // Processing loop.
              while (true) {
                   // Create a datagram packet to hold incoming UDP packet.
                   DatagramPacket request = new DatagramPacket(new byte[1024], 1024);
                   // Block until the host receives a UDP packet.
                   try {
                        socket.receive(request);
                   } catch (IOException e) {
                        System.out.println("Error receiving from socket");
                        System.out.println(e);
                        break;
                   // Print the received data.
                   printData(request);
                   // Decide whether to reply, or simulate packet loss.
                   if (random.nextDouble() < lossRate) {
                        System.out.println("   Reply not sent.");
                        continue;
                   // Simulate network delay.
                   try {
                        Thread.sleep((int) (random.nextDouble() * 2 * averageDelay));
                   } catch (InterruptedException e) {}; // Ignore early awakenings.
                   // Send reply.
                   InetAddress clientHost = request.getAddress();
                   int clientPort = request.getPort();
                   byte[] buf = request.getData();
                   DatagramPacket reply = new DatagramPacket(buf, buf.length,
                             clientHost, clientPort);
                   try {
                        socket.send(reply);
                   } catch (IOException e) {
                        System.out.println("Error sending to a socket");
                        System.out.println(e);
                        break;
                   System.out.println("   Reply sent.");
          * Print ping data to the standard output stream.
         private static void printData(DatagramPacket request) {
              // Obtain references to the packet's array of bytes.
              byte[] buf = request.getData();
              // Wrap the bytes in a byte array input stream,
              // so that you can read the data as a stream of bytes.
              ByteArrayInputStream bais = new ByteArrayInputStream(buf);
              // Wrap the byte array output stream in an input stream reader,
              // so you can read the data as a stream of characters.
              InputStreamReader isr = new InputStreamReader(bais);
              // Wrap the input stream reader in a buffered reader,
              // so you can read the character data a line at a time.
              // (A line is a sequence of chars terminated by any combination of \r
              // and \n.)
              BufferedReader br = new BufferedReader(isr);
              // We will display the first line of the data.
              String line = "";
              try {
                   line = br.readLine();
              } catch (IOException e) {
              // Print host address and data received from it.
              System.out.println("Received echo request from "
                        + request.getAddress().getHostAddress() + ": " + line);
    }I'm looking to do the "processing loop" in a separate thread, but I'd also like to do the client in a separate thread
    So you're saying, just put the client code in a separate class and start the thread and that's it? As far as the packet rate loss thread, is this possible to do in another thread?

  • Calling a external Java method from JSP - using Tomcat server

    Hi all,
    I am trying to call a method in an external Java file from my JSP. I am using Tomcat server.
    I have my class within the package package "mypackage" and it is called myclass.class. It has only one static method mymethod() which reads from a file and writes to a file.
    I compiled the java class and I put the class file under webapps/ROOT/web-inf/classes/mypackage/myclass.class
    I am trying to say something like this from my JSP file(which is under webapps/ROOT) :
    <%@ page import = "mypackage.myclass"%>
    <% myclass.mymethod(); %>
    I am not instatiating the class as its a static method.
    This is what I get while accessing my jsp file :
    javax.servlet.ServletException: try to access class mypackage.myclass from class org.apache.jsp.index_005ftest_jsp
    To put my problem in a nutshell, Can someone guide me how to access a method of an external class from a JSP page? I have a bunch of pages doing the same operation so I thought I would have it in a method and call it from every page. Even though I tried to put the file under web-inf/classes, The JSP is not able to see the class.
    Please help.
    Thanks
    -Uday

    I have a situation that is a bit similar. I have successfully used beans for storing methods used in JSPs and used by other methods in the same class as was suggested above. Now I would like to break some methods into another (utility) class since they are lower level and can be used by lots of things. They are for database operations (given a String query and String dbname, it queries and returns ResultSet for example). I want to have them in a separate class for reusability and OOP.
    I am having problems calling those public static methods in the public class from my bean that communicates with the JSP. I can't compile the class that calls the method in the database ops class. I get an error like :
    loginHelper.java:45: cannot find symbol
    symbol : variable sqlHelper
    location: class dbHelperBean.loginHelper
    and when I include the package name in the call I get
    loginHelper.java:45: cannot find symbol
    symbol : class sqlHelper
    location: package dbHelperBean
    That's strange since the package of both classes is dbHelperBean and the class is indeed called sqlHelper. I tried to compile it in the same directory as sqlHelper as well. What am I doing wrong?
    Thanks for any help.

  • How to run jsp using  tomcat server?

    hai friends,
    i'm using jsp for my application and for that i'm using tomcat server.
    i was runing my jsp files like this
    http://localhost:8080/examples/jsp/myapp/index.jsp but instead of this
    i need to run my jsp files like this
    http://localhost:8080/myapp/index.jsp
    what r the changes that i should do in tomcat installation to run myapplication in such a way.
    thanks in advance

    you need to redefine the server root...
    for that do the following...
    copy all the directory tree rooted at
    JAKARTA-HOME/webapps/ROOT/examples/jsp/myapp/ to
    JAKARTA-HOME/webapps/ROOT/myapp/
    -OR-
    in the server.xml, search for "Tomcat Root Context" and un-comment the code defining Root Context...
    change the docBase value from "ROOT" to "ROOT/examples/jsp"
    that shud help...
    -Pranav
    hai friends,
    i'm using jsp for my application and for that i'm
    using tomcat server.
    i was runing my jsp files like this
    http://localhost:8080/examples/jsp/myapp/index.jsp but
    instead of this
    i need to run my jsp files like this
    http://localhost:8080/myapp/index.jsp
    what r the changes that i should do in tomcat
    installation to run myapplication in such a way.
    thanks in advance

  • Re: Using already running Tomcat server for development.

    Hi Nick,
    Yes, you can use existing Tomcat Server for debugging app developed with
    NitroX. And you can refer to Help > Help Contents > NitroX User Guide >
    NitroX Tour > Running and debugging the application.
    We do support Tomcat 4.0.x to Tomcat 5.0.x. If you need any further
    assistance please get back to us.
    Thanks
    M7 Support
    "Nick Mulder" <[email protected]> wrote in message
    news:41d9f379$[email protected]..
    Sorry if this has been covered anywhere else.Just wondering if you can use an existing tomcat server for debugging
    webapps being developed in NitroX. I have a non dedicated server a
    development server. Up until purchasing NitroX I have been using ant build
    files to compile and re-deploy my apps into the running tomcat server.
    Just wondering if I can do something similar thru NitroX and Eclipse.
    Forgive me if I am missing something obvious, but I am new to eclipse.
    Thanks,
    Nick Mulder

    Take a look at these links: http://plato.acadiau.ca/courses/comp/dsilver/2513/EclipseAndTomcatTutorial/
    http://www.keyboardsamurais.de/2004/01/15/tomcat_tutorial_helloworld_for_complete_fools_-_english/
    http://www-128.ibm.com/developerworks/opensource/library/os-ectom/?ca=dgr-lnxw16EclipsTomcat
    I've found going through tutorials is a proven, quick way of getting up to speed with new tools and configurations.
    HTH,
    James

  • Using already running Tomcat server for development.

    Sorry if this has been covered anywhere else.
    Just wondering if you can use an existing tomcat server for debugging
    webapps being developed in NitroX. I have a non dedicated server a
    development server. Up until purchasing NitroX I have been using ant build
    files to compile and re-deploy my apps into the running tomcat server. Just
    wondering if I can do something similar thru NitroX and Eclipse. Forgive me
    if I am missing something obvious, but I am new to eclipse.
    Thanks,
    Nick Mulder

    Take a look at these links: http://plato.acadiau.ca/courses/comp/dsilver/2513/EclipseAndTomcatTutorial/
    http://www.keyboardsamurais.de/2004/01/15/tomcat_tutorial_helloworld_for_complete_fools_-_english/
    http://www-128.ibm.com/developerworks/opensource/library/os-ectom/?ca=dgr-lnxw16EclipsTomcat
    I've found going through tutorials is a proven, quick way of getting up to speed with new tools and configurations.
    HTH,
    James

  • [svn] 1590: Updating WebService RPC tests that previously used external endpoints at whitemesa . net to now use internal endpoints accessed through Tomcat server on localhost :8400/qa-regress/axis/services/{SERVICE_NAME}?wsdl

    Revision: 1590
    Author: [email protected]
    Date: 2008-05-07 08:49:22 -0700 (Wed, 07 May 2008)
    Log Message:
    Updating WebService RPC tests that previously used external endpoints at whitemesa.net to now use internal endpoints accessed through Tomcat server on localhost:8400/qa-regress/axis/services/{SERVICE_NAME}?wsdl
    Endpoints built from Axis SOAPBuilder tests in Perforce's /depot/axis/xml-axis/java/tests/
    Modified Paths:
    blazeds/branches/3.0.x/qa/apps/qa-regress/WEB-INF/server-config.wsdd
    blazeds/branches/3.0.x/qa/apps/qa-regress/WEB-INF/web.xml
    blazeds/branches/3.0.x/qa/apps/qa-regress/testsuites/flexunit/src/tests/flexunit/wscl/int erop/SOAPBuilderRound3Import1_WhiteMesaTest.as
    blazeds/branches/3.0.x/qa/apps/qa-regress/testsuites/flexunit/src/tests/flexunit/wscl/int erop/SOAPBuilderRound3Import3_WhiteMesaTest.as
    blazeds/branches/3.0.x/qa/apps/qa-regress/testsuites/flexunit/src/tests/flexunit/wscl/int erop/SOAPBuilderRound3RPCEncoded.as
    Added Paths:
    blazeds/branches/3.0.x/qa/apps/qa-regress/WEB-INF/lib/
    blazeds/branches/3.0.x/qa/apps/qa-regress/WEB-INF/lib/javax_mail.jar
    blazeds/branches/3.0.x/qa/apps/qa-regress/WEB-INF/lib/qa-services-wm.jar
    blazeds/branches/3.0.x/qa/apps/qa-regress/testsuites/flexunit/src/tests/flexunit/wscl/int erop/SOAPBuilderRound3Compound1.as

  • Problem while starting Apache Tomcat Server (Ports already in use)...

    Hi,
    I am using an Eclipse IDE for web service Client creation.. Also I have used Apache Tomcat5.5 Server inorder to run the application*...*
    While starting Tomcat Server, I am getting an error that the port numbers are already in use.
    So, I have changed the port numbers in the Server.xml file.
    But, still it is throwing the same error , even though the port numbers are not in use.
    Can any one please provide some suitable solution for this ASAP....
    I need very urgent and so please provide some solution..
    Thanks in Advance,
    roopa

    Hey...
    Did u start restarting your machine after you changed the ports..
    Is your tomcat server running perfectly after you changed the port number...
    I had a similar prob.. But i jus reinstalled both and gave different port numbers while re-installling.
    Jus give it it a try.. The ports need to be refreshed.. So try rebooting yr machine first !
    All the best !

  • Problem connecting oracle database to jsp pages using Apache Tomcat server 8.0

    Well...I tried too many things..googled so many times..but still could not find solution to my problem.
    I use windows 8 Enterprise Edition(if this has to do something with the problem)
    Oracle 11.2.0
    Apache Tomcat server 8.0
    JDK 1.7
    My oracle is installed in the D: drive and tomcat in c:. i copied the ojdbc6.jar file from oracle to lib directory of tomcat server.
    Then i set  CLASSPATH in environment variables as "C:\Program Files\Apache Software Foundation\Tomcat 8.0\lib\ojdbc6.jar" in system variables
    My path variable is set as "C:\Program Files\Java\jdk1.7.0_02\bin".
    My program is as follows in notepad:
    <%@ page import="java.sql.*" %>
    <html>
    <body>
    <%
    Connection conn;
    Statement st;
    ResultSet rs;
    try{
    new oracle.jdbc.driver.OracleDriver();
    String dbURL="jdbc:odbc:oracle:thin:@localhost:1521:XE";
    String userId="system";
    String pwd="moon";
    conn=DriverManager.getConnection(dbURL,userId,pwd);
    st=conn.createStatement();
    rs= st.executeQuery("SELECT * FROM login");
    while(rs.next())
    System.out.println(rs.getString(1)+""+rs.getString(2));
    catch(Exception e){}
    %>
    </body>
    </html>
    I get too many errors then
    eroors
    org.apache.jasper.JasperException: An exception occurred processing JSP page /page2.jsp at line 14
    11: String userId="system";
    12: String pwd="moon";
    13:
    14: conn=DriverManager.getConnection(dbURL,userId,pwd);
    15: st=conn.createStatement();
    16:
    17: rs= st.executeQuery("SELECT * FROM login");
    Stacktrace:
    org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:568)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:455)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:403)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:347)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:725)
    org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
    root cause
    javax.servlet.ServletException: java.sql.SQLException: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
         org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:905)
         org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:834)
         org.apache.jsp.page2_jsp._jspService(page2_jsp.java:102)
         org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:725)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:403)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:347)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:725)
         org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
    Nothing solved this problem.

    >> Nothing solved this problem.
    Can't fix a problem 'till an actual problem is identified.
    >> ODBC Driver Manager ... Data source name not found
    That appears to be ODBC drivers looking for a DSN (Data Set Name). If it wants a DSN, the DSN has to be specified in the code, and the DSN has to be configured in the windows host ODBC applet. So that is at least two squirrels to get in the right tree before moving forward. A ...host:...[port:]SID|service name are some of the bits needed in a jdbc connect string, and that is in no way related to DSNs. A Whole Different Animal. If it wants a DSN that might be what needs to go in the URL bit.
    And ODBC setups can be confusing, especially if an x64 OS is in the mix- if that is the case there are two different ODBC configuration applets, one for x64 the other for x86, and if one gets as far as talking to an actual database it might toss an architecture error. Only way to fix that "problem" is *delete* the ODBC DSN and then run the correct (maybe the x86) ODBC config utility, and set up the DSN. Again.

  • Help on using Tomcat server

    hi there
    currently i am creating a web service running on Tomcat server. but it does not support the SOAP services. do i need a seperate package, if i need to send message using SOAP? if so, where can i get it.

    http://xml.apache.org/soap/index.html
    Jesper

  • [svn] 1605: Bug: BLZ-155 - Deadlock using a thread pool for tomcat connectors

    Revision: 1605
    Author: [email protected]
    Date: 2008-05-07 14:24:53 -0700 (Wed, 07 May 2008)
    Log Message:
    Bug: BLZ-155 - Deadlock using a thread pool for tomcat connectors
    QA: Yes - Jorge verified in the QE lab
    Doc: No
    Ticket Links:
    http://bugs.adobe.com/jira/browse/BLZ-155
    Modified Paths:
    blazeds/branches/3.0.x/modules/core/src/java/flex/messaging/client/EndpointPushNotifier.j ava

    Cross post: http://forum.java.sun.com/thread.jspa?threadID=5215686&tstart=0
    If you must post across forums, just post in the most relevant one and then give the link to that in the other posts.

  • Restarting of tomcat server while using jsp

    hi,
    Iam using a jsp page on tomcat server. It actually sends message to a phone, after that it comes back to the same jsp using the same url.
    But after it comes back, the jsp is not working properly. I have to restart tomcat server each time for it to work.
    As iam redirecting it back to the same jsp , i expect it to work properly as nothing is being changed. Its not practical to restart the server each time.
    Can anyone help me with this?
    Thanks in advance
    san

    Hi,
    Iam getting error at this particular point in the code
    DirContext ctx = new InitialDirContext(env);
    The function contains the following code
    Hashtable env = new Hashtable();
    env.put(Context.INITIAL_CONTEXT_FACTORY,
    "com.sun.jndi.ldap.LdapCtxFactory");
    env.put(Context.PROVIDER_URL,
    "ldap://" + ldapServer + ":" + String.valueOf(ldapPort) + "/" + rootDn);
    env.put(Context.SECURITY_AUTHENTICATION, "simple");
    env.put(Context.SECURITY_PRINCIPAL, ldapUserId);
    env.put(Context.SECURITY_CREDENTIALS, ldapPassword);
    DirContext ctx = new InitialDirContext(env);
    //at this point its gives array out of bound , java.util.vector error
    Attributes matchAttrs = new BasicAttributes(ignoreCase);
    if (matchRules != null) {
    Iterator attrIter = matchRules.keySet().iterator();
    while (attrIter.hasNext()) {
    String key = (String) attrIter.next();
    String value = (String) matchRules.get(key);
    matchAttrs.put(new BasicAttribute(key, value));
    response = ctx.search(searchBase, matchAttrs, returnAttrs);
    lastResult = new Vector();
    while (response.hasMore()) {
    HashMap attrMap = new HashMap();
    SearchResult sr = (SearchResult) response.next();
    Attributes attrs = sr.getAttributes();
    NamingEnumeration attrsEnum = attrs.getAll();
    while (attrsEnum.hasMore()) {
    Vector values = new Vector();
    Attribute attr = (Attribute) attrsEnum.next();
    for (int i = 0; i < attr.size(); i++) {
    values.add(attr.get(i));
    attrMap.put(attr.getID(), values);
    lastResult.add(attrMap);
    First time when i run it runs fine, but the second time , it gives error.

Maybe you are looking for