⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 classloader.xtp

📁 解压在c盘
💻 XTP
字号:
<s1 title="Classloading and Compilation"><summarylist/><s2 title="Where do I put my jars and classes?"><p>Application classes belong in <var/WEB-INF/classes/>.  Jars belongin <var/WEB-INF/lib/>.</p><p>Look at the standard installation and check theHelloWorld example.  The HelloWorld source is in<var/resin-2.1/doc/WEB-INF/classses/>.  Resin will automatically compilethat source when running the demo and put the class in the same directory.</p><p>If you change the app-dir to /usr/local/apache/htdocs, servlets and beanswill belong in /usr/local/apache/htdocs/WEB-INF/classes.</p><p>Until you get your first servlets working, don't try to create yourown web-apps.  When you do start working with web-apps, look at theguest book examples to see where beans and servlets belong.</p><p>You can also change the default location with the<var/&lt;classpath>/> directive.</p><p>Application jars belong in <var/WEB-INF/lib/> and standard libraries,like JDBC drivers, belong in the global classpath.  Ingeneral, you should put standard libraries in the global classpath.Resin has several equivalent methods to add a jar to the classpath:</p><ol><li>Add the driver to the CLASSPATH environment variable.<li>Start Resin with a -classpath argument including the driver.<li>Put the jar file in resin1.1/lib.<li>Put the classes in resin1.1/classes.</ol><p>Only the last two will be automatically reloaded when the class orjar changes.  For the first two, you'll need to restart Resin.</p><p>You can see Resin's global classpath by starting it with the-verbose option:</p><example>unix> httpd.sh -verbose</example><p>You must restart Resin to pick up the new classpath.When using the Win32 Resin, you must quit the Resin application.  Justpressing the stop and start buttons will not suffice.</p></s2><s2 title="Where does Resin generate *.java and *.class files?"><p>The &lt;work-dir>'<var/foo/>'&lt;/work-dir> attribute configures thedirectory where generated *.java (for JSP) and *.class files go.  Ifunassigned, they go into <var//tmp/caucho/> on Unix and <var/\temp\caucho/>on Windows.</p></s2><s2 title="Resin doesn't update changed servlets and JSP pages"><p>Resin has a delay for testing updated servlets and JSP pages.The configuration variable for both is 'class-update-interval' inresin.conf.  It's an application-level variable.  The default is 15seconds.  So Resin will only check every 15 seconds for an updatedpage.  You can set this value to 0 for development work.</p><example>&lt;http-config class-update-interval='0'>  ...&lt;/http-config></example><p>If you want Resin to check servlets for updates every hour, yourresin.conf might look like:</p><example>&lt;http-config class-update-interval='3600'>  ...&lt;/http-config></example></s2><s2 title="Servlets don't compile"><example>java.lang.NoClassDefFoundError: sun/tools/javac/Main</example><p>The JRE does not contain a Java compiler.  You either need to getthe JDK or use another compiler.  To configure another compiler use:</p><example>&lt;caucho.com>  &lt;java compiler='/usr/local/bin/jikes'/>  ...&lt;/caucho.com></example></s2><s2 title="ClassNotFoundException for servlet or bean"><p>First check that the class is in the right location.  In the standardconfiguration, Java classes belong in <var/resin/doc/WEB-INF/classes/>.If you're using Resin's autocompilation, the Java source file must be in thesame location.</p><p>If you're using the automatic compilation, check that the <var/package/>in the *.java file matches its location.</p></s2><s2 title="How do I get the application class loader?"><p>cyou can get the application classloader from a servletusing the standard call <var/Thread.getContextClassLoader()/>.</s2><s2 title="The application gets reloaded on each request"><p>Other symptoms are that sessions are killed on each request.<p>This may occur if your *.java files have a date in the future.When the *.class is compiled, it will have an date before the *.java.So Resin will think it's old and recompile on the next request.<p>This may occur, for example, if you work on NT and use Linux as afileserver and the two clocks aren't properly synchronized.<p>The only solution is to synchronize the clocks for both machines.</s2><!--<s2 title="Resin crashes on Windows when recompiling">This appears to be a problem with the internal javac compiler for someversions of the JDK.<p/>To solve the problem, just use an external compiler, either javac orjikes:<example>&lt;java compiler='javac'/></example></section>--><s2 title='What is the classloader order?'><p>In Resin 2.1 the order is:</p><ol><li>The commandline classpath<li>The resin/lib directory<li>The envivonmental classpath<li>An application's WEB-INF/lib and WEB-INF/classes</ol></s2></s1>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -