I am using websphere liberty with java 8 docker image but after trying everything. i am unable to load my own bundled libs instead of liberty built-in as per my assumption and from logs
My jsp and other libs are in WEB-INF/lib directory inside my war file
Here is the config I am using
<?xml version="1.0" encoding="UTF-8"?>
<server description="Default server">
<!-- Enable features -->
<featureManager>
<feature>javaee-8.0</feature>
<feature>microProfile-3.0</feature>
</featureManager>
<basicRegistry id="basic" realm="BasicRealm">
<!-- <user name="yourUserName" password="" /> -->
</basicRegistry>
<logging traceSpecification="com.ibm.ws.webcontainer*=all:com.ibm.wsspi.webcontainer*=all:HTTPChannel=all:GenericBNF=all:HTTPDispatcher=all"
traceFileName="trace.log"
maxFileSize="20"
maxFiles="10"
traceFormat="BASIC" />
<library id="OJDBC5Lib">
<fileset dir="/config/ojdbc5.jar" includes="ojdbc5.jar"/>
</library>
<!-- To allow access to this server from a remote client host="*" has been added to the following element -->
<httpEndpoint id="defaultHttpEndpoint"
host="*"
httpPort="9080"
httpsPort="9443" />
<webApplication id="e-app" name="e-app" location="/apps/e-app.war" contextRoot="/e-app">
<classloader delegation="parentLast" />
</webApplication>
When I run. the application I get an exception
[AUDIT ] CWWKF0011I: The defaultServer server is ready to run a smarter planet. The defaultServer server started in 14.831 seconds.
[ERROR ] SRVE0271E: Uncaught init() exception created by servlet [Faces Servlet] in application [e-app]: java.lang.IllegalStateException: Could not find ba
ckup for factory javax.faces.context.FacesContextFactory.
at javax.faces.FactoryFinder$FactoryManager.getFactory(FactoryFinder.java:1004)
at [internal classes]
[ERROR ] SRVE0276E: Error while initializing Servlet [Faces Servlet]: javax.servlet.ServletException: SRVE0207E: Uncaught initialization exception created by servlet
at com.ibm.ws.webcontainer.servlet.ServletWrapper.init(ServletWrapper.java:360)
at [internal classes]
Caused by: java.lang.IllegalStateException: Could not find backup for factory javax.faces.context.FacesContextFactory.
at javax.faces.FactoryFinder$FactoryManager.getFactory(FactoryFinder.java:1004)
... 1 more
Can someone tell me what needs to be done in config to make it work
The problem here is that the javaee-8.0 feature includes the jsf-2.3 feature that includes the JSF APIs and Liberty's JSF implementation. In order to provide your own JSF implementation, you will need to remove the jsf-2.3 feature and use the jsfContainer-2.3 feature instead. This doc has more details: https://www.ibm.com/support/knowledgecenter/SSEQTP_liberty/com.ibm.websphere.wlp.doc/ae/twlp_jsf23_implementations.html
The javaee-8.0 feature includes a ton of features - many of which you may not need, but unfortunately you will need to specify all of the features that you do need (in addition to jsfContainer-2.3). So your server.xml's <featureManager> element might end up looking something like this:
<featureManager>
<!-- webprofile-8.0 features but using jsfContainer instead of jsf -->
<feature>appSecurity-3.0</feature>
<feature>beanValidation-2.0</feature>
<feature>cdi-2.0</feature>
<feature>ejbLite-3.2</feature>
<feature>el-3.0</feature>
<feature>jaspic-1.1</feature>
<feature>jaxrs-2.1</feature>
<feature>jdbc-4.2</feature>
<feature>jndi-1.0</feature>
<feature>jpa-2.2</feature>
<feature>jsfContainer-2.3</feature>
<feature>jsonb-1.0</feature>
<feature>jsonp-1.1</feature>
<feature>jsp-2.3</feature>
<feature>managedBeans-1.0</feature>
<feature>servlet-4.0</feature>
<feature>transaction-1.2</feature>
<feature>websocket-1.1</feature>
<!-- full profile 8 features not in web profile -->
<feature>appClientSupport-1.0</feature>
<feature>batch-1.0</feature>
<feature>concurrent-1.0</feature>
<feature>ejb-3.2</feature>
<feature>jacc-1.5</feature>
<feature>javaMail-1.6</feature>
<feature>javax.persistence.base-2.2</feature>
<feature>jaxws-2.2</feature>
<feature>jca-1.7</feature>
<feature>jcaInboundSecurity-1.0</feature>
<feature>jms-2.0</feature>
<feature>j2eeManagement-1.1</feature>
<feature>wasJmsClient-2.0</feature>
<feature>wasJmsSecurity-1.0</feature>
<feature>wasJmsServer-1.0</feature>
</featureManager>
It's a huge list, so you'll likely want to prune it a little (for example, remove all JMS-related feature if you are not using JMS). But once you swap jsf-2.3 for jsfContainer-2.3 then Liberty should find and use the JSF implementation in your app - and you shouldn't need to use parentLast delegation in your app either.
Related
On starting up my Web app with Velocity 2.0 I'm getting the following error:
Caused by: java.lang.NoClassDefFoundError:
org/apache/velocity/runtime/log/CommonsLogLogChute
at org.springframework.ui.velocity.VelocityEngineFactory.createVelocityEngine(VelocityEngineFactory.java:240)
at org.springframework.ui.velocity.VelocityEngineFactoryBean.afterPropertiesSet(VelocityEngineFactoryBean.java:60)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1687)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1624)
... 34 more
All dependencies have been satisfied. We are using
slf4j-api-1.7.25.jar
slf4j-simple-1.7.25.jar
commons-lang3-3.5.jar
commons-io-2.5.jar
commons-logging-1.2.jar (yes we do have Commons-Logging)
In applicationContext.xml the velocityEngine bean is defined as follows
<bean id="velocityEngine"
class="org.springframework.ui.velocity.VelocityEngineFactoryBean"/>
Any thoughts on this?
My file velocity-engine-core-2.0.jar only contains the following .runtime subpackages:
defaults, directive, parser, resource, visitor
but no log .
UPDATE The following overrideLogging = FALSE in the Spring Velocity Engine bean declaration solved the problem. But why?
<bean id="velocityEngine" class="org.springframework.ui.velocity.VelocityEngineFactoryBean">
<property name="overrideLogging" value="false" />
</bean>
I just followed a tip on
https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/ui/velocity/VelocityEngineFactory.html
but not sure what happened.
When overrideLogging is true, the class org.apache.velocity.runtime.log.CommonsLogLogChute is still required by Spring while it has disappeared in Velocity 2.0, since Velocity now uses the slf4j logging framework.
You'll need to wait for an update of the Spring Velocity classes if you need overrideLogging to be true.
Edit on June 21st, 2022 - Since version 2.3, Velocity does provide Spring support.
Velocity made a change in logging:
Make Velocity use the base logger namespace 'org.apache.velocity'
unless specified with runtime.log.name in the configuration, and have
the runtime instance log with this base namespace, and other modules
log with children namespaces
CommonsLogLogChute added in before major version velocity 1.7:
Add a CommonsLogLogChute that allows logging through commons-logging.
So you probably have an old jar or configuration in your runtime environment.
Alibaba implemented a support context package for that case: https://github.com/alibaba/spring-velocity-support
Just add to maven:
<!-- Spring Framework -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
<version>${spring.framework.version}</version>
</dependency>
<!-- Spring Context Velocity -->
<dependency>
<groupId>com.alibaba.spring</groupId>
<artifactId>spring-context-velocity</artifactId>
<version>1.4.3.18.RELEASE</version>
</dependency>
But beware that your project now uses Velocity 2.0.
I'm migrating an application based on Alfresco 3.2r13 from linux/IntelliJ/Ant toward Windows/Eclipse.
Later the aimed will be to add Maven to the Eclipse project, but for now, I just want it to work.
Currently I'm facing the following issue:
I add the contentTypesModel.xml to the project, here are the first lines:
<?xml version="1.0" encoding="UTF-8"?>
<!-- Optional meta-data about the model -->
<description>Example custom Model</description>
<author></author>
<version>1.0</version>
<!-- Imports are required to allow references to definitions in other models -->
<imports>
<!-- Import Alfresco Dictionary Definitions -->
<import uri="http://www.alfresco.org/model/dictionary/1.0"
prefix="d"/>
<!-- Import Alfresco Content Domain Model Definitions -->
<import uri="http://www.alfresco.org/model/content/1.0" prefix="cm"/>
<import uri="http://www.alfresco.org/grimoire/model/ma0189cstr/1.0" prefix="ma0189cstr"/>
<import uri="http://www.alfresco.org/grimoire/model/ma43110cstr/1.0" prefix="ma43110cstr" />
<import uri="http://www.alfresco.org/grimoire/model/baremesSys/1.0"
prefix="baremesSys"/>
<import uri="http://www.alfresco.org/grimoire/model/baremes/1.0"
prefix="baremes"/>
<import
uri="http://www.alfresco.org/grimoire/model/workflow/baremes/perimetres/1.0"
prefix="perimetres"/>
</imports>
<!-- Introduction of new namespaces defined by this model -->
<!-- NOTE: The following namespace my.new.model should be changed to reflect
your own namespace -->
<namespaces>
<namespace uri="http://www.alfresco.org/grimoire/model/contenttypes/1.0"
prefix="GPCT"/>
</namespaces>
When trying to Run the Tomcat Server, I got the following error trace:
> 23 déc. 2015 16:28:44,047 ERROR [web.context.ContextLoader] Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'extension.dictionaryBootstrap' defined in file [D:\TomcatGrimoire\webapps\GrimoireMk0\WEB-INF\classes\alfresco\extension\gp-models-context.xml]: Invocation of init method failed; nested exception is org.alfresco.service.cmr.dictionary.DictionaryException: 11230001 Could not import bootstrap model alfresco/extension/contentTypesModel.xml
Caused by: org.alfresco.service.cmr.dictionary.DictionaryException: 11230001 Could not import bootstrap model alfresco/extension/contentTypesModel.xml
at org.alfresco.repo.dictionary.DictionaryBootstrap.onDictionaryInit(DictionaryBootstrap.java:150)
at org.alfresco.repo.dictionary.DictionaryBootstrap.bootstrap(DictionaryBootstrap.java:108)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeCustomInitMethod(AbstractAutowireCapableBeanFactory.java:1242)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1208)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1172)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:427)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:249)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:155)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:246)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:160)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:291)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:352)
at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:246)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:189)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:49)
at org.alfresco.web.app.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:69)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4205)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4704)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:840)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463)
at org.apache.catalina.core.StandardService.start(StandardService.java:525)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:754)
at org.apache.catalina.startup.Catalina.start(Catalina.java:595)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
Caused by: org.alfresco.service.cmr.dictionary.DictionaryException: 11230000 Failed to compile model GPCT:gpcontenttypeswfmodel
at org.alfresco.repo.dictionary.CompiledModel.<init>(CompiledModel.java:112)
at org.alfresco.repo.dictionary.M2Model.compile(M2Model.java:134)
at org.alfresco.repo.dictionary.DictionaryDAOImpl.putModel(DictionaryDAOImpl.java:273)
at org.alfresco.repo.dictionary.DictionaryBootstrap.onDictionaryInit(DictionaryBootstrap.java:146)
... 34 more
Caused by: org.alfresco.service.namespace.NamespaceException: URI http://www.alfresco.org/grimoire/model/ma0189cstr/1.0 cannot be imported as it is not defined (with prefix ma0189cstr
at org.alfresco.repo.dictionary.CompiledModel.createLocalPrefixResolver(CompiledModel.java:209)
at org.alfresco.repo.dictionary.CompiledModel.constructDefinitions(CompiledModel.java:134)
at org.alfresco.repo.dictionary.CompiledModel.<init>(CompiledModel.java:94)
... 37 more
The file wfMA0189Constraints.xml contains the following definition:
<!-- Optional meta-data about the model -->
<description>MA0189 Constraints Workflow Model</description>
<author>FSE</author>
<version>1.0</version>
<!-- Imports are required to allow references to definitions in other models -->
<imports>
<!-- Import Alfresco Dictionary Definitions -->
<import uri="http://www.alfresco.org/model/dictionary/1.0" prefix="d"/>
<!-- Import Alfresco Content Domain Model Definitions -->
<import uri="http://www.alfresco.org/model/content/1.0" prefix="cm"/>
</imports>
<!-- Introduction of new namespaces defined by this model -->
<namespaces>
<namespace uri="http://www.alfresco.org/grimoire/model/ma0189cstr/1.0" prefix="ma0189cstr"/>
</namespaces>
As far as I understand the error, the content of the file is not acknowledged by the tomcat server. The thing is that after a check the tomcat build does contain the file.
So I'm stuck on this error. Any hlep will be welcome.
Thanks in advance and happy holidays.
There should be a spring context file deployed probably in the extension path.
The name of the file usually ends with "-context.xml".
Look for a context file that contains the name of the content model file: you should see the definition of a bean with parent="dictionaryModelBootstrap".
If you cannot find this context file, try to find it in your source code and see how it was packaged by intellij/ant
Please find more details at:
http://docs.alfresco.com/5.1/tasks/dev-extensions-content-models-tutorials-deploy-model.html
The issue might be caused by the order in which the content models are loaded. This might explain the difference between IntelliJ and Eclipse.
If you want to be sure about the order you can use depends-on as an attribute in the bean initialization.
If the models are in different modules you can also use module dependencies.
See example: http://docs.alfresco.com/4.2/concepts/dev-extensions-modules-module-properties.html
It seems like you are missing entry of "wfMA0189Constraints.xml" model file in your context file. That is the reason Alfresco is not able to pickup that model and hence it shows prefix as unidentified prefix.
Based on your logs I see you are using "gp-models-context.xml" as your context file. Are you able to see entry of this model file (wfMA0189Constraints.xml) there?
If you are sure that no context files are loading the model, it is possible that the model is manually uploaded in "Data Dictionary/model". This folder can be used to add new content models dynamically on a running instance of Alfresco.
Is it possible that someone wanted to make these constraints modifiable by end users?
Do you have an instance where the deployment worked? If yes, could you check if the model is deployed in that folder?
I have a web application that is deployed locally to a Liberty Profile server, and that is already working with log4j2. My end goal is to log all of the PreparedStatements with their parameter values included in the query string, just before they are run against a DB2 database.
I've been following the instructions at https://code.google.com/p/log4jdbc-log4j2 to set up log4jdbc-log4j2. I was able to pull down the dependency files with Maven:
<dependency>
<groupId>org.bgee.log4jdbc-log4j2</groupId>
<artifactId>log4jdbc-log4j2-jdbc4</artifactId>
<version>1.16</version>
</dependency>
However, I've been stuck at steps 3.1 and 3.2 for awhile, and so far, nothing on stackoverflow or instructional blogs has helped me move forward, so I thought it was time to ask my own question.
Could someone please let me know in which file(s), and how, I should make the changes mentioned in steps 3.1 ("Change your JDBC URL") and 3.2 ("Change the driver used")? Please let me know if there's something I can clarify further in order to help get my question answered, and thank you in advance for any help or guidance you can provide.
Update
After making the changes to server.xml suggested aguibert and including all log4j*.jar files from the dependency in the db2 drivers directory, my server.xml entry looks like this:
<dataSource id="myDataSource" jndiName="jdbc/myDataSource" type="javax.sql.DataSource">
<jdbcDriver javax.sql.DataSource="net.sf.log4jdbc.sql.jdbcapi.DataSourceSpy">
<library>
<fileset dir="<path to dir>/db2" includes="db2jcc_license_cisuz.jar db2jcc4.jar log4j-api-2.3.jar log4j-core-2.3.jar log4jdbc-log4j2-jdbc4-1.16-sources.jar log4jdbc-log4j2-jdbc4-1.16.jar"/>
</library>
</jdbcDriver>
<properties
password="password"
user="user"
URL="jdbc:log4jdbc:db2://<normal jdbc url>" />
</dataSource>
Now, when the first query is made, I get an InstantiationException on net.sf.log4jdbc.sql.jdbcapi.DataSourceSpy:
java.lang.Exception:
at <my files>
at javax.servlet.http.HttpServlet.service(HttpServlet.java:595) [com.ibm.ws.javaee.servlet.3.0_1.0.8.jar:?]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:668) [com.ibm.ws.javaee.servlet.3.0_1.0.8.jar:?]
at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1285) [com.ibm.ws.webcontainer_1.0.8.jar:?]
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:776) [com.ibm.ws.webcontainer_1.0.8.jar:?]
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:473) [com.ibm.ws.webcontainer_1.0.8.jar:?]
at com.ibm.ws.webcontainer.filter.WebAppFilterManager.invokeFilters(WebAppFilterManager.java:1104) [com.ibm.ws.webcontainer_1.0.8.jar:?]
at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:4845) [com.ibm.ws.webcontainer_1.0.8.jar:?]
at com.ibm.ws.webcontainer.osgi.DynamicVirtualHost$2.handleRequest(DynamicVirtualHost.java:297) [com.ibm.ws.webcontainer_1.0.8.jar:?]
at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:981) [com.ibm.ws.webcontainer_1.0.8.jar:?]
at com.ibm.ws.webcontainer.osgi.DynamicVirtualHost$2.run(DynamicVirtualHost.java:262) [com.ibm.ws.webcontainer_1.0.8.jar:?]
at com.ibm.ws.http.dispatcher.internal.channel.HttpDispatcherLink$TaskWrapper.run(HttpDispatcherLink.java:955) [com.ibm.ws.transport.http_1.0.8.jar:?]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [?:1.7.0_60]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [?:1.7.0_60]
at java.lang.Thread.run(Thread.java:745) [?:1.7.0_60]
Caused by: javax.naming.NamingException: CWWKN0008E: An object could not be obtained for name jdbc/myDataSource.
at com.ibm.ws.jndi.internal.WSContext.resolveObject(WSContext.java:128) ~[?:?]
at com.ibm.ws.jndi.internal.WSContext.lookup(WSContext.java:364) ~[?:?]
at com.ibm.ws.jndi.internal.WSContext.lookup(WSContext.java:359) ~[?:?]
at org.apache.aries.jndi.DelegateContext.lookup(DelegateContext.java:161) ~[?:?]
at javax.naming.InitialContext.lookup(InitialContext.java:411) ~[?:1.7.0_60]
at <my files>
... 16 more
[ERROR ] CWWKE0701E: FrameworkEvent ERROR Bundle:com.ibm.ws.jdbc(id=69) org.osgi.framework.ServiceException: Exception in com.ibm.ws.resource.internal.ResourceFactoryTrackerData$1.getService()
at org.eclipse.osgi.internal.serviceregistry.ServiceFactoryUse.factoryGetService(ServiceFactoryUse.java:222)
at [internal classes]
at javax.naming.InitialContext.lookup(InitialContext.java:411)
at <my files>
at javax.servlet.http.HttpServlet.service(HttpServlet.java:595)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:668)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1285)
at [internal classes]
Caused by: java.lang.RuntimeException: java.sql.SQLNonTransientException: java.lang.InstantiationException: net.sf.log4jdbc.sql.jdbcapi.DataSourceSpy
at com.ibm.ws.resource.internal.ResourceFactoryTrackerData$1.getService(ResourceFactoryTrackerData.java:109)
... 10 more
Caused by: java.sql.SQLNonTransientException: java.lang.InstantiationException: net.sf.log4jdbc.sql.jdbcapi.DataSourceSpy
at com.ibm.ws.jdbc.internal.JDBCDriverService.create(JDBCDriverService.java:287)
... 10 more
Caused by: java.lang.InstantiationException: net.sf.log4jdbc.sql.jdbcapi.DataSourceSpy
at java.lang.Class.newInstance(Class.java:359)
at com.ibm.ws.jdbc.internal.JDBCDriverService$1.run(JDBCDriverService.java:228)
... 10 more
Event:org.osgi.framework.FrameworkEvent[source=com.ibm.ws.jdbc_1.0.8.cl50520150305-2202 [69]]
If it looks like there's anything that I've missed, please let me know. Searching for the errors in the stack trace hasn't resulted in any solutions.
Final Status
As aguibert pointed out, it seems like a different direction will be best here. Based on a comment in Logging PreparedStatements in Java, I've decided to implement a LoggableStatement wrapper as described here: ibm.com/developerworks/java/library/j-loggable
For a WebSphere Liberty server, all of the global server config is done in the server.xml file (located by defualt at WLP_INSTALL/usr/servers//server.xml).
You will probably want something along these lines in your server.xml:
<dataSource id="myDataSource" jndiname="jdbc/myDataSource" type="javax.sql.DataSource">
<jdbcDriver javax.sql.DataSource="net.sf.log4jdbc.sql.jdbcapi.DataSourceSpy">
<library>
<fileset dir="C:/path/to/libs" includes="thedb2jar.jar log4j.jar" />
</library>
</jdbcDriver>
<properties user="user" password="password"
url="jdbc:log4jdbc:<the normal jdbc url>"/>
</dataSource>
The key parts here is that the element has the "javax.sql.DataSource" property set and the value is the name of the DataSource class for the log4j jar. Also, in the element, you'll see that the url is specified with the "jdbc:log4jdbc" prefix as described in section 3.1.
This is untested advice, but you may need to include both jars (the db2 jar and the log4j jar) in the same folder so they are picked up in the same element.
I'm deploying a web service application on Weblogic 12. The application uses jersey and thus depends on javax.ws.rs-api:2.0.1 library.
However when I deploy it to server I have a following error :
Caused By: java.lang.NoSuchMethodError: javax.ws.rs.core.Application.getProperties()Ljava/util/Map;
at org.glassfish.jersey.server.ApplicationHandler.<init>(ApplicationHandler.java:304)
at org.glassfish.jersey.server.ApplicationHandler.<init>(ApplicationHandler.java:285)
at org.glassfish.jersey.servlet.WebComponent.<init>(WebComponent.java:311)
at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:170)
at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:358)
at javax.servlet.GenericServlet.init(GenericServlet.java:240)
at weblogic.servlet.internal.StubSecurityHelper$ServletInitAction.run(StubSecurityHelper.java:337)
at weblogic.servlet.internal.StubSecurityHelper$ServletInitAction.run(StubSecurityHelper.java:288)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
...
I think that weblogic might have it's own version of javax.ws.rs.core.Application that doesn't have this getProperties() method. I'm packaging the application in a WAR file and tried to use
<container-descriptor>
<prefer-web-inf-classes>true</prefer-web-inf-classes>
</container-descriptor>
in weblogic.xml, to explicitly tell Weblogic to use 2.0.1 version of this library.
Nothing helped so far, the issue still in place..
Thanks.
I found this to work as a solution. Add it in your weblogic.xml:
<wls:container-descriptor>
<wls:prefer-application-packages>
<!-- jersey-bundle-*.jar-->
<wls:package-name>com.sun.jersey.*</wls:package-name>
<wls:package-name>com.sun.research.ws.wadl.*</wls:package-name>
<wls:package-name>com.sun.ws.rs.ext.*</wls:package-name>
<!-- Jackson-*.jar -->
<wls:package-name>org.codehaus.jackson.*</wls:package-name>
<!-- jettison-*.jar -->
<wls:package-name>org.codehaus.jettison.*</wls:package-name>
<!-- jsr311*.jar -->
<wls:package-name>javax.ws.rs.*</wls:package-name>
<!-- asm.jar -->
<wls:package-name>org.objectweb.asm.*</wls:package-name>
</wls:prefer-application-packages>
</wls:container-descriptor>
Reference from Oracle Weblogic Documenation
I have a web service project implemented in java and it also contains jsp pages. I deploy it on jetty 8.1.5 on my machine and it works normally. But when I deploy on a windows server 2003 with jetty 8.1.3 it gives this exception:
org.apache.jasper.el.ELContextImpl cannot be cast to org.apache.jasper.runtime.ELContextImpl
This is the full trace:
java.lang.ClassCastException: org.apache.jasper.el.ELContextImpl cannot be cast to org.apache.jasper.runtime.ELContextImpl
at org.apache.jasper.runtime.PageContextImpl.evaluateExpression(PageContextImpl.java:1002)
at org.apache.jsp.home.index_jsp._jspService(org.apache.jsp.home.index_jsp:52)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:111)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:848)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:403)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:492)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:378)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:848)
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:598)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:486)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:119)
at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:542)
at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:233)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1065)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:413)
at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:192)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:999)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:117)
at org.eclipse.jetty.server.Dispatcher.forward(Dispatcher.java:271)
at org.eclipse.jetty.server.Dispatcher.forward(Dispatcher.java:98)
at org.eclipse.jetty.servlet.DefaultServlet.doGet(DefaultServlet.java:557)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:735)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:848)
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:598)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:486)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:119)
at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:499)
at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:233)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1065)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:413)
at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:192)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:999)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:117)
at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:250)
at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:149)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:111)
at org.eclipse.jetty.server.Server.handle(Server.java:350)
at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:454)
at org.eclipse.jetty.server.AbstractHttpConnection.headerComplete(AbstractHttpConnection.java:890)
at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.headerComplete(AbstractHttpConnection.java:944)
at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:630)
at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:230)
at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:77)
at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:606)
at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:46)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:603)
at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:538)
at java.lang.Thread.run(Unknown Source)
Any idea what is this exception and how to fix it?
That can happen if your webapp ships with servletcontainer-specific JAR files such as jasper.jar, jetty.jar servlet.jar, etc in the /WEB-INF/lib for some unclear reason. This is in turn conflicting with with a different versioned JAR file on the target servletcontainer.
Remove that servletcontainer-specific JAR file from your webapp's /WEB-INF/lib. It doesn't belong there. It's supposed to be already supplied by the servletcontainer itself.
See also:
How do I import the javax.servlet API in my Eclipse project? (this doesn't exactly answer your concrete problem, but this is at least technically the same core problem which should give you a better understanding of this common starter's mistake)
IF you are using maven (I asked on a comment without response), you can avoid conflictive jars using a "provided" scope. When you deploy it for production, jars are not included.
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jsp-api</artifactId>
<version>2.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<scope>provided</scope>
</dependency>
I'm not sure about jetty's jars but it's probably the same.
IF you are NOT using maven, you should move your conflictive jars (servlets and jetty) to your develompent container lib folder and remove them from your applications WEB-INF/lib folder.
If the folder /WEB-INF/lib of your webapp does not contain a jasper.jar (see BalusC' answer), please check whether another webapp is running in your container. Then check if that webapp contains a jasper.jar in its folder /WEB-INF/lib. This happened to us. Be removing jasper.jar from those webapps (sic!), the problem could be solved. Obviously, the webapps are not that isolated for meach other as they should be. The problem appeared as we switched from Tomcat6 to Tomcat7 and jasper.jar (version 6) was bundled accidently with one of our webapps.
Apart from the answers mentioned watch out for one more thing. I've another war deployed under the same Tomcat 7.0.42 instance which had a jsp-2.1-6.0.2.jar under its WEB-INF/lib. This jar has org.apache.jasper.runtime.ELContextImpl class.
My understanding was that each webapp has its own classloader and the class files loaded by one webapp is not visible to the other webapp. Still as nothing was working I removed the other war which had that jsp.jar and restarted my tomcat and to my surprise the exception was no longer coming. Somehow this class was getting loaded and causing the issue.
The interesting thing is that both of these wars work perfectly fine in Tomcat 6.x.
I faced the same problem and tried all suggestions, none worked for me. I finally found out that the issue was caused after using Spring Boot overriding my tomcat version, as I had
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.1.0.M2</version>
Removing the Spring Boot solves the problem. This answer could provide the solution for using Spring Boot + Maven + Tomcat 8.
For me (Jetty 8.1.14), this exact error message was actually caused by another webapp in the same Jetty container. Are you running more than one webapps?
Add this line in <context>:
<Loader delegate="true" />
This problem is related with a conflicted jars in the applications
tag. This looks like:
<?xml version='1.0' encoding='utf-8'?>
<!-- The contents of this file will be loaded for each web application -->
<Context>
<!-- Default set of monitored resources -->
<WatchedResource>WEB-INF/web.xml</WatchedResource>
<Loader delegate="true" /> <!--this line-->
<!-- Uncomment this to disable session persistence across Tomcat restarts -->
<!--
<Manager pathname="" />
-->
<!-- Uncomment this to enable Comet connection tacking (provides events on session expiration as well as webapp lifecycle) -->
<!--
<Valve className="org.apache.catalina.valves.CometConnectionManagerValve" />
-->
</Context>