Using Session Bean in JSP differs from the usage in servlets. We can inject session bean in servlets or in another session bean. But in JSP we can not use EJB in the same way. Most common approach would be a JNDI lookup to find the required bean.
First add a reference in deployment descriptor to the session bean.
[sourcecode language="xml"]
<ejb-local-ref>
<ejb-ref-name>AccountTypeFacadeRef</ejb-ref-name>
<ejb-ref-type>Session</ejb-ref-type>
<local>com.my.ejb.AccountTypeFacade</local>
<ejb-link>BankApp-ejb.jar#AccountTypeFacade</ejb-link>
</ejb-local-ref>
[/sourcecode]
is optional.
In JSP use JNDI lookup to find the resource.
[sourcecode language="xml"]
<%
String prefix = "java:comp/env/";
String ejbRefName = "AccountTypeFacadeRef";
String jndiUrl = prefix + ejbRefName;
javax.naming.Context ctx = new javax.naming.InitialContext();
AccountTypeFacade atf = ( AccountTypeFacade ) ctx.lookup( jndiUrl );
List<AccountType> accountTypeList = atf.findAll();
%>
[/sourcecode]
Showing posts with label j2ee. Show all posts
Showing posts with label j2ee. Show all posts
Saturday, November 9, 2013
Saturday, November 3, 2012
Java SOAP Web Service With Apache Axis2 in Netbeans
Requirements
Main Topics
- Setup Development Environment
- Create Web Service
- Deploy Web Service to Tomcat Server
1. Setup Development Environment
Install Axis2 Support Plugin
Go to Tools >> Plugins and open Plugin Manager. Check whether Axis2 Support Plugin is already installed. Otherwise you may need to find it from Available Plugins and install.
Configure Axis2 for Tomcat
Extract axis2.war archive to Tomcat webapps directory.
You can find this directory in your CATALINA_BASE/webapps. If you are not sure where CATALINA_BASE points to, open Services tab and select Tomcat server. Right click Tomcat server and select properties. Most probably you will find it there. If there is no CATALINA_BASE, you have not run your Tomcat before. Start and stop Tomcat to allow this varible generate.
Start or restart the Tomcat server. Tomcat unpacks the axis2.war file into an axis2 folder in CATALINA_BASE/webapps.
Go to Tools >> Options and click Axis2 icon to view deployment options. Set the target location for Axis2 AAR files to your CATALINA_BASE (not TOMCAT_HOME)/ webapps/axis2 directory.
Make sure the Axis2 URL field contains the correct port number for your Tomcat server. To check the port number, start Tomcat (from the Services tab or from Tools -> Servers) and see what port Coyote HTTP/1.1 uses.
select Use Tomcat Manager for Deployment
Check whether username and password of manager role are correct by referring CATALINA_BASE/conf/tomcat-users.xml.
2. Create Web Service
File >> New Project. The New Project wizard opens. From the Java category, select a Java class library project. Click Next.
Right-click the project and choose New >> Other. The New File wizard opens. From the Web Services category, choose Axis2 Service from Java and click Next.
Keep settings as it is in the following wizard and click Next.
In this wizard enter Java Web Service class name and click Finish.
The IDE generates a HelloAxisWorld.java class in the axishello source package and a HelloAxisWorld Axis2 web service that mirrors this Java class.
3. Deploy Web Service to Tomcat Server
Right-click the web service's node. The context menu opens. Select Deploy to Server. The IDE compiles an Axis2 AAR file and copies it to the axis2.war file used by the application server.
If you enabled automatic deployment in Tomcat Manager, axis.war will automatically redeploy to server whenever it 's get updated.
To test the service, expand the web service node to reveal the operations. Right-click the hello:String node and select Test Operation in Browser.
To test the service, expand the web service node to reveal the operations. Right-click the hello:String node and select Test Operation in Browser.
Browser opens with a test value of your variables. You can find test value in the URL. Change it and refresh the page.
Subscribe to:
Posts (Atom)
How to enable CORS in Laravel 5
https://www.youtube.com/watch?v=PozYTvmgcVE 1. Add middleware php artisan make:middleware Cors return $next($request) ->header('Acces...
-
I have already written several posts regarding Android database applications. This post might be similar to those tuts. However this is more...
-
< Requirements Java Development Kit (JDK) NetBeans IDE Apache Axis 2 Apache Tomcat Server Main Topics Setup Development Environ...