Sean Li

Ranch Hand
+ Follow
since Feb 27, 2002
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Sean Li

I posted this question http://seamframework.org/Community/221CR1EntityQueryBug but got no response(never got). So I thought maybe can get some help here.

I generated UserList.java(EntityQuery class) and UserList.xthml using "seam generate-ui" command, based on entity class: User.java.

The problem is: when testing the search function in UserList.xhtml, I got the following error:

WARN [org.jboss.seam.Component] Cannot create Seam component, scope is not active: entityManager(CONVERSATION)



I searched deeper into code and found this seems something inevitable.

After 'Search's clicked, UserList.xhtml will go into JSF restore view phase. Since the page uses 'userList' component, the component needs to be created.

When creating 'userList' component, it needs to call component's @Create method, which is validate(). In EntityQuery's validate method, it checks for entity manager, which is in conversation scope.

The problem is, at that time, conversation context has not been created for the thread. Thus entity manager cannot be created. Exception throws.

An interesting thing is, the conversation context is created just after that, in handleAfterPhase of restore view phase:

SeamPhaseListener.java:


FacesLifecycle.java:



Have I missed anything? Or it's a bug?
13 years ago
thanks guys, I think I almost got it.

ClassNotFoundException is thrown when the class cannot be found on the classpath, no matter it's using reflection or classloader.

NoClassDefFoundError is a subclass of java.lang.LinkageError, which means:

a class has some dependency on another class; however, the latter class has incompatibly changed after the compilation of the former class.



This exception is thrown when the dependent class cannot be found on the classpath or has been changed.

Correct me if I'm wrong.
[ January 04, 2006: Message edited by: Sean Li ]
18 years ago

Originally posted by Roger Chung-Wee:

Some common faults ...

1. The classpath is wrong despite what the programmer thinks.
2. The class or package name is wrong (could be incorrect case).



I should get ClassNotFoundException in such cases

Originally posted by Roger Chung-Wee:

Some common faults ...

3. The class references another class that can't be found.



You are right, this is the case I will get NoClassDefFoundError.
18 years ago

Originally posted by Ken Blair:
No, I mean compiling an application that uses a library and that library not being on the classpath at runtime. i.e. I send you an app that uses JAI and you don't have JAI.



but that's compile time, not run time. isn't it?
[ January 03, 2006: Message edited by: Sean Li ]
18 years ago

Originally posted by Ken Blair:
Compiling an application that uses a library not on the classpath at runtime.

EDIT: In regards to inconsistencies that is.

[ January 03, 2006: Message edited by: Ken Blair ]



Compiling an application at runtime? you mean JIT?
18 years ago
Thanks, guys.

Now I can understand ClassNotFoundException happens when the class cannot be found on classpath.

But I still don't understand NoClassDefFoundError.

NoClassDefFoundError is thrown when the JVM or a class loader can't locate a class (for example because it's not on the classpath).



Why doesn't the JVM throw a ClassNotFoundException when it cannot load a class? And sometimes even the class is on classpath, I still got this NoClassDefFoundError.

The error is thrown when a class couldn't be loaded because of some inconsistencies - a required class wasn't found, classes weren't compatible etc. pp.



This does make sense, but could you please explain how inconsistencies could happen?

You need to go through VMs linking modele concepts to find what you need.



I will have a look of that. thanks.
18 years ago
Someone told me that ClassNotFoundError is got from compile time, and NoClassDefFoundError is got from run time. Is that correct?
18 years ago
I know that Microsoft SDK for Java version 3.2 is a Java 1.1 implementation.

Does anyone know about the Microsoft SDK for Java version 5.0.0? which Java specification version it implements?
18 years ago
Marco, thanks for your reply.

But I still have something not clear.

What's the different between JNP name service and RMI name service? And what does it mean to set the port to be -1 or 0?

Waiting for further explanation. thanks.
18 years ago


A lot of concepts I don't understand.

Is this configuring a JNDI service for JBoss?

I understand we can bind a service to an address and a port, but what does 'all addresses' mean? and what does 'without the JNP invoker listening port' mean?

Thanks and waiting for your help.
[ September 06, 2005: Message edited by: Sean Li ]
18 years ago

Originally posted by Jim Yingst:

So, what to do? Don't use available. Period. (Except maybe for some rare cases too esoteric to get into here.) Just use the fact that the read() method by default will wait until either more data is available, or the stream closes, and will return -1 in the latter case:

Or for greater efficiency, use a buffer to read bytes in bulk:

Of course in this particular example you could just modify your shell script to read from the file directly, rather than copy the bytes to the process input stream.

[ July 05, 2005: Message edited by: Jim Yingst ][/QB]



Thank you, buddy. That resolves all the problems. I don't have to know whether the process is finished or not. Just read the output until I got a -1.

The only thing is the stream I'm reading is the normal output stream. I didn't read the error output, which works for this case. My question is will it have different stuff from error steam? And how do I know which one should I read?

Thanks for the article as well. It really helps me understanding the exec() pitfalls.
18 years ago
thanks for you reply. I think I cannot rely too much on the waitfor() method, because I know it's still a bug in Java when runing in some operating system like windows 2000.

Could you tell me whether there're other ways to walk around?
18 years ago
but I can get something from p.getInputStream(). It's exactely what I want but just slow.

I don't know whether the getErrorStream() can return the same thing. but I reckon I still need to wait until the process finished. am I right?
18 years ago
I tried p.waitFor(). But it seems waiting there forever.

Did I do something wrong?
18 years ago