Albert Kam

Ranch Hand
+ Follow
since Oct 18, 2007
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 Albert Kam

Hello, thank you for sharing your thought.

But as long as i can remember, i never extend any classes from weld.
12 years ago
JSF
I decided to try out the newer Weld, which is 1.1.0-Final, and here' the maven i added successfully:



Restarting my tomcat on my newly deployed webapp with the newer Weld displays this in the log file :


SEVERE: Error deploying web application directory primebert
java.lang.VerifyError: Cannot inherit from final class
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:632)
at java.lang.ClassLoader.defineClass(ClassLoader.java:616)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:2818)
at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1148)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1643)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1521)
at org.apache.catalina.startup.ContextConfig.checkHandlesTypes(ContextConfig.java:1947)
at org.apache.catalina.startup.ContextConfig.processAnnotationsStream(ContextConfig.java:1910)
at org.apache.catalina.startup.ContextConfig.processAnnotationsJar(ContextConfig.java:1797)
at org.apache.catalina.startup.ContextConfig.processAnnotationsUrl(ContextConfig.java:1756)
at org.apache.catalina.startup.ContextConfig.processAnnotations(ContextConfig.java:1742)
at org.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.java:1245)
at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:874)
at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:317)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:89)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:4974)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:812)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:787)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:607)
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1044)
at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:967)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:472)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1302)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:89)
at org.apache.catalina.util.LifecycleBase.setState(LifecycleBase.java:343)
at org.apache.catalina.util.LifecycleBase.setState(LifecycleBase.java:323)
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1043)
at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:774)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1035)
at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:291)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
at org.apache.catalina.core.StandardService.startInternal(StandardService.java:443)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:724)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
at org.apache.catalina.startup.Catalina.start(Catalina.java:620)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:304)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:432)



So basically, using Weld 1.0.1-Final, this error doesnt happen. Switching to 1.1.1.Final, this happens.

I tried finding all my java source which has the final class, and tried removing the final words, and redeploy, but still, with the same error.

Any ideas why this is happening ?

Thank you !
12 years ago
JSF
Hello ..

Im currently using :

1. Apache tomcat 7
2. JBoss Weld servlet 1.0.1-Final
3. empty beans.xml
4. `<listener-class>org.jboss.weld.environment.servlet.Listener</listener-class>` in the web.xml

I'm currently testing a simple counter @ConversationScoped bean, and the intention is, after beginning the conversation scope, to keep incrementing the counter whenever the button is clicked ..

But it seems that after submit, the bean will **always** be recreated, even after i've begin the conversation in the 1st place.

Here's my simple bean :


Here's my simple jsf view :


Here's the log file for the 1st access :

INFO: Server startup in 12055 ms
beginning conversation : ID: 1, transient: true, timeout: 600000ms


And after the view is displayed, i clicked on the button, and there goes the exception throwing with this log in catalina.out :

beginning conversation : ID: 2, transient: true, timeout: 600000ms
unhandled exception : org.jboss.weld.context.ContextNotActiveException: WELD-001303 No active contexts for scope type @ConversationScoped
cause exception : org.jboss.weld.context.ContextNotActiveException: WELD-001303 No active contexts for scope type @ConversationScoped, cause exception is BE : false


Here's the exception trace from tomcat log :

