Skip navigation

Monthly Archives: January 2009

See you Lufthansa Systems, thank you so much for great moments… 🙂

Welcome PT. Aero Systems Indonesia, let’s build this company… 🙂

Updated 10-05-2010:
Currently i’m not working here anymore. It’s just me, not the company.

Refer to this link to prepare the instalation. Follow every steps mentioned. Here is the steps:

  1. Install openSUSE 11.0 with “C/C++ Development” selection.
  2. Download and Install orarun package. Enable and set password for newly created user oracle by orarun.
  3. Change some environment variables – ORACLE_HOME, ORACLE_SID, TNS_ADMIN in /etc/profile.d/oracle.sh.
  4. Set updated kernel parameters by executing /etc/init.d/oracle start or rcoracle start.
  5. Download and extract Oracle Oracle 11gR1 SW.
  6. login as user oracle and run Oracle Universal Installer “database/runInstaller“. Just follow step by step questions of Oracle installer.

On my experience the setup isn’t working after I try to login (from console) as “oracle” user and start installation (step 6).
The orarun setup create “oracle” user as “System Users” not as “Local Users”, so i decide to delete “oracle” user and make the user manually from Yast –> Security And Users –> User and Group Management. Set Default Group to “oinstall” and additional groups to “dba” and “disk”.

Add user 1 Add user 2

Note: Do not create user from console (using useradd command), the created user not registered with X Server (and i dont know how to register user with X Server 🙂 ), caused failed when try to start installation.

After “oracle” user is created, login as “oracle” user from console then start installation by typing “./runInstaller”. Just fill every required information, and keep press next or press yes if there’s prerequisite check warning, until installation is finished. After installation is finished we can browse to oracle database using Oracle Enterprise Manager Database Control using address https://%5BHOST_NAME%5D:1158/em

Installation Screenshot
oracle01 oracle02

oracle03 oracle04

oracle05 oracle06

oracle07 oracle08

oracle09 oracle10

Starting Oracle database after Reboot/Restarting
Oracle 11g database is not automatically started when we turn on computer/laptop, this is steps to start oracle database:
1. Open console, login as “oracle” user
startoracle01

2. login to sqlplus, then type “STARTUP” to start database.
startoracle02

3. Exit from sqlplus (type “exit”)

4. Start Oracle Net Listener, type “lsnrctl start [LISTENER]”
startoracle03

5. Start Oracle Enterprise Manager Database Control service, type “emctl start dbconsole”
startoracle04

Oracle Enterprise Manager Database Control Screenshot
oem01 oem02oem03

– Extract tar.gz files
> tar –xvzf FILE_NAME.tar.gz

– Compress to tar.gz
> tar –cvzf OUTPUT_FILE_NAME.tar.gz FOLDER_OR_FILES_BEING_COMPRESS/

– Extract tar.bz2 files
> tar –xvjf FILE_NAME.tar.bz2

– Compress to tar.bz2
> tar –cvjf OUTPUT_FILE_NAME.tar.bz2 FOLDER_OR_FILES_BEING_COMPRESS/

– Start/Restart network
> /etc/init.d/network [start|restart]

– Force kill process
> kill -9 [PID]

– Show services/process
> ps aux

– Show services/process with filter
> ps aux | grep [FILTER]

– SSH
> ssh [USERNAME]@[HOST/IP] <enter then enter pasword>

– Change files or folder owner (must as root)
> chown USERNAME:GROUP FILE_NAME_OR_FOLDER_NAME

– Change folder owner and it’s subdirectory (must as root)
> chown -R USERNAME:GROUP FOLDER_NAME

– Start Mysql service on openSuse 11
> service mysql start (as root)
then type “mysql” to login into Mysql

– SCP , transfer files over network
(for single file)
> scp [USER@HOST:]SOURCE_FILE_NAME USER@HOST:DESTINATION_DIRECTORY
(eg. “> scp Twilight.avi root@168.27.10.200:/home/root/movie“)
then enter destination password.

(for directory with multiple files)
> scp –r [USER@HOST:]SOURCE_DIRECTORY_NAME USER@HOST:DESTINATION_DIRECTORY
(eg. “> scp –r Movies budi@140.27.10.240:/home/budi“)
then enter destination password.

Other samples:
“> scp –r budi@140.27.10.240:/home/budi/SexyImage .” , will copies “SexyImage” directory from user “budi” at “140.27.10.240” to our current directory. We need to provide user “budi” password.

– Remove folder
> rm -rf FOLDER_NAME

I use Glassfish for application server. Here is the EJB:
(interface)

package ejb3.bean;
import javax.ejb.Remote;

@Remote
public interface HelloEjb {                                        
    String printHello(String name);
}

(implementation)

package ejb3.bean;
import javax.ejb.Stateless;

@Stateless( name="HelloEjb")
public class HelloEjbBean implements HelloEjb {
    public HelloEjbBean() {}

    public String printHello(String name) {
        return "Hello bro " + name + " welcome to EJB 3";
    }
}

Package it as JAR or EAR, start Glassfish( GLASSFISH_HOME/bin/asadmin start-domain DOMAIN_NAME ) then use Admin Console (default: http://localhost:4848 ) to deploy the EJB.

To call the EJB from servlet we can directly use @EJB annotations, to get the instance of the EJB. In below sample i send the EJB to JSP page:

package ejb3.servlet;

import ejb3.bean.HelloEjb;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.ServletException;
import javax.ejb.EJB;
import java.io.IOException;

public class HelloEjb3Servlet extends HttpServlet {
    @EJB
    private HelloEjb helloEjb;

	protected void doGet(HttpServletRequest request, HttpServletResponse response)
		throws ServletException, IOException
	{
		execute(request, response);
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response)
		throws ServletException, IOException
	{
		execute(request, response);
	}

	private void execute(HttpServletRequest request, HttpServletResponse response)
		throws ServletException, IOException
	{
        	request.setAttribute("helloEjb", helloEjb);
        	request.setAttribute("printHello", helloEjb.printHello("Djunaedi"));
        	request.getRequestDispatcher("/HelloEjb3.jsp").forward(request, response);                            
	}
}

To get EJB instance in JSP using @EJB (inside scriplets) isn’t working, i get null instance. So i use JNDI lookup and that’s work:

<%@ page import="ejb3.bean.HelloEjb" %>
<%@ page import="javax.naming.InitialContext" %>
<%@ page import="javax.naming.Context" %>
<html>
<head><title>Hello EJB 3 !</title></head>
<body>
<%!
HelloEjb helloEjb;
%>
<%
try {
Context context = new InitialContext();
helloEjb = (HelloEjb) context.lookup(HelloEjb.class.getName());
}
catch(Exception e) {
// exception code here
}
%>
<p>
Object HelloEjb Directly : <%= helloEjb %><br>
Print Hello : <%= helloEjb.printHello("Ujang") %>

<p>
Object HeloEjb from Servlet : <%= request.getAttribute("helloEjb") %><br>
Print Hello : <%= request.getAttribute("printHello") %>
</body>
</html>

notes:
Calling EJB 3 using JNDI lookup isn’t the same between Application Server, JNDI lookup name is not standardized. Refer to this article find out more.

References:
http://www.adam-bien.com/roller/abien/entry/ejb_3_portability_issue_why
http://javahowto.blogspot.com/2006/09/default-jndi-name-for-resource-or-ejb.html
https://glassfish.dev.java.net/javaee5/ejb/EJB_FAQ.html