开发者

Startup Class in Websphere

I need to create a startup class in Websphere. This class is present in abc.jar. And also abc.jar开发者_JAVA百科 requires log4j.jar at startup of server.

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. 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. If I keep Log4j.jar in other place and keep that location in 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:

<?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?

Here's what I mean:

  • create a abc.war with abc.jar and log4j.jar copied to abc.war/WEB-INF/lib
  • define your startup class in abc.war/WEB-INF/web.xml as follows:

<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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