( 0-5 years ) Bsnl, Infosys, Tcs, IBM, HP are Hiring - Apply Here

SURESHKUMAR.NET FORUMS
Registered Member Login:
Not a member? Register today!



Welcome to the SURESHKUMAR.NET FORUMS.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.




Doubt in EJB deployment in IBM Websphere Application Server

        

Reply
 
LinkBack Thread Tools Display Modes
Old 10-10-06, 10:58 AM   #1 (permalink)
Junior Member
 
Join Date: Oct 2006
Posts: 7
Thanks: 1
Thanked 1 Time in 1 Post
Rep Power: 4 sentil77 is on a distinguished road
Doubt in EJB deployment in IBM Websphere Application Server

This is senthil doing M.Tech. Happy to be a member of this forum. The first day, I wish to post a query related to my project.

Hi all,
I'm doing a project now. I'm using JSP, EJB. The environment is WindowsXP in which I have installed IBM SDK 1.4.2+IBM Websphere Application Server Community Edition+Eclipse 3.2. After developing a Stateless Session Bean Named "HelloBean", I'm able to deploy the jar file in the server, but unable to get response from the server, the request being made from the WebClient, a JSP.
I'm getting the error message HTTP 500 error. Jasper Exception, root cause for which being NullPointerException.
Kindly give me useful suggestion and tips to work in this environment.
How to get around this problem?
Will anyone in this group help me?

/* Hello.java
* Generated by XDoclet - Do not edit!
*/
package com.tutorial;

/**
* Remote interface for Hello.
* @generated
* @wtp generated
*/
public interface Hello
extends javax.ejb.EJBObject
{
/**
*
* @generated //TODO: Must provide implementation for bean method stub */
public java.lang.String sayHello( java.lang.String param )
throws java.rmi.RemoteException;

}
/**
*
*/
package com.tutorial;


/** HelloBean.java
*
*
* A generated session bean
*
* *
*
* @ejb.bean name="Hello"
* description="An EJB named Hello"
* display-name="Hello"
* jndi-name="Hello"
* type="Stateless"
* transaction-type="Container"
*
*
* @generated
*/

public abstract class HelloBean implements javax.ejb.SessionBean {

/**
*
*
* @ejb.create-method view-type="remote"
*
* @generated
*
* //TODO: Must provide implementation for bean create stub
*/
public void ejbCreate() {
}

/**
*
*
* @ejb.interface-method view-type="remote"
*
* @generated
*
* //TODO: Must provide implementation for bean method stub
*/
public String sayHello(String param) {
return "Hello!!!";
}
}

/*
* Generated by XDoclet - Do not edit!
*/
package com.tutorial;

/**HelloHome.java
* Home interface for Hello.
* @generated
* @wtp generated
*/
public interface HelloHome
extends javax.ejb.EJBHome
{
public static final String COMP_NAME="java:comp/env/ejb/Hello";
public static final String JNDI_NAME="Hello";

public com.tutorial.Hello create()
throws javax.ejb.CreateException,java.rmi.RemoteException;

}
/*
* Generated by XDoclet - Do not edit!
*/
package com.tutorial;

/**HelloLocal.java
* Local interface for Hello.
* @generated
* @wtp generated
*/
public interface HelloLocal
extends javax.ejb.EJBLocalObject
{

}
/*
* Generated by XDoclet - Do not edit!
*/
package com.tutorial;

/**HelloLocalHome.java
* Local home interface for Hello.
* @generated
* @wtp generated
*/
public interface HelloLocalHome
extends javax.ejb.EJBLocalHome
{
public static final String COMP_NAME="java:comp/env/ejb/HelloLocal";
public static final String JNDI_NAME="HelloLocal";

public com.tutorial.HelloLocal create()
throws javax.ejb.CreateException;

}
/*
* Generated by XDoclet - Do not edit!
*/
package com.tutorial;

