javax.servlet-api-3.0.1.jar not loded in liferay 6.1 and tomcat 7.0 - liferay

With a custom plugin deployed, I'm getting the following error message and the webapp doesn't start:
validateJarFile(E:\6.1\liferay-portal-tomcat-6.1.1-ce-ga2-20120731132656558\liferay-portal-6.1.1-ce-ga2\tomcat-7.0.27\temp\4-SiteSkills_CMS-portlet\WEB-INF\lib\javax.servlet-api-3.0.1.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class
Why and how can I get rid of this message?

Do not package the servlet jar in an application's WEB-INF/lib directory. This jar comes with the appserver, tomcat in this case.
As your error message states the file to be in the temp folder: make sure you don't only remove the file from the webapps directory, but do a redeploy. Or just empty your temp folder

Related

Hotswapper plugin is not reloading classes in web project

Hotswapper plugin is not reloading classes in web project (JSF, maven based) but resource files(xhtml) are reloading smoothly.
Following are my configurations.
Server: Wildfly11
Java version : 1.8.0_191
DCEVM Vesion: 25.71-b01-dcevmlight-26
Hot swapper agent : 1.3.1-SNAPSHOT (2019-04-02)
Java Option to start server: -XXaltjvm=dcevm -javaagent:/home/user/HotSwapAgent/hotswap-agent-1.3.1-SNAPSHOT.jar=autoHotswap=true -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=8000"
I have added the following attributes in hotswap-agent.properties file of war project
LOGGER=trace
extraClasspath=/home/user/HotSwapTest/target/classes
webappDir=/home/user/HotSwapTest/src/main/webapp
watchResources=/home/user/HotSwapTest/target/classes
autoHotswap=true
autoHotswap.port=8000
In server startup i'm getting the following message.
'org.hotswap.agent.plugin.hotswapper.HotswapperPlugin' initialized in ClassLoader 'ModuleClassLoader for Module
Now i'm compiling the java file and the class is updated in the class folder. But the changes are not reloaded in the wildfly server.
How to make reloading of classes?
Note: Hotswapp is working fine if i'm attching netbeans debugger.

log4j 2.0.2 on slf4j 1.7.7 can't find log4j.xml on startup?

I'm trying to get slf4j 1.7.7 to use log4j 2.0.2 as its implementation. I think I have all the necessary JARs in my WAR and the log4j.xml just gets dropped into the classes directory, but when my webapp starts up, it can't locate the log4j.xml. When I crack open the WAR, I can see it in the WEB-INF/classes, so it should be on the classpath. What am I missing?
meta-inf/manifest.mf
index.html
...
WEB-INF/web.xml
WEB-INF/classes/log4j.xml
...
WEB-INF/lib/log4j-api-2.0.2.jar
...
WEB-INF/lib/slf4j-api-1.7.7.jar
...
WEB-INF/lib/log4j-core-2.0.2.jar
WEB-INF/lib/log4j-slf4j-impl-2.0.2.jar
...
Jetty has this in its stderrout.log file, recording its disappointment...
ERROR StatusLogger No log4j2 configuration file found. Using default configuration: logging only errors to the console.
Well that is subtle. log4j-core-2.0.2 isn't looking for log4j.xml, its looking for log4j2.xml. The FAQ page http://logging.apache.org/log4j/2.x/faq.html has, in bold, "By default, Log4j looks for a configuration file named log4j2.xml (not log4j.xml) in the classpath." Renaming my file to log4j2.xml gets it found. Now I've got to make it correct.
2014-10-24 10:34:53,542 ERROR Unknown object "property" of type org.apache.logging.log4j.core.config.Property is ignored.
2014-10-24 10:34:53,545 ERROR Unknown object "logger" of type org.apache.logging.log4j.core.config.LoggerConfig is ignored.
2014-10-24 10:34:53,546 ERROR Unknown object "root" of type org.apache.logging.log4j.core.config.LoggerConfig is ignored.

log4j and Weblogic Server : Logs not getting generated

I have multiple ears,For certain Ears I want log4j details to be picked from Weblogic level and for certain application I have application level log4j.xml bundled with ear.
Copied wllog4j.jar and Log4j-x.x.x.jar to Server classpath
Added the following JAVA_OPTION in
startWebLogic.sh -Dlog4j.Configuration=Mylog4j.xml
and add the "Mylog4j.xml" in the Server Classpath
as :
SAVE_JAVA_OPTIONS="${JAVA_OPTIONS}" -Dlog4j.Configuration=Mylog4j.xml
SAVE_CLASSPATH="${CLASSPATH}:/apps/myfiles/MyLog4j.xml"
For application which have application level log4j.xml ,I have mentioned prefer-application-packages in weblogic-application.xml
<prefer-application-packages>
<package-name>org.apache.log4j.*</package-name>
</prefer-application-packages>
But the logs are not getting generated for those application which has there log4j.xml
Also,Just for info : Applications are using slf4j/commons-logging and log4j
Please suggest !!!
The issue was related to classloading : Below line in weblogic-applicaton.xml does the trick.
<prefer-application-packages>
<package-name>org.apache.log4j.*</package-name>
<package-name>org.apache.*</package-name>
<package-name>org.slf4j.*</package-name>
</prefer-application-packages>
Follow below steps
1) copy log4j.jar and wllog4j.jar in server lib folder
2) copy your log4j.xml in server domain folder
3) change setDomaninEnv.xml to point to your log4j.xml file ex: LOG4J_CONFIG_FILE="${DOMAIN_HOME}/log4j.xml"

Is it possible to deploy JSF-Web-Apps in WSO2 AS 5.2?

I tried the following steps:
At first I installed the feature "WSO2 Carbon - J2EE Runtime Environment" in the AS. Then I created a new dynamic web project in Eclipse with Servlet Module 2.5 and a configuration for JSF 1.2 using Myfaces 1.2.9 and a JSF-HTML-Template. After I had written "hello" in the view, I tested it with "run on server" in Eclipse and it runs. Then I created a WAR-File and deployed it in the AS with pasting the file in "asroot/repository/deployment/server/webapps".
Then I tried the page and it throws this error:
"/NewFile.jsp(2,57) PWC6188: The absolute uri: http://java.sun.com/jsf/core cannot be resolved in either web.xml or the jar files deployed with this application
Caused by:
org.apache.jasper.JasperException - /NewFile.jsp(2,57) PWC6188: The absolute uri: http://java.sun.com/jsf/core cannot be resolved in either web.xml or the jar files deployed with this application"
I tried it also on a local Tomcat-Server with the same result like in Eclipse.
The libs in the WAR are:
javax.servlet.jsp.jstl-1.2.1.jar
javax.servlet.jsp.jstl-api-1.2.1.jar
commons-beanutils-1.7.0.jar
commons-codec-1.3.jar
commons-collections-3.2.jar
commons-digester-1.8.jar
commons-discovery-0.4.jar
commons-logging-1.1.1.jar
myfaces-api-1.2.9.jar
myfaces-impl-1.2.9.jar
This could be a classloading issue. Please put webapp-classloading.xml file in META-INF directory of your web application with following configurations
<?xml version="1.0" encoding="ISO-8859-1"?>
<Classloading xmlns="http://wso2.org/projects/as/classloading">
<Environments>Tomcat</Environments>
</Classloading>
Refer http://docs.wso2.org/display/AS520/Webapp+ClassLoading

JSF how upgrade to Mojarra 2.1.21 in Netbeans7.1 (just sub jsf-api.jar and jsf-impl.jar fails)

