Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

initial version for an advanced ejb-multi-server quickstart using a domain #350

Closed
wants to merge 8 commits into from

5 participants

@wfink

version tested with 7.1.1 (need patch see README), 7.1.2, 7.1.3, 7.2 SNAPSHOT, EAP6.0.0

@wfink

amend bugfix with pom versions

@sgilda
Owner

@wfink : Is this quickstart ready for review?

@wfink

I thought a pull-request mean that ;)

@sgilda
Owner

Sorry. It was the "initial version" copy that threw me. :-)

I'll review it next. Thanks!

ejb-multi-server/README.md
((54 lines not shown))
+ `bin/domain.sh`
+
+ * navigate to the project root directory and run the following command
+
+ `JBOSS_HOME/bin/jboss-cli.sh --connect --file=install-domain.cli`
+
+ * Add application user [Add an Application User](../README.md#addapplicationuser)
+ To add all necessary users run the following commands, please use this usernames and paswords because the domain configuration and the client use it.
+
+ `bin/add-user.sh -a -u quickuser -p quick-123 --silent`
+ `bin/add-user.sh -a -u quickuser1 -p quick123+ --silent`
+ `bin/add-user.sh -a -u quickuser2 -p quick+123 --silent`
+
+_NOTE: If a server 7.1.1 is used the install-domain.cli will fail because of unsupported commands, see the comments within the cli script._
+_NOTE: The add-user script does not support the direct user add until 7.2, please add the required users manually without apply any roles._
+_NOTE: If there are ERROR's shown in the server.log during installing or deploying please restart the domain to ensure further steps are running correct._
@pmuir Owner
pmuir added a note

It would be nice to have an instruction about how to restart the domain.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
...ar/src/main/application/META-INF/jboss-ejb-client.xml
@@ -0,0 +1,21 @@
+<jboss-ejb-client xmlns:xsi="urn:jboss:ejb-client:1.2" xsi:noNamespaceSchemaLocation="jboss-ejb-client_1_2.xsd">
+ <client-context>
+ <ejb-receivers>
+ <!-- this is the connection to access the app-one -->
+ <remoting-ejb-receiver outbound-connection-ref="remote-ejb-connection-1"/>
+ <!-- this is the connection to access the app-two -->
+ <remoting-ejb-receiver outbound-connection-ref="remote-ejb-connection-2"/>
+ </ejb-receivers>
+
+ <!-- if there is a cluster behind the outbound connection the cluster element must be defined -->
@pmuir Owner
pmuir added a note

I'm struggling to parse this sentence. Do you mean

"if the client connects to a cluster of servers, then a cluster element must be defined"?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
.../as/quickstarts/ejb/multi/server/app/MainAppBean.java
((15 lines not shown))
+
+/**
+ * <p>The main bean called by the standalone client.</p>
+ * <p>The sub applications, deployed in different servers are called direct or via indirect naming
+ * to hide the lookup name and use a configured name via comp/env environment.</p>
+ *
+ * @author <a href="mailto:wfink@redhat.com">Wolf-Dieter Fink</a>
+ */
+@Stateless
+public class MainAppBean implements MainApp {
+ private static final Logger LOGGER = Logger.getLogger(MainAppBean.class);
+ @Resource SessionContext context;
+ private InitialContext iCtx;
+
+ /**
+ * Initialize an store the context for the EJB invocation.
@pmuir Owner
pmuir added a note

s/an/and/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
...s/quickstarts/ejb/multi/server/app/EjbInvocation.java
@@ -0,0 +1,20 @@
+package org.jboss.as.quickstarts.ejb.multi.server.app;
+
+public class EjbInvocation {
@pmuir Owner
pmuir added a note

Comments?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
...s/quickstarts/ejb/multi/server/app/JsfController.java
((18 lines not shown))
+ private static final Logger LOOGER = Logger.getLogger(JsfController.class);
+ private EjbInvocation invocation;
+
+ @EJB
+ MainApp mainApp;
+
+ /**
+ * Injection is not possible for foreign application in a different server.
+ * The reference will be set during PostConstruct
+ */
+ AppOne oneApp;
+ /**
+ * Injection is not possible for foreign application in a different server.
+ * The reference will be set during PostConstruct
+ */
+ AppTwo twoApp;
@pmuir Owner
pmuir added a note

This doesn't seem right. You should still be able to use @resource here?

Also, I think we should demonstrate the resource producer pattern here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@pmuir
Owner

In general this could do to go through a formatter.

Once you've made the above changes I'll try to do a re-review.

@wfink

rework due to Pete's comment. Add an EJBClient-34 example with scoped context
ReTest with EAP6.0.X AS7.2 and AS(upstream) add comments for several configurations based on the server version.

@wfink wfink new quickstart with a multi server application managed in a domain.
the installation an deployment will be handled by CLI scripts.
5fc8ba2
ejb-multi-server/README.md
@@ -0,0 +1,176 @@
+ejb-multi-server: EJB applications deployed in different servers communicating vie EJB remote calls
+======================================================
+Author: Wolf-Dieter Fink
+Level: Advanced
+Technologies: EJB, EAR
+
+
+What is it?
+-----------
+
+This example demonstrates the communication between applications deployed to different servers.
+Each application is deployed as an EAR that contains a simple EJB3.1 bean which only log the invocation.
+
+Also the configuration is done by CLI batch-scripts.
@sgilda Owner
sgilda added a note

I would move this down to the end of this section or to where you configure the server.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
ejb-multi-server/README.md
@@ -0,0 +1,176 @@
+ejb-multi-server: EJB applications deployed in different servers communicating vie EJB remote calls
+======================================================
+Author: Wolf-Dieter Fink
+Level: Advanced
+Technologies: EJB, EAR
+
+
+What is it?
+-----------
+
+This example demonstrates the communication between applications deployed to different servers.
+Each application is deployed as an EAR that contains a simple EJB3.1 bean which only log the invocation.
@sgilda Owner
sgilda added a note

s/log/logs
Each application is deployed as an EAR that contains a simple EJB3.1 bean which only logs the invocation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@sgilda sgilda commented on the diff
ejb-multi-server/README.md
@@ -0,0 +1,176 @@
+ejb-multi-server: EJB applications deployed in different servers communicating vie EJB remote calls
+======================================================
+Author: Wolf-Dieter Fink
+Level: Advanced
+Technologies: EJB, EAR
+
@sgilda Owner
sgilda added a note

We have new metadata. You need to add:
Target Product: EAP
Source: < https://github.com/jboss-jdf/jboss-as-quickstart/>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
ejb-multi-server/README.md
@@ -0,0 +1,176 @@
+ejb-multi-server: EJB applications deployed in different servers communicating vie EJB remote calls
+======================================================
+Author: Wolf-Dieter Fink
+Level: Advanced
+Technologies: EJB, EAR
@sgilda Owner
sgilda added a note

I have to think about this. It seems like we need to add a technology related to cross app communication. :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
ejb-multi-server/README.md
((2 lines not shown))
+======================================================
+Author: Wolf-Dieter Fink
+Level: Advanced
+Technologies: EJB, EAR
+
+
+What is it?
+-----------
+
+This example demonstrates the communication between applications deployed to different servers.
+Each application is deployed as an EAR that contains a simple EJB3.1 bean which only log the invocation.
+
+Also the configuration is done by CLI batch-scripts.
+
+
+The example is composed of multiple maven projects, each with a shared parent. The projects are as follows:
@sgilda Owner
sgilda added a note

s/maven/Maven

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@sgilda
Owner

@wfink : It might be easier for me to make the edits for the README file and email it to you.

Just to be clear, this application requires JBoss Enterprise Application Platform 6.1 or JBoss AS 7.2, correct?

@sgilda
Owner

@wfink: When I run 'mvn clean install', I get these compile errors:

[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /home/sgilda/GitRepos/quickstart-jdf/ejb-multi-server/app-main/web/src/main/java/org/jboss/as/quickstarts/ejb/multi/server/app/JsfController.java:[42,12] cannot find symbol
symbol : method lookup()
location: @interface javax.annotation.Resource
[ERROR] /home/sgilda/GitRepos/quickstart-jdf/ejb-multi-server/app-main/web/src/main/java/org/jboss/as/quickstarts/ejb/multi/server/app/JsfController.java:[45,12] cannot find symbol
symbol : method lookup()
location: @interface javax.annotation.Resource
[ERROR] /home/sgilda/GitRepos/quickstart-jdf/ejb-multi-server/app-main/web/src/main/java/org/jboss/as/quickstarts/ejb/multi/server/app/JsfController.java:[51,12] cannot find symbol
symbol : method lookup()
location: @interface javax.annotation.Resource
[ERROR] /home/sgilda/GitRepos/quickstart-jdf/ejb-multi-server/app-main/web/src/main/java/org/jboss/as/quickstarts/ejb/multi/server/app/JsfController.java:[57,12] cannot find symbol
symbol : method lookup()
location: @interface javax.annotation.Resource
[INFO] 4 errors

I'll see if I can figure it out, but thought you might have an idea.
I'm compiling against the AS 7.2 Maven repository created when I built AS 7.2 from source.

@sgilda
Owner

@wfink : Are there supposed to be multiple servers running? I only see one server start command.

@wfink

@sgilda: no problem if you send a README with your changes.

"Are there supposed to be multiple servers running? I only see one server start command. "
The example will start a domain, so you have multiple servers to process the application started by this domain.

"Just to be clear, this application requires JBoss Enterprise Application Platform 6.1 or JBoss AS 7.2, correct?"
No, within the README you will find some NOTEs regarding the differences between the versions.

with AS7.1.x and EAP6.0.x it is possible to run most of the example with small changes in the add-user command and install-cli script.
The feature of EJBCLIENT-34 sections 'Access ....' I need to add a hint that this feature will only work correct if AS7.2 or EAP6.1 is used, otherwise the behaviour will not be different.

regarding the build, I'm able to build that with a new Maven repository, all files are correct downloaded.

@sgilda
Owner

@wfink: Thanks for the clarifications. I think we need to be more clear on the intructions for EAP 6/AS 7 versus EAP 6.1/AS 7.2. I will make more changes to the README and send it to you as soon as I can.

@sgilda
Owner
@sgilda
Owner

@wfink : I tried this using the EAP 6.1 Beta server and Maven repository and still get the compile errors "cannot find symbol : method lookup()"
Could this be due to the version of Java I'm using? Is "lookup" an newer attribute?

This is what I'm using:
$ java -version
java version "1.6.0_33"
Java(TM) SE Runtime Environment (build 1.6.0_33-b03)
Java HotSpot(TM) 64-Bit Server VM (build 20.8-b03, mixed mode)

@sgilda
Owner

@wfink : Just to let you know, If I change the @Resource(lookup = to @EJB(lookup = , it compiles and installs fine.

ejb-multi-server/install-domain.cli
((3 lines not shown))
+# first stop the default servers, block until the server is down
+/host=master/server-config=server-one:stop(blocking=true)
+/host=master/server-config=server-two:stop(blocking=true)
+
+# remove the default server configuration and server-groups
+/host=master/server-config=server-one:remove
+/host=master/server-config=server-two:remove
+/host=master/server-config=server-three:remove
+/server-group=main-server-group:remove
+/server-group=other-server-group:remove
+
+
+# ---- configure the domain for the quickstart ejb-multi-server
+
+# disable the local authentication for applications
+# remove this command if a 7.1.1 server is used, here it is not possible to remove the 'local' functionality.
@sgilda Owner
sgilda added a note

Could you make this line more prominent and easy to search for:
*** NOTE: If you are running JBoss Enterprise Application Platform 6.0 or JBoss AS 7.1, comment the following command ***

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@sgilda sgilda commented on the diff
ejb-multi-server/install-domain.cli
((94 lines not shown))
+/profile=default-web/subsystem=ejb3/service=async:add(thread-pool-name=default)
+/profile=default-web/subsystem=ejb3/service=timer-service:add(thread-pool-name=default,path=timer-service-data,relative-to=jboss.server.data.dir)
+
+/profile=default-web/subsystem=ejb3/service=remote:add(connector-ref=remoting-connector,thread-pool-name=default)
+/profile=default-web/subsystem=ejb3/thread-pool=default:add(max-threads=10,keepalive-time={"time"=>"100","unit"=>"MILLISECONDS"})
+
+/profile=default-web/subsystem=jca:add()
+/profile=default-web/subsystem=jca/archive-validation=archive-validation:add(enabled=true, fail-on-error=true, fail-on-warn=false)
+/profile=default-web/subsystem=jca/bean-validation=bean-validation:add(enabled=true)
+/profile=default-web/subsystem=jca/cached-connection-manager=cached-connection-manager:add(install=true)
+/profile=default-web/subsystem=jca/workmanager=default:add(name=default)
+/profile=default-web/subsystem=jca/workmanager=default/short-running-threads=default:add(core-threads=50,queue-length=50,max-threads=50,keepalive-time={"time"=>"10", "unit"=>"SECONDS"})
+/profile=default-web/subsystem=jca/workmanager=default/long-running-threads=default:add(core-threads=50,queue-length=50,max-threads=50,keepalive-time={"time"=>"10", "unit"=>"SECONDS"})
+
+/profile=default-web/subsystem=naming:add()
+# remove this command if a 7.1.1 server is used
@sgilda Owner
sgilda added a note

Could you make this line more prominent and easy to search for:
*** NOTE: If you are running JBoss Enterprise Application Platform 6.0 or JBoss AS 7.1, comment the following command ***

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@sgilda
Owner

I found this: http://middlewaremagic.com/jboss/?p=473
If what they say is correct, it seems like changing it to @EJB(lookup (if it works the same) might be easier?

ejb-multi-server/README.md
((43 lines not shown))
+
+Configure Maven
+---------------
+
+If you have not yet done so, you must [Configure Maven](../README.md#mavenconfiguration) before testing the quickstarts.
+
+
+Modify the CLI Scripts (if you are running JBoss Enterprise Application Platform 6.0 or JBoss AS 7.1 servers)
+---------------------------
+
+The CLI scripts provided with this quickstart target JBoss Enterprise Application Platform 6.1 and JBoss AS 7.2. If you are running older versions of the server, JBoss Enterprise Application Platform 6.0 or JBoss AS 7.1, you must modify the scripts to work against these servers.
+
+1. Open the `install-domain.cli` file located in the root of this quickstart folder for editing.
+2. Find the lines that contain the following text:
+
+ *** NOTE: If you are running JBoss .... ***
@sgilda Owner
sgilda added a note

I'm afraid developers will copy and paste the the whole line *** NOTE: If you are running JBoss .... *** and won't find a match because the .... doesn't match a version.
Maybe this like could just be:

  1. Find the lines that contain the following text:

    *** NOTE:
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
ejb-multi-server/README.md
((148 lines not shown))
+* _If exec is called multiple times, the invocation for `app1` might use `app-oneA` and `app-oneB` node due to cluster loadbalancing._
+* _If you use a version from JBoss Enterprise Platform 6.1 or JBoss AS7.2, a new feature will deny the invocation of unsecured methods of `appOne`/`appTwo` since security is enabled but the method does not include @Roles. You need to set 'default-missing-method-permissions-deny-access = false' for the `ejb3` subsystem within the domain profile "ha" and "default" to allow the method invocation. See the install-domain.cli script._
+* _For JBoss Enterprise Application Platform 6.0 and AS 7.1.x, the scoped-client-context is not implemented. Therefore you will not see a difference between step 3 and step 4, the properties of the InitialContext will be ignored._
+* _For JBoss Enterprise Application Platform 6.0 and AS 7.1.x, the client library must not be changed for this test. But if additional tests are added or a newer server version is used, you might update the property `<jboss.client.bom.version>7.1.1.Final</jboss.client.bom.version>` in the root `pom.xml` to an appropriate version._
+
+
+Access the JSF application inside the main-application
+---------------------
+
+1. Make sure that the deployments are successful as described above.
+2. Use a browser to access the JSF application at the following URL: <http://localhost:8080/multi-server-MainApp/>
+3. Insert a message in the Text input and invoke the different methods. The result is shown in the browser.
+4. See server logfiles and find your given message logged as INFO.
+
+_NOTE :_
+* _If you try to invoke `MainEjbClient34App` you need to update the user `quickuser1` and `quickuser2` and give them one of the Roles `AppTwo` or `Intern`._
@sgilda Owner
sgilda added a note

This doesn't render as a bullet. You need a blank line between this and the line with NOTE.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@sgilda
Owner

This looks great! I made a couple of minor comments in the README file.

I will try this again today against AS 7.1.1 and also build the source AS 7.2 to regenerate my Maven repository.

@wfink: One more comment. Your install-domain.cli is amazing! That alone will be a great example for adminstrators. I will point the doc team to it as well for examples of CLI command. Thanks so much for creating it!

ejb-multi-server/install-domain.cli
((6 lines not shown))
+
+# remove the default server configuration and server-groups
+/host=master/server-config=server-one:remove
+/host=master/server-config=server-two:remove
+/host=master/server-config=server-three:remove
+/server-group=main-server-group:remove
+/server-group=other-server-group:remove
+
+
+# ---- configure the domain for the quickstart ejb-multi-server
+
+# disable the local authentication for applications
+# *** NOTE: If you are running JBoss AS 7.1.1, comment the following command ***
+/host=master/core-service=management/security-realm=ApplicationRealm/authentication=local:remove
+
+# *** NOTE: If you are running JBoss Enterprise Application Platform 6.0 or JBoss AS 7.1, un-comment the following commands.
@sgilda Owner
sgilda added a note

s/un-comment/uncomment (no hyphen needed).
Do you think this should be more specific, for example:
If you are running JBoss Enterprise Application Platform 6.0 or JBoss AS 7.1, uncomment the following 2 /profile commands

@sgilda Owner
sgilda added a note

Looking at this again, I think the "un-comment" was a typo because the following 2 lines are not commented out.
Can you clarify if the should be "comment the following 2 profile commands?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
ejb-multi-server/README.md
((44 lines not shown))
+Configure Maven
+---------------
+
+If you have not yet done so, you must [Configure Maven](../README.md#mavenconfiguration) before testing the quickstarts.
+
+
+Modify the CLI Scripts (if you are running JBoss Enterprise Application Platform 6.0 or JBoss AS 7.1 servers)
+---------------------------
+
+The CLI scripts provided with this quickstart target JBoss Enterprise Application Platform 6.1 and JBoss AS 7.2. If you are running older versions of the server, JBoss Enterprise Application Platform 6.0 or JBoss AS 7.1, you must modify the scripts to work against these servers.
+
+1. Open the `install-domain.cli` file located in the root of this quickstart folder for editing.
+2. Find the lines that contain the following text:
+
+ *** NOTE: If you are running JBoss .... ***
+3. Comment or remove the line directly following the text if you use a noted version.
@sgilda Owner
sgilda added a note

This is not accurate since sometimes you comment, and sometimes you uncomment. Maybe it should say:

  1. Follow the Note instructions to comment or uncomment lines in the file.
@sgilda Owner
sgilda added a note

If the "un-comment' in the install-domain.cli file wwas a mistake, ignore my comment above. :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
ejb-multi-server/install-domain.cli
((7 lines not shown))
+# remove the default server configuration and server-groups
+/host=master/server-config=server-one:remove
+/host=master/server-config=server-two:remove
+/host=master/server-config=server-three:remove
+/server-group=main-server-group:remove
+/server-group=other-server-group:remove
+
+
+# ---- configure the domain for the quickstart ejb-multi-server
+
+# disable the local authentication for applications
+# *** NOTE: If you are running JBoss AS 7.1.1, comment the following command ***
+/host=master/core-service=management/security-realm=ApplicationRealm/authentication=local:remove
+
+# *** NOTE: If you are running JBoss Enterprise Application Platform 6.0 or JBoss AS 7.1, un-comment the following commands.
+ The reason is that the invocation of unsecured methods inside of a secured application is denied otherwise.
@sgilda Owner
sgilda added a note

This line errors out. It needs a comment #.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@sgilda
Owner

I tried testing this with the previous release of the JBoss 7.1.1.Final:
I started with a clean JBoss AS 7.1.1.Final "Brontes" server
I deleted the ~/.m2/repository/ directory
I started bin/domain.sh
I modifed the install-domain.cli script and ran it successfully.
I ran mvn clean install with the same compile errors as above:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.5.1:compile (default-compile) on project jboss-as-ejb-multi-server-appMain-web: Compilation failure: Compilation failure:
[ERROR] /home/sgilda/GitRepos/quickstart-jdf/ejb-multi-server/app-main/web/src/main/java/org/jboss/as/quickstarts/ejb/multi/server/app/JsfController.java:[42,12] cannot find symbol
[ERROR] symbol : method lookup()
[ERROR] location: @interface javax.annotation.Resource
[ERROR] /home/sgilda/GitRepos/quickstart-jdf/ejb-multi-server/app-main/web/src/main/java/org/jboss/as/quickstarts/ejb/multi/server/app/JsfController.java:[45,12] cannot find symbol
[ERROR] symbol : method lookup()
[ERROR] location: @interface javax.annotation.Resource
[ERROR] /home/sgilda/GitRepos/quickstart-jdf/ejb-multi-server/app-main/web/src/main/java/org/jboss/as/quickstarts/ejb/multi/server/app/JsfController.java:[51,12] cannot find symbol
[ERROR] symbol : method lookup()
[ERROR] location: @interface javax.annotation.Resource
[ERROR] /home/sgilda/GitRepos/quickstart-jdf/ejb-multi-server/app-main/web/src/main/java/org/jboss/as/quickstarts/ejb/multi/server/app/JsfController.java:[57,12] cannot find symbol
[ERROR] symbol : method lookup()
[ERROR] location: @interface javax.annotation.Resource

@sgilda
Owner

According to http://middlewaremagic.com/jboss/?p=473: 'the compile time issue occurs because the JDK API’s “javax.annotation.Resource” annotation does not contain any attribute with name “lookup”. So we need to make sure that you include the “jboss-annotations-api_1.1_spec-1.0.0.Final.jar” location in the “-endorseddirs” endorsed directory argument of the Java Comiler because the JDK APIs also contains the annotation “@javax.annotation.Resource”..but the JDK APIs do not have the “lookup” attribute in ther annotations.'

@pmuir or @LightGuard : Are you familiar with this problem? Would a simpler solution be to change the @Resource(lookup = to @EJB(lookup = ? I tried that and it compiles and installs fine. Just not sure that's a correct or good solution.

@LightGuard
@sgilda
Owner

@LightGuard : I got the compile error running AS 7.2 against a Maven repository creating building AS 7.2 from source, so it appears to be an issue unless I did something wrong. I will rebuild the latest again and see what I find.

From what I can tell, they appear to be EJB lookups. This is the result of the grep search for the lookups in the code:
@Resource(lookup = "ejb:appmain/ejb/MainAppBean!org.jboss.as.quickstarts.ejb.multi.server.app.MainApp")
@Resource(lookup = "ejb:appmain/ejb/MainEjbClient34AppBean!org.jboss.as.quickstarts.ejb.multi.server.app.MainApp")
@Resource(lookup = "ejb:appone/ejb//AppOneBean!org.jboss.as.quickstarts.ejb.multi.server.app.AppOne")
@Resource(lookup = "ejb:apptwo/ejb//AppTwoBean!org.jboss.as.quickstarts.ejb.multi.server.app.AppTwo")

@LightGuard
@wfink

I need to take a look into, as I remember correct the @EJB will not work in that case.
I was using a programatic lookup but Paul point to Resourse

@wfink

The EJB annotation will not work in that case. The app will be compiled and deployed in that case but access to 'http://localhost:8080/multi-server-MainApp' will throw an Exception because of the unsuccessful injection.

@sgilda see whether the last commit solve the compiler problem, if not I'll revert it

@sgilda
Owner

@wfink: I just compiled agiainst both AS 7.1.1 and AS 7.2. and got the same error. It must be something I'm doing wrong. I'll try to look into in more closely.

@sgilda
Owner

Found another reference to the @Resource(lookup= compile error here: http://www.mastertheboss.com/jboss-maven/solving-the-resource-lookup-compilation-issue
They give the same work-around.

@sgilda
Owner

Wolf, I resolved the compile error using the approach outlined in the links above:
1. I created an endorsed subdirectory in my JAVA_HOME/jre/lib/ directory
2. I copied the jboss-as-7.1.1.Final/modules/javax/annotation/api/main/jboss-annotations-api_1.1_spec-1.0.0.Final.jar to the endorsed directory

We need to provide these instructions for the users of this quickstart that run into the same compile error. The instuctions are dependent on the version of the server since the modules/ directory structure changed for EAP 6.1 / AS 7.2.

@pmuir: Can you review the @Resource(lookup= code in ejb-multi-server/app-main/web/src/main/java/org/jboss/as/quickstarts/ejb/multi/server/app/JsfController.java and see if there is a better or easier solution to this compile error?

@sgilda
Owner

Wolf, I continued testing.

I ran JBOSS_HOME/bin/jboss-cli.sh --connect --file=deploy-domain.cli successfully:
$ ~/tools/jboss-as-7.1.1.Final/bin/jboss-cli.sh --connect --file=deploy-domain.cli
#1 deploy app-one/ear/target/appone.ear --server-groups=quickstart-ejb-multi-appOne-server
#2 deploy app-two/ear/target/apptwo.ear --server-groups=quickstart-ejb-multi-appTwo-server
#3 deploy app-main/ear/target/appmain.ear --server-groups=quickstart-ejb-multi-main-server
#4 deploy app-web/target/appweb.war --server-groups=quickstart-ejb-multi-appWeb-server
The batch executed successfully.

Then I navigated to the client directory and ran: mvn exec:java. and saw this error:
[WARNING]
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.codehaus.mojo.exec.ExecJavaMojo$1.run(ExecJavaMojo.java:297)
at java.lang.Thread.run(Thread.java:662)
Caused by: java.lang.IllegalStateException: EJBCLIENT000025: No EJB receiver available for handling [appName:appmain, moduleName:ejb, distinctName:] combination for invocation context org.jboss.ejb.client.EJBClientInvocationContext@a2ba05
at org.jboss.ejb.client.EJBClientContext.requireEJBReceiver(EJBClientContext.java:588)
at org.jboss.ejb.client.ReceiverInterceptor.handleInvocation(ReceiverInterceptor.java:116)
at org.jboss.ejb.client.EJBClientInvocationContext.sendRequest(EJBClientInvocationContext.java:181)
at org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:136)
at org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:121)
at org.jboss.ejb.client.EJBInvocationHandler.invoke(EJBInvocationHandler.java:104)
at $Proxy16.invokeAll(Unknown Source)
at org.jboss.as.quickstarts.ejb.multi.server.Client.main(Client.java:79)
... 6 more
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE

I restarted my server, and it worked the next time. Is this the expected behavior?

I then tried: mvn exec:java -DUseEjbClient34=true and got this error:
[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:java (default-cli) on project jboss-as-ejb-multi-server-client: An exception occured while executing the Java class. null: InvocationTargetException: JBAS014502: Invocation on method: public abstract java.lang.String org.jboss.as.quickstarts.ejb.multi.server.app.AppTwo.invokeSecured(java.lang.String) of bean: AppTwoBean is not allowed -> [Help 1]
[ERROR]

The server log contains the following:
[Server:app-twoA] 16:02:20,355 ERROR org.jboss.ejb3.invocation JBAS014134: EJB Invocation failed on component AppTwoBean for method public abstract java.lang.String org.jboss.as.quickstarts.ejb.multi.server.app.AppTwo.invokeSecured(java.lang.String): javax.ejb.EJBAccessException: JBAS014502: Invocation on method: public abstract java.lang.String org.jboss.as.quickstarts.ejb.multi.server.app.AppTwo.invokeSecured(java.lang.String) of bean: AppTwoBean is not allowed
[Server:app-twoA] at org.jboss.as.ejb3.security.AuthorizationInterceptor.processInvocation(AuthorizationInterceptor.java:101) [jboss-as-ejb3-7.1.1.Final.jar:7.

I'm making progress though :-)

ejb-multi-server/README.md
((26 lines not shown))
+
+The server configuration is done using CLI batch scripts located in the root of the quickstart folder.
+
+
+
+System requirements
+-------------------
+
+All you need to build this project is Java 6.0 (Java SDK 1.6) or better, Maven 3.0 or better.
+
+The application this project produces is designed to be run on any of the following:
+
+ JBoss Enterprise Application Platform 6.0
+ JBoss Enterprise Application Platform 6.1
+ JBoss AS 7.1
+ JBoss AS 7.2
@pmuir Owner
pmuir added a note

JBoss AS 7.2 doesn't exist.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
ejb-multi-server/README.md
((38 lines not shown))
+ JBoss Enterprise Application Platform 6.0
+ JBoss Enterprise Application Platform 6.1
+ JBoss AS 7.1
+ JBoss AS 7.2
+
+
+Configure Maven
+---------------
+
+If you have not yet done so, you must [Configure Maven](../README.md#mavenconfiguration) before testing the quickstarts.
+
+
+Modify the CLI Scripts (if you are running JBoss Enterprise Application Platform 6.0 or JBoss AS 7.1 servers)
+---------------------------
+
+The CLI scripts provided with this quickstart target JBoss Enterprise Application Platform 6.1 and JBoss AS 7.2. If you are running older versions of the server, JBoss Enterprise Application Platform 6.0 or JBoss AS 7.1, you must modify the scripts to work against these servers.
@pmuir Owner
pmuir added a note

JBoss AS 7.2 doesn't exist, so you'll need to just reference EAP 6.1.

@pmuir Owner
pmuir added a note

In fact, I would probably just target EAP 6.1 with this quickstart, and drop the support for EAP 6.0 entirely.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
ejb-multi-server/app-main/ejb/pom.xml
((45 lines not shown))
+ <artifactId>
+ jboss-as-ejb-multi-server-appTwo-ejb
+ </artifactId>
+ <version>${project.version}</version>
+ <type>ejb-client</type>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin> <!-- must include ejb-plugin to change the EJB version from 2.1 to 3.0 -->
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-ejb-plugin</artifactId>
+ <version>${ejb.plugin.version}</version>
+ <configuration>
+ <ejbVersion>3.0</ejbVersion>
@pmuir Owner
pmuir added a note

Java EE 6 contains EJB 3.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
ejb-multi-server/app-two/ejb/pom.xml
((43 lines not shown))
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.ejb3</groupId>
+ <artifactId>jboss-ejb3-ext-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin> <!-- must include ejb-plugin to change the EJB version from 2.1 to 3.0 -->
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-ejb-plugin</artifactId>
+ <version>${ejb.plugin.version}</version>
+ <configuration>
+ <ejbVersion>3.0</ejbVersion>
@pmuir Owner
pmuir added a note

should be ejb 3.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@pmuir
Owner

Generally looks very good. Comments where they exist are very good, but I think it would be helpful to have more comments, as this is a complex quickstart! Especially introducing some of the POMs (explaining what module they are etc.) I know adding comments is boring, but it does make it much easier to understand!

I'm going to ask @jaikiran to take a look as well :-)

@pmuir
Owner

2 options for @Resource:

1) use mappedName instead
2) Follow Jaikiran's approach at http://jaitechwriteups.blogspot.co.uk/2011/02/resource-and-new-lookup-attribute-how.html

@sgilda
Owner

@pmuir: how the heck did you find Jaikiran's approach? It didn't show up with google! That's much better. :-)
Thanks!

@jaikiran

I'm going to ask @jaikiran to take a look as well :-)

I'll look into this today. Might need some time though since this is a slightly complicated and yet an important quickstart :)

@sgilda
Owner

@wfink , I tested this and now get the following error on the mvn exec:java command. I suspect I need to start over with a fresh 7.2.Snapshot server, but that means I need to rebuild it from source, so it may take a bit.

This was the error:

java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.codehaus.mojo.exec.ExecJavaMojo$1.run(ExecJavaMojo.java:297)
at java.lang.Thread.run(Thread.java:662)
Caused by: java.lang.IllegalStateException: EJBCLIENT000025: No EJB receiver available for handling [appName:appmain, moduleName:ejb, distinctName:] combination for invocation context org.jboss.ejb.client.EJBClientInvocationContext@54c707c
at org.jboss.ejb.client.EJBClientContext.requireEJBReceiver(EJBClientContext.java:588)
at org.jboss.ejb.client.ReceiverInterceptor.handleInvocation(ReceiverInterceptor.java:116)
at org.jboss.ejb.client.EJBClientInvocationContext.sendRequest(EJBClientInvocationContext.java:181)
at org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:136)
at org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:121)
at org.jboss.ejb.client.EJBInvocationHandler.invoke(EJBInvocationHandler.java:104)
at $Proxy16.invokeAll(Unknown Source)
at org.jboss.as.quickstarts.ejb.multi.server.Client.main(Client.java:79)
... 6 more
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------

@sgilda
Owner

@wfink : I tried this with a fresh JBoss AS 7.2.0.Alpha1-SNAPSHOT server.

When I run the script "jboss-as-7.2.0.Alpha1-SNAPSHOT/bin/jboss-cli.sh --connect --file=install-domain.cli", I get this error:
{"JBAS014653: Composite operation failed and was rolled back. Steps that failed:" => {"Operation step-9" => "JBAS014792: Unknown attribute default-missing-method-permissions-deny-access"}}

Line #9 is: /profile=default/subsystem=ejb3:write-attribute(name=default-missing-method-permissions-deny-access, value=false)

Since I'm running 7.2, I didn't comment it out. Is that correct?

When I list the available attribute names, I don't see see: default-missing-method-permissions-deny-access
I do see the following:
[domain@localhost:9999 /] /profile=default/subsystem=ejb3:write-attribute(name=
default-security-domain
default-entity-bean-instance-pool
enable-statistics

default-mdb-instance-pool
default-distinct-name
default-stateful-bean-access-timeout

default-entity-bean-optimistic-locking

default-singleton-bean-access-timeout

default-slsb-instance-pool

in-vm-remote-interface-invocation-pass-by-value

default-sfsb-cache

default-clustered-sfsb-cache

default-resource-adapter-name

Do I need to update my server? My source is at this commit:
commit 4ed76ceef253c568b7475780a92e49a034f540c5
Author: Jason T. Greene jason.greene@redhat.com
Date: Mon Feb 11 23:35:47 2013 -0600
Prepare 7.2.0.Final for pre-releases

@sgilda
Owner

I gave up on AS 7.2.0 Alpha and moved to AS 7.1.1.Final. It worked for me the first time I ran mvn exec:java (step 4 in the instructions), but if I try it again, I get the following error, even if I restart the server:

[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:java (default-cli) on project jboss-as-ejb-multi-server-client: An exception occured while executing the Java class. null: InvocationTargetException: EJBCLIENT000025: No EJB receiver available for handling [appName:appmain, moduleName:ejb, distinctName:] combination for invocation context org.jboss.ejb.client.EJBClientInvocationContext@66b1db5 -> [Help 1]

Will start with a fresh server and try it again.

@sgilda
Owner

Works better with a fresh server.

When I run "bin/jboss-cli.sh --connect --file=deploy-domain.cli", it outputs:
#1 deploy app-one/ear/target/appone.ear --server-groups=quickstart-ejb-multi-appOne-server
#2 deploy app-two/ear/target/apptwo.ear --server-groups=quickstart-ejb-multi-appTwo-server
#3 deploy app-main/ear/target/appmain.ear --server-groups=quickstart-ejb-multi-main-server
#4 deploy app-web/target/appweb.war --server-groups=quickstart-ejb-multi-appWeb-server

It never returns after the last command. Is that to be expected? If so, we should note it in the README file.

This looks great. The instructions are much clearer now. Thanks Wolf!

@sgilda
Owner

@pmuir : Would you like to review this before we merge?

@sgilda
Owner

@pmuir: When you get a chance, can you review?

@pmuir
Owner

I reviewed a way back up, I'm happy with it :-)

@sgilda
Owner

Squashed the commits, rebased, and merged.

@sgilda sgilda closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 25, 2013
  1. @wfink

    new quickstart with a multi server application managed in a domain.

    wfink authored
    the installation an deployment will be handled by CLI scripts.
Commits on Mar 7, 2013
  1. @wfink
Commits on Mar 8, 2013
  1. @wfink

    add corrections after review

    wfink authored
  2. @wfink
Commits on Mar 13, 2013
  1. @wfink
Commits on Mar 25, 2013
  1. @wfink
  2. @wfink
  3. @wfink
Something went wrong with that request. Please try again.