如果我尝试读取消息驱动 Bean 中的属性文件,EJB 模块会失败
我正在研究 J2EE(消息驱动 Bean)和 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 中的文件有什么想法吗?是什么原因导致整个服务器瘫痪呢?
I am working on J2EE (Message Driven Beans) and Weblogic 10.3 and I am totally new to both of these. I am trying to read a properties file within a Message Driven Bean file. When I call a function which reads this properties file, I get the following error:
.
.
.
"[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
>
Here is the Java code:
@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);
}
If I do not call the setProperties()
function anywhere in this file, it does not fail.
Any thoughts about why I cannot read a file within a Message Driven Bean? What causes the entire server to fail?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的“错误”不是错误,而是线程转储。它根本不显示错误。
您的 FileInputStream 失败,因为“ReadingsProcessor.properties”不在当前工作目录中。您当前的工作目录是什么?谁知道呢,它是未指定的,WLS 可以将其放在任何它喜欢的地方(这可能不是您期望的地方)。
您可能会更幸运地在部署中找到类路径上方便的地方,并使用类加载器 getResourceAsStream 方法来加载属性文件。那是哪里,我也不能说——我不知道您正在部署什么,也不知道它是如何部署的,而且我不知道 WLS 可能放在类路径上的标准目录。您始终可以将自己的目录添加到容器类路径中,并将属性文件粘贴到其中。
Your "error" isn't an error, it's a thread dump. It doesn't show an error at all.
Your FileInputStream is failing because "ReadingsProcessor.properties" is not in the current working directory. What is your current working directory? Who knows, it's unspecified and WLS can put it anyplace it pleases (which is likely not someplace you expect).
You might have better luck finding someplace handy in your deploy that is on the classpath and using a class loaders getResourceAsStream method to load your property file. Where that is, I can't say either -- I don't know what you're deploying, or how it's deployed, and I don't know the standard directories that WLS may put on the classpath. You can always add your own directory to the containers classpath and stick the property file in there.