I want to upgrade from JSF implementation Mojarra 2.1.3 in Netbeans7.1 (Glassfish 3.1.1).
You might ask first why I don't just upgrade to Netbeans7.3, and the reasons include that it it runs Glassfish 3.1.2.2 and that I have some other 3rd party software in my web application that is not yet compatible with Glassfish higher than 3.1.1, and besides it only has Mojarra 2.1.6 anyway.
I used to be able to upgrade Mojarra by simply replacing jsf-api.jar and jsf-impl.jar under /glassfish/modules, but that does not work with:
https://maven.java.net/content/repositories/releases/com/sun/faces/jsf-api/2.1.21/jsf-api-2.1.21.jar
https://maven.java.net/content/repositories/releases/com/sun/faces/jsf-impl/2.1.21/jsf-impl-2.1.21.jar
I get the following error:
SEVERE: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.sun.enterprise.glassfish.bootstrap.GlassFishMain.main(GlassFishMain.java:97)
at com.sun.enterprise.glassfish.bootstrap.ASMain.main(ASMain.java:55)
Caused by: com.sun.enterprise.module.ResolveError: Failed to start Bundle Id [301] State [INSTALLED] [org.glassfish.web.weld-integration(Weld integration for glassfish):3.1.1]
at org.jvnet.hk2.osgiadapter.OSGiModuleImpl.start(OSGiModuleImpl.java:177)
at org.jvnet.hk2.osgiadapter.OSGiModuleImpl$2$1$1.loadClass(OSGiModuleImpl.java:344)
at com.sun.hk2.component.LazyInhabitant.loadClass(LazyInhabitant.java:124)
at com.sun.hk2.component.LazyInhabitant.fetch(LazyInhabitant.java:111)
at com.sun.hk2.component.EventPublishingInhabitant.get(EventPublishingInhabitant.java:135)
at com.sun.hk2.component.AbstractInhabitantImpl.get(AbstractInhabitantImpl.java:76)
at org.jvnet.hk2.component.Habitat$5.get(Habitat.java:701)
at java.util.AbstractList$Itr.next(AbstractList.java:345)
at java.util.AbstractCollection.toArray(AbstractCollection.java:124)
at java.util.ArrayList.addAll(ArrayList.java:472)
at com.sun.enterprise.v3.server.SnifferManagerImpl.getSniffers(SnifferManagerImpl.java:92)
at com.sun.enterprise.v3.server.SnifferManagerImpl.getSniffer(SnifferManagerImpl.java:120)
at com.sun.enterprise.v3.server.ApplicationLifecycle.getSniffersFromApp(ApplicationLifecycle.java:2140)
at com.sun.enterprise.v3.server.ApplicationLoaderService.processApplication(ApplicationLoaderService.java:375)
at com.sun.enterprise.v3.server.ApplicationLoaderService.postConstruct(ApplicationLoaderService.java:219)
at com.sun.hk2.component.AbstractCreatorImpl.inject(AbstractCreatorImpl.java:131)
at com.sun.hk2.component.ConstructorCreator.initialize(ConstructorCreator.java:91)
at com.sun.hk2.component.AbstractCreatorImpl.get(AbstractCreatorImpl.java:82)
at com.sun.hk2.component.SingletonInhabitant.get(SingletonInhabitant.java:67)
at com.sun.hk2.component.EventPublishingInhabitant.get(EventPublishingInhabitant.java:139)
at com.sun.hk2.component.AbstractInhabitantImpl.get(AbstractInhabitantImpl.java:76)
at com.sun.enterprise.v3.server.AppServerStartup.run(AppServerStartup.java:253)
at com.sun.enterprise.v3.server.AppServerStartup.doStart(AppServerStartup.java:145)
at com.sun.enterprise.v3.server.AppServerStartup.start(AppServerStartup.java:136)
at com.sun.enterprise.glassfish.bootstrap.GlassFishImpl.start(GlassFishImpl.java:79)
at com.sun.enterprise.glassfish.bootstrap.GlassFishDecorator.start(GlassFishDecorator.java:63)
at com.sun.enterprise.glassfish.bootstrap.osgi.OSGiGlassFishImpl.start(OSGiGlassFishImpl.java:69)
at com.sun.enterprise.glassfish.bootstrap.GlassFishMain$Launcher.launch(GlassFishMain.java:117)
... 6 more
Caused by: org.osgi.framework.BundleException: Unresolved constraint in bundle org.glassfish.web.weld-integration [301]: Unable to resolve 301.0: missing requirement [301.0] package; (&(package=com.sun.faces.spi)(version>=2.1.0)) [caused by: Unable to resolve 213.1: missing requirement [213.1] package; (package=javax.faces) [caused by: Unable to resolve 211.1: missing requirement [211.1] package; (&(package=javax.el)(version>=2.2.1))]]
at org.apache.felix.framework.Felix.resolveBundle(Felix.java:3443)
at org.apache.felix.framework.Felix.startBundle(Felix.java:1727)
at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:922)
at org.jvnet.hk2.osgiadapter.OSGiModuleImpl.start(OSGiModuleImpl.java:169)
I tried web app specific JSF but that also fails:
glassfish change default jsf impl
Added to web.xml:
<class-loader delegate="false" />
<property name="useBundledJsf" value="true" />
I get the error:
Error occurred during deployment: Exception while loading the app :
java.lang.IllegalStateException: ContainerBase.addChild: start:
org.apache.catalina.LifecycleException: java.lang.RuntimeException:
com.sun.faces.config.ConfigurationException: CONFIGURATION FAILED!
org.glassfish.weld.jsf.WeldFacesConfigProvider cannot be cast to
com.sun.faces.spi.ConfigurationResourceProvider. Please see server.log for more details.
Grateful for suggestions.
Try following steps
Download jsf 2.1.21 jar from here
Rename it to javax.faces.jar .
Take backup of javax.faces.jar available at docroot\glassfish\modules
Paste and replace the old javax.faces.jar with downloaded javax.faces.jar available at docroot\glassfish\modules
Delete the osgi cache glassfish3\glassfish\osgi for the changes to
take effect
OK I finally have 2 workarounds (only) for getting Mojarra-2.1.21 running with Netbeans7.1.
Firstly, the following recommended approach does not as far as I can tell work in Netbeans7.1, it stubbornly refuses to recognise the server installed javax.faces.jar.
From https://weblogs.java.net/blog/edburns/archive/2011/09/26/try-out-mojarra-220-snapshot?force=714:
Once you download the javax.faces.jar, you must take some steps to install it in GlassFish 3.1 or 3.1.1.
Remove jsf-api.jar and jsf-impl.jar from the modules directory.
Put javax.faces.jar in the modules directory.
You must modify the default-web.xml file in domains/domain1/config and lib/templates. In
each directory, remove any mention of jsf-api.jar and jsf-impl.jar from the default.web.xml file.
In place of the two jars, add a reference to javax.faces.jar.
No matter what I do with Netbeans7.1 (and no matter whether clear osgi-cache and netbeans cache or whether remove then re-add server in Netbeans7.1 or how many times I restart glassfish3.1.1 and/or netbeans7.1), Netbeans7.1 will NOT see javax.faces.jar.
If you try to add the javax.faces.jar (only) to your web app libs and use this in glassfish-web.xml to for it to use web-app specific JSF, it will prevent import errors in your Netbeans7.1 project, but it still will not run:
<class-loader delegate="false" />
<property name="useBundledJsf" value="true" />
I get this error:
Error occurred during deployment: Exception while loading the app :
java.lang.IllegalStateException: ContainerBase.addChild: start:
org.apache.catalina.LifecycleException: java.lang.RuntimeException:
com.sun.faces.config.ConfigurationException: CONFIGURATION FAILED!
org.glassfish.weld.jsf.WeldFacesConfigProvider cannot be cast to
com.sun.faces.spi.ConfigurationResourceProvider.
The reason is described here: http://java.dzone.com/articles/upgrading-latest-mojarra
The issue seems to be that there are two versions of
ConfigurationResourceProvider on the class path: one at the web app
level (your bundled jar file) and a second at the parent class loader
level (provided by GlassFish). WeldFacesConfigProvider extends
ConfigurationResourceProvider at the parent class loader, but it ends
up casting this to ConfigurationResourceProvider at the web app class
loader. ...
Workaround: Adding the missing dependency to your app If you can't cast across class loaders you have to make the missing part available
to the right class-loader. Not replacing the javax.faces.jar in your
server's modules leads to adding the magic WeldFacesConfigProvider to
your app. It is contained in the
glassfish3\glassfish\modules\weld-integration.jar and by simply
putting that as an additional library to your application you also
solve the issue.
You now have 2 workaround choices:
Include the weld-integration.jar in your web app libs, and run with web app JSF settings in glassfish-web.xml.
Dirty trick: With .../glassfish/modules/javax.faces.jar still in place and also in your web app libs, disable or uncomment the bit in your glassfish-web.xml. It will then run with the server javax.faces.jar (and will see /modules/weld-integration.jar), and Netbeans will see the web app specific lib for imports.
This is unsatisfactory, I don't consider the question fully answered.
Q: How can one run JSF Mojarra 2.1.21 as Glassfish3.1.1 server JSF libs in NetBeans7.1 ?
And again, the reason I can't just upgrade Netbeans+Glassfish is that I have multiple problems with ObjectDB with versions of Glassfish above 3.1.1, which is why I am so adamant about installing JSF Mojarra 2.1.21 on Netbeans7.1+Glassfish3.1.1.
Grateful for any further suggestions.

Resources