How to add Log4j to Eclipse RCP project - log4j

I made a plug-in project from this article.
Then I add this plug-in into my project. However, when I try to use it,
I got the following error:
java.lang.NoClassDefFoundError: org/apache/sel4j/log4j/api/LoggerFactory
Caused by: java.lang.ClassNotFoundException: org.apache.sel4j.log4j.api.LoggerFactory
What should I do?

Do you have the same setup as on this screenshot?:
Note, that you need to add your jars to the classpath as shown on the screenshot and not as you would usually do it for your Java application: Right Click-> Add to build path.
Also, I would like to suggest using this article for setting up logging with Eclipse-RCP for the first time. It is more complete and precise.

Related

Hazelcast IMDG 3.12.5 adding log4j dependency to support logging

i have followed the hazelcast docs for supporting log4j using below link:
https://docs.hazelcast.org/docs/latest/manual/html-single/#logging-configuration
but even after doing so i am not able to get hazelcast logs.
queries:
do we explicitly need to add log4j-1.2.17.jar file and add this dependency to pom.xml file? if yes
please let me know what is missing in hazelcast docs
is it possible to troubleshoot and check what is the error ?
There is a note in the Hazelcast reference manual section you've shared. It explains the thing:
If you choose to use log4j, log4j2, or slf4j, you should include the proper dependencies in the classpath.
It means, yes. If you use a logging framework different from the java.util.logging, then you have to provide the implementation yourself.
If you don't provide the proper implementation, the node fails to start:
java -Dhazelcast.logging.type=log4j -jar \
~/.m2/repository/com/hazelcast/hazelcast/3.12.5/hazelcast-3.12.5.jar
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/log4j/Logger
at com.hazelcast.logging.Log4jFactory.createLogger(Log4jFactory.java:29)
at com.hazelcast.logging.LoggerFactorySupport$1.createNew(LoggerFactorySupport.java:32)
at com.hazelcast.logging.LoggerFactorySupport$1.createNew(LoggerFactorySupport.java:30)
at com.hazelcast.util.ConcurrencyUtil.getOrPutIfAbsent(ConcurrencyUtil.java:125)
at com.hazelcast.logging.LoggerFactorySupport.getLogger(LoggerFactorySupport.java:38)
at com.hazelcast.logging.Logger.getLogger(Logger.java:110)
at com.hazelcast.logging.Logger.getLogger(Logger.java:64)
at com.hazelcast.instance.HazelcastInstanceFactory.<clinit>(HazelcastInstanceFactory.java:67)
at com.hazelcast.core.Hazelcast.newHazelcastInstance(Hazelcast.java:91)
at com.hazelcast.core.server.StartServer.main(StartServer.java:46)
Caused by: java.lang.ClassNotFoundException: org.apache.log4j.Logger
at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:352)
at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
... 10 more
log4j is deprecated since 5 years ago, has security vulnerabilities and may not work on newer versions of Java. See here.
Specifying hazelcast.logging.type as log4j indicates to Hazelcast to use whatever Log4j it finds at runtime, as this enables you to chose the version you want.
So your pom needs to build an executable Jar including at least the Hazelcast jar and Log4j jar. Or, you put both on the classpath for runtime.
For me, 3.12.5 fails immediately with
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/log4j/Logger
if I request Log4j but don't provide a Log4j jar on the runtime classpath. If you
don't get that message it could be that the configuration you specified isn't being used.

Howto simply setup an J2EE Project with JSF capability in IntelliJ

I have setup a new Project by selecting J2EE and JSF and let IntelliJ create the project.
IntelliJ also create a Glassfish server for me.
I didn't change any code so far.
When starting the server I get the following Error:
Error during artifact deployment. See server log for details.
Glassfish's log output is:
Critical error during deployment:
javax.faces.FacesException: Unable to find CDI BeanManager
at com.sun.faces.el.ELUtils.tryAddCDIELResolver(ELUtils.java:312)
at com.sun.faces.el.ELUtils.buildFacesResolver(ELUtils.java:242)
at com.sun.faces.application.ApplicationAssociate.initializeELResolverChains(ApplicationAssociate.java:499)
at com.sun.faces.application.ApplicationImpl.performOneTimeELInitialization(ApplicationImpl.java:1404)
at com.sun.faces.application.ApplicationImpl.getELResolver(ApplicationImpl.java:526)
at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:256)
at org.apache.catalina.core.StandardContext.contextListenerStart(StandardContext.java:5043)
at com.sun.enterprise.web.WebModule.contextListenerStart(WebModule.java:592)
Whats wrong here, or how can I simply setup such a project ?

DOTS Task Generates error on load

