Wrong library version when moving web application from Tomcat to WebLogic - web

My java web application was working on Apache Tomcat. It needs some third party libraries for its work (jasperreports 3.7.2 in particular). But now it became necessary to move application on WebLogic. And it appears that it uses not the library it was using before (on Tomcat) but some other version of this library (I suspect that one which comes with WebLogic by default). How can i specify concrete version of library and make WebLogic use it? I've never used weblogic before. May be i should type something in deployment descriptors or something like that? Thanks for your replies.

If you have the JAR you want inside WEB-INF/lib in your war, you can tell Weblogic to use that jar over any other jar that might be present in the Classloader.
Use the prefer-web-inf-classes element in a weblogic.xml Web application deployment descriptor (that goes in WEB-INF next to the web.xml)
Here is an example weblogic.xml:
<?xml version="1.0" encoding="UTF-8"?>
<weblogic-web-app
xmlns="http://www.bea.com/ns/weblogic/90"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.bea.com/ns/weblogic/90 http://www.bea.com/ns/weblogic/90/weblogic- web-app.xsd">
<container-descriptor>
<prefer-web-inf-classes>true</prefer-web-inf-classes>
</container-descriptor>
</weblogic-web-app>
Note: In this usage all WEB_INF/lib classes will be preferred over other versions in the classpath.

Related

Log4j Class missing on Weblogic

