Tomcat 7 Embedded: Manager *additional info*
Hi guys *kick* :) I have additional info on this topic. When deploying a webapp to an embedded tomcat server via ANT and listen all webapps via ANT afterwards, I noticed that the path information is completely missing for the freshly deployed webapp. In this case /test. I think I missed to setup a path directive?! [LIST] OK - Listed applications for virtual host localhost [LIST] /manager:running:0:C:\Users\xx\AppData\Local\Temp\tc7embedded\webapps [LIST] /test:running:0:test Java Code: http://pastie.org/268 Cheers Darky Am 27.09.2011 16:46, schrieb Dark Before Dawn: Hi guys, I am sorry to resurrect this topic, but I got stuck for weeks now. I would like to provide an embedded Tomcat 7 instance in my JavaSE 1.6 application (diploma thesis). This instance should run the Manager-Application for easy War-Deployment via ANT. With help of this mailing-list I managed to create a privilged context which hosts the HTMLManagerServlet and the ManagerServlet. Both show up correctly when browsing: http://localhost:8080/manager/html/ http://localhost:8080/manager/text/ I guess the Deployer is running too = stdHost.addLifecycleListener(new HostConfig()); Problem 1: ANT Script ManagerServlet(Text): It is possible to deploy/undeploy/start/stop a Webapplication via ANT. When deploying a WAR-file via Ant the file will be uploaded to webapps folder and expanded afterwards. The ANT-script terminates successful without warning. When browsing the HTMLManagerServlet the freshly deployed webapp is shown correctly in the Application list. = ContextPath is correct and even the DisplayName is shown correctly. It is possible to Start/Stop/Repload/Undeploy this freshly deployed webapp(browser/ant). But it is not possible to browse this webapp, I just got 404 pages. Problem 2: HTMLManagerServlet won't upload WAR-file when selecting a WAR-file not located on the server. Message: FAIL - File upload failed, no file Folders: C:\Users\darky\AppData\Local\Temp\tc7embedded C:\Users\darky\AppData\Local\Temp\tc7embedded\work C:\Users\darky\AppData\Local\Temp\tc7embedded\webapps Code: http://pastie.org/268 Any help is appreciated! Thanks in advance! Cheers Darky - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Tomcat 7 Embedded: Manager
Hi guys, I am sorry to resurrect this topic, but I got stuck for weeks now. I would like to provide an embedded Tomcat 7 instance in my JavaSE 1.6 application (diploma thesis). This instance should run the Manager-Application for easy War-Deployment via ANT. With help of this mailing-list I managed to create a privilged context which hosts the HTMLManagerServlet and the ManagerServlet. Both show up correctly when browsing: http://localhost:8080/manager/html/ http://localhost:8080/manager/text/ I guess the Deployer is running too = stdHost.addLifecycleListener(new HostConfig()); Problem 1: ANT Script ManagerServlet(Text): It is possible to deploy/undeploy/start/stop a Webapplication via ANT. When deploying a WAR-file via Ant the file will be uploaded to webapps folder and expanded afterwards. The ANT-script terminates successful without warning. When browsing the HTMLManagerServlet the freshly deployed webapp is shown correctly in the Application list. = ContextPath is correct and even the DisplayName is shown correctly. It is possible to Start/Stop/Repload/Undeploy this freshly deployed webapp(browser/ant). But it is not possible to browse this webapp, I just got 404 pages. Problem 2: HTMLManagerServlet won't upload WAR-file when selecting a WAR-file not located on the server. Message: FAIL - File upload failed, no file Folders: C:\Users\darky\AppData\Local\Temp\tc7embedded C:\Users\darky\AppData\Local\Temp\tc7embedded\work C:\Users\darky\AppData\Local\Temp\tc7embedded\webapps Code: http://pastie.org/268 Any help is appreciated! Thanks in advance! Cheers Darky - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Tomcat Versions
Hi guys, I am reading this list for a few weeks now. And I wonder where the differences between different Tomcat versions ie 5.X , 6.X and 7.X are. Since versions for Tomcat 5 and 6 are still released from time to time. Are these maintenance releases only or for some linux distributions? Cheers Darky - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
[JSP] List directory content within a war-file
Hi there, I am trying to list files and directories within an war-file i.e images/summer2010 images/winter2010. The war-file is deployed on a tomcat 7 instance with unpackWARs=false. Since I have no exposed filesystem getRealPath will return null. So I tried to use getResourceAsStream wich works fine for files but not for directories. My other idea was to use getResource and URL/URI to get a java.io.File via JNDI. But this file is not a file nor a directory. Cheers Darky Code Snippet: // null if unpackWar = false String absolute = this.getServletConfig().getServletContext().getRealPath(files); out.write(Files: + absolute); // jndi URL url = this.getServletConfig().getServletContext().getResource(files); out.write(br/ + url.toURI()); File f = new File(file: + url.toURI()); // Both null out.write( isDir: + f.isDirectory()); out.write( isFile: + f.isFile()); InputStream is = this.getServletConfig().getServletContext().getResourceAsStream(files/1.txt); // NPE if directory BufferedReader br = new BufferedReader(new InputStreamReader(is)); String line; out.write(br/contentbr/); while ((line = br.readLine()) != null) { // print file content out.write(line +br/); } br.close(); - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: RedHat and mod_jk
After some API reading I found getResourcePaths(). http://download.oracle.com/javaee/1.3/api/javax/servlet/ServletContext.html#getResourcePaths%28java.lang.String%29 Cheers Darky Hi there, I am trying to list files and directories within an war-file i.e images/summer2010 images/winter2010. The war-file is deployed on a tomcat 7 instance with unpackWARs=false. Since I have no exposed filesystem getRealPath will return null. So I tried to use getResourceAsStream wich works fine for files but not for directories. My other idea was to use getResource and URL/URI to get a java.io.File via JNDI. But this file is not a file nor a directory. Cheers Darky
Re: Tomcat 7 Embedded: Manager
Hi Pid, I wonder where the war-files are uploaded to? When uploading a war-file via HTMLManagerServlet a new error message will be shown: MESSAGE: FAIL - File upload failed, no file Do I need to enable file uploads somewhere? Is there a way to enable the Deployer via code or by adding new JARs? Cheers and thanks in davance Darky Am 03.07.2011 13:33, schrieb Pid: On 01/07/2011 20:49, Dark Before Dawn wrote: Hi Pid, hi Cuck! thanks for your help. Your suggestions fixed the naming issues :) thanks! But the error still occurs. FAIL - Encountered exception javax.management.InstanceNotFoundException: Tomcat:type=Deployer,host=localhost The Deployer isn't in the list of MBeans visible in your JConsole screenshot, which is probably why you can't connect to it. I don't know why that is, but presumably the embedded code doesn't enable it. I noticed an empty javax.management.ObjectName[0] Array, when browsing Servlet via jconsole. This could be in correlation to the exception above. The two things are not related. The empty array refers to child objects of the servlet (should there be any? no...), not the webapp. p See screenshots for further reference. If this is over we definitively need to grab some beer, I am buying :) Am 01.07.2011 17:54, schrieb Pid: On 01/07/2011 12:44, Dark Before Dawn wrote: Hi Pid, i guess the problem is that the manager-servlet's context is mounted at root and the ServletMapping points to /manager. server.addContext(, baseDirectory); ctx.addServletMapping(/manager/*, manager-servlet); So all relative paths will point to root That's easy to change, no? server.addContext(/manager, baseDirectory); ctx.addServletMapping(/text/*, manager-servlet); Note the additional '*' in the security collection: collection.addPattern(/text/*); (The role usually assigned for the text manager servlet is manager-script) p ie: localhost/manager/html vs localhost/html I don't know what I am exactly searching for at jconsole, so here is a overview :) Thnx and cheers Darky Am 01.07.2011 12:46, schrieb Pid: On 01/07/2011 10:40, Dark Before Dawn wrote: Hi again, this is realy driving me nuts for weeks :) FAIL - Encountered exception javax.management.InstanceNotFoundException: Tomcat:type=Deployer,host=localhost 1. Connect to your running instance with JConsole*. 2. Examine the MBeans published by the instance. 3. Confirm that you are connecting to the correct MBean. I wouldn't expect: Tomcat:type=Deployer,host=localhost to work. p * or VisualVM with the JConsole plugin enabled. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: Tomcat 7 Embedded: Manager
Hi again, this is realy driving me nuts for weeks :) I am developing a Java SE application using *Tomcat* 7 in embedded mode. I am attempting to use the *tomcat* manager application (ManagerServlet) and Ant tasks to perform operations on the running *tomcat* instance. Tasks such as list, start, stop work fine, however the deploy and undeploy tasks *fail* with the following *exception* (see below). I actually get the same *exception* when trying to use the manager web interface (HTMLManagerServlet) which leads me to believe that this is a general configuration issue somewhere or misunderstanding in my code. I guess there is still something wrong with my mappings as Chuck noticed. /manager/html /manager/jmxproxy /manager/status /manager/text I realy read the API Documentation and UnitTest examples and haven't got any further :( Code: http://www.pastie.org/private/rehlryloo0zyl9korkupq Errors via ANT and Web: FAIL - Encountered exception javax.management.InstanceNotFoundException: Tomcat:type=Deployer,host=localhost Trace: 01.07.2011 11:28:57 org.apache.catalina.core.ApplicationContext log manager-servlet: managerServlet.check[/sample] javax.management.InstanceNotFoundException: Tomcat:type=Deployer,host=localhost at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.getMBean(DefaultMBeanServerInterceptor.java:1094) at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:833) at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:761) at org.apache.catalina.manager.ManagerServlet.isServiced(ManagerServlet.java:1433) at org.apache.catalina.manager.ManagerServlet.deploy(ManagerServlet.java:721) at org.apache.catalina.manager.ManagerServlet.doGet(ManagerServlet.java:350) at javax.servlet.http.HttpServlet.service(HttpServlet.java:621) at javax.servlet.http.HttpServlet.service(HttpServlet.java:722) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:240) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:164) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:462) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:399) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:317) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:204) at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:311) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) at java.lang.Thread.run(Thread.java:662) Cheers Darky Am 28.06.2011 03:42, schrieb Caldarale, Charles R: From: Dark Before Dawn [mailto:dark.before.d...@gmail.com] Subject: Re: Tomcat 7 Embedded: Manager When using HTMLManagerServlet and navigating to http://localhost/manager the Manager's HTML Interface will appear. It shouldn't, unless you've been playing with the mappings in WEB-INF/web.xml. The valid URL paths are: /manager/html /manager/jmxproxy /manager/status /manager/text There is no /manager mapping, nor is there supposed to be one. Note that each mapping has its own security constraint. - Chuck THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: Tomcat 7 Embedded: Manager
sorry for that :) diddn't want to annoy Cheers Darky Am 01.07.2011 12:41, schrieb Pid: On 01/07/2011 10:40, Dark Before Dawn wrote: this is realy driving me nuts for weeks so *does* the arbit*rary* use of *bold* for me. p - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: Tomcat 7 Embedded: Manager
Am 28.06.2011 03:42, schrieb Caldarale, Charles R: From: Dark Before Dawn [mailto:dark.before.d...@gmail.com] Subject: Re: Tomcat 7 Embedded: Manager When using HTMLManagerServlet and navigating to http://localhost/manager the Manager's HTML Interface will appear. It shouldn't, unless you've been playing with the mappings in WEB-INF/web.xml. The valid URL paths are: /manager/html /manager/jmxproxy /manager/status /manager/text There is no /manager mapping, nor is there supposed to be one. Note that each mapping has its own security constraint. - Chuck THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org Hi Chuck, this is a general problem. On startup - embedded tomcat will nag about a missing global web.xml and I haven't set a web.xml (WEB-INF) for the ManagerServlet neither. org.apache.catalina.startup.ContextConfig webConfig INFO: No global web.xml found My next step would be to copy a custom web.xml (with manager mappings) to /conf Directroy and see what happens. I would prefer to programatic add a WebXml since I don't want to mess up with filesystems. Cheers Darky - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: Tomcat 7 Embedded: Manager
Am 17.06.2011 23:47, schrieb Caldarale, Charles R: From: Dark Before Dawn [mailto:dark.before.d...@gmail.com] Subject: Re: Tomcat 7 Embedded: Manager Where can i find the unit test examples? I browsed the src distribution but couldn't find any examples (I think I am blind :) Quite possibly, since they're cunningly hidden in a directory named ... test. - Chuck THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org Yeah! I finally found the Unit-Tests and got it basically working : the (HTML)ManagerServlet via MapRealm and Digest-Auth. Thanks so far :) When using HTMLManagerServlet and navigating to http://localhost/manager the Manager's HTML Interface will appear. This is also OK but when following any links I am led back to the ROOT. i.e the ServerStatus-Link will lead to http://localhost/status or when using the normal ManagerServlet I get an error FAIL - Unknown command /manager console output: org.apache.catalina.core.ApplicationContext log INFO: manager: init: Associated with Deployer 'Tomcat:type=Deployer,host=localhost' It looks like the |Manager Servlet Mapping is wrong. Can you tell me how to set it programatically for /deploy /undeploy ? Cheers Darky BTW: Here is the Code Snippet without Auth and Realm. StandardContext ctx = (StandardContext) server.addWebapp(, ); ManagerServlet mgmt = new ManagerServlet(); Wrapper mgmt_wrapper = Tomcat.addServlet(ctx, manager, mgmt); mgmt.setWrapper(mgmt_wrapper); ctx.addServletMapping(/manager, manager); |
Tomcat 7 Embedded: Manager
Hi guys, I am trying to deploy a WAR-File programmaticaly via ANT or manually. Therefore I would like to have a Manager Servlet which supports deploying/undeploying. My first try was something like this: Context ctx = server.addContext(/manager, baseDirectory); HTMLManagerServlet mgmt = new HTMLManagerServlet(); mgmt.setWrapper(Tomcat.addServlet(ctx, manager, mgmt)); I just get a 404 Error when visiting localhost:8080/manger and console output says: org.apache.catalina.realm.JAASRealm setContainer INFO: Set JAAS app name Tomcat I am also not sure where to set the manger name and password? Cheers and thanks in advance Darky - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: Tomcat 7 Embedded: Manager
Hi Mark, thanks for your fast reply. Where can i find the unit test examples? I browsed the src distribution but couldn't find any examples (I think I am blind :) Cheers Darky Am 17.06.2011 23:14, schrieb Mark Thomas: On 17/06/2011 21:14, Dark Before Dawn wrote: Hi guys, I am trying to deploy a WAR-File programmaticaly via ANT or manually. Therefore I would like to have a Manager Servlet which supports deploying/undeploying. My first try was something like this: Context ctx = server.addContext(/manager, baseDirectory); HTMLManagerServlet mgmt = new HTMLManagerServlet(); mgmt.setWrapper(Tomcat.addServlet(ctx, manager, mgmt)); I just get a 404 Error when visiting localhost:8080/manger and console output says: org.apache.catalina.realm.JAASRealm setContainer INFO: Set JAAS app name Tomcat I am also not sure where to set the manger name and password? Cheers and thanks in advance You need to configure a Realm. Take a look in the Tomcat 7 unit tests for examples. There are a couple of other issues with the above: - you don't want the HTML version - you'll need to make the context privileged Mark - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
[Embedded Tomcat 7] - Redeploy WAR File
Hi there! I am running tomcat 7.0.14-embed with JavaSE-1.6 on a Windows7 machine. /Autodeploy/, /DeployOnStartup/ and /UnpackWARs/ works like a charm when creating a new WAR-File at appBase directory for the firsttime. If my application generates a updated version of the WAR-File while the Tomcat isn't running, the new WAR-File never gets unpacked. This behaviour is also described at: * http://tomcat.apache.org/tomcat-6.0-doc/config/host.html#Automatic%20Application%20Deployment /Note: If you re-deploy an updated WAR file while Tomcat is stopped, be sure to delete the associated expanded directory before restarting Tomcat, so that the updated WAR file will be re-expanded when Tomcat restarts./ Is there a workarround to re-deploy a updated WAR-File, while Tomcat is offline, without deleting folders manually? Scenario: 1. my app generates a WAR File with a index.jsp and random image to display (basically just a zip file) 2. my app starts tomcat 7 embedded Current Behavior: 1. if the WAR-File was never deployed before, the WAR-File will be unpacked 2. if the WAR-File was deployed before, the WAR-File will not be unpacked and the old version is visible in the webbrowser In that case i have to delete the folder manually and restart tomcat. Wished Behavior: Everytime the WAR-File is updated it shall be re-deployed by Tomcat. Code Snippet: String tempDir = System.getProperty(java.io.tmpdir); String appID = test; RandomWarGenerator rwg = new RandomWarGenerator(tempDir, appID); rwg.export(); // generates WAR-File with index.jsp and random image to display File webApp = new File(tempDir, appID); Tomcat server = new Tomcat(); server.setBaseDir(tempDir); server.setPort(8080); StandardHost stdHost = (StandardHost) server.getHost(); stdHost.setAppBase(tempDir); stdHost.setUnpackWARs(true); stdHost.setAutoDeploy(true); stdHost.setDeployOnStartup(true); server.setHost(stdHost); server.addWebapp(server.getHost(), / + appID , webApp.getAbsolutePath()); server.start(); server.getServer().await(); Thanks in advance! Cheers Darky
Re: [Embedded Tomcat 7] - Redeploy WAR File
Am 14.06.2011 01:01, schrieb Mark Thomas: On 13/06/2011 23:57, Dark Before Dawn wrote: Hi there! I am running tomcat 7.0.14-embed with JavaSE-1.6 on a Windows7 machine. /Autodeploy/, /DeployOnStartup/ and /UnpackWARs/ works like a charm when creating a new WAR-File at appBase directory for the firsttime. If my application generates a updated version of the WAR-File while the Tomcat isn't running, the new WAR-File never gets unpacked. This behaviour is also described at: * http://tomcat.apache.org/tomcat-6.0-doc/config/host.html#Automatic%20Application%20Deployment /Note: If you re-deploy an updated WAR file while Tomcat is stopped, be sure to delete the associated expanded directory before restarting Tomcat, so that the updated WAR file will be re-expanded when Tomcat restarts./ Is there a workarround to re-deploy a updated WAR-File, while Tomcat is offline, without deleting folders manually? The simplest is probably use unpackWARs=false Mark - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org Hi Mark, that would be an option, but this could be a heavy footprint if WAR-Files grow in size? Cheers - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org