如果我尝试读取消息驱动Bean中的属性文件,EJB模块将失败

时间:2011-11-08 18:09:51

标签: java java-ee message-driven-bean

我正在研究J2EE(Message Driven Beans)和Weblogic 10.3,我对这两者都是全新的。我试图读取消息驱动Bean文件中的属性文件。当我调用一个读取此属性文件的函数时,我收到以下错误:

.
.
.

"[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)'" daemon prio=6 tid=0x2c686c00 nid=0x708 in Object.wait() [0x2ef1f000]
   java.lang.Thread.State: WAITING (on object monitor)
    at java.lang.Object.wait(Native Method)
    - waiting on <0x0d8df8d8> (a weblogic.work.ExecuteThread)
    at java.lang.Object.wait(Object.java:485)
    at weblogic.work.ExecuteThread.waitForRequest(ExecuteThread.java:162)
    - locked <0x0d8df8d8> (a weblogic.work.ExecuteThread)
    at weblogic.work.ExecuteThread.run(ExecuteThread.java:183)

"Timer-1" daemon prio=6 tid=0x2c60e400 nid=0x9b0 in Object.wait() [0x2eecf000]
   java.lang.Thread.State: TIMED_WAITING (on object monitor)
    at java.lang.Object.wait(Native Method)
    - waiting on <0x0d8dfae8> (a java.util.TaskQueue)
    at java.util.TimerThread.mainLoop(Timer.java:509)
    - locked <0x0d8dfae8> (a java.util.TaskQueue)
    at java.util.TimerThread.run(Timer.java:462)

"Timer-0" daemon prio=6 tid=0x2be8b800 nid=0x688 in Object.wait() [0x2ce6f000]
   java.lang.Thread.State: WAITING (on object monitor)
    at java.lang.Object.wait(Native Method)
    - waiting on <0x0d5303d8> (a java.util.TaskQueue)
    at java.lang.Object.wait(Object.java:485)
    at java.util.TimerThread.mainLoop(Timer.java:483)
    - locked <0x0d5303d8> (a java.util.TaskQueue)
    at java.util.TimerThread.run(Timer.java:462)

"Low Memory Detector" daemon prio=6 tid=0x009a7000 nid=0x1538 runnable [0x00000000]
   java.lang.Thread.State: RUNNABLE

"CompilerThread0" daemon prio=10 tid=0x009a0c00 nid=0x1e0 waiting on condition [0x00000000]
   java.lang.Thread.State: RUNNABLE

"Attach Listener" daemon prio=10 tid=0x0099f400 nid=0xc30 runnable [0x00000000]
   java.lang.Thread.State: RUNNABLE

"Signal Dispatcher" daemon prio=10 tid=0x0099e000 nid=0x5fc runnable [0x00000000]
   java.lang.Thread.State: RUNNABLE

"Finalizer" daemon prio=8 tid=0x0098d800 nid=0xdc in Object.wait() [0x2adcf000]
   java.lang.Thread.State: WAITING (on object monitor)
    at java.lang.Object.wait(Native Method)
    - waiting on <0x0d5305f0> (a java.lang.ref.ReferenceQueue$Lock)
    at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:118)
    - locked <0x0d5305f0> (a java.lang.ref.ReferenceQueue$Lock)
    at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:134)
    at java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:159)

"Reference Handler" daemon prio=10 tid=0x00988c00 nid=0x1334 in Object.wait() [0x2ad7f000]
   java.lang.Thread.State: WAITING (on object monitor)
    at java.lang.Object.wait(Native Method)
    - waiting on <0x0d5300d8> (a java.lang.ref.Reference$Lock)
    at java.lang.Object.wait(Object.java:485)
    at java.lang.ref.Reference$ReferenceHandler.run(Reference.java:116)
    - locked <0x0d5300d8> (a java.lang.ref.Reference$Lock)

"main" prio=6 tid=0x002bb400 nid=0x11a8 in Object.wait() [0x0090f000]
   java.lang.Thread.State: WAITING (on object monitor)
    at java.lang.Object.wait(Native Method)
    - waiting on <0x0d5306a0> (a weblogic.t3.srvr.T3Srvr)
    at java.lang.Object.wait(Object.java:485)
    at weblogic.t3.srvr.T3Srvr.waitForDeath(T3Srvr.java:981)
    - locked <0x0d5306a0> (a weblogic.t3.srvr.T3Srvr)
    at weblogic.t3.srvr.T3Srvr.run(T3Srvr.java:490)
    at weblogic.Server.main(Server.java:71)

"VM Thread" prio=10 tid=0x00986400 nid=0xcec runnable 

"VM Periodic Task Thread" prio=10 tid=0x009a9800 nid=0xc14 waiting on condition 

> 

这是Java代码:

@MessageDriven(
        messageListenerInterface = javax.jms.MessageListener.class,
        name = "MdbA",
        mappedName = "qA",
        activationConfig = {
                @ActivationConfigProperty(
                        propertyName = "connectionFactoryJndiName",
                        propertyValue = "connectionFactoryV"),
                @ActivationConfigProperty(
                        propertyName = "destinationType",
                        propertyValue = "javax.jms.Queue"),
                @ActivationConfigProperty(
                        propertyName  = "destinationJndiName",
                        propertyValue = "qA"
         )})
public class MdbA implements MessageListener {

    private static int fileCount = 0;
    private String[] aryReadingType;
    private long sleepMs;
    private String persistenceDirectory;
    private String tomcatServerInstance;
    private String tomcatStatusScript;
    private String readingsProcessorInstance;
    private String logServiceURL;

    private static Logger log = Logger.getLogger(MdbALIreadings.class.getName());       // log4j logger

    /**
     * Default constructor. 
     */
    public MdbALIreadings()
    {
        System.out.println("In onMessage of MdbALIreadings as of " + new Date());
        setProperties();          // fails if I call this function here
    }

    /**
     * @see MessageListener#onMessage(Message)
     */
    public void onMessage(Message message)
    {
        .
        .
        .

        setProperties();             // fails if I call this function here
    }

    private void setProperties() {
        .
        .
        .

        try {

            date = new Date();
            fis = new FileInputStream("ReadingsProcessor.properties");
            properties.load(fis);

    }

如果我没有在此文件中的任何位置调用setProperties()函数,则不会失败。 有关为什么我无法读取消息驱动Bean中的文件的任何想法?是什么导致整个服务器失败?

1 个答案:

答案 0 :(得分:1)

您的“错误”不是错误,它是一个线程转储。它根本不显示错误。

您的FileInputStream失败,因为“ReadingsProcessor.properties”不在当前工作目录中。你目前的工作目录是什么?谁知道,它没有具体说明,WLS可以把它放在任何它喜欢的地方(这可能不是你期望的地方)。

您可能有更好的运气在类路径的部署中找到方便的地方,并使用类加载器getResourceAsStream方法来加载属性文件。在那里,我也不能说 - 我不知道你正在部署什么,或者它是如何部署的,我不知道WLS可能在类路径上放置的标准目录。您始终可以将自己的目录添加到容器类路径中,并将属性文件粘贴在那里。