Does someone hurt my Tomcat on regular basis?
Hello Tomcat people, Sometimes in my Tomcat 3.2.3 log I can see messages like this: java.io.IOException: The filename, directory name, or volume label syntax is incorrect at java.io.Win32FileSystem.canonicalize(Native Method) at java.io.File.getCanonicalPath(File.java:440) at org.apache.tomcat.util.FileUtil.safePath(FileUtil.java:184) at org.apache.tomcat.core.Context.getRealPath(Context.java:797) at org.apache.tomcat.request.StaticInterceptor.requestMap(StaticInterceptor.java:196) at org.apache.tomcat.core.ContextManager.processRequest(ContextManager.java:835) at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:786) at org.apache.tomcat.core.ContextManager.service(ContextManager.java:758) at org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpConnectionHandler.java:213) at org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:416) at org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:501) at java.lang.Thread.run(Thread.java:484) 2001-09-01 06:10:09 - Ctx( ): 404 R( + http:/www.spedia.net/ + null) null Do I need to pay attention to these exceptions or there is no way to avoid them? Thank you! -- Andrey Myatlyuk - 212.269.4156 - 11 Broadway, Suite 700 - New York, NY 10004 www.oneworldinc.com
Re: TomCat - MySql
Hello java4dinman, Monday, March 19, 2001, 1:44:20 PM, you wrote: jic Hi jic I m trying to acces MySql database thru Servlets in Tomcat. But the jic same file runs in java public static void main application.. jic The error is jic Unable to load driver. jic java.sql.SQLException: General Error: Connection refused: connect jic at org.gjt.mm.mysql.Connection.init(Connection.java) jic at org.gjt.mm.mysql.Driver.connect(Driver.java) jic at java.sql.DriverManager.getConnection jic (DriverManager.java:517) jic at java.sql.DriverManager.getConnection jic (DriverManager.java:199) jic at IDSTest2.doGet(IDSTest2.java:28) jic at javax.servlet.http.HttpServlet.service jic (HttpServlet.java:740) jic at javax.servlet.http.HttpServlet.service jic (HttpServlet.java:853) jic Please let me know wger I am going wrong.. jic DINMAN jic Enjoy being an Indyan at http://www.indya.com Your exception is very clear. Unable to load driver. All you need is to put your driver classfiles in the classpath either WEB-INF/classes - in case unpacked classes or WEB-INF/lib - in case of jar -- Andrey Myatlyuk - 212.269.4156 - 11 Broadway, Suite 700 - New York, NY 10004 www.oneworldinc.com
Re[2]: ClassCastException :(
Hello Bo, Thank you for very helpful sample. I decided to use jsp instead of servlets. Several reasons: 1. My ClassCastException situation is eliminated. Although I don't understand why. 2. I use JSP for presentation("view") layer - so any web-designer can change presentation of data. 3. I use servlet only as controller. So far so good. :) -- Andrey Myatlyuk - 212.269.6082 - 11 Broadway, Suite 700 - New York, NY 10004 www.oneworldinc.com
Re[2]: ClassCastException :(
Hello Vladimir, Thank you for your help with classloaders. :) I tried to put my "shared" classes in the classpath. But this approach failed too. I cannot understand. In this case my "shared" classes loaded by "Bootstrap class loader (Java system classes)" and in case any references to them should use above classloader. Even in case servlet reloading. Of course, I removed these classes from web-inf/classes directory. May-be I need to load this "shared" class before loading my servlet, that uses this "shared" object? May-be it is loaded by "Webapp class loader (contents of WEB-INF/classes)"? I don't know. This situation doesn't hurt me. I just want to know, how other Tomcat users deal with such problem. I think many projects use "shared" objects between servlets. This situation may be happen only in "development stage" and never in "production". But let me know, how do you deal with it? Wednesday, March 14, 2001, 7:10:01 PM, you wrote: VG Bo Xu wrote: Andrey Myatlyuk wrote: Hello Vladimir, Thank you for your help. And I'm still have some questions. Why do we need to implement "some interface"? java.io.Serializable I think? But anyway I implemented this interface - it doesn't work. This approach works for EJB. :) And my question is: Is there any way to use "some shared" object with reloadable servlets without Tomcat restart? Thanks. VG After reading this message and some thinking I can say that the problem is VG harder than I thought. There's no way to trick it, at least there's no interface VG you can create/implement to fix it... And of course it wasn't the Serializable VG one... VG Sorry, for misleading... But... what about this: VG Object _statesBean = VG getServletContext().getAttribute(StatesBean.STATES_BEAN_NAME); VG Class sBeanClazz = _statesBean.getClass(); VG Method m = sBeanClazz.getMethod("foo", new Class[] {/*args*/}); VG m.invoke(_statesBean, new Object{ /*params*/ }); VG he-he, ugly :) Not sure if it'll work... VG Regards, VG VG. Wednesday, March 14, 2001, 3:16:45 PM, you wrote: VG I think you're experiencing a standard Java class loader problem. VG Java treats classes loaded into different classloaders as different VG classes, even though they share the same full. qual. name. VG Your recompiled servlets are reloaded by a brand new class loader VG to make sure the old classes are garbage collected. What you get VG from the context is actuially an instance of a class loaded into VG a different classloader, and (StatesBean) part in your statement VG causes StatesBean to be loaded again by this new classloader that VG reloaded your servlet, so VG VM complains that you cannot cast objects since it thinks they VG are instances of 2 completely different classes. No matter where VG you place your files you'll have the same problem. VG You can avoid this problem by writing some extra code and have your VG bean to implement some interface Extra work, just restart VG Tomcat every time... VG Regards, VG VG. VG Andrey Myatlyuk wrote: Hello Tomcat users, I'm in a trouble. I share some object(StatesBean) between servlets. And when I recompile _servlet_, I got ClassCastException about shared object. _statesBean= (StatesBean)getServletContext().getAttribute(StatesBean.STATES_BEAN_NAME); Classfile for this object is placed in the same directory, where servlets do - web-inf/classes. Where I need to place classfile for this object to prevent Tomcat exceptions? Of course, if I reload Tomcat everything is OK. Thank you in advance! -- Best regards, Andreymailto:[EMAIL PROTECTED] [...] Hi :-) I am not sure, I guess: * perhaps the problem is: - let use suppose: classloaderA - classA - instanceA then you "setAttribute" instanceA into ServletContext of this wepapp, so now ServletContext holds a reference to instanceA. - after a while, your Sevlet class is reloaded, with jakarta-tomcat-4.0-b1, now classloaderA is not there, so classA is not there, But instanceA is there: because at least there is One reference of instanceA is being holded by ServletContext, so it will not be GCed, and getAttribute() will not return null. - but now instanceA doesn't has "its original class" and "its original classloader", I am not sure, but I guess perhaps it is the reason. * IMHO, I guess: if you can find a way to load classA from a special classloader which will not be destroyed when/even if your Servlet class is reloaded, then you can solve the problem. It means that our Servlet class and some Helper classes are loaded by several classloaders in "diferent layer"
Re[4]: ClassCastException :(
Hello Allen, Thursday, March 15, 2001, 10:52:00 AM, you wrote: AA I ran into the same problem and found the only good solution was to take AA a look at my custom classes and strip away what was "custom" about them AA and only save core Java objects to the context. When I need my custom AA class, I create an instance of it and pass the references to the core AA Java objects saved in the context to the class in the constructor so AA that it is pointing to the objects in the shared context. There are AA some limitations to this, but it works in all situations given a little AA thought. Let me know if you need more clarification. Thanks. Foe example, I have the following objects public class City { private String _name; private int_population; ... getters/setters ... } and public class State { private City[] _cities; ... getters/setters ... } What is the best way to "share" State object between servlets? As I understand, your solution is to split "custom" objects on "core" objects. It means I should put into context at least one String and one Integer objects for each of my City object. Of course, it will work. But if I have several thousands of cities? Each should have unique name in the context. And how to get them from context? Parse names? For each request? May be I will test it with profiler, but it seems good solution for small amount of objects. Anyway, thanks for this help. -- Best regards, Andreymailto:[EMAIL PROTECTED]
Re[2]: ClassCastException :(
Hello Vladimir, Thursday, March 15, 2001, 12:25:24 PM, you wrote: VG What you describe should work... Unless Tomcat web-app CL doesn't VG adhere to standard CL delegation rules. Where did you put your classes? VG I think $TOMCAT_HOME/classes is automatically appended to system classpath VG by startup script. VG I don't think _bootstrap_ CL is the one VG that's loading classes if you put them on system classpath. VG Probably it's SystemClassLoader. You can test VG it like this from your servlet to find out what's going on: VG _statesBean= VG getServletContext().getAttribute(StatesBean.STATES_BEAN_NAME); VG ClassLoader cl = _statesBean.getClass().getClassLoader(); VG if (cl.getParent() == null) VG System.out.println("Bootstrap Class Loader"); VG if (cl == ClassLoader.getSystemClassLoader()) VG System.out.println("System Class Loader") VG if (cl == this.getClass().getClassLoader()) VG System.out.println("Current WebApps Class Loader"); In case StatesBean in web-inf/classes - "Current WebApps Class Loader" In case StatesBean in %CLASSPATH% - "System Class Loader" VG BTW, did you try to use reflection like I suggested before VG (scroll down...)? Not yet. :) from previous post Now, when your servlet class is loaded, Tomcat asks the webapp class loader to load it. Following the standard Java delegation model, the web app class loader first asks it's parent class loader to try to find the class -- and so on up the hierarchy. If your servlet class is actually in WEB-INF/classes or WEB-INF/lib, all of these attempts to delegate upwards will fail. Therefore, the web app class loader will load the class itself. The same thing happens for every other class that your servlet references -- it gets loaded by whichever class loader finds that class. If the load happens from a class loader *above* the calling class's class loader, that is fine. However, trouble occurs if you try the opposite direction, because there are no links *downward* in the class loader hierarchy. /from previous post I have my StatesBean loaded by SystemClassLoader. OK. MyServlet by WebAppLoader. Good. So when WebAppLoader reloads my servlet it should ask its parents about loaded class. Ang guess what? StatesBean loaded already with SystemClassLoader. What's wrong with it? Why do I get java.lang.NullPointerException in _statesBean= getServletContext().getAttribute(StatesBean.STATES_BEAN_NAME); after reloading servlets? -- Best regards, Andreymailto:[EMAIL PROTECTED]
Re[2]: ClassCastException :(
Hello Bo, BX * can you post the code of your StatesBean? and BX the version of TOMCAT? because I also want to BX know why :-) Tomcat 3.2.1 -- Best regards, Andreymailto:[EMAIL PROTECTED]
ClassCastException :(
Hello Tomcat users, I'm in a trouble. I share some object(StatesBean) between servlets. And when I recompile _servlet_, I got ClassCastException about shared object. _statesBean= (StatesBean)getServletContext().getAttribute(StatesBean.STATES_BEAN_NAME); Classfile for this object is placed in the same directory, where servlets do - web-inf/classes. Where I need to place classfile for this object to prevent Tomcat exceptions? Of course, if I reload Tomcat everything is OK. Thank you in advance! -- Best regards, Andreymailto:[EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, email: [EMAIL PROTECTED]
Re[2]: Tomcat as NT Service Error!!
Hello Mimi, I just compited the same operation on two machins. Everything works OK. What messages do you get in DOS window after BM 2. jk_nt_service -i service_name wrapper.properties (after modified it) command? Do you have Tomcat as standalone application now? Andrey. Monday, March 12, 2001, 1:01:38 PM, you wrote: BM I am having the same problem. Does any one have an answer for it? BM Thanks. BM -Original Message- BM From: Serra Giovanni [mailto:[EMAIL PROTECTED]] BM Sent: Monday, February 26, 2001 5:44 AM BM To: '[EMAIL PROTECTED]' BM Subject: Tomcat as NT Service Error!! BM Hi all, BM I am trying to set up Tomcat as a Nt Service but i always got the same BM error!! BM it is : BM The service_name is starting. BM The service_name service could not be started. BM The service did not report an error. BM More help is available by typing NET HELPMSG 3534. BM what i've done is : BM 1. open a dos window BM 2. jk_nt_service -i service_name wrapper.properties (after modified it) BM 3. net start service_name BM I am working on win 2k professional BM I read lot of mailing list and lot of peoples answered that it's a 1.3 jdk BM bug. BM I tried with 1.2 and it's the same!! BM I CANT START THE SERVICE !! BM Can anyone help please.. BM thanks a lot !! BM Giovanni BM - BM To unsubscribe, e-mail: [EMAIL PROTECTED] BM For additional commands, email: [EMAIL PROTECTED] BM - BM To unsubscribe, e-mail: [EMAIL PROTECTED] BM For additional commands, email: [EMAIL PROTECTED] -- Best regards, Andreymailto:[EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, email: [EMAIL PROTECTED]
Re[2]: Tomcat as NT Service Error!!
Hello Mimi, Also you need to define full path to the wrapper.properties file. jk_nt_service -i service_name c:\my_files\wrapper.properties -- Best regards, Andreymailto:[EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, email: [EMAIL PROTECTED]
Re[2]: servlet reload problem
Hello Dmitry, Thursday, March 08, 2001, 7:27:41 AM, you wrote: DM Hello Dmitry, DM Thursday, March 08, 2001, 7:58:19 PM, you wrote: DM I've been using Tomcat 3.1 for some time, and suddenly it stopped DM reloading my servlets :( All I can think as a reason is that I've DM installed and started using WebMacro. DM An addition to what I've said: I've just installed Resin and servlet DM reload doesn't work there too! I see. But my point is: In "examples" context servlets are reloaded fine, But in my context the don't reload at all. I'm going to investigate differences between these two contexts soon. I installed Tomcat as out-of-process servlet engine with IIS 4.0 using how-to documentation. -- Best regards, Andreymailto:[EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, email: [EMAIL PROTECTED]
Servlet is not reloadable. Why?
Hello! I have Tomcat Server 3.2.1 running on NT server. When I replace my existing classfiles(even one) in web-inf/classes directory with new ones, I get exception: Error: 500 Location: /flutrack/default.htm Internal Servlet Error: java.lang.IllegalStateException: Can't happen - classname is null, who added this ? at org.apache.tomcat.core.ServletWrapper.loadServlet(ServletWrapper.java:261) at org.apache.tomcat.core.ServletWrapper.init(ServletWrapper.java:289) at org.apache.tomcat.core.Handler.service(Handler.java:254) at org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372) at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:797) at org.apache.tomcat.core.ContextManager.service(ContextManager.java:743) at org.apache.tomcat.service.connector.Ajp12ConnectionHandler.processConnection(Ajp12ConnectionHandler.java:166) at org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:416) at org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:498) at java.lang.Thread.run(Thread.java:484) Of course, when I shut down and then restart tomcat, everything works OK. I read documentation about this topic and learned, that by default "reloadable" is false. So I added my context to the server.xml file(as stated in the documentation). ===cut=== ... Context path="/examples" docBase="webapps/examples" crossContext="false" debug="0" reloadable="true" /Context Context path="/flutrack" docBase="webapps/flutrack" crossContext="false" debug="0" reloadable="true" /Context ... ===cut=== uriworkermap.properties the same too... ===cut=== # Mount the examples context to the ajp12 worker /examples/*=ajp12 # Mount flutrack context /flutrack/*=ajp12 ===cut=== What's wrong with my configuration? Examples context works great. -- Best regards, Andreymailto:[EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, email: [EMAIL PROTECTED]