Weblogic 10 Ejb3 Message Bean 配置 Weblogic JMS 配置 Weblogic 10 EJB3 例子安装
今天研究EJB3,在JBOSS环境上玩了一把,但是WAS 6.1不支持EJB3,不爽啊,就到Weblogic下面再玩玩吧。一看Weblogic 10 的安装目录里面有个EJB3的很强大的例子,嗯,心想,这个不错,省事啊,直接安装得了。
但是令人不爽的问题是很多的,Weblogic 10 的JMS配置跟Weblogic 8 的不一样,配置了N下,也还是不能用,后台报错。
不管了,现在我们安装把,出问题了,然后就改呗,也是一个让大家学习的过程。
1,笨蛋式安装开始。
然后点击NEXT,缺省选择
然后点击NEXT,缺省选择
然后点击NEXT,缺省选择
然后点击完成。
靠,这下问题来了。
系统报错,报pointbase 什么manager找不到,什么问题呢,我把这个安装包给解压了开来,打开
domain.jar/META-INF/persistence.xml的内容有如下片段。
<properties>
<property name="kodo.ConnectionURL" value="jdbc:pointbase:server://localhost:9092/demo"/>
<property name="kodo.ConnectionDriverName" value="com.pointbase.jdbc.jdbcUniversalDriver"/>
<property name="kodo.ConnectionUserName" value="examples"/>
<property name="kodo.ConnectionPassword" value="examples"/>
<property name="kodo.jdbc.SynchronizeMappings" value="refresh"/>
</properties>
一看,我明白了,原来这个默认的玩意配置的数据库是这个玩意啊,我机器上有现成的mysql,我改成mysql试试吧。把以上内容改成
<property name="kodo.ConnectionURL" value="jdbc:mysql://localhost:3306/web"/>
<property name="kodo.ConnectionDriverName" value="com.mysql.jdbc.Driver"/>
<property name="kodo.ConnectionUserName" value="root"/>
<property name="kodo.ConnectionPassword" value="admin"/>
<property name="kodo.jdbc.SynchronizeMappings" value="refresh"/>
重新打包回去,然后继续发布。嗯,这下好了,没这个错误了。
我们看看mysql数据库里面发生了什么??
应用给表创建了以上我选择的表了,说明利用mysql还是可以的。
但是后台有以下输出。
<2009-7-19 上午12时15分10秒 CST> <Warning> <EJB> <BEA-010061> <The Message-Driven EJB: WatchProcessMDB is unable to conn
ect to the JMS destination: weblogic.examples.ejb30.ExampleQueue. The Error was:
weblogic.jms.common.JMSException: javax.naming.NameNotFoundException: Unable to resolve 'weblogic.jms.backend.JMSServer-
0'. Resolved 'weblogic.jms.backend'; remaining name 'JMSServer-0'
Nested exception: weblogic.jms.common.JMSException: javax.naming.NameNotFoundException: Unable to resolve 'weblogic.jms.
backend.JMSServer-0'. Resolved 'weblogic.jms.backend'; remaining name 'JMSServer-0'
Nested exception: weblogic.jms.common.JMSException: javax.naming.NameNotFoundException: Unable to resolve 'weblogic.jms.
backend.JMSServer-0'. Resolved 'weblogic.jms.backend'; remaining name 'JMSServer-0'
Nested exception: javax.naming.NameNotFoundException: Unable to resolve 'weblogic.jms.backend.JMSServer-0'. Resolved 'we
blogic.jms.backend'; remaining name 'JMSServer-0'>
119047 reviewService INFO [[STANDBY] ExecuteThread: '4' for queue: 'weblogic.kernel.Default (self-tuning)'] openjpa.
jdbc.JDBC - Shutting down connection pool.
<2009-7-19 上午12时15分33秒 CST> <Warning> <netuix> <BEA-423420> <Redirect is executed in begin or refresh action. Redir
ect url is /console/console.portal?_nfpb=true&_pageLabel=AppDeploymentsControlPage.>
<2009-7-19 上午12时15分47秒 CST> <Warning> <netuix> <BEA-423420> <Redirect is executed in begin or refresh action. Redir
ect url is /console/console.portal?_nfpb=true&_pageLabel=AppDeploymentsControlPage.>
<2009-7-19 上午12时26分30秒 CST> <Warning> <EJB> <BEA-010061> <The Message-Driven EJB: WatchProcessMDB is unable to conn
ect to the JMS destination: weblogic.examples.ejb30.ExampleQueue. The Error was:
Can not get distribute destination information. The destination JNDI name is weblogic.examples.ejb30.ExampleQueue, the p
rovider URL is null>
0 reviewService INFO [[STANDBY] ExecuteThread: '2' for queue: 'weblogic.kernel.Default (self-tuning)'] openjpa.Runti
me - Starting BEA Kodo 4.2.0load03
0 reviewService INFO [[STANDBY] ExecuteThread: '2' for queue: 'weblogic.kernel.Default (self-tuning)'] openjpa.jdbc.
JDBC - Using dictionary class "org.apache.openjpa.jdbc.sql.MySQLDictionary".
<2009-7-19 上午12时26分31秒 CST> <Warning> <netuix> <BEA-423420> <Redirect is executed in begin or refresh action. Redir
ect url is /console/console.portal?_nfpb=true&_pageLabel=AppApplicationOverviewPage&AppApplicationOverviewPortlethandle=
com.bea.console.handles.AppDeploymentHandle%28%22com.bea%3AName%3DreviewService%2CType%3DAppDeployment%22%29.>
<2009-7-19 上午12时27分30秒 CST> <Warning> <JMSPool> <BEA-169808> <There was an error while making the initial connectio
n to the JMS resource named weblogic.examples.ejb30.QueueConnectionFactory from the EJB "ReviewListenerBean" inside appl
ication "reviewService". The server will attempt the connection again later. The error was javax.jms.JMSException: [JMSP
ool:169803]JNDI lookup of the JMS connection factory weblogic.examples.ejb30.QueueConnectionFactory failed: javax.naming
.NameNotFoundException: Unable to resolve 'weblogic.examples.ejb30.QueueConnectionFactory'. Resolved 'weblogic.examples.
ejb30'; remaining name 'QueueConnectionFactory'>
一看就明白了。JMS没有配置。那我们去给Weblogic 配置JMS吧,我打开
public class ReviewListenerBean implements ReviewListener {
//The JNDI name of the Queue Connection Factory referenced here is specified by the mappedName attribute of @Resource,
//which can be overwritten in weblogic-ejb-jar.xml.
@Resource(name = "jms/mdbQCF", mappedName = "weblogic.examples.ejb30.QueueConnectionFactory")
private QueueConnectionFactory mdbQCF;
//The JNDI name of the Queue referenced here is specified by the mappedName attribute of @Resource,
//which can be overwritten in weblogic-ejb-jar.xml.
@Resource(name = "jms/mdbQueue", mappedName = "weblogic.examples.ejb30.ExampleQueue")
知道了需要配置的QueueFactory是 weblogic.examples.ejb30.QueueConnectionFactory
Queue是 weblogic.examples.ejb30.ExampleQueue
2,配置JMS。
第一步,创建一个JMS Server
点击New
新增一个JMS Server,
点击NEXT ,默认选项
点击NEXT,选择TARGET为当前的Server,如果是默认的Domain的话,应该是AdminServer
然后点击FINISH。成功创建JMS Server.
第二步,创建 JMS Modules。
点击Domain Structure -- Services -- Messaging--JMS Modules
然后点击NEW 按钮。
NEXT ,默认选项,
NEXT, Targets 选择 AdminServer.
然后NEXT, FINISH.
点击新建的 SystemModule-0,路径如下所示。
全部填写 weblogic.examples.ejb30.QueueConnectionFactory
点击NEXT
点击 “Advanced Targeting”
点击“Create a New Subdeployment”
然后点击 OK,下面有 Targets : 全不选。切记,别选。
然后点击 Finish。
点击 weblogic.examples.ejb30.QueueConnectionFactory 到Transactions Tab页,勾选 XA Connection ......选项,SAVE
然后同样的方式新建队列。
点击NEXT,名称全部写 weblogic.examples.ejb30.ExampleQueue
点击NEXT,然后 Subdeployments 选择刚才新建的那个。
然后点击Finish完成。
然后重启动server吧。
然后在IE 里面输入
http://localhost:7001/reviewService
欣赏WEBLOGIC自带的sample吧,
如果这里页面是404错误,那应该是应用没有启动,需要到控制台把应用启动下就OK了。
本文的 主要讲解的JMS的配置问题。
作者 keyboardsun
转载请标明出处:http:/blog.youkuaiyun.com/keyboardsun