Javax.ejb package
Hi
I am new to java, i just want to understand this, does the javax.ejb package come with J2EE jar file or must i download an SDK of some sort to have it my environment? I am currently using NetBeans 5.5 and getting package does not exist error.
Someone please clarify
thank you
Actually the javax.ejb package is not present ordinary J2SE.
It's present in the J2EE v1.4. You can download this from http://java.sun.com/j2ee/1.4/download.html.
The javax.ejb is present in the j2ee.jar which is present in C:\Sun\AppServer\lib\j2ee.jar (installed in C: drive).
Before compiling, classpath needs to declared either in environmental variables or in the command prompt.
classpath: C:\Sun\AppServer\lib\j2ee.jar;C:\Sun\AppServer\bin;
Then your javax.ejb package will be included.
Similar Messages
-
Question about javax.ejb package
Hi,
I am new to J2EE (Recently read a bood about it), and want to start writing some very simple session beans. However, I can't find any jar file that contains the interfaces that I have to implement (e.g. javax.ejb.EJBObject). I read somewhere that it's supposed to be in [JAVA_HOME]/lib/ext/j2ee.jar, but I can't find it.
Also, what is a good starting container enviroment for a beginner? JBoss or Weblogic?
Thanks in advand,
AKIn JBoss (at least the 3.0.4 I have installed right now), you'll find the EJB interfaces in $JBOSS_HOME/server/default/lib/jboss-j2ee.jar . Other parts of the API are in different jar files in the same directory.
-
Bug: weblogic.jar doesn't include the javax.ejb classes
In the
Oracle WebLogic Server 11gR1 (10.3.6) + Coherence -
Package Installer
the C:\Oracle\Middleware\wlserver_10.3\server\lib\weblogic.jar doesn't include the javax.ejb package classes. The javax.ejb package is empty.This is the correct behavior, stub and skeleton classes are generated at deployment time by WebLogic server and stored in a server internal location.
In case you are interested, it is something like: ...\samples\domains\medrec\servers\MedRecServer\cache\EJBCompilerCache\ with file named like HelloSession_gjfaqw_Intf.java., etc.
-danny -
Hi,
Can you any one help me to resolve this exception below. The conext is I
have successfully deplyed a bean and when i call the bean remot method I am
getting the following exception.
Can you any one help me in what situations we will get this type of
exception. I am using jdk1.3
Thanks
Kumar
*************** EXCEPTIN IS BELOW *****************************
PayDateRespondRequestBean lookup successful
creating session bean instance
Calling operation operation
java.io.InvalidClassException: javax.ejb.EJBException; Local class not
compatible: stream classdesc serialVersionUID=-9219910240172116449 local
class serialVers
ionUID=796770993296843510
at
java.io.ObjectStreamClass.validateLocalClass(ObjectStreamClass.java:523)
at java.io.ObjectStreamClass.setClass(ObjectStreamClass.java:567)
at
java.io.ObjectInputStream.inputClassDescriptor(ObjectInputStream.java:936)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:366)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:236)
at
weblogic.rjvm.ClassTableEntry.readExternal(ClassTableEntry.java:29)
at
java.io.ObjectInputStream.inputObject(ObjectInputStream.java:1212)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:386)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:236)
at
weblogic.rjvm.InboundMsgAbbrev.readObject(InboundMsgAbbrev.java:66)
at weblogic.rjvm.InboundMsgAbbrev.read(InboundMsgAbbrev.java:38)
at
weblogic.rjvm.MsgAbbrevJVMConnection.readMsgAbbrevs(MsgAbbrevJVMConnection.j
ava:175)
at
weblogic.rjvm.MsgAbbrevInputStream.readMessageContext(MsgAbbrevInputStream.j
ava:154)
at
weblogic.rjvm.ConnectionManager.dispatch(ConnectionManager.java:582)
at
weblogic.rjvm.t3.T3JVMConnection.dispatch(T3JVMConnection.java:454)
at
weblogic.socket.JavaSocketMuxer.processSockets2(JavaSocketMuxer.java:311)
at
weblogic.socket.JavaSocketMuxer.processSockets(JavaSocketMuxer.java:225)
at
weblogic.socket.SocketReaderRequest.execute(SocketReaderRequest.java:24)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:139)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)
--------------- nested within: ------------------
weblogic.utils.AssertionError: ***** ASSERTION FAILED *****[ Exception
creating response stream ] - with nested exception:
[java.io.InvalidClassException: javax.ejb.EJBException; Local class not
compatible: stream classdesc serialVersionUID=-9219910240172116449 local
class serialVersionUID=796770993296843510]
at
weblogic.rjvm.MsgAbbrevJVMConnection.readMsgAbbrevs(MsgAbbrevJVMConnection.j
ava:184)
at
weblogic.rjvm.MsgAbbrevInputStream.readMessageContext(MsgAbbrevInputStream.j
ava:154)
at
weblogic.rjvm.ConnectionManager.dispatch(ConnectionManager.java:582)
at
weblogic.rjvm.t3.T3JVMConnection.dispatch(T3JVMConnection.java:454)
at
weblogic.socket.JavaSocketMuxer.processSockets2(JavaSocketMuxer.java:311)
at
weblogic.socket.JavaSocketMuxer.processSockets(JavaSocketMuxer.java:225)
at
weblogic.socket.SocketReaderRequest.execute(SocketReaderRequest.java:24)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:139)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)
Error accessing PayDateRespondRequest bean
weblogic.rjvm.PeerGoneException: ; nested exception is:
weblogic.utils.NestedException: ***** ASSERTION FAILED
****[ Exception
creating response stream ] - with nested exception:
[weblogic.utils.AssertionError: ***** ASSERTION FAILED *****[ Exception
creating
response stream ] - with nested exception:Yes, this solved my problem. I was having two versions of javax.ejb package.
--Sajith
"Nils Winkler" <[email protected]> wrote in message
news:[email protected]...
Hi,
it looks like you have two different versions of the same class in the
classpath. Your client is expecting version A, but the server is
returning an instance of version B. Make sure that you only have one
version of the class in your classpath. If you're starting the client as
a separate app, also make sure that it's using the same classes as the
server.
Hope that helps,
Nils
Sajith wrote:
Hi,
Can you any one help me to resolve this exception below. The conext is I
have successfully deplyed a bean and when i call the bean remot method I
am
getting the following exception.
Can you any one help me in what situations we will get this type of
exception. I am using jdk1.3
Thanks
Kumar
*************** EXCEPTIN IS BELOW *****************************
PayDateRespondRequestBean lookup successful
creating session bean instance
Calling operation operation
java.io.InvalidClassException: javax.ejb.EJBException; Local class not
compatible: stream classdesc serialVersionUID=-9219910240172116449 local
class serialVers
ionUID=796770993296843510
at
java.io.ObjectStreamClass.validateLocalClass(ObjectStreamClass.java:523)
atjava.io.ObjectStreamClass.setClass(ObjectStreamClass.java:567)
at
java.io.ObjectInputStream.inputClassDescriptor(ObjectInputStream.java:936)
atjava.io.ObjectInputStream.readObject(ObjectInputStream.java:366)
atjava.io.ObjectInputStream.readObject(ObjectInputStream.java:236)
at
weblogic.rjvm.ClassTableEntry.readExternal(ClassTableEntry.java:29)
at
java.io.ObjectInputStream.inputObject(ObjectInputStream.java:1212)
atjava.io.ObjectInputStream.readObject(ObjectInputStream.java:386)
atjava.io.ObjectInputStream.readObject(ObjectInputStream.java:236)
at
weblogic.rjvm.InboundMsgAbbrev.readObject(InboundMsgAbbrev.java:66)
at weblogic.rjvm.InboundMsgAbbrev.read(InboundMsgAbbrev.java:38)
at
weblogic.rjvm.MsgAbbrevJVMConnection.readMsgAbbrevs(MsgAbbrevJVMConnection.j
ava:175)
at
weblogic.rjvm.MsgAbbrevInputStream.readMessageContext(MsgAbbrevInputStream.j
ava:154)
at
weblogic.rjvm.ConnectionManager.dispatch(ConnectionManager.java:582)
at
weblogic.rjvm.t3.T3JVMConnection.dispatch(T3JVMConnection.java:454)
at
weblogic.socket.JavaSocketMuxer.processSockets2(JavaSocketMuxer.java:311)
at
weblogic.socket.JavaSocketMuxer.processSockets(JavaSocketMuxer.java:225)
at
weblogic.socket.SocketReaderRequest.execute(SocketReaderRequest.java:24)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:139)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)
--------------- nested within: ------------------
weblogic.utils.AssertionError: ***** ASSERTION FAILED *****[ Exception
creating response stream ] - with nested exception:
[java.io.InvalidClassException: javax.ejb.EJBException; Local class not
compatible: stream classdesc serialVersionUID=-9219910240172116449 local
class serialVersionUID=796770993296843510]
at
weblogic.rjvm.MsgAbbrevJVMConnection.readMsgAbbrevs(MsgAbbrevJVMConnection.j
ava:184)
at
weblogic.rjvm.MsgAbbrevInputStream.readMessageContext(MsgAbbrevInputStream.j
ava:154)
at
weblogic.rjvm.ConnectionManager.dispatch(ConnectionManager.java:582)
at
weblogic.rjvm.t3.T3JVMConnection.dispatch(T3JVMConnection.java:454)
at
weblogic.socket.JavaSocketMuxer.processSockets2(JavaSocketMuxer.java:311)
at
weblogic.socket.JavaSocketMuxer.processSockets(JavaSocketMuxer.java:225)
at
weblogic.socket.SocketReaderRequest.execute(SocketReaderRequest.java:24)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:139)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)
Error accessing PayDateRespondRequest bean
weblogic.rjvm.PeerGoneException: ; nested exception is:
weblogic.utils.NestedException: ***** ASSERTION FAILED
****[ Exception
creating response stream ] - with nested exception:
[weblogic.utils.AssertionError: ***** ASSERTION FAILED *****[ Exception
creating
response stream ] - with nested exception:--
============================
[email protected] -
Could not import javax.ejb.* package
On compiling my EJB program the following errors appears
C:\bea\wlserver6.0sp1\samples\examples\ejb\basic\ValidateBean>javac ValidateBean
.java
ValidateBean.java:3: Package javax.ejb not found in import.
import javax.ejb.*;
^
ValidateBean.java:4: Class javax.ejb.CreateException not found in import.
import javax.ejb.CreateException;
^
ValidateBean.java:5: Class javax.ejb.SessionBean not found in import.
import javax.ejb.SessionBean;
^
ValidateBean.java:6: Class javax.ejb.SessionContext not found in import.
import javax.ejb.SessionContext;
^
ValidateBean.java:7: Class javax.naming.InitialContext not found in import.
import javax.naming.InitialContext;
^
ValidateBean.java:8: Class javax.naming.NamingException not found in import.
import javax.naming.NamingException;
^
ValidateBean.java:9: Package javax.sql not found in import.
import javax.sql.*;
^
ValidateBean.java:15: Interface javax.ejb.SessionBean of class examples.ejb.basi
c.ValidateBean.ValidateBean not found.
public class ValidateBean implements SessionBean {
^
8 errors
for these errors do i have to install any other package and
what are the classpath settings required.
and in which *.jar file, these classes and packages are availablejavax.ejb.* is in j2ee.jar
if you use weblogic6.0, you need download ejb20.jar from http://www.weblogic.com
if you use weblogic6.1 ,you need't this file. -
Package javax.ejb not found error
Hi there,
I've downloaded j2se 1.4 and j2ee 1.3.1 and installed it on Windows XP. I set the environment variables as described. When I compile a .java file that imports the javax.ejb.* package, then I get an error "package javax.ejb not found". I feel like an idiot and I know it's something to do with the environment variables. (or just XP, most likely)
Thanks in advance
HoennerHow are you compiling your source? If you're using an IDE then you should edit your project classpath to include the j2ee.jar file (it'll probably be in the lib directory of your J2EE installation).
If you're doing it from the command line then type in SET CLASSPATH, look at the classpath it returns and check that it includes the j2ee.jar file.
Hope this helps. -
Package javax.ejb doesnot exist
I installed weblogic 10 on "D:\weblogic10\"
Java is installed on "C:\java"
I am getting the problem "package javax.ejb doesnot exist"
I came to know that this problem is due to the class path.
and we have to set the class path as "\\weblogic\lib\weblogicaux.jar"
I didn't set find "lib" directory and that jar file also.
I tried weblogic 9.1 and 7.0. But I was unable to find those in my weblogic directory.
How can I set the class path?Thanx for reply.
I'm repeating the problem:
I could not find "lib" directory and that jar file
also.
In the "D:\weblogic", the following are present:
Different direcotries:
jdk150_06,jrockit90_150_06,logs,modules,
tools,user_projects,utils,weblogic100tp,
workshop100tp
Some files:
license.bea, registry,registry,UpdateLicense
Now, plz guide me where I can find the lib directory? and then jar file?
Thankx -
I have read many topics on this forum but i still can't understand. Is the package javax.ejb
application-server specific (weblogic, tomcat....) or is it always the same (whatever application server
i'm running)? Some people suggest to download j2ee.jar from sun page? Is this also ok for Weblogic or do they provide their one .jar file for that?Hi
For weblogic, you have weblogic.jar, which includes javax.ejb.* . -
Package javax.ejb doesn't exist
hi
iam using weblogic 6.0 on windows 98.and i've set the classpath according to setExamplesEnv given and when iam compiling example files in examples folder of server it says that package javax.ejb doesn't exist.and its not able to resolve EJBObject and EJBHome classes.plz let me know the solution for this.
i have set classpath explicitly in autoexec.bat.hi
iam able to compile my classes after removing white spaces in classpath.thanx for the help.but iam unable to run my client program .after setting environment using setExamplesEnv.cmd when iam trying to run my client program.actually iam executing the statefulsession bean example at config\examples directory.the command i used to do that is as follows
java examples.ejb.basic.statefulSession.Client "http:127.0.0.1:7001" it says that "we were unable to get a connection to the weblogic server at "http://127.0.0.1:7001" please make sure that the server is running"
when iam starting ExamplesServer it says <weblogic server>weblogic server started
<weblogic server>Listen thread listening on port 7001
<weblogic server>SSListen thread listening on port 7002
<Error><Performance Pack>unable to load Performance pack using java i/o
java.lang.UnsatisfiedLinkError:no muxer in java.library.path
at java.lang.ClassLoader.loadLibrary()
at java.lang.Runtime.loadLibrary0()
etc
i doubt whether my server is working properly or not.
i have weblogic6.0 and my o/s in windows 98.plz let me know the solution for this. -
How do I include javax.ejb.EJB in a Web Project?
Hi,
I have set up an application with two projects. One is called EJBModel and the other is UserInterface. In my UserInterface project, I am writing a bean class and I want it to access the controller beans created in EJBModel. I created a private type for the controller bean and used the @EJB annotation. When I try to import javax.ejb.EJB I get an error saying it is not found. Other javax packages popup on the list of available imports, but not ejb. How do I include it in the UserInterface project?
Thanks in advance...Yeah your right...let me further explain what I'm doing.
I'm creating a web application using the Model-View-Controller design pattern. Model represents data, View represents data display, and Controller is control. I created the EJBModel project in my web app to contain the model aspect. So it has entity objects and beans to access/manipulate the data. Then I created the UserInterface project to store the web interface - mostly jsps. In the UserInterace project, I need a managed bean that calls methods from the beans created in the EJBModel project. I can do this using the @EJB annotation and creating an instance of the class, but since the files are in separate projects that can't see each other and JDeveloper shows an error because it can't find the necessary file. It is best practice to create two projects to keep both elements distinct.
So I wanted to know the best way to access the files stored in separate projects within the same application. -
SOS: javax.ejb.CreateException: Create failed because primary key is null
Hello,
I am desperately trying to get my application server to create a record through CMP 2. My app server is JRun 4.
Here is the client:
package com.parispano.tests;
import java.util.Date;
import java.util.Properties;
import javax.naming.Context;
import javax.naming.InitialContext;
import com.parispano.account.entity.Account;
import com.parispano.account.entity.AccountHome;
public class ClientEJBDeuxTemp {
public static void main(String[] args) {
System.out.println("\nBegin account DemoClient...\n");
try {
// Create A Demo object, in the server
// Note: the name of the class corresponds to the JNDI
// property declared in the DeploymentDescriptor
// From DeploymentDescriptor ...
// beanHomeName demo.DemoHome
Context ctx = getInitialContext();
AccountHome ahome = (AccountHome) ctx.lookup("AccountEJBHome");
//System.out.println("Creating Demo\n");
Account account = ahome.create("toto","toto", "toto","toto","toto","toto","toto","toto","toto","toto","toto",new Date(),new Date());
catch (Exception e) {
System.out.println(":::::::::::::: Error :::::::::::::::::");
e.printStackTrace();
System.out.println("\nEnd DemoClient...\n");
static String user = "admin";
static String password = "admin";
static String url = "ordi:2908";
* Gets an initial context.
* @return Context
* @exception java.lang.Exception if there is
* an error in getting a Context
static public Context getInitialContext() throws Exception {
Properties p = new Properties();
p.put(Context.INITIAL_CONTEXT_FACTORY, "jrun.naming.JRunContextFactory");
p.put(Context.PROVIDER_URL, url);
if (user != null) {
System.out.println ("user: " + user);
p.put(Context.SECURITY_PRINCIPAL, user);
if (password == null)
password = "";
p.put(Context.SECURITY_CREDENTIALS, password);
return new InitialContext(p);
}and here is the exception I get:
javax.ejb.CreateException: Create failed because primary key is null
I don't understand why I get this as the primary key is "toto" and therefore is not null.
Here is the DD:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN" "http://java.sun.com/dtd/ejb-jar_2_0.dtd">
<ejb-jar>
<display-name>Account EJB</display-name>
<enterprise-beans>
<entity>
<display-name>Account EJB</display-name>
<ejb-name>AccountEJB</ejb-name>
<home>com.parispano.account.entity.AccountHome</home>
<remote>com.parispano.account.entity.Account</remote>
<local-home>com.parispano.account.entity.AccountLocalHome</local-home>
<local>com.parispano.account.entity.AccountLocal</local>
<ejb-class>com.parispano.account.entity.AccountEJB</ejb-class>
<persistence-type>Container</persistence-type>
<prim-key-class>java.lang.String</prim-key-class>
<reentrant>False</reentrant>
<cmp-version>2.x</cmp-version>
<abstract-schema-name>account</abstract-schema-name>
<cmp-field>
<description>Login</description>
<field-name>login</field-name>
</cmp-field>
<!-- -->
<cmp-field>
<description>Password</description>
<field-name>password</field-name>
</cmp-field>
<cmp-field>
<description>Surname</description>
<field-name>surname</field-name>
</cmp-field>
<cmp-field>
<description>First Name</description>
<field-name>firstName</field-name>
</cmp-field>
<cmp-field>
<description>Address One</description>
<field-name>addressOne</field-name>
</cmp-field>
<cmp-field>
<description>Address Two</description>
<field-name>addressTwo</field-name>
</cmp-field>
<cmp-field>
<description>Postcode</description>
<field-name>postcode</field-name>
</cmp-field>
<cmp-field>
<description>City</description>
<field-name>city</field-name>
</cmp-field>
<cmp-field>
<description>Country</description>
<field-name>country</field-name>
</cmp-field>
<cmp-field>
<description>Telephone</description>
<field-name>telephone</field-name>
</cmp-field>
<cmp-field>
<description>Email</description>
<field-name>email</field-name>
</cmp-field>
<cmp-field>
<description>Inscription Date</description>
<field-name>inscriptionDate</field-name>
</cmp-field>
<cmp-field>
<description>Last Visit Date</description>
<field-name>lastVisitDate</field-name>
</cmp-field>
<primkey-field>login</primkey-field>
</entity>
</enterprise-beans>
</ejb-jar>Can anyone tell me why I am getting this exception please?
Thanks in advance,
Julien Martin.Yes, I have set the PK. Actually this is happening when the number of columns are more than 63 columns. After I reduce the number of column, it is working fine.
Is it the actual problem???
fyi, I'm using jboss as the Application Server... -
Import javax.mail package does not exists
Hi,
when i tried to compile the source code for email using jdk1.3.1, it compiled fine. but when i tried to compile using jdk1.4.., it had the following errors such as
import javax.mail package does not exists,
import javax.mail.internet package does not exists
package javax.activation does not exist
Is it because of the jdk version problem???
Pls help meI have the same problem with javax.ejb
Now i've downloaded and installed the j2ee and set my classpath to the j2ee.jar. I've had to make a new path cause i'm running XP.
This doesn't work.
to compile it in Jcreator or JBuilder I can make it work by adding this package (j2ee.jar) in the project settings - required libraries.
But I have to do this for every project again and again.
I can make it work but i thougt the classpath would be enough ??
Bassegio -
package library.client;
import javax.naming.InitialContext;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.lang.reflect.Method;
import java.sql.ResultSet;
import javax.ejb.*;
import javax.naming.*;
import javax.swing.*;
import library.common.*;
@SuppressWarnings("serial")
public class LibraryClient extends JFrame implements ActionListener {
private static LibraryInterface li;
private JTextField book_author = new JTextField(10);
private JTextField book_title = new JTextField(10);
private JTextField book_isbn = new JTextField(10);
private JLabel author_label = new JLabel("Podaj autora:");
private JLabel book_title_label = new JLabel("Podaj tytul ksiazki");
private JLabel isbn_label = new JLabel("Podaj ISBN");
private JTextArea display_books = new JTextArea(20,50);
private JButton search = new JButton("Search");
private ResultSet resultset;
public LibraryClient() {
this("DEFAULT_CONTEXT");
private JPanel createPanel1(){
JPanel panel = new JPanel();
panel.add(author_label);
panel.add(book_author);
panel.add(book_title_label);
panel.add(book_title);
panel.add(isbn_label);
panel.add(book_isbn);
panel.add(search);
////search.setActionCommand("ISBN");
search.addActionListener(this);
return panel;
private JPanel createPanel2(){
JPanel panel = new JPanel();
panel.add(display_books);
return panel;
private JPanel createPanels(){
JPanel panel = new JPanel();
//Use default FlowLayout.
panel.setLayout(new BorderLayout());
panel.add(createPanel1(), BorderLayout.NORTH);
panel.add(createPanel2(), BorderLayout.SOUTH);
return panel;
public LibraryClient(String appType) {
init(appType);
JFrame frame = new JFrame("Library");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
// /final Table table = new Table();
frame.setContentPane(createPanels());
frame.pack();
// /f.setLocationRelativeTo(null);
frame.setVisible(true);
public void actionPerformed(ActionEvent e) {
try {
display_books.setText("");
display_books.setText("Wyszukane Ksiazki\n");
if(!book_author.getText().equals("")){
resultset=li.getBookByAuthor(book_author.getText());
}else if(!book_title.getText().equals("")){
resultset=li.getBookByName(book_title.getText());
}else if(!book_isbn.getText().equals("")){
resultset=li.getBookByISBN(book_isbn.getText());
}else {
System.out.println("Before->resultset=li.getAllBooks()");
resultset=li.getAllBooks();
System.out.println("After->resultset=li.getAllBooks()");
while(resultset.next()){
System.out.println("in while resultset.next()");
String name = resultset.getString("name");
String author =resultset.getString("author");
String isbn = resultset.getString("ISBN");
display_books.append("\n"+ name + " " + author +" "+ isbn);
} catch(Exception exc) { exc.printStackTrace(); }
private void init(String type) {
if (type.equals("JAVA_APP")) li = new library.ejb.LibraryBean();
else if (type.equals("JAVA_CLIENT")) {
try {
InitialContext ic = new InitialContext();
li = (LibraryInterface) ic.lookup("library.common.LibraryInterface");
} catch (NamingException e) {
e.printStackTrace();
public static void main(String[] args) {
if (args.length >= 1) new LibraryClient(args[0]);
else new LibraryClient();
}it throws the exception when it gets to
any of the functions
resultset=li.getBookByAuthor(book_author.getText());
resultset=li.getBookByName(book_title.getText());
resultset=li.getBookByISBN(book_isbn.getText());
resultset=li.getAllBooks();
Please help
Thank YouHi,
I also get the same error.have you got the solution,fi so explain me how to rectify the error
Regards
SamyMohan -
BMP question : got javax.ejb.EJBException error Object state not saved
Could anybody please help me? I could not figure out what i did wrong.
I got the javax.ejb.EJBException error: Object state not saved
when i test the getname() method for findByPrimaryKey() and findAll() methods.
Here is my code:
package org.school.idxc;
import javax.sql.*;
import javax.naming.*;
import javax.ejb.*;
import javax.sql.*;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Enumeration;
import java.util.Vector;
* Bean implementation class for Enterprise Bean: status
public class statusBean implements javax.ejb.EntityBean {
private javax.ejb.EntityContext myEntityCtx;
private int id;
private String name;
private DataSource ds;
private String dbname = "jdbc/idxc";
private Connection con;
* ejbActivate
public void ejbActivate() {
* ejbLoad
public void ejbLoad() {
System.out.println("Entering EJBLoad");
try
Integer primaryKey = (Integer) myEntityCtx.getPrimaryKey();
String sqlstmt = "select id, name from from status where id =?";
con = ds.getConnection();
PreparedStatement stmt = con.prepareStatement(sqlstmt);
stmt.setInt (1,primaryKey.intValue());
ResultSet rs = stmt.executeQuery();
if (rs.next())
this.id = rs.getInt(1);
this.name = rs.getString (2).trim();
stmt.close();
} // if
else
stmt.close();
throw new NoSuchEntityException ("Invalid id " + id);
}// else
} // try
catch (SQLException e)
System.out.println("EJBLOad : " + e.getMessage());
} // catch
finally
try
if (con != null)
con.close();
}// try
catch (SQLException e)
System.out.println("EJBLOad finally" + e.getMessage());
} // catch
}// finally
* ejbPassivate
public void ejbPassivate() {
* ejbRemove
public void ejbRemove() throws javax.ejb.RemoveException {
System.out.println ("Entering ejb Removed");
try
String sqlstmt = "delete from status where id=" + id;
con = ds.getConnection();
Statement stmt = con.createStatement();
stmt.executeUpdate(sqlstmt);
stmt.close();
}// try
catch (SQLException e)
System.out.println("Ejb Remove" + e.getMessage());
} // catch
finally
try
if (con!=null)
con.close();
}// try
catch (SQLException e)
System.out.println ("EJBRemoved " + e.getMessage());
} // catch
} // finally
* ejbStore
public void ejbStore() {
System.out.println("Entering the ejbStore");
try
String sqlstmt = "update status set id=" + id + ",name='" + name + "' where id=" + id;
con = ds.getConnection();
Statement stmt = con.createStatement();
if (stmt.executeUpdate(sqlstmt) != 1)
throw new EJBException ("Object state not saved");
stmt.close();
} // try
catch (SQLException e)
System.out.println ("EJBStore : " + e.getMessage());
}// catch
finally
try
if (con != null)
con.close();
} // try
catch(SQLException e)
System.out.println ("EJBStore finally " + e.getMessage());
} // catch
} // finally
* getEntityContext
public javax.ejb.EntityContext getEntityContext() {
return myEntityCtx;
* setEntityContext
public void setEntityContext(javax.ejb.EntityContext ctx) {
myEntityCtx = ctx;
try
InitialContext initial = new InitialContext();
ds = (DataSource)initial.lookup(dbname);
} // try
catch (NamingException e)
throw new EJBException ("set Entity context : Invalid database");
}// catch
* unsetEntityContext
public void unsetEntityContext() {
myEntityCtx = null;
* ejbCreate
public Integer ejbCreate(Integer key, String name) throws javax.ejb.CreateException {
this.id = key.intValue();
this.name = name;
System.out.println ("Entering ejbCreated!!!");
try
String sqlstmt = "insert into status(id,name) values (" + id + ",'" + (name == null ? "" : name) + "')";
con = ds.getConnection();
Statement stmt = con.createStatement();
stmt.executeUpdate(sqlstmt);
stmt.close();
}// try
catch (SQLException e)
System.out.println("EJBCreate : SQLEXception ");
}// catch
finally
try
if (con!=null)
con.close();
}// try
catch (SQLException e)
System.out.println ("EJB Created Finally : SQLException");
e.getMessage();
} // catch
}// finally
this.id = key.intValue();
this.name = name;
return key ;
* ejbPostCreate
public void ejbPostCreate(Integer id, String name) throws javax.ejb.CreateException {
* ejbFindByPrimaryKey
public Integer ejbFindByPrimaryKey(
Integer key) throws javax.ejb.FinderException {
try
String sqlstmt = "select id from status where id=" + key.intValue();
con = ds.getConnection();
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery(sqlstmt);
if (!rs.next())
throw new ObjectNotFoundException();
} // if
rs.close();
stmt.close();
} // try
catch (SQLException e)
System.out.println ("EJBFindBYPrimaryKey " + e.getMessage());
} // catch
finally
try
if (con!=null)
con.close();
}// try
catch (SQLException e)
System.out.println ("EJB Find by primary key" + e.getMessage());
}// catch
}// finally
return key;
* @return Returns the name.
public String getName() {
return this.name;
* @return Returns id
public int getId() {
return this.id;
* @param name The name to set.
public void setName(String xname) {
this.name = xname;
* ejbFindByLastnameContaining
public Enumeration ejbFindAllNamne () throws javax.ejb.FinderException
try
String sqlstmt = "select id from status order by id";
con = ds.getConnection();
Statement s = con.createStatement();
ResultSet rs = s.executeQuery(sqlstmt);
Vector keys = new Vector();
while (rs.next())
keys.add(new Integer(rs.getInt(1)));
}// while
rs.close();
s.close();
con.close();
return keys.elements();
} // try
catch (SQLException e)
throw new FinderException (e.toString());
} // catch
}Hi,
if you look at your error message you will see the problem. In your code you've missed to implement
public void ejbPassivate {}
so your code looks like this
import java.lang.Object;
import javax.ejb.SessionBean;
import javax.ejb.SessionContext;
import java.rmi.RemoteException;
import java.lang.Math;
import java.util.Random;
import java.io.*;
/** * Title: * Description: * Copyright: Copyright (c) 2001 * Company: * @author * @version 1.0 */
public class DiceEJB implements SessionBean, Serializable
public int[] Roll()
Random rng = new Random();
int[] diceArray = new int[5];
for(int i =0; i < diceArray.length;i++)
diceArray[i] = (Math.abs (rng.nextInt()) % 6) +1;
return diceArray;
public DiceEJB(){}
public void ejbCreate() {}
public void ejbRemove() {}
public void ejbActivate() {}
public void ejbPassivate() {}
public void setSessionContext (SessionContext sc)
private void writeObject(ObjectOutputStream oos) throws IOException
oos.defaultWriteObject();
private void readObject(ObjectInputStream ois) throws ClassNotFoundException, IOException
ois.defaultReadObject();
bye -
Error:ejb package does not exist
I seem to be having a problem with recognizing my EJB packages. I tried putting some quick & dirty java code directly into a jsp to see if I can use the EJB correctly. I keep getting compile errors that the package is not there:
testEJB_jsp.java:8: package com.hs.ejbs does not exist import com.hs.ejbs.*;
testEJB_jsp.java:66: package com.hs.ejbs does not exist
com.hs.ejbs.XreviewsLocalHome rv;
^
testEJB_jsp.java:73: package com.hs.ejbs does not exist
rv = (com.hs.ejbs.XreviewsLocalHome) c.lookup("java:comp/env/ejb/XreviewsBean");
I have tried putting the jar files in several locations and adding those locations to my class path. Apparently I still do not have the right path there.
Here is my code:
<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<%@page import= "javax.ejb.*" %>
<%@page import= "javax.naming.*" %>
<%@page import= "com.hs.ejbs.*" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>testEJB</title>
</head>
<body>
<%
SessionContext context;
com.hs.ejbs.XreviewsLocalHome rv;
try {
javax.naming.Context c = new javax.naming.InitialContext();
rv = (com.hs.ejbs.XreviewsLocalHome) c.lookup("java:comp/env/ejb/XreviewsBean");
} catch(Exception e){
out.println("ejb retrieval error e="+e);
out.println("made it past the ejb retrieval code");
%>
</body>
</html>Assistance will be greatly appreciated.Hi,
You can get this by putting your jar file in
YourApp/WEB-INF/lib folderstill if you are not getting then extract the jar file in
YourApp/WEB-INF/classes folderok
bye
Maybe you are looking for
-
With the new actualization of my ipod, app store wont let me download apps like kik, tumblr and more, i really need kik cause theres were i text my friends, what is happening?
-
Nokia 500 symbian belle w/ NFC support?
i wonder if i upgrade to symbian belle on my nokia 500, will it able to add NFC support? TY Nokia user since 2004. Owned 3310, 1100, 3300, 6600, 6300, 5310, 5130, N79, 5800. Owns: 6230 (still alive) and 500.... Solved! Go to Solution.
-
Exchange Support ~ Push Not Working??
Is there any reason that the Droid 2 Global would not receive push corporate email when set up through corporate sync properly? I have heard mixed feedback from members of the tech world stating that the only Verizon android that support "real push"
-
Upgrade video card for Motion 2 in dual 1.8
I would like to upgrade my GeForce FX 5200 for a more efficient and faster card. Could someone please tell me what are the PCI-X options? Thank you
-
IPhone 5 getting white spots on the aluminum back what can I do?
my iphone 5 is getting white spots of decoloration on the aluminum back does the warranty cover this? if not what can i do? have this happened to you? why is this happening to my iphone?