/**HelloSession.java
* Session layer for Hello.
* @generated
* @wtp generated
*/
public class HelloSession
extends com.tutorial.HelloBean
implements javax.ejb.SessionBean
{
public void ejbActivate()
{

}

public void ejbPassivate()
{
}

public void setSessionContext(javax.ejb.SessionContext ctx)
{
}

public void unsetSessionContext()
{
}

public void ejbRemove()
{
}

}
/*
* Generated file - Do not edit!
*/
package com.tutorial;

/**HelloUtil.java
* Utility class for Hello.
* @generated
* @wtp generated
*/
public class HelloUtil
{
/** Cached remote home (EJBHome). Uses lazy loading to obtain its value (loaded by getHome() methods). */
private static com.tutorial.HelloHome cachedRemoteHome = null;
/** Cached local home (EJBLocalHome). Uses lazy loading to obtain its value (loaded by getLocalHome() methods). */
private static com.tutorial.HelloLocalHome cachedLocalHome = null;

private static Object lookupHome(java.util.Hashtable environment, String jndiName, Class narrowTo) throws javax.naming.NamingException {
// Obtain initial context
javax.naming.InitialContext initialContext = new javax.naming.InitialContext(environment);
try {
Object objRef = initialContext.lookup(jndiName);
// only narrow if necessary
if (java.rmi.Remote.class.isAssignableFrom(narrowTo))
return javax.rmi.PortableRemoteObject.narrow(objRef, narrowTo);
else
return objRef;
} finally {
initialContext.close();
}
}

// Home interface lookup methods

/**
* Obtain remote home interface from default initial context
* @return Home interface for Hello. Lookup using JNDI_NAME
*/
public static com.tutorial.HelloHome getHome() throws javax.naming.NamingException
{
if (cachedRemoteHome == null) {
cachedRemoteHome = (com.tutorial.HelloHome) lookupHome(null, com.tutorial.HelloHome.JNDI_NAME, com.tutorial.HelloHome.class);
}
return cachedRemoteHome;
}

/**
* Obtain remote home interface from parameterised initial context
* @param environment Parameters to use for creating initial context
* @return Home interface for Hello. Lookup using JNDI_NAME
*/
public static com.tutorial.HelloHome getHome( java.util.Hashtable environment ) throws javax.naming.NamingException
{
return (com.tutorial.HelloHome) lookupHome(environment, com.tutorial.HelloHome.JNDI_NAME, com.tutorial.HelloHome.class);
}

/**
* Obtain local home interface from default initial context
* @return Local home interface for Hello. Lookup using JNDI_NAME
*/
public static com.tutorial.HelloLocalHome getLocalHome() throws javax.naming.NamingException
{
if (cachedLocalHome == null) {
cachedLocalHome = (com.tutorial.HelloLocalHome) lookupHome(null, com.tutorial.HelloLocalHome.JNDI_NAME, com.tutorial.HelloLocalHome.class);
}
return cachedLocalHome;
}

/** Cached per JVM server IP. */
private static String hexServerIP = null;

// initialise the secure random instance
private static final java.security.SecureRandom seeder = new java.security.SecureRandom();

/**
* A 32 byte GUID generator (Globally Unique ID). These artificial keys SHOULD NOT be seen by the user,
* not even touched by the DBA but with very rare exceptions, just manipulated by the database and the programs.
*
* Usage: Add an id field (type java.lang.String) to your EJB, and add setId(XXXUtil.generateGUID(this)); to the ejbCreate method.
*/
public static final String generateGUID(Object o) {
StringBuffer tmpBuffer = new StringBuffer(16);
if (hexServerIP == null) {
java.net.InetAddress localInetAddress = null;
try {
// get the inet address

localInetAddress = java.net.InetAddress.getLocalHost();
}
catch (java.net.UnknownHostException uhe) {
System.err.println("HelloUtil: Could not get the local IP address using InetAddress.getLocalHost()!");
// todo: find better way to get around this...
uhe.printStackTrace();
return null;
}
byte serverIP[] = localInetAddress.getAddress();
hexServerIP = hexFormat(getInt(serverIP), 8);
}

String hashcode = hexFormat(System.identityHashCode(o), 8);
tmpBuffer.append(hexServerIP);
tmpBuffer.append(hashcode);

long timeNow = System.currentTimeMillis();
int timeLow = (int)timeNow & 0xFFFFFFFF;
int node = seeder.nextInt();

StringBuffer guid = new StringBuffer(32);
guid.append(hexFormat(timeLow, 8));
guid.append(tmpBuffer.toString());
guid.append(hexFormat(node, 8));
return guid.toString();
}

private static int getInt(byte bytes[]) {
int i = 0;
int j = 24;
for (int k = 0; j >= 0; k++) {
int l = bytes[k] & 0xff;
i += l << j;
j -= 8;
}
return i;
}

private static String hexFormat(int i, int j) {
String s = Integer.toHexString(i);
return padHex(s, j) + s;
}

private static String padHex(String s, int i) {
StringBuffer tmpBuffer = new StringBuffer();
if (s.length() < i) {
for (int j = 0; j < i - s.length(); j++) {
tmpBuffer.append('0');
}
}
return tmpBuffer.toString();
}

}


regards,
senthil.

sentil77 is offline Offline   Reply With Quote
Old 12-10-06, 06:42 PM   #2 (permalink)
Moderator
 
t_mohan's Avatar
 
Join Date: Apr 2006
Location: India
Posts: 637
Thanks: 57
Thanked 91 Times in 70 Posts
Rep Power: 20 t_mohan has much to be proud of t_mohan has much to be proud of t_mohan has much to be proud of t_mohan has much to be proud of t_mohan has much to be proud of t_mohan has much to be proud of t_mohan has much to be proud of t_mohan has much to be proud of
Re: Doubt in EJB deployment in IBM Websphere Application Server

Hello Sentil

The code is lil bit clumpsy, but first of all tell me whether you have configured the JNDI in the Websphere application server or not.
To invoke an EJB ,i could not see a connector port over there , if i'am right the RMI over IIOP port to invoke the EJBs using JNDI should be like this iiop://localhost:2809
2809 is default port in Websphere app server.

So thats is why u r getting a null pointer exception, i hope

Please let me know your questions

Thank You,
Mohan.T
t_mohan is offline Offline   Reply With Quote
The Following User Says Thank You to t_mohan For This Useful Post:
sentil77 (19-10-06)
Old 19-10-06, 02:04 PM   #3 (permalink)
Junior Member
 
Join Date: Oct 2006
Posts: 7
Thanks: 1
Thanked 1 Time in 1 Post
Rep Power: 4 sentil77 is on a distinguished road
Re: Doubt in EJB deployment in IBM Websphere Application Server

Hi, I have posted my doubt on EJB invocation thru' JSP. Will anyone get back to my query? regards, Senthil. Wish u a happy diwali.
__________________
R.Senthil, M.Tech II CS,
MNNIT,
Allahabad.(U.P)-211004.
sentil77 is offline Offline   Reply With Quote
Reply

Tags
application , deployment , doubt , ejb , ibm , server , websphere


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Some Loadrunner FAQs kiran2710 Testing Tools & QA 1 25-10-08 12:42 AM
ejb bujjimadhu JAVA Technologies 4 10-09-06 09:15 PM
deploying EJB application in JBOSS application server anitha.s JAVA Technologies 0 06-09-06 02:44 PM
difference between app server &web server Unregistered JAVA Technologies 3 06-09-06 12:06 PM
Servers mahender9885 Aptitude Questions 2 21-02-06 03:02 AM


All times are GMT +6.5. The time now is 07:08 AM.

More Interview Questions Here...

Content Relevant URLs by vBSEO 3.3.2