JSP + Beans + WebServices = NoClassDefFound :(

G

GoostleeK

Jest sobie aplikacja JSP korzystaj±ca z bean'a:
http://miner.cs.put.poznan.pl/inf48702/currency/index.jsp

No w³a¶nie i tu jest problem:

w katalogu web-inf/classes
jest katalog currency a w nim bean calcBean.class korzystaj±cy z
CurrencyExchangeServiceProxy.class obie klasy siedz± w pakiecie currency.
Proxy zosta³o wygenerowane za pomoc± wsdl2java. nastêpnie ca³y pakiet
kompilujê siê bez b³êdów. Napisa³em pod konsolê programik który korzysta z
klasy currency.CurrencyExchangeServiceProxy i w tym wypadku wszystko dzia³a
ok. Ale gdy chcê wykorzystaæ proxy w jsp i bean'ie to wywala mi:

java.lang.NoClassDefFoundError: CurrencyExchangeServiceProxy
at currency.calcBean.getCalculated(calcBean.java:22)

Czemu? Z góry dziêki.

PS. Serwerem aplikacji jest Oracle 9iAS v9.0.3
 
G

GoostleeK

There's an JSP app:
http://miner.cs.put.poznan.pl/inf48702/currency/index.jsp
and there's also a problem:

I've a directory named currency in web-inf/classes
The directory contains bean calcBean.class which uses
CurrencyExchangeServiceProxy.class. Both classes are packaged in currency
package. Proxy class was generated by wsdl2java (Oracle WSDL Toolkit). There
are no errors while compilng whole package. I wrote a small console app
which uses proxy class and there everything works fine, but when I'm using
this proxy in jsp (in calcBean.class) it throws an ugly exception

java.lang.NoClassDefFoundError: CurrencyExchangeServiceProxy
at currency.calcBean.getCalculated(calcBean.java:22)

Why, why, why?

App Server is Oracle9iAS v9.0.3

and src:
-------------------------------------------------------
package currency;

//import currency.CurrencyExchangeServiceProxy;
public class calcBean {
private String SrcCountry = "";
private String DstCountry = "";
private int Amount = 0;

public void setSrcCountry(String src) {
SrcCountry = src;
}

public void setDstCountry(String dst) {
DstCountry = dst;
}

public void setAmount(String amount) {
Amount = Integer.parseInt(amount);
}

public String getCalculated() throws Exception {
CurrencyExchangeServiceProxy CurrencyService = new
CurrencyExchangeServiceProxy();
return CurrencyService.getRate(SrcCountry, DstCountry).toString();
}

}
----------------------------------------------------------
 
S

Sudsy

GoostleeK wrote:
I've a directory named currency in web-inf/classes
The directory contains bean calcBean.class which uses
CurrencyExchangeServiceProxy.class. Both classes are packaged in currency
package. Proxy class was generated by wsdl2java (Oracle WSDL Toolkit). There
are no errors while compilng whole package. I wrote a small console app
which uses proxy class and there everything works fine, but when I'm using
this proxy in jsp (in calcBean.class) it throws an ugly exception

java.lang.NoClassDefFoundError: CurrencyExchangeServiceProxy
at currency.calcBean.getCalculated(calcBean.java:22)

Why, why, why?

Because you've specified that the classes are in the package
currency. Hence your class files must be in the
WEB-INF/classes/currency directory.
 
G

GoostleeK

Because you've specified that the classes are in the package
currency. Hence your class files must be in the
WEB-INF/classes/currency directory.

Sory, it's my mistake. (in prev. post shuld beWEB-INF/classes/currency, but
I wrote WEB-INF/classes)
I've my classes in WEB-INF/classes/currency dir already and even now I got
this exception... so problem still not solved :(
 
W

William

GoostleeK wrote:

Why, why, why?

App Server is Oracle9iAS v9.0.3

and src:
-------------------------------------------------------
package currency;

//import currency.CurrencyExchangeServiceProxy;
public class calcBean {
private String SrcCountry = "";
private String DstCountry = "";
private int Amount = 0;

public void setSrcCountry(String src) {
SrcCountry = src;
}

public void setDstCountry(String dst) {
DstCountry = dst;
}

public void setAmount(String amount) {
Amount = Integer.parseInt(amount);
}

public String getCalculated() throws Exception {
CurrencyExchangeServiceProxy CurrencyService = new
CurrencyExchangeServiceProxy();
return CurrencyService.getRate(SrcCountry, DstCountry).toString();
}

}
----------------------------------------------------------

Hi I may be barking up the wrong tree here but don't you need to have an
empty constructor?

public calcBean() {}

So that it can be instansiated?
 
G

GoostleeK

Uzytkownik "William said:
GoostleeK wrote:



Hi I may be barking up the wrong tree here but don't you need to have an
empty constructor?

public calcBean() {}

So that it can be instansiated?

Still throws exception..... :(
 
S

Sudsy

GoostleeK said:
Still throws exception..... :(

Why is your import statement commented-out? How does the code
compile if it can't find the class in the correct path? There's
got to be more to this than you've supplied. Considering that
people have troubles when first using packages, I'm guessing
that you've got a copy of your Proxy class WITHOUT a package
statement in the same directory as you're trying to compile
your other class. Show us the EXACT steps you took to generate
the code.
 
G

GoostleeK

Thanks to all ya for good intentions, problem was solved.
Guess what was wrong??? Well, nothing... :) Srcs are correct. The problem is
in Application Server. When I'd created an compiled a bean (for example
foo.class) and then changed that bean and recompiled it, the server didn't
noticed that it had been changed. In this case it serves previously compiled
jsp app. (Even when I deleted my bean from class dir) To apply new changes I
had to rename my bean to foo2.class. After that server compiled new jsp and
new named bean was applied. Another changes requires new name for beans (eg
foo3.class) unless the server is restarted (that is my opinion, but I didn't
check it, because I couldn't catch the admin at my univercity to restart the
server). Then we can use previous names for beans because they are unknown
for newly started server instance so the server will create new servlet
based upon them. In my opinon it uses some kind of cache or something like
that. So sumarrizing everything main reason is that jsp is once compilated
we cannot reuse our beans' names becuse server will use its old contents and
our changes wouldn't be applied, would it be?? Thats the clue...

Please RFC 4 it :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top