I'm running Domino 9.0.1 and was attempting to load up the DOTS task. Getting an exception when attempting to load it. From the below it seems DOTS isn't installed. Thought it was part of the default installation for XWork/ Domino 9x releases. Do I need to follow the install steps for 8.5.3, another installer to use?
Exception in thread "main" java.lang.NoClassDefFoundError: com.ibm.dots.launcher.OSGiProfile
Caused by: java.lang.ClassNotFoundException: com.ibm.dots.launcher.OSGiProfile
at java.net.URLClassLoader.findClass(URLClassLoader.java:434)
at java.lang.ClassLoader.loadClass(ClassLoader.java:672)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:358)
at java.lang.ClassLoader.loadClass(ClassLoader.java:638)
Unable to access OSGiProfile class, make sure the launcher.jar is in osgi-dots directory
thanks
-Mark
The DOTS extension started its life as an OpeNTF project by the ingenious David Taieb, because he could and was later adopted for use with the OpenSocial Extensions (the part that renders the Embedded Experiences). So you need to have one of the two installed to get it to work. On a 9.0x server the social extensions are most current DOTS.

Xerces error: org.apache.xerces.impl.dv.dtd.DTDDVFactoryImpl

I'm developing a web application using JSF 2.0, NetBeans 6.9.1, GlassFish Server 3.1, mojarra 2.0.3, and JasperReports 3.7.6. Included in my project library is the jar file "xerces-2.8.0.jar". This file was imported as part of the JasperReports jar file library. Whenever I try to deploy, run, or debug my project through NetBeans, I receive this error:
java.lang.Exception: java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: com.sun.faces.config.ConfigurationException: CONFIGURATION FAILED! DTD factory class org.apache.xerces.impl.dv.dtd.DTDDVFactoryImpl does not extend from DTDDVFactory.
After any change in my project my build fails, and I receive the above error, when I try to deploy, run, or debug it. I have to restart the server and run/debug a second time. I've searched the internet and cannot find a solution to this problem. I've looked at the jar file in question, and and DTDDVFactoryImpl does indeed extend from DTDDVFactory - I don't know why I'm receiving this error. While I can eventually get my project running, it would be much nicer if I wasn't receiving this error.
Can anyone please tell me how I can fix this? Do I need to remove this file from my project library? Do I need to update this file with a newer version/older version?
If you provide your own xerces.jar, you have to do that through the Endorsed Standards Override Mechanism (java -Djava.endorsed.dirs=/path/to/xerces.jar), you are not allowed to just add it on the classpath (and will sooner or later run into trouble if you do). Let me explain.
JAXP is the Java API for XML Processing. The creation of JAXP objects (like parsers, XSLT transfomers, DOM Documents) is done through the factory/factory-method pattern so you can plugin a new JAXP implementation (it has to be newer than the one provided in your JRE). Xerces provides (part of) a JAXP implementation and contains endorsed standards (an endorsed standard is a Java API defined through a standards process other than the Java Community Process, see the Endorsed Standards Override Mechanism). You'll run in all kinds of troubles if you don't use the ESOM.
I got this error when using Selenium with Glassfish. I got around it by copying XML jars (xerces-*, xalan-*, xml-apis*, serialize*) from selenium/libs/ to $AS_HOME/lib/endorsed (for Glassfish 2) or to $AS_HOME/glassfish/lib/endorsed for Glassfish 4.

Java ME bundle Microlog jars with my midlet jar

I'm pretty new to Java ME and i'm trying to use Microlog to handle logging in my midlet.
In eclipse i can reference Microlog jars and it's all good in dev time,
but when i try to launch the application the jars aren't found on the device.
How can i bundle those referenced libs into my midlet?
Someone have any experience with using Microlog in a midlet?
Thanks.
The classes are not found, because they are not inside the final MIDlet suite you are trying to run run in the device. In fact, you can't add external jars directly inside your midlet jar file as J2ME class loader is much more simple than the one in desktop Java. It only loads the classes found inside the midlet jar.
So, you have to extract everything from the Microlog jar and put them into you midlet jar just like you put your own classes and other resources. Probably you can configure your build tool to do this automatically for you.
Eclipse is able to find the classes because you have added the jar into your project's classpath.
Just a little addition. If you are using Eclipse to export the midlet you are able to generate the jar-file including all the classes of the dependencies for you.
Select "Java Build Path" of your project and then "Order and Export". Make sure the microlog jar-files are checked in that list. This will bundle everything into one jar-file.
Hope this helps.
I would recommend to use ProGuard to reduce the size of the final jar. Please read this article to figure out how to do it with Microlog:
http://myossdevblog.blogspot.com/2009/06/using-proguard-to-shrink-microlog.html

Resources