You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by "bear.giles" <Be...@si-intl.com> on 2008/02/26 20:13:12 UTC

ActiveMQ 5.0 & java applets

I'm getting a class initialization error when I try to launch an applet using
ActiveMQ 5.0.0.  The applet is basically a variant of the provided examples,
and they work within the eclipse applet viewer so I know the basic code is
sound.

The error is:

java.lang.NoClassDefFoundError: Could not initialize class
org.apache.activemq.ActiveMQConnection
	at com.si.applet.JmsApplet.<init>(JmsApplet.java:36)
	at
com.si.applet.ProducerConsumerApplet.<init>(ProducerConsumerApplet.java:36)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown
Source)
	at java.lang.reflect.Constructor.newInstance(Unknown Source)
	at java.lang.Class.newInstance0(Unknown Source)
	at java.lang.Class.newInstance(Unknown Source)
	at sun.applet.AppletPanel.createApplet(Unknown Source)
	at sun.plugin.AppletViewer.createApplet(Unknown Source)
	at sun.applet.AppletPanel.runLoader(Unknown Source)
	at sun.applet.AppletPanel.run(Unknown Source)
	at java.lang.Thread.run(Unknown Source)

and I've sometimes see a reference to an access control violation with a
hash map property.  Unfortunately I can't reproduce the error at this time.

This may be a simple applet configuration error -- we're all very familiar
with j2ee, but haven't done much with applets.  I'm loading the j2ee and
activemq libraries via an applet 'archive' property.  (We'll switch to
'object' once we get everything working.  One step at a time. :working:)

-- 
View this message in context: http://www.nabble.com/ActiveMQ-5.0---java-applets-tp15665219s2354p15665219.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: ActiveMQ 5.0 & java applets

Posted by piotr_rezmer <pi...@ens.net.pl>.

bear.giles wrote:
> 
> I'm getting a class initialization error when I try to launch an applet
> using ActiveMQ 5.0.0.  The applet is basically a variant of the provided
> examples, and they work within the eclipse applet viewer so I know the
> basic code is sound.
> 
> The error is:
> 
> java.lang.NoClassDefFoundError: Could not initialize class
> org.apache.activemq.ActiveMQConnection
> 
> 

Check if you have all necessary jars in the same web directory as your
applet. I needed following jars:
activemq-core-4.1.1
backport-util-concurrent-2.1
commons-logging-1.1
geronimo-j2ee-management_1.0_spec1.0
geronimo-jms_1.1_spec-1.0


best regards
Piotr Rezmer

-- 
View this message in context: http://www.nabble.com/ActiveMQ-5.0---java-applets-tp15665219p19407251.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: ActiveMQ 5.0 & java applets

Posted by nickso <kn...@gmail.com>.
Thanks James! Yes, I was curious about giving that a try... think I will!


James.Strachan wrote:
> 
> 2008/9/18 nickso <kn...@gmail.com>:
>>
>> Thanks for your help Bruce... but I've kicked a dead horse long enough.
>> If
>> anyone has any examples that I might try, please post them. If the bug is
>> in
>> log4j, then IMHO, I'd remove it because it's killing activemq.
>> I'm not going the ajax route, and I need some near real-time messages
>> pushed
>> out to clients/applets. Polling is not an option for my app to work...
>> guess
>> I need to start writing some good 'ol fashioned sockets.
>>
>> I hope to hear what others have done. All ears here!
> 
> You could always create a simple STOMP applet using sockets in a few
> hours for communicating to ActiveMQ - then you can miss out
> commons-logging and log4j etc.
> http://activemq.apache.org/stomp.html
> 
> its pretty trivial to communicate with ActiveMQ over stomp by just
> sending and receiving some text over a socket...
> http://stomp.codehaus.org/Protocol
> 
> -- 
> James
> -------
> http://macstrac.blogspot.com/
> 
> Open Source Integration
> http://open.iona.com
> 
> 

-- 
View this message in context: http://www.nabble.com/ActiveMQ-5.0---java-applets-tp15665219p19556574.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: ActiveMQ 5.0 & java applets

