简体   繁体   English

Websphere中的启动类

[英]Startup Class in Websphere

I need to create a startup class in Websphere. 我需要在Websphere中创建启动类。 This class is present in abc.jar. 此类存在于abc.jar中。 And also abc.jar requires log4j.jar at startup of server. 并且abc.jar在服务器启动时也需要log4j.jar。

For above scenario, i have created the startup class with abc.jar in classpath in websphere console and I kept log4j.jar in ext folder of WAS. 对于上述情况,我已经在Websphere控制台的类路径中使用abc.jar创建了启动类,并且将log4j.jar保留在WAS的ext文件夹中。 This works for me. 这对我有用。 But problem is that the other profiles share same ext folder of WAS and does not able to start up due to Log4j.jar. 但是问题在于其他配置文件共享WAS的相同ext文件夹,并且由于Log4j.jar而无法启动。 If I keep Log4j.jar in other place and keep that location in classpath. 如果我将Log4j.jar保留在其他位置,并将该位置保留在classpath中。 Startup class will not fails.Please help me. 启动课程不会失败。请帮助我。

If your application uses EJBs, then you can use a peculiar feature of WAS with the ibm-ejb-jar-ext.xml descriptor, which includes a start-at-app-start element: 如果您的应用程序使用EJB,那么您可以将WAS的特殊功能与ibm-ejb-jar-ext.xml描述符一起使用,该描述符包括start-at-app-start元素:

<?xml version="1.0" encoding="UTF-8"?>
<ejb-jar-ext
    xmlns="http://websphere.ibm.com/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://websphere.ibm.com/xml/ns/javaee http://websphere.ibm.com/xml/ns/javaee/ibm-ejb-jar-ext_1_1.xsd"
    version="1.1">

    <session name="TestBean">
        <start-at-app-start value="true"/>
    </session>
</ejb-jar-ext>

I'm not very familiar with WebSphere and maybe I do not fully understand your problem - but how about deploying a webapp with a startup servlet defined in web.xml? 我对WebSphere不太熟悉,也许我还不太了解您的问题-但是如何使用在web.xml中定义的启动servlet部署Web应用程序呢?

Here's what I mean: 这就是我的意思:

  • create a abc.war with abc.jar and log4j.jar copied to abc.war/WEB-INF/lib 使用abc.jar和log4j.jar创建一个abc.war复制到abc.war / WEB-INF / lib
  • define your startup class in abc.war/WEB-INF/web.xml as follows: 在abc.war / WEB-INF / web.xml中定义您的启动类,如下所示:

<web-app id="WebApp">
<display-name>abc.war</display-name>
<servlet> 
    <servlet-name>ABCStartupServlet</servlet-name>
    <display-name>ABCStartupServlet</display-name>
    <servlet-class>abc.ABCStartupServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
 </servlet>
 ...

That way you have log4j.jar and abc.jar together in one place, you can use the WebSphere classloader settings if another log4j version causes problems and your class is called during the startup of the server. 这样,就可以将log4j.jar和abc.jar放在一个地方,如果另一个log4j版本导致问题并且在服务器启动期间调用了您的类,则可以使用WebSphere classloader设置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM