I'm attempting to get a basic Struts2 application (using tomcat, building with maven) up and running. Tomcat and Maven are both working correctly; the page is served normally until I add some Struts filters into my web.xml (located at src/main/webapp/WEB-INF). Here's the code for my web.xml:
<?xml version="1.0" encoding="UTF-8" ?>
<web-app>
<display-name>app</display-name>
<description>tagline</description>
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>
Additionally, here is the code for my struts.xml (located at src/main/resources:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<constant name="struts.devMode" value="true" />
<package name="app" extends="struts-default">
<action name="index">
<result>/index.jsp</result>
</action>
</package>
</struts>
My catalina.log has the following error messages:
12-Jan-2014 15:33:20.256 SEVERE [localhost-startStop-16] org.apache.catalina.core.StandardContext.startInternal Error filterStart
12-Jan-2014 15:33:20.256 SEVERE [localhost-startStop-16] org.apache.catalina.core.StandardContext.startInternal Context [/app] startup failed due to previous errors
I've just noticed another issue present in catalina.log that only shows upon starting up tomcat:
13-Jan-2014 20:19:57.465 SEVERE [main] org.apache.catalina.core.AprLifecycleListener.init An incompatible version 1.1.27 of the APR based Apache Tomcat Native library is installed, while Tomcat requires version 1.1.29
The really weird thing is that the tomcat-native.tar.gz in my apache-tomcat-ver/bin is version 1.1.29.
Additionally, my localhost.log has a mess of errors:
13-Jan-2014 20:20:04.780 SEVERE [localhost-startStop-1] org.apache.catalina.core.StandardContext.filterStart Exception starting filter struts2
Unable to load configuration. - bean - jar:file:/usr/local/apache-tomcat/apache-tomcat-8.0.0-RC10/webapps/symIOsis/WEB-INF/lib/struts2-portlet-plugin-2.3.16.jar!/struts-plugin.xml:31:133
at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:501)
at org.apache.struts2.dispatcher.ng.InitOperations.initDispatcher(InitOperations.java:74)
at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.init(StrutsPrepareAndExecuteFilter.java:57)
at org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig.java:281)
at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:262)
at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:107)
at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4646)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5274)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:726)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:702)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:699)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:977)
at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1763)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:744)
Caused by: Unable to load configuration. - bean - jar:file:/usr/local/apache-tomcat/apache-tomcat-8.0.0-RC10/webapps/symIOsis/WEB-INF/lib/struts2-portlet-plugin-2.3.16.jar!/struts-plugin.xml:31:133
at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:70)
at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:445)
at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:489)
... 18 more
Caused by: Unable to load bean: type:org.apache.struts2.components.UrlRenderer class:org.apache.struts2.components.PortletUrlRenderer - bean - jar:file:/usr/local/apache-tomcat/apache-tomcat-8.0.0-RC10/webapps/symIOsis/WEB-INF/lib/struts2-portlet-plugin-2.3.16.jar!/struts-plugin.xml:31:133
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.register(XmlConfigurationProvider.java:245)
at org.apache.struts2.config.StrutsXmlConfigurationProvider.register(StrutsXmlConfigurationProvider.java:102)
at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:234)
at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:67)
... 20 more
Caused by: java.lang.NoClassDefFoundError: javax/portlet/PortletMode
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Class.java:2493)
at java.lang.Class.getDeclaredConstructors(Class.java:1901)
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.register(XmlConfigurationProvider.java:235)
... 23 more
Caused by: java.lang.ClassNotFoundException: javax.portlet.PortletMode
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1286)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1128)
... 27 more
To me this looks like a dependency issue, however struts2-portlet-plugin-2.3.16.java exists in that location. Does anyone know how to resolve this?
Edit: I've also added the struts2-portlet-plugin as a maven dependency in hopes that it would resolve the problem. No avail, the same errors are still appearing.
Also, here's the requested pom.xml:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.company.webapp</groupId>
<artifactId>webapp</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>webapp</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<finalName>app</finalName>
</build>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-core</artifactId>
<version>2.3.16</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-portlet-plugin</artifactId>
<version>2.3.16</version>
</dependency>
</dependencies>
</project>
After much headache and plenty of circles, I seem to have figured out the issue. Apparently, when building with maven, I do not need to copy the .jars from the distributed struts-ver/lib into my WEB-INF/lib folder. It's always something simple, eh?
Related
This error message shows that the Tomcat is 8.0.30, and I am using JDK 8. I am creating a Spring-boot project. Some suggested that JDK 8 should be used but I indeed am using JDK 8. What's the problem here?
信息: Starting Servlet Engine: Apache Tomcat/8.0.30
十月 18, 2018 12:26:19 下午 org.apache.catalina.startup.HostConfig deployDescriptor
信息: Deploying configuration descriptor /home/export/Domains/nluqe.jd.com/server1/conf/Catalina/localhost/ROOT.xml
十月 18, 2018 12:26:19 下午 org.apache.catalina.core.StandardContext setPath
警告: A context path must either be an empty string or start with a '/' and do not end with a '/'. The path [/] does not meet these criteria and has been changed to []
十月 18, 2018 12:26:32 下午 org.apache.catalina.startup.ContextConfig processAnnotationsJar
严重: Unable to process Jar entry [module-info.class] from Jar [jar:file:/home/export/App/nluqe.jd.com/WEB-INF/lib/lombok-1.16.22.jar!/] for annotations
org.apache.tomcat.util.bcel.classfile.ClassFormatException: Invalid byte tag in constant pool: 19
at org.apache.tomcat.util.bcel.classfile.Constant.readConstant(Constant.java:97)
at org.apache.tomcat.util.bcel.classfile.ConstantPool.<init>(ConstantPool.java:55)
at org.apache.tomcat.util.bcel.classfile.ClassParser.readConstantPool(ClassParser.java:176)
at org.apache.tomcat.util.bcel.classfile.ClassParser.parse(ClassParser.java:85)
at org.apache.catalina.startup.ContextConfig.processAnnotationsStream(ContextConfig.java:2011)
at org.apache.catalina.startup.ContextConfig.processAnnotationsJar(ContextConfig.java:1961)
at org.apache.catalina.startup.ContextConfig.processAnnotationsUrl(ContextConfig.java:1936)
at org.apache.catalina.startup.ContextConfig.processAnnotations(ContextConfig.java:1897)
at org.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.java:1149)
at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:771)
at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:305)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:95)
at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5154)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:725)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:701)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:717)
at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:586)
at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1777)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
十月 18, 2018 12:26:34 下午 org.apache.catalina.startup.ContextConfig processAnnotationsJar
严重: Unable to process Jar entry [module-info.class] from Jar [jar:file:/home/export/App/nluqe.jd.com/WEB-INF/lib/log4j-api-2.10.0.jar!/] for annotations
org.apache.tomcat.util.bcel.classfile.ClassFormatException: Invalid byte tag in constant pool: 19
at org.apache.tomcat.util.bcel.classfile.Constant.readConstant(Constant.java:97)
at org.apache.tomcat.util.bcel.classfile.ConstantPool.<init>(ConstantPool.java:55)
at org.apache.tomcat.util.bcel.classfile.ClassParser.readConstantPool(ClassParser.java:176)
at org.apache.tomcat.util.bcel.classfile.ClassParser.parse(ClassParser.java:85)
at org.apache.catalina.startup.ContextConfig.processAnnotationsStream(ContextConfig.java:2011)
at org.apache.catalina.startup.ContextConfig.processAnnotationsJar(ContextConfig.java:1961)
at org.apache.catalina.startup.ContextConfig.processAnnotationsUrl(ContextConfig.java:1936)
at org.apache.catalina.startup.ContextConfig.processAnnotations(ContextConfig.java:1897)
at org.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.java:1149)
at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:771)
at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:305)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:95)
at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5154)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:725)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:701)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:717)
at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:586)
at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1777)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Updated (I want to configure not scanning annotation per suggestions):
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop" xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd">
<bean id="executorService" class="java.util.concurrent.Executors" factory-method="newFixedThreadPool">
<constructor-arg value="20"></constructor-arg>
</bean>
<!-- jsf -->
<import resource="jsf-context.xml"/>
<aop:aspectj-autoproxy proxy-target-class="true"/>
<bean class="com.jd.ump.annotation.JAnnotation">
<property name="systemKey" value="com.nlu-qe-service.systemKey"></property>
<property name="jvmKey" value="com.nlu-qe-service.jvmKey"></property>
</bean>
</beans>
Tomcat 8.0 has reached End of Life and should not be used!
The replacement is Tomcat 8.5 (implementing the same specifications as Tomcat 8.0) or Tomcat 9.0 (newer versions of specifications). See "Migration Guide" at tomcat.apache.org.
org.apache.tomcat.util.bcel.classfile.Constant.readConstant(Constant.java:97)
The BCEL library here is used to parse class files when Tomcat scans for annotations. The version that you are using does not support some features in class file format of Java 8, and thus fails when trying to parse the file.
Your options:
Ignore.
Upgrade Tomcat.
Exclude those jars from annotation scanning. (See the official Tomcat FAQ → Performance → How do I make Tomcat start up faster?).
In order to upgrade the tomcat version for the tomcat7-maven-plugin.
<properties>
<tomcat7-version>7.0.93</tomcat7-version>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<dependencies>
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-core</artifactId>
<version>${tomcat7-version}</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
You can try to downgrade the version of glassfish packages in your dependencies.
Had the problem with 2.30.1 version (and Tomcat 8.5 Server), no more issue after changing to 2.22.2.
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-client</artifactId>
<version>2.22.2</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-json-jackson</artifactId>
<version>2.22.2</version>
</dependency>
I also got same issue. I just changed aspectjrt and aspectjweaver jar version to
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<version>1.8.5</version>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>1.8.5</version>
</dependency>
Try this one might work for you also.
I have application which uses camunda and spring boot
, and worked with embedded tomcat. But now I needed to install the application as war.
With standalone tomcat all is ok, but with weblogic I can not start the application.
I get the following error:
<Sep 5, 2018 9:59:42,539 PM MSK> <Error> <Deployer> <BEA-149265> <Failure occurred in the execution of deployment request with ID "24521744092298" for task "1" on [partition-name: DOMAIN]. Error is: "weblogic.application.ModuleException: java.lang.AbstractMethodError"
weblogic.application.ModuleException: java.lang.AbstractMethodError
at weblogic.application.internal.ExtensibleModuleWrapper.start(ExtensibleModuleWrapper.java:140)
at weblogic.application.internal.flow.ModuleListenerInvoker.start(ModuleListenerInvoker.java:124)
at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:233)
at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:228)
at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:45)
Truncated. see log file for complete stacktrace
Caused By: java.lang.AbstractMethodError
at org.glassfish.jersey.server.ApplicationHandler$4.get(ApplicationHandler.java:408)
at org.glassfish.jersey.server.ApplicationHandler$4.get(ApplicationHandler.java:399)
at org.glassfish.jersey.internal.util.collection.Values$LazyValueImpl.get(Values.java:340)
at org.glassfish.jersey.server.ApplicationHandler$3.call(ApplicationHandler.java:350)
at org.glassfish.jersey.server.ApplicationHandler$3.call(ApplicationHandler.java:347)
Truncated. see log file for complete stacktrace
>
<Sep 5, 2018 9:59:42,543 PM MSK> <Error> <Deployer> <BEA-149202> <Encountered an exception while attempting to commit the 9 task for the application "order-management-service_war_exploded" on [partition-name: DOMAIN].>
<Sep 5, 2018 9:59:42,545 PM MSK> <Warning> <Deployer> <BEA-149004> <Failures were detected while initiating deploy task for application "order-management-service_war_exploded".>
<Sep 5, 2018 9:59:42,545 PM MSK> <Warning> <Deployer> <BEA-149078> <Stack trace for message 149004
weblogic.application.ModuleException: java.lang.AbstractMethodError
at weblogic.application.internal.ExtensibleModuleWrapper.start(ExtensibleModuleWrapper.java:140)
at weblogic.application.internal.flow.ModuleListenerInvoker.start(ModuleListenerInvoker.java:124)
at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:233)
at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:228)
at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:45)
Truncated. see log file for complete stacktrace
Caused By: java.lang.AbstractMethodError
at org.glassfish.jersey.server.ApplicationHandler$4.get(ApplicationHandler.java:408)
at org.glassfish.jersey.server.ApplicationHandler$4.get(ApplicationHandler.java:399)
at org.glassfish.jersey.internal.util.collection.Values$LazyValueImpl.get(Values.java:340)
at org.glassfish.jersey.server.ApplicationHandler$3.call(ApplicationHandler.java:350)
at org.glassfish.jersey.server.ApplicationHandler$3.call(ApplicationHandler.java:347)
Truncated. see log file for complete stacktrace
And does not matter, do I use camunda enterprise edition or standard.
My pom contains the following dependencies:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.camunda.bpm.springboot</groupId>
<artifactId>camunda-bpm-spring-boot-starter-webapp-ee</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
How can I solve this problem?
EDIT
As I understand, the whole problem can be in the jersey, which is inside the dependency camunda.
I edit my weblogic.xml and this is how he came out:
<?xml version="1.0" encoding="UTF-8"?>
<wls:weblogic-web-app
xmlns:wls="http://xmlns.oracle.com/weblogic/weblogic-web-app"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.oracle.com/weblogic/weblogic-web-app
http://xmlns.oracle.com/weblogic/weblogic-web-app/1.9/weblogic-web-app.xsd">
<wls:container-descriptor>
<wls:prefer-application-packages>
<wls:package-name>org.apache.taglibs.*</wls:package-name>
<wls:package-name>org.springframework.*</wls:package-name>
<!--<wls:package-name>org.glassfish.*</wls:package-name>-->
<wls:package-name>javax.persistence.*</wls:package-name>
<wls:package-name>org.hibernate.*</wls:package-name>
<wls:package-name>javax.validation.*</wls:package-name>
<wls:package-name>javax.validation.bootstrap.*</wls:package-name>
<wls:package-name>javax.validation.constraints.*</wls:package-name>
<wls:package-name>javax.validation.groups.*</wls:package-name>
<wls:package-name>javax.validation.metadata.*</wls:package-name>
<wls:package-name>javax.validation.spi.*</wls:package-name>
<wls:package-name>com.fasterxml.jackson.*</wls:package-name>
<wls:package-name>org.slf4j.*</wls:package-name>
<wls:package-name>org.apache.logging.*</wls:package-name>
<!-- jsr311 -->
<wls:package-name>javax.ws.rs.*</wls:package-name>
<!-- javassist -->
<wls:package-name>javassist.*</wls:package-name>
<!-- aop repackaged -->
<wls:package-name>org.aopalliance.*</wls:package-name>
<!-- jersey 2 -->
<wls:package-name>jersey.repackaged.*</wls:package-name>
<wls:package-name>org.glassfish.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>
<!-- media providers -->
<wls:package-name>org.eclipse.persistence.*</wls:package-name>
<wls:package-name>org.codehaus.jackson.*</wls:package-name>
<wls:package-name>org.codehaus.jettison.*</wls:package-name>
<!-- hk2 -->
<wls:package-name>org.glassfish.hk2.*</wls:package-name>
<wls:package-name>org.jvnet.hk2.*</wls:package-name>
<wls:package-name>org.jvnet.tiger_types.*</wls:package-name>
<wls:package-name>org.objectweb.asm.*</wls:package-name>
<wls:package-name>antlr.*</wls:package-name>
<wls:package-name>com.sun.jersey.*</wls:package-name>
<wls:package-name>jersey.repackaged.org.objectweb.asm.*</wls:package-name>
</wls:prefer-application-packages>
<wls:prefer-application-resources>
<wls:resource-name>org.apache.taglibs.*</wls:resource-name>
<wls:resource-name>org.springframework.*</wls:resource-name>
<wls:resource-name>javax.persistence.*</wls:resource-name>
<wls:resource-name>javax.validation.*</wls:resource-name>
<wls:resource-name>org.hibernate.*</wls:resource-name>
<wls:resource-name>com.fasterxml.jackson.*</wls:resource-name>
</wls:prefer-application-resources>
</wls:container-descriptor>
</wls:weblogic-web-app>
But it also does not work, i get this error:
ogic.application.ModuleException: java.lang.ClassCastException: weblogic.jaxrs.server.media.multipart.Jersey1MultiPartSupport cannot be cast to org.glassfish.jersey.internal.spi.AutoDiscoverable
at weblogic.application.internal.ExtensibleModuleWrapper.start(ExtensibleModuleWrapper.java:140)
at weblogic.application.internal.flow.ModuleListenerInvoker.start(ModuleListenerInvoker.java:124)
at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:233)
at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:228)
at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:45)
Truncated. see log file for complete stacktrace
Caused By: java.lang.ClassCastException: weblogic.jaxrs.server.media.multipart.Jersey1MultiPartSupport cannot be cast to org.glassfish.jersey.internal.spi.AutoDiscoverable
at java.util.TreeMap.put(TreeMap.java:552)
at java.util.TreeSet.add(TreeSet.java:255)
at java.util.AbstractCollection.addAll(AbstractCollection.java:344)
at java.util.TreeSet.addAll(TreeSet.java:312)
at org.glassfish.jersey.model.internal.CommonConfig.configureAutoDiscoverableProviders(CommonConfig.java:599)
Truncated. see log file for complete stacktrace
>
I used latest weblogic 12.2.1.3, spring boot 2.0.4 and camunda 7.9.0 (starter 3.0.0)
I found a solution.
I edited my weblogic.xml to:
<?xml version="1.0" encoding="UTF-8"?>
<wls:weblogic-web-app
xmlns:wls="http://xmlns.oracle.com/weblogic/weblogic-web-app"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.oracle.com/weblogic/weblogic-web-app
http://xmlns.oracle.com/weblogic/weblogic-web-app/1.9/weblogic-web-app.xsd">
<wls:context-root>/order</wls:context-root>
<wls:container-descriptor>
<wls:prefer-application-packages>
<wls:package-name>org.apache.taglibs.*</wls:package-name>
<wls:package-name>org.springframework.*</wls:package-name>
<wls:package-name>javax.persistence.*</wls:package-name>
<wls:package-name>org.hibernate.*</wls:package-name>
<wls:package-name>javax.validation.*</wls:package-name>
<wls:package-name>javax.validation.bootstrap.*</wls:package-name>
<wls:package-name>javax.validation.constraints.*</wls:package-name>
<wls:package-name>javax.validation.groups.*</wls:package-name>
<wls:package-name>javax.validation.metadata.*</wls:package-name>
<wls:package-name>javax.validation.spi.*</wls:package-name>
<wls:package-name>com.fasterxml.jackson.*</wls:package-name>
<!--<wls:package-name>org.slf4j.*</wls:package-name>-->
<wls:package-name>org.apache.logging.*</wls:package-name>
<!-- jsr311 -->
<wls:package-name>javax.ws.rs.*</wls:package-name>
<!-- javassist -->
<wls:package-name>javassist.*</wls:package-name>
<!-- aop repackaged -->
<wls:package-name>org.aopalliance.*</wls:package-name>
<!-- jersey 2 -->
<wls:package-name>jersey.repackaged.*</wls:package-name>
<wls:package-name>org.glassfish.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>
<!-- media providers -->
<wls:package-name>org.eclipse.persistence.*</wls:package-name>
<wls:package-name>org.codehaus.jackson.*</wls:package-name>
<wls:package-name>org.codehaus.jettison.*</wls:package-name>
<!-- hk2 -->
<wls:package-name>org.glassfish.hk2.*</wls:package-name>
<wls:package-name>org.jvnet.hk2.*</wls:package-name>
<wls:package-name>org.jvnet.tiger_types.*</wls:package-name>
<wls:package-name>org.objectweb.asm.*</wls:package-name>
<wls:package-name>antlr.*</wls:package-name>
<wls:package-name>jersey.repackaged.org.objectweb.asm.*</wls:package-name>
</wls:prefer-application-packages>
<wls:prefer-application-resources>
<wls:resource-name>org.apache.taglibs.*</wls:resource-name>
<wls:resource-name>org.springframework.*</wls:resource-name>
<wls:resource-name>javax.persistence.*</wls:resource-name>
<wls:resource-name>javax.validation.*</wls:resource-name>
<wls:resource-name>org.hibernate.*</wls:resource-name>
<wls:resource-name>com.fasterxml.jackson.*</wls:resource-name>
<!-- apis -->
<wls:resource-name>javax.ws.rs.*</wls:resource-name>
<!-- jersey -->
<wls:resource-name>META-INF/services/org.glassfish.jersey.*</wls:resource-name>
<wls:resource-name>com.sun.jersey.*</wls:resource-name>
<wls:resource-name>org.glassfish.jersey.*</wls:resource-name>
<wls:resource-name>jersey.repackaged.*</wls:resource-name>
<!-- hk2 -->
<wls:resource-name>META-INF/services/org.glassfish.hk2.*</wls:resource-name>
<wls:resource-name>org.glassfish.hk2.*</wls:resource-name>
<wls:resource-name>org.jvnet.hk2.*</wls:resource-name>
<wls:resource-name>org.jvnet.hk2.tiger_types.*</wls:resource-name>
</wls:prefer-application-resources>
</wls:container-descriptor>
</wls:weblogic-web-app>
and to starter webapp added starter rest (I do not know why, but it works) with excluding jersey-container-servlet in pom.xml:
<dependency>
<groupId>org.camunda.bpm.springboot</groupId>
<artifactId>camunda-bpm-spring-boot-starter-rest</artifactId>
<version>${camunda.spring.boot.starter.version}</version>
<exclusions>
<exclusion>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.camunda.bpm.springboot</groupId>
<artifactId>camunda-bpm-spring-boot-starter-webapp</artifactId>
<version>${camunda.spring.boot.starter.version}</version>
<exclusions>
<exclusion>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet</artifactId>
</exclusion>
</exclusions>
</dependency>
I have 2 projects:
ProjectA And SharedProject.
I use the following POM file in ProjectA:
<dependency>
<groupId>MyGroup</groupId>
<artifactId>shared</artifactId>
<version>SNAPSHOT-1.0.0</version>
<scope>compile</scope>
</dependency>
<dependency>
And the pom of the shared project looks like this:
<modelVersion>4.0.0</modelVersion>
<groupId>MyGroup</groupId>
<artifactId>shared</artifactId>
<version>SNAPSHOT-1.0.0</version>
<name>shared</name>
<packaging>jar</packaging>
My ProjectA compiles (and actually do use imports from SharedProject) so I got that going on for me.
Problem is after running : ProjectA -> mvn install
and running on tomcat
I get an error of:
SEVERE: Exception starting filter cors
java.lang.ClassNotFoundException: com.mygroup.shared.filter.common.CorsFilter
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1702)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1547)
at org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:532)
at org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged(DefaultInstanceManager.java:514)
at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:142)
at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:260)
at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:107)
at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4775)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5452)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:724)
This not-found class is located in the SharedProject and referenced in ProjectA web.xml file. here is the ProjectA web.xml specific reference code:
<filter>
<filter-name>cors</filter-name>
<filter-class>com.mygroup.shared.filter.common.CorsFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>cors</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
Remove scope tag from dependency declaration, and everything will be okay.
The scope compile says to maven, that this dependency would be used only at the compile time. For example, it used in MapStruct, that generates code at compile phase, and after that there is no need for dependencies.
I want to connect to my MySQL database, and query some data. I am getting the following error:
2016-02-28 10:42:17,438] Artifact JavaEESecurity:war exploded: Error during artifact deployment. See server log for details. [2016-02-28 10:42:17,438] Artifact JavaEESecurity:war exploded: java.lang.Exception: {"WFLYCTL0080: Failed services" => {"jboss.deployment.unit.\"JavaEESecurity_war_exploded.war\".INSTALL"
=> "org.jboss.msc.service.StartException in service jboss.deployment.unit.\"JavaEESecurity_war_exploded.war\".INSTALL: WFLYSRV0153: Failed to process phase INSTALL of deployment \"JavaEESecurity_war_exploded.war\"
Caused by: org.jboss.as.server.deployment.DeploymentUnitProcessingException:
java.lang.ClassNotFoundException: com.mysql.jdbc.jdbc2.optional.MysqlDataSource from
[Module \"deployment.JavaEESecurity_war_exploded.war:main\" from Service Module Loader]
Caused by: java.lang.ClassNotFoundException: com.mysql.jdbc.jdbc2.optional.MysqlDataSource from [Module \"deployment.JavaEESecurity_war_exploded.war:main\" from Service Module Loader]"}}
I'm using maven in my project. This is my pom.xml file:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>my.own.group</groupId>
<artifactId>myOwnArtifactId</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-api</artifactId>
<version>2.2.13</version>
</dependency>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>7.0</version>
</dependency>
<dependency>
<groupId>jstl</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.38</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
This is my web.xml file:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
version="3.1">
<data-source>
<name>java:global/JavaEESecurity/myDS</name>
<class-name>com.mysql.jdbc.jdbc2.optional.MysqlDataSource</class-name>
<server-name>localhost</server-name>
<database-name>mncpp</database-name>
<user>root</user>
<transactional>true</transactional>
<initial-pool-size>2</initial-pool-size>
<max-pool-size>10</max-pool-size>
<min-pool-size>5</min-pool-size>
<max-statements>0</max-statements>
</data-source>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
</web-app>
And this is my bean class, in which I'd like to access my database:
#Named("questionListBean")
#RequestScoped
public class QuestionListBean {
List<String> questions;
#Resource(lookup = "java:global/JavaEESecurity/myDS")
DataSource ds;
public List<String> getQuestions() {
try (Connection connection = ds.getConnection()) {
Statement statement = connection.createStatement();
ResultSet rs = statement.executeQuery("SELECT question FROM questions");
questions = new ArrayList<>();
while(rs.next()) {
questions.add(rs.getString(1));
}
} catch (SQLException e) {
e.printStackTrace();
}
return questions;
}
}
Thanks in advance!
The ClassNotFoundException means that the Java runtime (the JVM) that runs your application server (Java EE server) is somehow not able to find the class com.mysql.jdbc.jdbc2.optional.MysqlDataSource. This class is a part of the MySQL JDBC Driver. Since this class is not available when your bean's method getQuestions() is called, the exception is thrown.
There are multiple ways in which you can fix this:
Make your application self contained. This means that you bundle
all the classes that your application needs along with it. This is
the whole point of a Java .ear (enterprise application archive).
Doing this (in theory) means that your application can be ported
rather easily. To do this, you can assemble your app in such a way
that you specify a runtime dependency on MySQL connector (see
mvnrepository
for the snippet and add <scope>runtime</scope>) in a
<dependency> element in your pom.xml. Then you can use the Maven
ear
plugin if you are assembling a .ear or Maven war plugin if you are assembling a .war
to bundle everything up.
Make the MySQL driver jar a part of your application server's classpath. That way, other applications can leverage those classes (you may have more than one app using MySQL, for instance). Application servers have this facility so that these classes are made available to apps. Read up your app server's documentation to see how to do it.
So I have two modules, let's call them moduleA and moduleB. My goal is to deploy both of them to Tomcat. Here is what I have done:
parent pom.xml
<project>
....
<artifactId>parentModule</artifactId>
<packaging>pom</packaging>
<modules>
<module>moduleA</module>
<module>moduleB</module>
</modules>
....
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk</artifactId>
<version>1.4.3</version>
</dependency>
</dependencies>
</dependencyManagement>
...
</project>
moduleA pom.xml
<project>
...
<parent>
...
<artifactId>parentModule</artifactId>
</parent>
...
</project>
moduleB pom.xml
<project>
...
<parent>
...
<artifactId>parentModule</artifactId>
</parent>
...
</project>
The directory structure looks like this
Users/swidjaja/dev/parentProject
pom.xml
moduleA
pom.xml
moduleB
pom.xml
These are the steps that I do to deploy it to Tomcat
[On Terminal] mvn clean install
[On Terminal] mvn eclipse:eclipse
[Eclipse] import project
[Eclipse] Create new Tomcat 7.0 server and add the two modules to Resources [Eclipse] Run Tomcat server
Running the Tomcat server, I got the following exception
SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanDefinitionStoreException: Invalid bean definition with name 'awsCredentials' defined in file [/Users/swidjaja/dev/parentProject/moduleA/target/moduleA-SNAPSHOT/WEB-INF/classes/applicationContext.xml]: null
at org.springframework.beans.factory.config.PlaceholderConfigurerSupport.doProcessProperties(PlaceholderConfigurerSupport.java:209)
at org.springframework.beans.factory.config.PropertyPlaceholderConfigurer.processProperties(PropertyPlaceholderConfigurer.java:220)
at org.springframework.beans.factory.config.PropertyResourceConfigurer.postProcessBeanFactory(PropertyResourceConfigurer.java:84)
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:681)
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:656)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:446)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:385)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:284)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:111)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:5003)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5517)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1574)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1564)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
And here is what the file applicationContext.xml looks like
<beans>
<bean id="awsCredentials" class="com.amazonaws.auth.BasicAWSCredentials">
<constructor-arg index="0" value="accessKey" />
<constructor-arg index="1" value="secretKey" />
</bean>
</beans>
My guess here is that somehow I didn't deploy it correctly. The BasicAWSCredentials class is part of aws-java-sdk which is defined as dependency in parent pom.xml and it looks like this module is not deployed correctly to Tomcat.
What did I do wrong in my steps? What will be the correct way to deploy such project? I've been struggling with this for 2 days now.
Any help is highly appreciated. Many Thanks!