I have deployed a war file on Oracle Weblogic. War files contain all the required libraries in WEB-INF/lib. But whenever I am trying to visit my webpage, it gives error of
java.lang.NoClassDefFoundError: org/apache/log4j/Logger.
try adding to weblogic.xml :
<container-descriptor>
<prefer-web-inf-classes>true</prefer-web-inf-classes>
</container-descriptor>
(Although this may cause secondary issues with JSF jar's.)
The problem is resolved. One of my custom library using log4j, that one was not able to find log4j. So I created the jar including log4j and its working.

Shared library with newer version of MyFaces on WebSphere 8.5

I'm migrating applications from WebSphere 7.0 to WebSphere 8.5. WebSphere 8.5 uses older version of MyFaces (2.0.2) than we use (2.0.7) so I've tried to configure the newer version in the same way as under WAS 7.0, that is, using shared library.
I've configured shared library with the following jars:
myfaces-api-2.0.7.jar
myfaces-impl-2.0.7.jar
commons-logging-1.1.1.jar
commons-digester-1.8.jar
commons-collections-3.2.jar
commons-codec-1.3.jar
I've checked the option Use an isolated class loader for this shared library . I've got the error:
com.ibm.ws.webcontainer.webapp.WebApp logServletError SRVE0293E:
[Servlet Error]-[Faces Servlet]: java.lang.IllegalStateException: No
Factories configured for this Application. This happens if the
faces-initialization does not work at all - make sure that you
properly include all configuration settings necessary for a basic
faces application and that all the necessary libs are included. Also
check the logging output of your web application and your container
for any exceptions! If you did that and find nothing, the mistake
might be due to the fact that you use some special web-containers
which do not support registering context-listeners via TLD files and a
context listener is not setup in your web.xml. A typical config looks
like this;
<listener>
<listener-class>org.apache.myfaces.webapp.StartupServletContextListener</listener-class>
</listener>
at javax.faces.FactoryFinder.getFactory(FactoryFinder.java:196) at
javax.faces.webapp.FacesServlet.init(FacesServlet.java:112) at
com.ibm.ws.webcontainer.servlet.ServletWrapper.init(ServletWrapper.java:337)
The same configuration worked on WAS 7.0, with the exception that there was an additional jar configured in the shared library:
C:\IBM\SDP\runtimes\base_v7\optionalLibraries\IBM\JSFProviders\WebSphere-MyFaces20-annotation-provider.jar
What is wrong here? Do I need to specify something in place of that WebSphere-MyFaces20-annotation-provider.jar? I wasn't able to find any example of configuring such shared library for WAS 8.5. There's only that for WAS 7.0, that I've used successfully on WAS 7.0.
There is some related discussion in the WASdev forum but apparently no actual answer yet.
https://www.ibm.com/developerworks/community/forums/html/topic?id=d2261080-de03-4aef-97ce-b60c5b8a517b&ps=25

How to override server jar with ones from WEB-INF/lib or use them instead?

i have Web Application which should use JSF 2.0 libraries included in WEB-INF/lib... but it does not... instead of i'm getting exception because my server (JBoss 4.2) also provides JSF libraries...
How can i force my application to use .jar's from WEB-INF/lib ?
Note: When i removed JSF libs from server, my application runs as it should.
Tell JBoss that your WAR already bundles JSF by the following entry in your webapp's web.xml.
<context-param>
<param-name>org.jboss.jbossfaces.WAR_BUNDLES_JSF_IMPL</param-name>
<param-value>true</param-value>
</context-param>
Why can't you use the server versions of those JARs?
You should be writing and testing your application using the same versions of the JARs that the server you deploy to is using. Synch up....I'd either upgrade JBOSS or downgrade your app.
But, if you must, perhaps this document can tell you how:
http://www.datadisk.co.uk/html_docs/java_app/jboss5/jboss5_deployment.htm

Application was not properly initialized at startup (JSF 1.2, WS 7)

i have developed an application using jsf 1.2. it worked fine with apache tomcat 6. i took the war file on production with websphere 7 and deployed the application. i recieved following error.
E com.ibm.ws.webcontainer.servlet.ServletWrapper init SRVE0100E: Uncaught init()
exception created by servlet Faces Servlet in application Products_war:
java.lang.IllegalStateException: Application was not properly initialized at startup,
could not find Factory: javax.faces.context.FacesContextFactory
my classpath file has following entries
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con"
path="org.eclipse.jdt.launching.JRE_CONTAINER/
org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jre6"/>
<classpathentry kind="con"
path="org.eclipse.jst.server.core.container/org.eclipse.jst.server.tomcat.runtimeTarget
/Apache Tomcat v6.0"/>
<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.web.container"/>
<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.module.container"/>
<classpathentry kind="output" path="build/classes"/>
</classpath>
i have made following tries after googling till now..
including following listener in web.xml
<listener>
<listener-class>com.sun.faces.config.ConfigureListener</listener-class>
</listener>
and removed jsf-api and jsf-impl from the lib folder of my application but to no avail.
plz help.
thanks in advance
WAS 7 already ships with JSF 1.2 bundled which can be either the "Sun RI" (Mojarra) or "MyFaces" (from Apache) implementation which is configureable in the WAS admin console. You need to remove the JSF JAR files from /WEB-INF/lib and you need to remove the listener from the web.xml.
See also:
WAS 7 developer guide - Configuring JavaServer Faces implementation
Another thing to check: We have myfaces configured as a shared library on WebSphere. In troubleshooting my local configuration I had to set the shared library to "Use an isolated class loader for this shared library"
This is identified as part of the requirements for running a third-party JSF implementer:
Be Aware: If the you want to use a third party JSF implementation that is not shipped with the product, then:
Keep the configuration set to the SUN RI.
Add the third party listener to the web.xml file that is required.
Add the third party implementation Java archive (JAR) files to the
application as an isolated shared library.
http://pic.dhe.ibm.com/infocenter/wasinfo/v7r0/index.jsp?topic=/com.ibm.websphere.express.doc/info/exp/ae/tweb_jsf.html
Maybe this will help someone if the first answer doesn't work for them.

tomahawk jar not getting loaded weblogic portal 10.3

I have made a jsf 1.1 portlet in weblogic 10.3, but in one scenario I need tomahawk library help. I just dropped the jar file and supporting ones in lib folder in WEB-INF in my portal application, but when I hit the url it gives me error of NoClassdef..... exception for classes in tomahawk jar and jsp compilation fails.
I am new to weblogic, I'll really appreciate if someoe can suggest what I might be doing wrong.
The setup is that whole application goes as ear. Ear contains app-inf and weblogic specific xml files, main portal web application goes as war inside this ear. I am using workshop that ships with weblogic portal 10.3. Well this project was migrated from weblogic portal 9.3.
Note: I dont want to but this jar in domain/lib, when I did so I dont know why it loaded my application and all the class defined in servlet startup with load-on-startups got fired well before time and none of the classes were found by server.
Jsf libraries currently used are in shared mode.
java.lang.NoClassDefFoundError means the runtime version of the class in the classpath is not the same as that at compile time.
Note: it's not a ClassNotFoundException.
Your problem is in fact multiple versions of the class being found.
Also, JSF 1.2 libraries are bundled with Weblogic server, so it can cause this exception if one of those classes is again added into the WEB-INF/lib. Which is the exact class on which the error is thrown, do you have multiple versions of Tomahawk lying around in WEB-INF and domain/lib?
Remove the extras and keep one in WEB-INF/lib only.
Update:
The docs state that Separate JSF 1.2 and JSTL 1.2 JAR files and implementation JAR files are also provided in the WL_HOME/server/lib/api.jar file.
Check for that class javax/faces/webapp/UIComponentELTag in this jar.
I still think you should use the weblogic.xml setting to force the WEB-INF/lib class to get loaded in preference to that in server/lib with
<container-descriptor>
<prefer-web-inf-classes>true</prefer-web-inf-classes>
</container-descriptor>
Being new to weblogic and infrastructure I messed up with different versions. Figured out it was just because of incompatible jars.

Resources