JBoss AS7 app deployed on a Mac can't find com.apple.laf.AquaLookAndFeel
Asked Answered
F

2

5

We're migrating to JBoss AS7 from an older version of JBoss and we use JFreeChart in one part of our app:

chart = ChartFactory.createStackedBarChart( "", "", "Data", dataset,
            PlotOrientation.HORIZONTAL, true, false, false );

When we hit this line, we get the stack trace below indicating that com.apple.laf.AquaLookAndFeel can't be found. We only see this issue on a Mac which makes sense given the com.apple.laf package name. Running on a Linux server seems to work fine. Is there something we need to do to get AS7 on a Mac to recognize Apple's look and feel classes?

All of the Macs I've tried this on are fully updated as of 4/26/12. I haven't been able to find one that has some of the older JVMs.

Stack trace:

15:38:30,125 SEVERE [javax.enterprise.resource.webcontainer.jsf.lifecycle] (http--0.0.0.0-8080-1) JSF1054: (Phase ID: RENDER_RESPONSE 6, View ID: /blah/blah/blah/blahInfo.xhtml) Exception thrown during phase execution: javax.faces.event.PhaseEvent[source=com.sun.faces.lifecycle.LifecycleImpl@3dc264b1]
15:38:30,129 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/mgmt].[Faces Servlet]] (http--0.0.0.0-8080-1) Servlet.service() for servlet Faces Servlet threw exception: java.lang.ClassNotFoundException: com.apple.laf.AquaLookAndFeel from [Module "deployment.blah_war-1001.0-SNAPSHOT.war:main" from Service Module Loader]
    at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:190)
    at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:468)
    at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:456)
    at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:423)
    at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:398)
    at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:120)
    at java.lang.Class.forName0(Native Method) [classes.jar:1.6.0_31]
    at java.lang.Class.forName(Class.java:247) [classes.jar:1.6.0_31]
    at javax.swing.SwingUtilities.loadSystemClass(SwingUtilities.java:1856) [classes.jar:1.6.0_31]
    at javax.swing.UIManager.setLookAndFeel(UIManager.java:563) [classes.jar:1.6.0_31]
    at javax.swing.UIManager.initializeDefaultLAF(UIManager.java:1329) [classes.jar:1.6.0_31]
    at javax.swing.UIManager.initialize(UIManager.java:1422) [classes.jar:1.6.0_31]
    at javax.swing.UIManager.maybeInitialize(UIManager.java:1410) [classes.jar:1.6.0_31]
    at javax.swing.UIManager.getDefaults(UIManager.java:645) [classes.jar:1.6.0_31]
    at javax.swing.UIManager.getColor(UIManager.java:687) [classes.jar:1.6.0_31]
    at org.jfree.chart.JFreeChart.<clinit>(JFreeChart.java:261) [jfreechart-1.0.13.jar:]
    at org.jfree.chart.ChartFactory.createStackedBarChart(ChartFactory.java:950) [jfreechart-1.0.13.jar:]
    at this.is.our.code.DisplayChart.buildChart(DisplayChart.java:73) [classes:]

For now we've been able to get around this problem by specifying the default look and feel as a system property when starting JBoss:

-Dswing.defaultlaf=javax.swing.plaf.metal.MetalLookAndFeel

This seems like more of a hack so if there's a better way, we'd like to try that.

Fundament answered 26/4, 2012 at 21:13 Comment(6)
Did you check that particular class exists in war? as per exception stack, it was unable find that class from deployment.blah_war.Algicide
@thinksteep, I see it in /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Classes/ui.jar/com/apple/lafFundament
Is JAVA_HOME pointed to correct path? I would suggest post in jboss community forum also.Algicide
@thinksteep, JAVA_HOME is /System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/HomeFundament
Have you tried Using Headless Mode?Mesarch
@trashgod, we are using headless mode.Fundament
P
10

I'm not really sure how to test where exactly to add this, but you need to add com.apple.laf,com.apple.laf.resources as dependencies. In the CLI GUI that ships with AS 7 it's defined in the JAVA_OPTS with -Djboss.modules.system.pkgs=com.apple.laf,com.apple.laf.resources. You could add that to your standalone.conf or domain.conf depending on which mode you're running in.

You might also just try adding Dependencies: com.apple.laf,com.apple.laf.resources to your MANIFEST.MF in your deployment too. I'm not sure if that will work, but it's probably worth a test.

Prankster answered 27/4, 2012 at 16:36 Comment(3)
I added the following to our standalone.conf and it works: if [ "``uname``" = "Darwin" ]; then JBOSS_MODULES_SYSTEM_PKGS="$JBOSS_MODULES_SYSTEM_PKGS,com.apple.laf,com.apple.laf.resources" fiFundament
Great, thanks for letting me know. I think it makes sense to have it there.Prankster
Works with wildfly 9.0.0 final as well.Unfeeling
S
2

Not sure if related, but for me adding fork="true to the <java ...> task in the Ant file helped.

Source: http://lists.apple.com/archives/java-dev/2004/Oct/msg00529.html

Swallowtail answered 24/9, 2014 at 18:17 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.