Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

HelloWorld EJB

 
Ranch Hand
Posts: 198
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
I am unable to run a simple HelloWorld ejb .I am using websphere 4.0 .
I am get an error while deploying .
The code is as follows
**************HelloWorld .java*******************
package myejbpackage;
import javax.ejb.*;
import java.rmi.*;
public interface HelloWorldHome extends EJBHome
{
public HelloWorld create() throws RemoteException , javax.ejb.CreateException ;
}
*********HelloWorldBean ******************
package myejbpackage;
import java.rmi.RemoteException;
import java.util.Properties;
import javax.ejb.*;
public class HelloWorldBean implements SessionBean {
public void ejbActivate() {}
public void ejbCreate() {}
public void ejbPassivate() {}
public void ejbRemove() throws java.rmi.RemoteException {}
public String getTextMessage() {
return "hello world";
}
public void setSessionContext(SessionContext ctx)
{
}
}
************HelloWorldHome .java
package myejbpackage;
import javax.ejb.*;
import java.rmi.*;
public interface HelloWorldHome extends EJBHome {
public HelloWorld create() throws RemoteException , javax.ejb.CreateException ;
}
******************************************************************
All these files reside in C:\JDK..\bin\myejbpackage
I compile these
C:\jdk1.3.1_02\bin>javac myejbpackage\*.java
C:\jdk1.3.1_02\bin>jar cvf HelloWorld.jar myejbpackage\*.class
*************************************************
I deploy these in AAT and I save archive as hello.jar in C:\jdk..\bin.
After I click Generate Now button it gives the following o/p with an error at the end.
Starting workbench.
Creating the project.
Creating EJB Project...
Creating EJB Project... Opening: /Deployed_hello.jar.
Creating EJB Project...
Creating EJB Project... Setting classpath...
Creating EJB Project...
Updating.
Importing EJB Jar.. Importing Jar..
Importing file..
Updating.
Generating deployment code
Processing session bean: HelloWorld
Committing working copy...
Updating.
Committing working copy...
Updating.
Committing working copy...
Updating.
Building: /Deployed_hello.jar.
Invoking Java Builder on /Deployed_hello.jar.
Scrubbing output folder
Analyzing packages
Analyzing sources
Compiling content of ejbModule/myejbpackage
(1 problem found) Copying all resources on the classpath
(1 problem found) Build done
Java build completed
Invoking Validation on /Deployed_hello.jar.
ejbModule/myejbpackage/EJSRemoteStatefulHelloWorld.java(-1): This compilation unit indirectly references the missing type myejbpackage.HelloWorld (typically some required class file is referencing a type outside the classpath)
Shutting down workbench.
Execution Halted: Compilation Errors Reported
1 Errors, 0 Warnings, 0 Informational Messages.
Please advice where am I going wrong???
Thanks in advance.
Buggi.
 
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think you are incorectly creating your jar file.
C:\jdk1.3.1_02\bin>jar cvf HelloWorld.jar myejbpackage\*.class
usually, I would do:
create a new folder, e.g.: c:\test
move myejbpackage there so you have c:\test\myejbpackage
then
c:\test>jar cvf HelloWorld.jar .
This will correctly give you the packages.
Can you look at the jar and see if you see any packages?
 
author
Posts: 3892
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Look at your own code. You declared the class "HelloWorldHome" in the Java file for both the remote and the home.
Kyle
 
Ajai
Ranch Hand
Posts: 198
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ,
Sorry Kyle , I tested the correct code , but pasted wrong one here.
I tried creating the jar as suggested by Thembile Mzantsi .
But result is still the same .I want to highlight that in the AAT i am giving
Bindings as HelloWorldBean .Is that OK??
**************HelloWorld .java*******************
package myejbpackage;
import javax.ejb.*;
import java.rmi.*;
public interface HelloWorld extends EJBObject
{
String getTextMessage() throws RemoteException ;
}
*********HelloWorldBean ******************
package myejbpackage;
import javax.ejb.*;
public class HelloWorldBean implements SessionBean {
public void ejbActivate() {}
public void ejbCreate() {}
public void ejbPassivate() {}
public void ejbRemove() throws java.rmi.RemoteException {}
public String getTextMessage() {
return "hello world";
}
public void setSessionContext(SessionContext ctx)
{
}
}
************HelloWorldHome .java
package myejbpackage;
import javax.ejb.*;
import java.rmi.*;
public interface HelloWorldHome extends EJBHome {
public HelloWorld create() throws RemoteException , javax.ejb.CreateException ;
}
******************************************************************
All these files reside in C:\JDK..\bin\myejbpackage
I compile these as
C:\jdk1.3.1_02\bin>javac myejbpackage\*.java
and creating a jar file like this after putting myejbpackage dir in c:\test
C:\test>jar cvf HelloWorld.jar myejbpackage\*.class
*************************************************
I deploy these in AAT and I save archive as hello.jar in C:\test\Hello.jar.
After I click Generate Now button it gives the following o/p with an error at the end.
Starting workbench.
Creating the project.
Creating EJB Project...
Creating EJB Project... Opening: /Deployed_Hello.jar.
Creating EJB Project...
Creating EJB Project... Setting classpath...
Creating EJB Project...
Updating.
Importing JAR..META-INF/ejb-jar.xml
Importing JAR..META-INF/ibm-ejb-jar-ext.xmi
Importing JAR..META-INF/ibm-ejb-jar-bnd.xmi
Updating.
Generating deployment code
Processing session bean: HelloWorld
Building: /Deployed_Hello.jar.
Invoking Java Builder on /Deployed_Hello.jar.
Scrubbing output folder
Analyzing packages
Analyzing sources
Compiling content of ejbModule/myejbpackage
(1 problem found) Copying all resources on the classpath
(1 problem found) Build done.
Java build completed
ejbModule/myejbpackage/EJSRemoteStatefulHelloWorld.java(-1): This compilation unit indirectly references the missing type myejbpackage.HelloWorld (typically some required class file is referencing a type outside the classpath)
Shutting down workbench.
Execution Halted: Compilation Errors Reported
1 Errors, 0 Warnings, 0 Informational Messages
Any suggesions???
TIA
Buggi
 
Kyle Brown
author
Posts: 3892
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In your remote interface your method is not declared public. Make it so.
Kyle
[ September 20, 2002: Message edited by: Kyle Brown ]
 
Ajai
Ranch Hand
Posts: 198
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Kyle ,
Gives the same error even after making it public.
I am totally clueless why is it not working fine.
TIA,
Buggi
 
This tiny ad is guaranteed to be gluten free.
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic