Issue with deploying maven project with multiple modules to Tomcat 7.0 - java

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!

Related

Bootstrap a simple Java SE "Hello World" desktop application using JBoss Weld environment causes a runtime error

I'd like to use JBoss Weld as a CDI facility in a classic Hello World application in a maven structured project. To keep the things as clean & simple as possible, I only created a Weld environment object and nothing more. I also created the deployment descriptor file beans.xml in src/main/resources/META-INF and src/test/resources directories. I did't go further by creating and initializing a WeldContainer etc. I'm just wondering why this settings don't work in the first place.
The application compiles perfectly and generates an executable jar file with mvn package command. However I got a runtime error:
C:\dev\eclipse-workspace\my-app>java -cp target/my-app-1.0.jar app.Hello
Exception in thread "main" java.lang.NoClassDefFoundError: org/jboss/weld/environment/se/Weld
at app.Hello.main(Hello.java:7)
Caused by: java.lang.ClassNotFoundException: org.jboss.weld.environment.se.Weld
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.j
ava:602)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoader
s.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
... 1 more
So, here is my main class:
1 package app;
2
3 import org.jboss.weld.environment.se.Weld;
4
5 public class Hello {
6 public static void main(String[] args) {
7 Weld weld = new Weld();
8
9 System.out.println("Hello World");
10
11 weld.shutdown();
12 System.exit(0);
13 }
14 }
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
https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>jee</groupId>
<artifactId>my-app</artifactId>
<version>1.0</version>
<name>my-app</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>13</maven.compiler.source>
<maven.compiler.target>13</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>org.jboss.weld.se</groupId>
<artifactId>weld-se-core</artifactId>
<version>3.1.3.Final</version>
</dependency>
</dependencies>
</project>
and lastly my project structure:
Your help is appreciated in advance.
Thank you.
Alex
You will note that java -cp target/my-app-1.0.jar app.Hello does not include the Weld jars on the classpath (unless your jar file's META-INF/MANIFEST.MF has a Class-Path entry that references them). That is why Weld classes cannot be found at runtime when you start your application in this manner.

#PostConstruct method called twice when making the module containing the EJB a dependency of another module

My maven project structure looks like this:
test_project-parent
|test_project-ejb.jar
|test_project-depl.jar
|test_project-web.war
|test_project-ear.ear
My 3 modules: ejb, depl and web are packaged into the EAR.
I have an EJB in my ejb module that looks like this:
#Startup
#Singleton
public class StartupBean {
#PersistenceContext
private EntityManager em;
#PostConstruct
private void sayHello () {
System.out.println("HELLO !!!");
}
}
My problem is that that the sayHello() method is executed twice.
Here's the output from the log:
00:16:13,803 INFO [stdout] (ServerService Thread Pool -- 113) HELLO !!!
00:16:13,803 INFO [stdout] (ServerService Thread Pool -- 117) HELLO !!!
My ejb module is a dependency of my web module.
When I remove the dependency it works fine (the method is called once as it should be).
The pom.xml of my web module looks like this:
<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>
<parent>
<groupId>com.testing</groupId>
<artifactId>test_project</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>test_project-web</artifactId>
<packaging>war</packaging>
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>test_project-ejb</artifactId>
<version>${test_project.version}</version>
</dependency>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
</dependency>
</dependencies>
</project>
NOTE: I have read all the related posts and found no answer
I found my error. I needed to change the scope of my dependency to provided, because the way it was the dependency was packaged inside the war archive in it's lib folder. So, basically, my ejb module was deployed twice, and hence the double execution of the #PostConstruct method.
I added <scope>provided</scope> to the ejb dependency inside my web module pom.xml and everything works fine. The ejb module is no longer packaged inside the lib folder of the war archive and the #PostConstruct method is called only once.

Lifecycle exception when deploying example spring boot app

I am trying to understand the basic steps of how to deploy a spring boot application. However, despite the fact that I do everything correctly, I can't deploy it on a tomcat server. The tomcat successfuly extracts my war archive but it gives the folloving below error:
11-Dec-2016 16:49:31.975 SEVERE [localhost-startStop-1] org.apache.catalina.core.ContainerBase.addChildInternal ContainerBase.addChild: start:
org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/springrest]]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:167)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:752)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:728)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:734)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:952)
at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1823)
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)
Caused by: org.apache.catalina.LifecycleException: Failed to start component [org.apache.catalina.webresources.StandardRoot#5a0050e9]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:167)
at org.apache.catalina.core.StandardContext.resourcesStart(StandardContext.java:4842)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:4974)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
... 10 more
Caused by: org.apache.catalina.LifecycleException: Failed to initialize component [org.apache.catalina.webresources.JarResourceSet#57a81b37]
at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:112)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:140)
at org.apache.catalina.webresources.StandardRoot.startInternal(StandardRoot.java:708)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
... 13 more
Caused by: java.lang.IllegalArgumentException: java.util.zip.ZipException: invalid END header (bad central directory offset)
at org.apache.catalina.webresources.AbstractSingleArchiveResourceSet.initInternal(AbstractSingleArchiveResourceSet.java:113)
at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:107)
... 16 more
Caused by: java.util.zip.ZipException: invalid END header (bad central directory offset)
at java.util.zip.ZipFile.open(Native Method)
at java.util.zip.ZipFile.<init>(ZipFile.java:219)
at java.util.zip.ZipFile.<init>(ZipFile.java:149)
at java.util.jar.JarFile.<init>(JarFile.java:166)
at java.util.jar.JarFile.<init>(JarFile.java:103)
at org.apache.catalina.webresources.AbstractSingleArchiveResourceSet.initInternal(AbstractSingleArchiveResourceSet.java:110)
... 17 more
11-Dec-2016 16:49:31.976 SEVERE [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployWAR Error deploying web application archive /home/bora/Desktop/apache-tomcat-8.5.9/webapps/springrest.war
java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/springrest]]
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:756)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:728)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:734)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:952)
at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1823)
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)
I think the error is caused by a ZipException. But I don't understand why. I have followed this and this guides as exactly as it written, but ...
Here is more files, maybe it will be useful:
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.bora.test</groupId>
<artifactId>springrest</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.2.RELEASE</version>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.jayway.jsonpath</groupId>
<artifactId>json-path</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<properties>
<java.version>1.8</java.version>
</properties>
<!-- <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId> </plugin> </plugins> </build> -->
<repositories>
<repository>
<id>spring-releases</id>
<url>https://repo.spring.io/libs-release</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>spring-releases</id>
<url>https://repo.spring.io/libs-release</url>
</pluginRepository>
</pluginRepositories>
</project>
And my Application class:
package com.bora.rest;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.support.SpringBootServletInitializer;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.bind.annotation.RequestMapping;
#Configuration
#ComponentScan
#EnableAutoConfiguration
public class Application extends SpringBootServletInitializer {
private static Class<Application> applicationClass = Application.class;
#Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
// TODO Auto-generated method stub
return builder.sources(Application.class);
}
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
class GreetingController {
#RequestMapping("/")
String hello() {
return "Hello World";
}
}
I compile and package my maven project by givin mvn clean package and coppy the .war file into my tomcat's webapps folder. Restart the tomcat, it extracts but the above error occurs. I have been searching for solution for about 2 hours, but ...
My tomcat version is 8.5.9. I am using Ubuntu 16.04. Environment variables:
$CATALINA_BASE: /home/bora/Desktop/apache-tomcat-8.5.9
$CATALINA_HOME: /home/bora/Desktop/apache-tomcat-8.5.9
$CATALINA_TMPDIR: /home/bora/Desktop/apache-tomcat-8.5.9/temp
$JRE_HOME: /home/bora/Applications/jdk1.8.0_111
$CLASSPATH: /home/bora/Desktop/apache-tomcat-8.5.9/bin/bootstrap.jar:/home/bora/Desktop/apache-tomcat-8.5.9/bin/tomcat-juli.jar
I have strong knowledge about java language, I develop android applications. However, I am totally stranger to Java EE technologies. If someone finds an answer, could you please tell me the answer like you telling a child?
Thank you very much.
Spring-Boot ist using Tomcat 7 as default. This should be the reason why you get an exception. If u want to use Tomcat 8.5.9 u have to set the Version in your pom.xml:
<properties>
<tomcat.version>8.5.9</tomcat.version>
</properties>
EDIT
Use the spring-boot-maven-plugin for building the app. So you cant be sure your app is builded correctly.
EDIT 2
Just annotate your class with #SpringBootApplication this is enough. your Dont need the other ones.
EDIT 3
After compiling your code with my mentioned changes it worket fine. So the issue must be your config. Clear your local maven-repository and redownload the libaries. That should work.
It seems the version conflict, please check compiled version and JVM of Tomcat version are same.
Pls check JAVA_HOME
Check the Tomcat version to build. Follow the link: https://docs.spring.io/spring-boot/docs/current/reference/html/howto-embedded-servlet-containers.html
Check the Java version to build: http://docs.spring.io/spring-boot/docs/current/reference/html/using-boot-build-systems.html
Hope this help.

weblogic 12c deployment failure

I'm migrating from Weblogic 11g to 12c, during the deployment process it fails and shows the following error:
Caused by: weblogic.application.naming.ReferenceResolutionException: [J2EE:160199]Error resolving ejb-ref "ejb/BizRuleFacade" from module "BizAgi-ejb.jar" of application "BizAgi-ear-Weblogic". The ejb-ref does not have an ejb-link and the JNDI name of the target bean has not been specified. Attempts to automatically link the ejb-ref to its target bean failed because multiple EJBs in the application were found to implement the "BizAgi.bpm.rules.entities.BizRuleFacade" interface, including BizAgi-war.war/BizRuleFacadeBean, BizAgi-ejb.jar/BizRuleFacadeBean. Specify a qualified ejb-link for this ejb-ref to indicate which EJB is the target of this ejb-ref.
My web.xml file looks like this:
<ejb-local-ref>
<ejb-ref-name>ejb/BAScopeLogFacade</ejb-ref-name>
<ejb-ref-type>Session</ejb-ref-type>
<local>BizAgi.PAL.historylog.entities.BAScopeLogFacade</local>
<ejb-link>BizAgi-ejb.jar#BAScopeLogFacadeBean</ejb-link>
</ejb-local-ref>
The BizAgi-ejb.jar is a module inside the ear (BizAgi-ear-Weblogic.ear).
How can i properly deploy my application?
Thank you so much everybody, I've finally found the solution, it is to simply delete/remove the META-INF/MANIFEST.MF file from the .war file. That way the EJBs aren't double referenced.
1.Add below dependency in Ear Pom.xml
<dependency>
<groupId>com.example</groupId>
<artifactId>ejbModel</artifactId>
<version>1.0-SNAPSHOT</version>
<type>ejb</type>
</dependency>
2.In Ear pom.xml in modules add ejb module
<modules>
<ejbModule>
<groupId>com.example</groupId>
<artifactId>ejbModel</artifactId>
<bundleFileName>ejbModel-1.0-SNAPSHOT.jar</bundleFileName>
</ejbModule>
.......
</modules>
3.Change scope of ejbmodel dependency to provided in application pom.xml
<dependency>
<groupId>com.example</groupId>
<artifactId>ejbModel</artifactId>
<version>1.0-SNAPSHOT</version>
<type>jar</type>
<scope>provided</scope>
</dependency>
4.add persistence.xml of ejbmodel application to resource folder
Make sure that the same EJBs are not loaded multiple times in your deployment. You can check this by using the weblogic console (AdminServer) and checking the EJBs of the deployment (by clicking the little "+" sign next to the deployment that is failing int the deployments overview).
In my case I had to fix the maven dependencies (by setting one dependency of one project to "provided") so that it did not load the same EJB twice.
ERROR:
weblogic.management.DeploymentException: weblogic.application.naming.ReferenceResolutionException: [J2EE:160199]Error resolving ejb-ref "com.xxx.xxx.xxx.xxx.xxx.xxx.XXXX/xxxRemote" from module
"XXX-X.X.X.war" of application "XXX-X.X.X". The ejb-ref does not have an ejb-link and the JNDI name of the target Bean has not been specified.
SOLUTION:
1 SOLUTION: pom.xml (Web Project)
<dependencies>
<dependency>
<groupId>co.xx.cxxxx</groupId>
<artifactId>xxxxx-ejb</artifactId>
<version>1.0</version>
<type>ejb</type>
<scope>provided</scope>
</dependency>
<dependencies>
2 SOLUTION: Delete xxxxx-ejb.jar
xxxx.ear > xxxx.war > WEB-INF > lib > xxx-ejb.jar [remove]
3 Conclusion:
This is because there is a double reference to the ejb.jar, therefore the best way to control this is by saying in pom (web) that the is of type EJB, in order to take the (ejb.jar ) from the parent (EAR, where the ejb module is added).
I hope to be of help

Adding Struts2 Filters Causes Blank Page

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?

Categories

Resources