Apr 4, 2011 3:56:27 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [Faces Servlet] in context with path [/primebert] threw exception [WELD-001303 No active contexts for scope type @ConversationScoped] with root cause
org.jboss.weld.context.ContextNotActiveException: WELD-001303 No active contexts for scope type @ConversationScoped
at org.jboss.weld.conversation.ConversationImpl.checkConversationActive(ConversationImpl.java:79)
at org.jboss.weld.conversation.ConversationImpl.isTransient(ConversationImpl.java:234)
at org.jboss.weld.conversation.ConversationImpl.toString(ConversationImpl.java:199)
at java.text.MessageFormat.subformat(MessageFormat.java:1246)
at java.text.MessageFormat.format(MessageFormat.java:836)
at java.text.Format.format(Format.java:140)
at java.text.MessageFormat.format(MessageFormat.java:812)
at ch.qos.cal10n.MessageConveyor.getMessage(MessageConveyor.java:89)
at org.jboss.weld.logging.WeldMessageConveyor.getMessage(WeldMessageConveyor.java:78)
at org.slf4j.cal10n.LocLogger.debug(LocLogger.java:95)
at org.jboss.weld.conversation.ConversationImpl.switchTo(ConversationImpl.java:190)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.jboss.weld.util.reflection.SecureReflections$13.work(SecureReflections.java:304)
at org.jboss.weld.util.reflection.SecureReflectionAccess.run(SecureReflectionAccess.java:54)
at org.jboss.weld.util.reflection.SecureReflectionAccess.runAsInvocation(SecureReflectionAccess.java:163)
at org.jboss.weld.util.reflection.SecureReflections.invoke(SecureReflections.java:298)
at org.jboss.weld.bean.proxy.ClientProxyMethodHandler.invoke(ClientProxyMethodHandler.java:113)
at org.jboss.weld.util.CleanableMethodHandler.invoke(CleanableMethodHandler.java:43)
at org.jboss.weld.conversation.ConversationImpl_$$_javassist_2.switchTo(ConversationImpl_$$_javassist_2.java)
at org.jboss.weld.conversation.AbstractConversationManager.beginOrRestoreConversation(AbstractConversationManager.java:137)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.jboss.weld.util.reflection.SecureReflections$13.work(SecureReflections.java:304)
at org.jboss.weld.util.reflection.SecureReflectionAccess.run(SecureReflectionAccess.java:54)
at org.jboss.weld.util.reflection.SecureReflectionAccess.runAsInvocation(SecureReflectionAccess.java:163)
at org.jboss.weld.util.reflection.SecureReflections.invoke(SecureReflections.java:298)
at org.jboss.weld.bean.proxy.ClientProxyMethodHandler.invoke(ClientProxyMethodHandler.java:113)
at org.jboss.weld.util.CleanableMethodHandler.invoke(CleanableMethodHandler.java:43)
at org.jboss.weld.conversation.ServletConversationManager_$$_javassist_0.beginOrRestoreConversation(ServletConversationManager_$$_javassist_0.java)
at org.jboss.weld.jsf.WeldPhaseListener.initiateSessionAndConversation(WeldPhaseListener.java:171)
at org.jboss.weld.jsf.WeldPhaseListener.beforeRestoreView(WeldPhaseListener.java:118)
at org.jboss.weld.jsf.WeldPhaseListener.beforePhase(WeldPhaseListener.java:87)
at com.sun.faces.lifecycle.Phase.handleBeforePhase(Phase.java:228)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:99)
at com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:111)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:312)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:306)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:240)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:541)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:383)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:243)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:188)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:288)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)

Any ideas what went wrong ?

Thank you !

12 years ago
JSF
Hello, thank you for your response.

I've just tested the solution suggested in this webpage,
and seems to works cool.

But i was hoping for some other insights for the seamless JSF and spring integration ..

Thank you !
12 years ago
Hello !

I've been preordering this book for so long now from the amazon,
and really cant wait since the review for the older editions for this book is simply encouraging.

Actually i've been testing extensively using the newest Spring with JSF 2,
like using spring el-resolver in the faces-config also, which is cool, since i can @Named my JSF 2 Beans, and make use of @Scope("session") for example,
and iim wondering whether this book discusses about the conversation scope provided by the CDI ?
I mean, can spring become an implementation for CDI api replacing jboss Weld ?

I see that spring bean can have several common scopes like request, session, application,
and even with some hacks i saw and tested from this nice article i can make use of JSF 2 View Scope,
but having conversation scope is kinda a requirement for me, for being able to use tabbed web-application that has their own conversation-session.
And so far i notice that i've to use Weld to make use of the conversation scope.

And i wonder, if in my JSF 2 beans, if i have to stay with Weld to get my conversation scope requirement,
how can i inject spring beans into the JSF beans that are managed by Weld ?

I mean, doing this seems not good ? since one JSF bean managed by 2 containers could be disasterous ?
@Named
@Component
@ConversationScoped
public class MyJSFBean {
...
}

