第一个EJB示例

FirstEJB2.0.zip

Eclipse + JBoss 5.1

Ejb3Example.zip

Eclipse + JBoss 7.1

注意点:

1. jboss 增加用户:

D:DevProgramsjbossjboss-as-7.1.1.Finalin>add-user.bat

What type of user do you wish to add?
 a) Management User (mgmt-users.properties)
 b) Application User (application-users.properties)
(a): b

Enter the details of the new user to add.
Realm (ApplicationRealm) :
Username : cg
Password :
Re-enter Password :
What roles do you want this user to belong to? (Please enter a comma separated l
ist, or leave blank for none) : testrole
About to add user 'cg' for realm 'ApplicationRealm'
Is this correct yes/no? yes
Added user 'cg' to file 'D:DevProgramsjbossjboss-as-7.1.1.Finalstandaloneco
nfigurationapplication-users.properties'
Added user 'cg' to file 'D:DevProgramsjbossjboss-as-7.1.1.Finaldomainconfig
urationapplication-users.properties'
Added user 'cg' with roles testrole to file 'D:DevProgramsjbossjboss-as-7.1.1
.Finalstandaloneconfigurationapplication-roles.properties'
Added user 'cg' with roles testrole to file 'D:DevProgramsjbossjboss-as-7.1.1
.Finaldomainconfigurationapplication-roles.properties'
Press any key to continue . . .

  

2.  jboss-as-7.1.1.Finalstandaloneconfigurationstandalone.xml

    <interfaces>
        <interface name="management">
            <inet-address value="${jboss.bind.address.management:127.0.0.1}"/>
        </interface>
        <interface name="public">
            <inet-address value="${jboss.bind.address:0.0.0.0}"/>
        </interface>
        <interface name="unsecure">
            <inet-address value="${jboss.bind.address.unsecure:127.0.0.1}"/>
        </interface>
		<-- add begin -->
        <interface name="any">
            <any-ipv4-address/>
        </interface>
		<-- add end -->
    </interfaces>
	<!--default-interface="public" 改为 default-interface="any"  >
    <socket-binding-group name="standard-sockets" default-interface="any" port-offset="${jboss.socket.binding.port-offset:0}">

3. EJB Client项目要引用:  jboss-as-7.1.1.Finalinclientjboss-client.jar

PS:

ejb查找名:
ejb:<app-name>/<module-name>/<distinct-name>/<bean-name>!<fully-qualified-classname-of-the-remote-interface>
ejb stateful:
ejb:<app-name>/<module-name>/<distinct-name>/<bean-name>!<fully-qualified-classname-of-the-remote-interface>?stateful

原文地址:https://www.cnblogs.com/wucg/p/4037580.html