How do you import the log4j jar file into an NSF? - xpages

I wanted to use the Apache POI classes for Streaming Excel spreadsheets. If I import the log4j-1.2.17.jar file into my Jars in the nsf then no XPages will load.
If I don't I get an error:
java.lang.NoSuchMethodError:
javax/xml/stream/XMLEventFactory.newFactory()Ljavax/xml/stream/XMLEventFactory;
at
org.apache.poi.openxml4j.opc.internal.marshallers.PackagePropertiesMarshaller.<clinit>(PackagePropertiesMarshaller.java:45)
at
java.lang.J9VMInternals.initializeImpl(Native Method)
at
java.lang.J9VMInternals.initialize(J9VMInternals.java:201)
at
Since many third party Java apis seem to use the log4j is there a solution? I think this is the same issue that came up with the web services API in XPages?

Your best course of action is to deploy OpenNTF essentials. It contains the POI classes and quite some ready made wrappers to make your life easier.
Deploy into sever via update site nsf approach and deploy to your designer too

Maybe your error can be from the same reason than in that questions. It's a problem of standard jars which come along with the domino installation.
Using External jar causing Error
Axis 1.4 log4j-1.2.8.jar incompatible with XPages?

Howard, put the jar file on the server as well as your local notes client and open up Java security permissions, I think that should do it. Also check that the version you are importing is compatible with Java version on Domino.

Related

Domino 9 Update site osgi class not found

I'm trying to use an Updatesite.nsf to deploy jar to a test server. I can see it in this case the jdbc driver plugin at the server console using the http osgi ss command. But when I use it I get a java.lang.ClassNotFoundException com.mysql.jdbc.driver. What I'm missing or doing wrong. Thank you
The immediate answer is that the code that's calling Class.forName will need to have the MySQL driver in its classloader one way or another, which an XPage or in-NSF Java won't have by default.
To expand on it a bit:
If you're trying to call it from an XPage or Java code in an NSF, it would have to be part of an XPages Library from another plugin, which in turn depends on and re-exports the driver plugin.
If you're trying to call it from another plugin, that other plugin should have a Require-Bundle or Import-Package entry to bring it in.
The class will be available to NSFs by default if you plunk it in jvm/lib/ext, though that admittedly gives up the niceties of OSGi-based deployment.
The reason it works for the XPages JDBC support is that the wrapped plugins created by the wizard in Designer include a special extension point to provide the driver class to the ExtLib code that wants it, but they don't make it automatically available to XPages apps themselves.

Automatic start of a bundle in XPages OSGI runtime on Domino 9

Many sources noted that in Domino 8.5.4/9 should be clean way of starting OSGi bundles on HTTP startup as noted for example here http://lekkimworld.com/2011/07/08/dots_and_automatic_startup_of_bundles.html
Currently I'm still not able to find any documentation about it. Is there some extension point or other configuration that can be used for that?
In Domino 8.5.3 we did ugly hack when bundles pretend to be Dojo libraries and so they started automatically. On one of our Domino 9 test machines this probably causes troubles (every other restart server complains that No Dojo library could be found), so I wanted to cleanup our code.
Bundle is our workflow engine and since it can do some automatic processing we need to start it even when no request comes to server.
The webdav plug-in on OpenNTF has an autostart option. In this case it was linked to the Servlet extension point. That might help. Are you extending Activiti?

How can I use an updated version of JavaMail in XPages?

I have a XPage application where I use JavaMail in one of my managed beans. Currently I have added the jar-file C:\Programme\IBM\Notes\framework\shared\eclipse\plugins\com.ibm.designer.lib.javamail_9.0.0.20130301-1431\lib\mail.jarto the build-path of the manged bean. This works well. But now I want to use a newer version of JavaMail as the Domino server uses version 1.3 but I need version 1.4.x.
I have downloaded the new JavaMail jar-files from Oracle. In Domino Designer (version 9) I add this jar-file to the new design element "Code / Jars" and remove the old jar-files from the build path.
My managed bean is still compiling and running as desired, but if I check the version the bean is using it reports still version 1.3. To check the version number I use the debug property of JavaMail and it's reporting version 1.3 to the domino server console.
Is there a way to tell the domino server to use the jar-files in the application (i.e. the nsf) and not his own? Is there another approach to update the JavaMail version?
The reason I want to use a newer version of JavaMail is as follows: I want to read mails from an imap server with ssl. To avoid the problem of importing ssl-certificates I simply want to trust all hosts. This can be be done via MailSSLSocketFactory, but this is only available since version 1.4.2. Therefore I want to use a newer version of JavaMail.
Another reason I want to use a newer version is as follows: the method "getSortedMessages" of "IMAPFolder" is only available since version 1.4.4. (and so are some other features of JavaMail).
This may be a little too late for you... I think the right approach may be to include the jar file as an OSGi plugin.
I have spent some time to figure out how to do that - and recently succeeded :-) I have described the steps to perform to make this work in two articles. The first is about wrapping a JAR into a plug-in: http://www.dalsgaard-data.eu/blog/wrap-an-existing-jar-file-into-a-plug-in/ - the second is about deployment (and there is a link in the first one).
/John
You can solve the problem by creating an OSGi plug-in that supersedes the one that sports the JavaMail library: com.ibm.designer.lib.javamail.
In order to do that do the following:
Create an OSGi plugin whose id is com.ibm.designer.lib.javamail (Dalsgaard's tutorial on how to do it)
Set its version to a higher number than the one the Domino server is shipped with (to know the version type tell http osgi ss com.ibm.designer.lib.javamail). As of now using 9.0.1.qualifier should be fine
Deploy the plugin either through an update site or by directly copying it under the domino\workspace\applications\eclipse\plugins folder.
Restart the HTTP service. The higher version - the one you created - will now be used
I've got the same problem here, but found a solution. Be warned, this is not the best answer but it will work. Simply download the latest javamail jar here and rename the jar file to 'mail.jar'. Just replace the current file in IBM\Notes\framework\shared\eclipse\plugins\com.ibm.designer.lib.javamail_9.0.0.20130301-1431\lib\mail.jar with this file. Quit the http task and restart it. The code will now work with the latest version.

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.

Classloading conflicts with apache commons classes for app deployed to WAS 6.1

I have an app that uses apache-commons-collections v3.2.1. When I deploy the war file using the WAS 6.1 Integrated Solutions Console I get errors because the commons-collections.jar file in isclite.ear gets loaded before the one that I bundle with my .war file. The problem is that my application requires v3.0.0+ of commons collections. The one in isclite.ear is version 2.1.
So, can I deploy into WAS 6.1 without involving isclite? Can I just drop a war file into a directory somewhere? Is there an option I can select in the process of deploying through the admin interface to skip or remove the isclite.ear dependency?
Thanks.
I had a very similar problem with ColdFusion where a jar in the server was a different version than the one that was needed by my application. I had to call a non-delegating loader (one that doesn't ask the parent to first load the class before loading the requested jar). The loader I used is open source. You can find out about it at
http://groups.google.com/group/javaloader-dev

Resources