Thank you !

Regards,
Albert Kam
12 years ago
Hello ...

Im sorry to post there coz i was uncertain about where to post. I thought JRE implementation problem fits.

Thanks for the search keywords, this is a good start

Regards,
Albert Kam

14 years ago
Dear Ranchers,

I'm facing difficulties in finding a better way to setup workstations that will be used to access our legacy web-application. The clients' platform is Microsoft Windows XP.

The usual task is like this, and must be repeated across all workstatios :
1. Install Mozilla Firefox 3.x
2. Install specific jre 1.4.x -> to view java applets for report previewing etc
Because this legacy web application still uses an old report engine, it must stick to this jre version, otherwise, the print preview and the print output could be different from what we wanted.
3. Install specific font on Java
Must place several ttf files into font folder of Java

Problem :
- What is the client already has another newer version of JRE installed ? How do i make the Firefox to use the older JRE ?

How-to-make-it-easier problem :
- Can i 'bundle' the JRE along with the specific fonts with the Firefox and 'installs' it without affecting the client's already existing JRE and firefox ? The bundled firefox would use the bundled JRE, not the already installed JRE.
If i were to implement this in linux, i think i could copy the ttf files into the extracted jvm, and simply make a symbolic link of the libjavaplugin_oji.so to the plugin directory of firefox. All that is left is to provide a desktop icon for the bundled firefox, that will use the bundled JRE.

Please share your enlightening ideas ..

Regards,
Albert Kam
14 years ago
Dear all,

Hello and thank you all for your enlightening replies.
I'll dig into JavaFX pretty soon, seems to be very exciting now ..

Anyway i found this link on PacMan game using JavaFX for those who're interested :
http://weblogs.java.net/blog/editors/archives/2009/06/pacman_in_javaf.html



Regards,
Albert Kam
14 years ago
Hello ranchers,

I havent tried Java FX since there was no support for linux until recently, and i dont really understand what Java FX is for ?
But from googling around, i've seen Java FX is compared with other technologies like Adobe Air and Silverlight. And from the screenshots, it seems to me that Java FX is like another GUI app, like Applet or JavaWebStart's GUI app.
I wonder what's the reason for the birth of Java FX when Swing seems to be able to do the GUI stuffs .. ?
Why choose Java FX over Swing ? Or do i completely misunderstand everything here ?

Regards,
Albert Kam
14 years ago
Hello ..

The last code you posted will return 0, because the static variable i has not been incremented
In the original code, the static variable is incremented by the loop 1

So, to make your code more similar to the orignal code, i modified your code by adding the loop code from the original question


Here's the modified code :


Cheers,
Albert Kam
Quackk ... i'm tricked by this loop !!

Thanks for posting this..
Hello

The static int i; is what's get printed in the statement of System.out.print(JMM125.i);
It has the value of 3 since it's used in the loop statement of :


The others has no relevance of the static i variable.

This statement makes use of block variable inside (declare inside loop, and vanishes outside loop)


This code makes use of local variable (declare inside method, and vanishes outside method)


Cheers,
Albert Kam
Hi,

My 2 cents .. i hope others could correct me if i'm mistaken

I think your graph is great !


T two objects eligible for gc are s1.a1.a2.a2 And s1.a1.a2.a2.a2



I think the objects eligible for garbage collection are :
s1.a1.a2.a2 (same with your answer) and ..
s1.a1.a2.
In this case, both of these objects are still connected, but they are consideres an island of unreferenced objects, thus being eligible for garbage collection ..

Cheers,
Albert Kam
Hello ..

I'm still learning generics too. I want to share my current experiment n conclusion so far. Any corrections and thoughts would be very appreciated !

Here's my experiment code :


And here's my temporary conclusions ..

Conclusion for the List<? super MyType>

What you can reference :
- Any lists without the specific parameterized type
- Any lists with any specific parameterized type which is equal or above the declared MyType

What you can add :
- Only the MyType objects

What you can get :
- Only Object type (just like the legacy lists), which means you'll have to downcast to make it a specific type

Cheers,
Albert Kam