Posted by James Strachan <ja...@gmail.com>.
2008/9/18 nickso <kn...@gmail.com>:
>
> Thanks for your help Bruce... but I've kicked a dead horse long enough. If
> anyone has any examples that I might try, please post them. If the bug is in
> log4j, then IMHO, I'd remove it because it's killing activemq.
> I'm not going the ajax route, and I need some near real-time messages pushed
> out to clients/applets. Polling is not an option for my app to work... guess
> I need to start writing some good 'ol fashioned sockets.
>
> I hope to hear what others have done. All ears here!

You could always create a simple STOMP applet using sockets in a few
hours for communicating to ActiveMQ - then you can miss out
commons-logging and log4j etc.
http://activemq.apache.org/stomp.html

its pretty trivial to communicate with ActiveMQ over stomp by just
sending and receiving some text over a socket...
http://stomp.codehaus.org/Protocol

-- 
James
-------
http://macstrac.blogspot.com/

Open Source Integration
http://open.iona.com

Re: ActiveMQ 5.0 & java applets

Posted by nickso <kn...@gmail.com>.
Thanks for your help Bruce... but I've kicked a dead horse long enough. If
anyone has any examples that I might try, please post them. If the bug is in
log4j, then IMHO, I'd remove it because it's killing activemq. 
I'm not going the ajax route, and I need some near real-time messages pushed
out to clients/applets. Polling is not an option for my app to work... guess
I need to start writing some good 'ol fashioned sockets.

I hope to hear what others have done. All ears here!
Thanks again!


bsnyder wrote:
> 
> On Tue, Sep 9, 2008 at 4:10 PM, nickso <kn...@gmail.com> wrote:
>>
>> I have not found an answer for this exact same problem. I've googled
>> until
>> I'm googled... Been working on this for a week now... any suggestions..
>> anyone?? .. please??
> 
> IIRC, applets aren't allowed to access the filesystem and the default
> Log4J config in ActiveMQ defines a file appender. I don't know if
> you've already attempted this, but have you tried defining a new
> log4j.properties file that does not define a file appender (instead
> use System.out or a socket appender or something other than the
> filesystem) and point to that config via the log4j.configuration
> system property?
> 
> Bruce
> -- 
> perl -e 'print
> unpack("u30","D0G)U8V4\@4VYY9&5R\"F)R=6-E+G-N>61E<D\!G;6%I;\"YC;VT*"
> );'
> 
> Apache ActiveMQ - http://activemq.org/
> Apache Camel - http://activemq.org/camel/
> Apache ServiceMix - http://servicemix.org/
> 
> Blog: http://bruceblog.org/
> 
> 

-- 
View this message in context: http://www.nabble.com/ActiveMQ-5.0---java-applets-tp15665219p19556172.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: ActiveMQ 5.0 & java applets

Posted by Bruce Snyder <br...@gmail.com>.
On Tue, Sep 9, 2008 at 4:10 PM, nickso <kn...@gmail.com> wrote:
>
> I have not found an answer for this exact same problem. I've googled until
> I'm googled... Been working on this for a week now... any suggestions..
> anyone?? .. please??

IIRC, applets aren't allowed to access the filesystem and the default
Log4J config in ActiveMQ defines a file appender. I don't know if
you've already attempted this, but have you tried defining a new
log4j.properties file that does not define a file appender (instead
use System.out or a socket appender or something other than the
filesystem) and point to that config via the log4j.configuration
system property?

Bruce
-- 
perl -e 'print unpack("u30","D0G)U8V4\@4VYY9&5R\"F)R=6-E+G-N>61E<D\!G;6%I;\"YC;VT*"
);'

Apache ActiveMQ - http://activemq.org/
Apache Camel - http://activemq.org/camel/
Apache ServiceMix - http://servicemix.org/

Blog: http://bruceblog.org/

Re: ActiveMQ 5.0 & java applets

Posted by nickso <kn...@gmail.com>.
I have not found an answer for this exact same problem. I've googled until
I'm googled... Been working on this for a week now... any suggestions..
anyone?? .. please??


