when i launch the application from sun application server
the console opens throws something i cannt even read what and closes
before the application opened and threw nullpointerexce ption now it suddenly stopped even opening ?
but when i run it form bat with JAVA_CLIENT parameter it throws
javax.ejb.EJBEx ception: nested exception is: java.rmi.Remote Exception:
[code=java]
package library.common;
import java.sql.Result Set;
import javax.ejb.Remot e;
@Remote
public interface LibraryInterfac e {
public ResultSet getBookByAuthor (String author);
public ResultSet getBookByName(S tring name);
public ResultSet getBookByISBN(S tring isbn);
public ResultSet getAllBooks();
}
package library.client;
import javax.naming.In itialContext;
import java.awt.Border Layout;
import java.awt.Color;
import java.awt.FlowLa yout;
import java.awt.event. ActionEvent;
import java.awt.event. ActionListener;
import java.lang.refle ct.Method;
import java.sql.Result Set;
import javax.ejb.*;
import javax.naming.*;
import javax.swing.*;
import library.common. *;
@SuppressWarnin gs("serial")
public class LibraryClient extends JFrame implements ActionListener {
private @EJB LibraryInterfac e 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_labe l = 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_C ONTEXT");
}
private JPanel createPanel1(){
JPanel panel = new JPanel();
panel.add(autho r_label);
panel.add(book_ author);
panel.add(book_ title_label);
panel.add(book_ title);
panel.add(isbn_ label);
panel.add(book_ isbn);
panel.add(searc h);
////search.setActio nCommand("ISBN" );
search.addActio nListener(this) ;
return panel;
}
private JPanel createPanel2(){
JPanel panel = new JPanel();
panel.add(displ ay_books);
return panel;
}
private JPanel createPanels(){
JPanel panel = new JPanel();
//Use default FlowLayout.
panel.setLayout (new BorderLayout()) ;
panel.add(creat ePanel1(), BorderLayout.NO RTH);
panel.add(creat ePanel2(), BorderLayout.SO UTH);
return panel;
}
public LibraryClient(S tring appType) {
init(appType);
JFrame frame = new JFrame("Library ");
frame.setDefaul tCloseOperation (JFrame.EXIT_ON _CLOSE);
// /final Table table = new Table();
frame.setConten tPane(createPan els());
frame.pack();
// /f.setLocationRe lativeTo(null);
frame.setVisibl e(true);
}
public void actionPerformed (ActionEvent e) {
try {
display_books.s etText("");
display_books.s etText("Wyszuka ne Ksiazki\n");
if(!book_author .getText().equa ls("")){
resultset=li.ge tBookByAuthor(b ook_author.getT ext());
}else if(!book_title. getText().equal s("")){
resultset=li.ge tBookByName(boo k_title.getText ());
}else if(!book_isbn.g etText().equals ("")){
resultset=li.ge tBookByISBN(boo k_isbn.getText( ));
}else {
System.out.prin tln("Before->resultset=li.g etAllBooks()");
resultset=li.ge tAllBooks();
System.out.prin tln("After->resultset=li.g etAllBooks()");
}
while(resultset .next()){
System.out.prin tln("in while resultset.next( )");
String name = resultset.getSt ring("name");
String author =resultset.getS tring("author") ;
String isbn = resultset.getSt ring("ISBN");
display_books.a ppend("\n"+ name + " " + author +" "+ isbn);
}
} catch(Exception exc) { exc.printStackT race(); }
}
private void init(String type) {
if (type.equals("J AVA_APP")) li = new library.ejb.Lib raryBean();
else if (type.equals("J AVA_CLIENT")) {
try {
InitialContext ic = new InitialContext( );
li = (LibraryInterfa ce) ic.lookup("libr ary.common.Libr aryInterface");
} catch (NamingExceptio n e) {
e.printStackTra ce();
}
}
}
public static void main(String[] args) {
if (args.length >= 1) new LibraryClient(a rgs[0]);
else new LibraryClient() ;
}
}
package library.ejb;
import java.sql.*;
import javax.ejb.*;
import library.common. *;
@Stateless
public class LibraryBean implements LibraryInterfac e{
ResultSet resultset;
Statement statement;
public LibraryBean() {
}
public ResultSet getBookByAuthor (String author){
try {
Class.forName(" com.mysql.jdbc. Driver");
//Define URL of database server for
// database named JunkDB on the localhost
// with the default port number 3306.
String url =
"jdbc:mysql ://localhost:3306/Library";
//Get a connection to the database for a
Connection connection =DriverManager. getConnection(
url,"kasia", "p1fk0zs0k1em") ;
System.out.prin tln("Connected to the database");
statement = connection.crea teStatement();
resultset = statement.execu teQuery("SELECT * " +
"from books WHERE author = "+author+" ORDER BY name");
connection.clos e();
}catch( Exception e ) {
e.printStackTra ce();
}//end catch
return resultset;
}
public ResultSet getBookByName(S tring name){
try {
Class.forName(" com.mysql.jdbc. Driver");
//Define URL of database server for
// database named JunkDB on the localhost
// with the default port number 3306.
String url =
"jdbc:mysql ://localhost:3306/Library";
//Get a connection to the database for a
Connection connection =DriverManager. getConnection(
url,"kasia", "p1fk0zs0k1em") ;
System.out.prin tln("Connected to the database");
statement = connection.crea teStatement();
resultset = statement.execu teQuery("SELECT * " +
"from books WHERE name ="+name+" ORDER BY name");
connection.clos e();
}catch( Exception e ) {
e.printStackTra ce();
}//end catch
return resultset;
}
public ResultSet getBookByISBN(S tring isbn){
try {
Class.forName(" com.mysql.jdbc. Driver");
//Define URL of database server for
// database named JunkDB on the localhost
// with the default port number 3306.
String url =
"jdbc:mysql ://localhost:3306/Library";
//Get a connection to the database for a
Connection connection =DriverManager. getConnection(
url,"kasia", "p1fk0zs0k1em") ;
System.out.prin tln("Connected to the database");
statement = connection.crea teStatement();
resultset = statement.execu teQuery("SELECT * " +
"from books WHERE ISBN ="+isbn+" ORDER BY name");
connection.clos e();
}catch( Exception e ) {
e.printStackTra ce();
}//end catch
return resultset;
}
public ResultSet getAllBooks(){
try {
Class.forName(" com.mysql.jdbc. Driver");
//Define URL of database server for
// database named JunkDB on the localhost
// with the default port number 3306.
String url =
"jdbc:mysql ://localhost:3306/Library";
//Get a connection to the database for a
Connection connection =DriverManager. getConnection(
url,"kasia", "p1fk0zs0k1em") ;
System.out.prin tln("URL: " + url);
System.out.prin tln("Connection : " + connection);
statement = connection.crea teStatement();
resultset = statement.execu teQuery("SELECT * " +
"from books ORDER BY name");
connection.clos e();
}catch( Exception e ) {
e.printStackTra ce();
}//end catch
return resultset;
}
}
[/code]
thank YOU
the console opens throws something i cannt even read what and closes
before the application opened and threw nullpointerexce ption now it suddenly stopped even opening ?
but when i run it form bat with JAVA_CLIENT parameter it throws
javax.ejb.EJBEx ception: nested exception is: java.rmi.Remote Exception:
[code=java]
package library.common;
import java.sql.Result Set;
import javax.ejb.Remot e;
@Remote
public interface LibraryInterfac e {
public ResultSet getBookByAuthor (String author);
public ResultSet getBookByName(S tring name);
public ResultSet getBookByISBN(S tring isbn);
public ResultSet getAllBooks();
}
package library.client;
import javax.naming.In itialContext;
import java.awt.Border Layout;
import java.awt.Color;
import java.awt.FlowLa yout;
import java.awt.event. ActionEvent;
import java.awt.event. ActionListener;
import java.lang.refle ct.Method;
import java.sql.Result Set;
import javax.ejb.*;
import javax.naming.*;
import javax.swing.*;
import library.common. *;
@SuppressWarnin gs("serial")
public class LibraryClient extends JFrame implements ActionListener {
private @EJB LibraryInterfac e 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_labe l = 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_C ONTEXT");
}
private JPanel createPanel1(){
JPanel panel = new JPanel();
panel.add(autho r_label);
panel.add(book_ author);
panel.add(book_ title_label);
panel.add(book_ title);
panel.add(isbn_ label);
panel.add(book_ isbn);
panel.add(searc h);
////search.setActio nCommand("ISBN" );
search.addActio nListener(this) ;
return panel;
}
private JPanel createPanel2(){
JPanel panel = new JPanel();
panel.add(displ ay_books);
return panel;
}
private JPanel createPanels(){
JPanel panel = new JPanel();
//Use default FlowLayout.
panel.setLayout (new BorderLayout()) ;
panel.add(creat ePanel1(), BorderLayout.NO RTH);
panel.add(creat ePanel2(), BorderLayout.SO UTH);
return panel;
}
public LibraryClient(S tring appType) {
init(appType);
JFrame frame = new JFrame("Library ");
frame.setDefaul tCloseOperation (JFrame.EXIT_ON _CLOSE);
// /final Table table = new Table();
frame.setConten tPane(createPan els());
frame.pack();
// /f.setLocationRe lativeTo(null);
frame.setVisibl e(true);
}
public void actionPerformed (ActionEvent e) {
try {
display_books.s etText("");
display_books.s etText("Wyszuka ne Ksiazki\n");
if(!book_author .getText().equa ls("")){
resultset=li.ge tBookByAuthor(b ook_author.getT ext());
}else if(!book_title. getText().equal s("")){
resultset=li.ge tBookByName(boo k_title.getText ());
}else if(!book_isbn.g etText().equals ("")){
resultset=li.ge tBookByISBN(boo k_isbn.getText( ));
}else {
System.out.prin tln("Before->resultset=li.g etAllBooks()");
resultset=li.ge tAllBooks();
System.out.prin tln("After->resultset=li.g etAllBooks()");
}
while(resultset .next()){
System.out.prin tln("in while resultset.next( )");
String name = resultset.getSt ring("name");
String author =resultset.getS tring("author") ;
String isbn = resultset.getSt ring("ISBN");
display_books.a ppend("\n"+ name + " " + author +" "+ isbn);
}
} catch(Exception exc) { exc.printStackT race(); }
}
private void init(String type) {
if (type.equals("J AVA_APP")) li = new library.ejb.Lib raryBean();
else if (type.equals("J AVA_CLIENT")) {
try {
InitialContext ic = new InitialContext( );
li = (LibraryInterfa ce) ic.lookup("libr ary.common.Libr aryInterface");
} catch (NamingExceptio n e) {
e.printStackTra ce();
}
}
}
public static void main(String[] args) {
if (args.length >= 1) new LibraryClient(a rgs[0]);
else new LibraryClient() ;
}
}
package library.ejb;
import java.sql.*;
import javax.ejb.*;
import library.common. *;
@Stateless
public class LibraryBean implements LibraryInterfac e{
ResultSet resultset;
Statement statement;
public LibraryBean() {
}
public ResultSet getBookByAuthor (String author){
try {
Class.forName(" com.mysql.jdbc. Driver");
//Define URL of database server for
// database named JunkDB on the localhost
// with the default port number 3306.
String url =
"jdbc:mysql ://localhost:3306/Library";
//Get a connection to the database for a
Connection connection =DriverManager. getConnection(
url,"kasia", "p1fk0zs0k1em") ;
System.out.prin tln("Connected to the database");
statement = connection.crea teStatement();
resultset = statement.execu teQuery("SELECT * " +
"from books WHERE author = "+author+" ORDER BY name");
connection.clos e();
}catch( Exception e ) {
e.printStackTra ce();
}//end catch
return resultset;
}
public ResultSet getBookByName(S tring name){
try {
Class.forName(" com.mysql.jdbc. Driver");
//Define URL of database server for
// database named JunkDB on the localhost
// with the default port number 3306.
String url =
"jdbc:mysql ://localhost:3306/Library";
//Get a connection to the database for a
Connection connection =DriverManager. getConnection(
url,"kasia", "p1fk0zs0k1em") ;
System.out.prin tln("Connected to the database");
statement = connection.crea teStatement();
resultset = statement.execu teQuery("SELECT * " +
"from books WHERE name ="+name+" ORDER BY name");
connection.clos e();
}catch( Exception e ) {
e.printStackTra ce();
}//end catch
return resultset;
}
public ResultSet getBookByISBN(S tring isbn){
try {
Class.forName(" com.mysql.jdbc. Driver");
//Define URL of database server for
// database named JunkDB on the localhost
// with the default port number 3306.
String url =
"jdbc:mysql ://localhost:3306/Library";
//Get a connection to the database for a
Connection connection =DriverManager. getConnection(
url,"kasia", "p1fk0zs0k1em") ;
System.out.prin tln("Connected to the database");
statement = connection.crea teStatement();
resultset = statement.execu teQuery("SELECT * " +
"from books WHERE ISBN ="+isbn+" ORDER BY name");
connection.clos e();
}catch( Exception e ) {
e.printStackTra ce();
}//end catch
return resultset;
}
public ResultSet getAllBooks(){
try {
Class.forName(" com.mysql.jdbc. Driver");
//Define URL of database server for
// database named JunkDB on the localhost
// with the default port number 3306.
String url =
"jdbc:mysql ://localhost:3306/Library";
//Get a connection to the database for a
Connection connection =DriverManager. getConnection(
url,"kasia", "p1fk0zs0k1em") ;
System.out.prin tln("URL: " + url);
System.out.prin tln("Connection : " + connection);
statement = connection.crea teStatement();
resultset = statement.execu teQuery("SELECT * " +
"from books ORDER BY name");
connection.clos e();
}catch( Exception e ) {
e.printStackTra ce();
}//end catch
return resultset;
}
}
[/code]
thank YOU
Comment