bear.giles wrote:
> 
> I'm getting a class initialization error when I try to launch an applet
> using ActiveMQ 5.0.0.  The applet is basically a variant of the provided
> examples, and they work within the eclipse applet viewer so I know the
> basic code is sound.
> 
> The error is:
> 
> java.lang.NoClassDefFoundError: Could not initialize class
> org.apache.activemq.ActiveMQConnection
> 	at com.si.applet.JmsApplet.<init>(JmsApplet.java:36)
> 	at
> com.si.applet.ProducerConsumerApplet.<init>(ProducerConsumerApplet.java:36)
> 	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
> 	at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
> 	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown
> Source)
> 	at java.lang.reflect.Constructor.newInstance(Unknown Source)
> 	at java.lang.Class.newInstance0(Unknown Source)
> 	at java.lang.Class.newInstance(Unknown Source)
> 	at sun.applet.AppletPanel.createApplet(Unknown Source)
> 	at sun.plugin.AppletViewer.createApplet(Unknown Source)
> 	at sun.applet.AppletPanel.runLoader(Unknown Source)
> 	at sun.applet.AppletPanel.run(Unknown Source)
> 	at java.lang.Thread.run(Unknown Source)
> 
> and I've sometimes see a reference to an access control violation with a
> hash map property.  Unfortunately I can't reproduce the error at this
> time.
> 
> This may be a simple applet configuration error -- we're all very familiar
> with j2ee, but haven't done much with applets.  I'm loading the j2ee and
> activemq libraries via an applet 'archive' property.  (We'll switch to
> 'object' once we get everything working.  One step at a time. :working:)
> 
> 

-- 
View this message in context: http://www.nabble.com/ActiveMQ-5.0---java-applets-tp15665219p19402341.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: ActiveMQ 5.0 & java applets

Posted by "bear.giles" <Be...@si-intl.com>.
I've been able to learn more about the problem.  It appears to be a problem
initializing log4j within the ActiveMQConnectionFactory initialization. 
Others have reported this problem with applets (in log4j, not activemq) in
the log4j mailing list.

I've given the applet full permission in java.policy, so it's not a simple
problem with the security policy. (I'm using 'http://10.10.6.5/*', but it
doesn't work in the main stanza either.)

The stack trace is

java.lang.ExceptionInInitializerError
            at
org.apache.activemq.ActiveMQConnection.<clinit>(ActiveMQConnection.java:106)
            at com.si.applet.JmsApplet.<init>(JmsApplet.java:36)
            at
com.si.applet.ProducerConsumerApplet.<init>(ProducerConsumerApplet.java:36)
            at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
Method)
            at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown
Source)
            at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
            at java.lang.reflect.Constructor.newInstance(Unknown Source)
            at java.lang.Class.newInstance0(Unknown Source)
            at java.lang.Class.newInstance(Unknown Source)
            at sun.applet.AppletPanel.createApplet(Unknown Source)
            at sun.plugin.AppletViewer.createApplet(Unknown Source)
            at sun.applet.AppletPanel.runLoader(Unknown Source)
            at sun.applet.AppletPanel.run(Unknown Source)
            at java.lang.Thread.run(Unknown Source)

Caused by: java.security.AccessControlException: access denied
(java.util.PropertyPermission
org.apache.commons.logging.LogFactory.HashtableImpl read)
            at java.security.AccessControlContext.checkPermission(Unknown
Source)
            at java.security.AccessController.checkPermission(Unknown
Source)
            at java.lang.SecurityManager.checkPermission(Unknown Source)
            at java.lang.SecurityManager.checkPropertyAccess(Unknown Source)
            at java.lang.System.getProperty(Unknown Source)
            at
org.apache.commons.logging.LogFactory.createFactoryStore(LogFactory.java:320)
            at
org.apache.commons.logging.LogFactory.<clinit>(LogFactory.java:1725)
            ... 14 more
 
The obvious solution of putting my own (empty) log4j.properties file in the
default package didn't work, nor did setting the system property to disable
log4j initialization in a static block.

-- 
View this message in context: http://www.nabble.com/ActiveMQ-5.0---java-applets-tp15665219s2354p15721861.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.