Liferay 6 Using Common Service Builder layer Error - BeanLocatorException - BeanLocator has not been set - exception

We are trying to use liferay service builder as a common layer for all our portlets. We have created a separate common portlet project where we are building the service using service.xml This generates a service.jar file for us. We are copying this jar to all portlets WEB-INF/lib dir.
When we run the portlet it throws following error on the logs and Portlet is temporarily unavailable message is displayed on the portlet.
14:43:17,447 ERROR [jsp:154] com.liferay.portal.kernel.bean.BeanLocatorException: BeanLocator has not been set
at com.liferay.portal.kernel.bean.PortletBeanLocatorUtil.locate(PortletBeanLocatorUtil.java:40)
at com.cogs.common.service.CourseLocalServiceUtil.getService(CourseLocalServiceUtil.java:223)
at com.cogs.common.service.CourseLocalServiceUtil.getCoursesCount(CourseLocalServiceUtil.java:187)
at org.apache.jsp.jsps.course.course_005fview_jsp._jspService(course_005fview_jsp.java:542)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:377)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:646)
at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:551)
at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:488)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:646)
I am sure that this approach should work seamlessly. But found several people complaining about it on liferay forums, but did not find any solution yet. Please let us know if you found a way to use service builder as a common layer and it worked for you.
We are using maven for building all portlet projects.
Liferay Version is 6.0.5
And we are using Spring Portlet MVC for our portlet development.

You have to build-service AND deploy the (Portlet-Hook) that is required for your current portlet, you can know it by see its name in liferay-plugin-package.properties file as:
required-deployment-contexts=[Portlet-Hook name]

I tryed anything written on that page, but nothing worked for me, until i added the project's version
to maven-pluginname in pom:
<configuration>
<autoDeployDir>${liferay.auto.deploy.dir}</autoDeployDir>
<appServerDeployDir>${liferay.app.server.deploy.dir}</appServerDeployDir>
<appServerLibGlobalDir>${liferay.app.server.lib.global.dir}</appServerLibGlobalDir>
<appServerPortalDir>${liferay.app.server.portal.dir}</appServerPortalDir>
<liferayVersion>${liferay.version}</liferayVersion>
<pluginType>portlet</pluginType>
<pluginName>${project.artifactId}-${project.version}</pluginName>
</configuration>
and in liferay-plugin-package.properties:
artifactId-version-deployment-context=artifactId-version
for example:
portlet-sample-1.0-deployment-context=portlet-sample-1.0
where artifactId = portlet-sample
and version = 1.0
After all I i built services, and redeployed my war.
I came to the solution because I debugged:
com.liferay.portal.kernel.bean.PortletBeanLocatorUtil
where
BeanLocator beanLocator = getBeanLocator(servletContextName);
is called which always returned null without versionnumber...
I hope someone helps this.

I had a hard time finding a solution to this error so I will post what we did. The name of the portlet changed, built the service and when running the portlet throws the same error:
com.liferay.portal.kernel.bean.BeanLocatorException: BeanLocator has not been set for servlet context
In our case we had to remove the jar file from ../docroot/WEB-INF/lib/portlet-service.jar

We had a requirement to use something similar: Have a portlet (lets say Source-portlet) whose services will be used by other portlets.
So we moved the generated sourceportlet-service.jar from the Source-portlet's WEB-INF/lib to {tomcat_home}/lib/ext folder were other jars like portlet-service.jar etc reside.
The down side of this approach is whenever there is a change in the Source-portlet we would need to restart the server.
If the other portlet's are your custom plugin portlets than another approach would be to copy the generated sourceportlet-service.jar to other portlet's WEB-INF/lib. This approach does not work if you are using the service in a JSP hook.
Hope this would help.

The previous answer by Martin Gamulin is correct. If you have two separate web apps, one for Spring portlets and another with your Service Builder (which seems to be the correct way to do things in Liferay), then you need to ensure that your Spring portlets do not reference your ServiceBuilder classes during initialization.
If they do then depending on the order in which your app server instantiates your webapps (and in Tomcat you can't specify a startup order), the BeanLocatorException will happen every time the portlets webapp deploys before the builder webapp.
In our case this meant moving a XxxLocalServiceUtil.createXxx(0) call from the constructor of the portlet Controller to the relevant methods.

I had a a similar problem doing a maven portlet.
First i did the portlet and then i put the service.xml
The issue was that the generator was looking for a portlet name that was not there
i solved making expliciting the portlet name i wanteed the genrator to look for
in particular, to do this two pom nodes must be equal
project.artifatctId = (liferay creates a bean locator for this)
and
project.build.(liferay plugin).configuration.pluginName = the internal name of the portlet for the generator
as an example, a small exerpt from my pom.xml
<modelVersion>4.0.0</modelVersion>
<groupId>io.endeios</groupId>
<artifactId>ShowTheCats-portlet</artifactId><!-- ONE -->
<packaging>war</packaging>
<name>ShowTheCats Portlet</name>
<version>1.0-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<groupId>com.liferay.maven.plugins</groupId>
<artifactId>liferay-maven-plugin</artifactId>
<version>${liferay.maven.plugin.version}</version>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>build-css</goal>
</goals>
</execution>
</executions>
<configuration>
<autoDeployDir>${liferay.auto.deploy.dir}</autoDeployDir>
<appServerDeployDir>${liferay.app.server.deploy.dir}</appServerDeployDir>
<appServerLibGlobalDir>${liferay.app.server.lib.global.dir}</appServerLibGlobalDir>
<appServerPortalDir>${liferay.app.server.portal.dir}</appServerPortalDir>
<liferayVersion>${liferay.version}</liferayVersion>
<pluginType>portlet</pluginType>
<pluginName>ShowTheCats-portlet</pluginName><!-- TWO -->
</configuration>
</plugin>
ONE and TWo must be the same

Problem with BeenLocator with my spring portlet for me was
that my portlet's spring context was getting initialized before liferay's spring context did.
I was using
ClassName className = ClassNameLocalServiceUtil.getClassName(JournalArticle.class.getName()); in my constructor. LIferay's context was not loaded hence the error. I moved that piece of code to be called when (only that time) first request needed it. Problem was solved.
So do not depend on lifery during initialization of your portlet, do some kind of "lazy" wiring of dependencies to liferay.

Since you are using maven, try to make sure your war name equals to your portlet project name.
After debug i've found that ClpSerializer defines _servletContextName which is equal to <artifactId> of war project. If you deploy artifact named artifactId-1.0.0-snapshot.war the context will be created with that name, but code, generated by servicegen expects it to be artifactId. Verify with your ClpSerializer.

I also had the same problem. I placed the following code in liferay-plugin-package.properties file of portlets which uses the service layer of common portlet. It worked for me.
required-deployment-contexts=common-portlet
It's better to copy the service.jar file to tomcat/lib/ext instead of all portlets WEB-INF/lib.

I did the following to solve the above problem:
Set the plugin config property pluginName in pom.xml to the correct context
<plugin>
<groupId>com.liferay.maven.plugins</groupId>
<artifactId>liferay-maven-plugin</artifactId>
<version>${liferay.version}</version>
<configuration>
<autoDeployDir>${liferay.auto.deploy.dir}</autoDeployDir>
<appServerPortalDir>${liferay.app.server.portal.dir}</appServerPortalDir>
<liferayVersion>${liferay.version}</liferayVersion>
<pluginType>portlet</pluginType>
<pluginName>XXXX-portlet</pluginName>
</configuration>
</plugin>
Optionally set the XXXX-portlet-deployment-context property in liferay plugin properties file or portlet.properties file
XXXX-portlet-deployment-context=XXXX-portlet
Re-Build the services
Verify if the generated ClpSerializer.java contains the correct contexts
` public static String getServletContextName() {
if (Validator.isNotNull(_servletContextName)) {
return _servletContextName;
}
synchronized (ClpSerializer.class) {
if (Validator.isNotNull(_servletContextName)) {
return _servletContextName;
}
try {
ClassLoader classLoader = ClpSerializer.class.getClassLoader();
Class<?> portletPropsClass = classLoader.loadClass(
"com.liferay.util.portlet.PortletProps");
Method getMethod = portletPropsClass.getMethod("get",
new Class<?>[] { String.class });
String portletPropsServletContextName = (String) getMethod.invoke(null,
"XXXX-portlet-deployment-context");
if (Validator.isNotNull(portletPropsServletContextName)) {
_servletContextName = portletPropsServletContextName;
}
} catch (Throwable t) {
if (_log.isInfoEnabled()) {
_log.info(
"Unable to locate deployment context from portlet properties");
}
}
if (Validator.isNull(_servletContextName)) {
try {
String propsUtilServletContextName = PropsUtil.get(
"XXXX-portlet-deployment-context");
if (Validator.isNotNull(propsUtilServletContextName)) {
_servletContextName = propsUtilServletContextName;
}
} catch (Throwable t) {
if (_log.isInfoEnabled()) {
_log.info(
"Unable to locate deployment context from portal properties");
}
}
}
if (Validator.isNull(_servletContextName)) {
_servletContextName = "upay-portlet";
}
return _servletContextName;
}
}`
Deploy the war, verify the war name and the logs for the correct context name.

Related

Error 404 webpage not found when submitting form [duplicate]

I have an HTML form in a JSP file in my WebContent/jsps folder. I have a servlet class servlet.java in my default package in src folder. In my web.xml it is mapped as /servlet.
I have tried several URLs in action attribute of the HTML form:
<form action="/servlet">
<form action="/servlet.java">
<form action="/src/servlet.java">
<form action="../servlet.java">
But none of those work. They all keep returning a HTTP 404 error like below in Tomcat 6/7/8:
HTTP Status 404 — /servlet
Description: The requested resource (/servlet) is not available.
Or as below in Tomcat 8.5/9:
HTTP Status 404 — Not Found
Message: /servlet
Description: The origin server did not find a current representation for the target resource or is not willing to disclose that one exists
Or as below in Tomcat 10:
HTTP Status 404 — Not Found
Type: Status Report
Message: The requested resource (/servlet) is not available
Description: The origin server did not find a current representation for the target resource or is not willing to disclose that one exists
Why is it not working?
Introduction
This can have a lot of causes which are broken down in following sections:
Put servlet class in a package
Set servlet URL in url-pattern
#WebServlet works only on Servlet 3.0 or newer
javax.servlet.* doesn't work anymore in Servlet 5.0 or newer
Make sure compiled *.class file is present in built WAR
Test the servlet individually without any JSP/HTML page
Use domain-relative URL to reference servlet from HTML
Use straight quotes in HTML attributes
Put servlet class in a package
First of all, put the servlet class in a Java package. You should always put publicly reuseable Java classes in a package, otherwise they are invisible to classes which are in a package, such as the server itself. This way you eliminate potential environment-specific problems. Packageless servlets work only in specific Tomcat+JDK combinations and this should never be relied upon.
In case of a "plain" IDE project, the class needs to be placed in its package structure inside the "Java Sources" folder, not inside "Web Content" folder, which is for web files such as JSP. Below is an example of the folder structure of a default Eclipse Dynamic Web Project as seen in Navigator view (the "Java Sources" folder is in such project by default represented by src folder):
EclipseProjectName
|-- src
| `-- com
| `-- example
| `-- YourServlet.java
|-- WebContent
| |-- WEB-INF
| | `-- web.xml
| `-- jsps
| `-- page.jsp
:
In case of a Maven project, the class needs to be placed in its package structure inside main/java and thus not main/resources, this is for non-class files and absolutely also not main/webapp, this is for web files. Below is an example of the folder structure of a default Maven webapp project as seen in Eclipse's Navigator view:
MavenProjectName
|-- src
| `-- main
| |-- java
| | `-- com
| | `-- example
| | `-- YourServlet.java
| |-- resources
| `-- webapp
| |-- WEB-INF
| | `-- web.xml
| `-- jsps
| `-- page.jsp
:
Note that the /jsps subfolder is not strictly necessary. You can even do without it and put the JSP file directly in webcontent/webapp root, but I'm just taking over this from your question.
Set servlet URL in url-pattern
The servlet URL is specified as the "URL pattern" of the servlet mapping. It's absolutely not per definition the classname/filename of the servlet class. The URL pattern is to be specified as value of #WebServlet annotation.
package com.example; // Use a package!
import jakarta.servlet.annotation.WebServlet; // or javax.*
import jakarta.servlet.http.HttpServlet; // or javax.*
#WebServlet("/servlet") // This is the URL of the servlet.
public class YourServlet extends HttpServlet { // Must be public and extend HttpServlet.
// ...
}
In case you want to support path parameters like /servlet/foo/bar, then use an URL pattern of /servlet/* instead. See also Servlet and path parameters like /xyz/{value}/test, how to map in web.xml?
Do note that it's considered a bad practice to use a Servlet URL pattern of /* or / in an attempt to have a "front controller". So do not abuse these URL patterns in an attempt to try to catch all URLs. For an in depth explanation see also Difference between / and /* in servlet mapping url pattern.
#WebServlet works only on Servlet 3.0 or newer
In order to use #WebServlet, you only need to make sure that your web.xml file, if any (it's optional since Servlet 3.0), is declared conform Servlet 3.0+ version and thus not conform e.g. 2.5 version or lower. It should absolutely also not have any <!DOCTYPE> line. Below is a Servlet 6.0 compatible one (which matches Tomcat 10.1+, WildFly 27+ (Preview), GlassFish/Payara 7+, etc) in its entirety:
<?xml version="1.0" encoding="UTF-8"?>
<web-app
xmlns="https://jakarta.ee/xml/ns/jakartaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee https://jakarta.ee/xml/ns/jakartaee/web-app_6_0.xsd"
version="6.0"
>
<!-- Config here. -->
</web-app>
And below is a Servlet 5.0 compatible one (which matches Tomcat 10.0.x, WildFly 22+ (Preview), GlassFish/Payara 6+, etc).
<?xml version="1.0" encoding="UTF-8"?>
<web-app
xmlns="https://jakarta.ee/xml/ns/jakartaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee https://jakarta.ee/xml/ns/jakartaee/web-app_5_0.xsd"
version="5.0"
>
<!-- Config here. -->
</web-app>
And below is a Servlet 4.0 compatible one (which matches Tomcat 9+, WildFly 11+, GlassFish/Payara 5+, etc).
<?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_4_0.xsd"
version="4.0"
>
<!-- Config here. -->
</web-app>
Or, in case you're not on Servlet 3.0+ yet (e.g. Tomcat 6 or older), then remove the #WebServlet annotation.
package com.example;
import javax.servlet.http.HttpServlet;
public class YourServlet extends HttpServlet {
// ...
}
And register the servlet instead in web.xml like this:
<servlet>
<servlet-name>yourServlet</servlet-name>
<servlet-class>com.example.YourServlet</servlet-class> <!-- Including the package thus -->
</servlet>
<servlet-mapping>
<servlet-name>yourServlet</servlet-name>
<url-pattern>/servlet</url-pattern> <!-- This is the URL of the servlet. -->
</servlet-mapping>
Note thus that you should not use both ways. Use either annotation based configuarion or XML based configuration. When you have both, then XML based configuration will override annotation based configuration.
javax.servlet.* doesn't work anymore in Servlet 5.0 or newer
Since Jakarta EE 9 / Servlet 5.0 (Tomcat 10, TomEE 9, WildFly 22 Preview, GlassFish 6, Payara 6, Liberty 22, etc), the javax.* package has been renamed to jakarta.* package.
In other words, please make absolutely sure that you don't randomly put JAR files of a different server in your WAR project such as tomcat-servlet-api-9.x.x.jar merely in order to get the javax.* package to compile. This will only cause trouble. Remove it altogether and edit the imports of your servlet class from
import javax.servlet.*;
import javax.servlet.annotation.*;
import javax.servlet.http.*;
to
import jakarta.servlet.*;
import jakarta.servlet.annotation.*;
import jakarta.servlet.http.*;
In case you're using Maven, you can find examples of proper pom.xml declarations for Tomcat 10+, Tomcat 9-, JEE 9+ and JEE 8- in this answer: How to properly configure Jakarta EE libraries in Maven pom.xml for Tomcat? The alternative is to downgrade the server to an older version, e.g. from Tomcat 10 back to Tomcat 9 or older, but this is clearly not the recommended way to go.
Make sure compiled *.class file is present in built WAR
In case you're using a build tool such as Eclipse and/or Maven, then you need to make absolutely sure that the compiled servlet class file resides in its package structure in /WEB-INF/classes folder of the produced WAR file. In case of package com.example; public class YourServlet, it must be located in /WEB-INF/classes/com/example/YourServlet.class. Otherwise you will face in case of #WebServlet also a 404 error, or in case of <servlet> a HTTP 500 error like below:
HTTP Status 500
Error instantiating servlet class com.example.YourServlet
And find in the server log a java.lang.ClassNotFoundException: com.example.YourServlet, followed by a java.lang.NoClassDefFoundError: com.example.YourServlet, in turn followed by jakarta.servlet.ServletException: Error instantiating servlet class com.example.YourServlet.
An easy way to verify if the servlet is correctly compiled and placed in classpath is to let the build tool produce a WAR file (e.g. rightclick project, Export > WAR file in Eclipse) and then inspect its contents with a ZIP tool. If the servlet class is missing in /WEB-INF/classes, or if the export causes an error, then the project is badly configured or some IDE/project configuration defaults have been mistakenly reverted (e.g. Project > Build Automatically has been disabled in Eclipse).
You also need to make sure that the project icon has no red cross indicating a build error. You can find the exact error in Problems view (Window > Show View > Other...). Usually the error message is fine Googlable. In case you have no clue, best is to restart from scratch and do not touch any IDE/project configuration defaults. In case you're using Eclipse, you can find instructions in How do I import the javax.servlet / jakarta.servlet API in my Eclipse project?
Test the servlet individually without any JSP/HTML page
Provided that the server runs on localhost:8080, and that the WAR is successfully deployed on a context path of /contextname (which defaults to the IDE project name, case sensitive!), and the servlet hasn't failed its initialization (read server logs for any deploy/servlet success/fail messages and the actual context path and servlet mapping), then a servlet with URL pattern of /servlet is available at http://localhost:8080/contextname/servlet.
You can just enter it straight in browser's address bar to test it invidivually. If its doGet() is properly overriden and implemented, then you will see its output in browser. Or if you don't have any doGet() or if it incorrectly calls super.doGet(), then a "HTTP 405: HTTP method GET is not supported by this URL" error will be shown (which is still better than a 404 as a 405 is evidence that the servlet itself is actually found).
Overriding service() is a bad practice, unless you're reinventing a MVC framework — which is very unlikely if you're just starting out with servlets and are clueless as to the problem described in the current question ;) See also Design Patterns web based applications.
Regardless, if the servlet already returns 404 when tested invidivually, then it's entirely pointless to try with a HTML form instead. Logically, it's therefore also entirely pointless to include any HTML form in questions about 404 errors from a servlet.
Use domain-relative URL to reference servlet from HTML
Once you've verified that the servlet works fine when invoked individually, then you can advance to HTML. As to your concrete problem with the HTML form, the <form action> value needs to be a valid URL. The same applies to <a href>, <img src>, <script src>, etc. You need to understand how absolute/relative URLs work. You know, an URL is a web address as you can enter/see in the webbrowser's address bar. If you're specifying a relative URL as form action, i.e. without the http:// scheme, then it becomes relative to the current URL as you see in your webbrowser's address bar. It's thus absolutely not relative to the JSP/HTML file location in server's WAR folder structure as many starters seem to think.
So, assuming that the JSP page with the HTML form is opened by http://localhost:8080/contextname/jsps/page.jsp (and thus not by file://...), and you need to submit to a servlet located in http://localhost:8080/contextname/servlet, here are several cases (note that you can here safely substitute <form action> with <a href>, <img src>, <script src>, etc):
Form action submits to an URL with a leading slash.
<form action="/servlet">
The leading slash / makes the URL relative to the domain, thus the form will submit to
http://localhost:8080/servlet
But this will likely result in a 404 as it's in the wrong context.
Form action submits to an URL without a leading slash.
<form action="servlet">
This makes the URL relative to the current folder of the current URL, thus the form will submit to
http://localhost:8080/contextname/jsps/servlet
But this will likely result in a 404 as it's in the wrong folder.
Form action submits to an URL which goes one folder up.
<form action="../servlet">
This will go one folder up (exactly like as in local disk file system paths!), thus the form will submit to
http://localhost:8080/contextname/servlet
This one must work!
The canonical approach, however, is to make the URL domain-relative so that you don't need to fix the URLs once again when you happen to move the JSP files around into another folder.
<form action="${pageContext.request.contextPath}/servlet">
This will generate
<form action="/contextname/servlet">
Which will thus always submit to the right URL.
Use straight quotes in HTML attributes
You need to make absolutely sure you're using straight quotes in HTML attributes like action="..." or action='...' and thus not curly quotes like action=”...” or action=’...’. Curly quotes are not supported in HTML and they will simply become part of the value. Watch out when copy-pasting code snippets from blogs! Some blog engines, notably Wordpress, are known to by default use so-called "smart quotes" which thus also corrupts the quotes in code snippets this way. On the other hand, instead of copy-pasting code, try simply typing over the code yourself. Additional advantage of actually getting the code through your brain and fingers is that it will make you to remember and understand the code much better in long term and also make you a better developer.
See also:
Our servlets wiki page - Contains some hello world examples
How to call servlet class from HTML form
doGet and doPost in Servlets
How do I pass current item to Java method by clicking a hyperlink or button in JSP page?
Other cases of HTTP Status 404 error:
HTTP Status 404 - Servlet [ServletName] is not available
HTTP Status 404 - The requested resource (/ProjectName/) is not available
HTTP Status 404 - The requested resource (/) is not available
JSP in /WEB-INF returns "HTTP Status 404 The requested resource is not available"
Referencing a resource placed in WEB-INF folder in JSP file returns HTTP 404 on resource
Browser can't access/find relative resources like CSS, images and links when calling a Servlet which forwards to a JSP
Scenario #1: You accidentially re-deployed from the command line while tomcat was already running.
Short Answer: Stop Tomcat, delete target folder, mvn package, then re-deploy
Scenario #2: request.getRequestDispatcher("MIS_SPELLED_FILE_NAME.jsp")
Short Answer: Check file name spelling, make sure case is correct.
Scenario #3: Class Not Found Exceptions
(Answer put here because: Question# 17982240 )
(java.lang.ClassNotFoundException for servlet in tomcat with eclipse )
(was marked as duplicate and directed me here )
Short Answer #3.1: web.xml has wrong package path in servlet-class tag.
Short Answer #3.2: java file has wrong import statement.
Below is further details for Scenario #1:
1: Stop Tomcat
Option 1: Via CTRL+C in terminal.
Option 2: (terminal closed while tomcat still running)
------------ 2.1: press:Windows+R --> type:"services.msc"
------------ 2.2: Find "Apache Tomcat #.# Tomcat#" in Name column of list.
------------ 2.3: Right Click --> "stop"
2: Delete the "target" folder.
(mvn clean will not help you here)
3: mvn package
4: YOUR_DEPLOYMENT_COMMAND_HERE
(Mine: java -jar target/dependency/webapp-runner.jar --port 5190 target/*.war )
Full Back Story:
Accidentially opened a new git-bash window and
tried to deploy a .war file for my heroku project via:
java -jar target/dependency/webapp-runner.jar --port 5190 target/*.war
After a failure to deploy, I realized I had two git-bash windows open,
and had not used CTLR+C to stop the previous deployment.
I was met with:
HTTP Status 404 – Not Found Type Status Report
Message /if-student-test.jsp
Description The origin server did not find a current representation
for the target resource or is not willing to disclose that one
exists.
Apache Tomcat/8.5.31
Below is further details for Scenario #3:
SCENARIO 3.1:
The servlet-class package path is wrong
in your web.xml file.
It should MATCH the package statement at top
of your java servlet class.
File: my_stuff/MyClass.java:
package my_stuff;
File: PRJ_ROOT/src/main/webapp/WEB-INF/web.xml
<servlet-class>
my_stuff.MyClass
</servlet-class>
SCENARIO 3.2:
You put the wrong "package" statement
at top of your myClass.java file.
For example:
File is in: "/my_stuff" folder
You mistakenly write:
package com.my_stuff
This is tricky because:
1: The maven build (mvn package) will not report any errors here.
2: servlet-class line in web.xml can have CORRECT package path. E.g:
<servlet-class>
my_stuff.MyClass
</servlet-class>
Stack Used:
Notepad++ + GitBash + Maven + Heroku Web App Runner + Tomcat9 + Windows10:
Check if you have entered the correct URL Mapping as specified in the Web.xml
For example:
In the web.xml, your servlet declaration maybe:
<servlet>
<servlet-name>ControllerA</servlet-name>
<servlet-class>PackageName.ControllerA</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>ControllerA</servlet-name>
<url-pattern>/theController</url-pattern>
</servlet-mapping>
What this snippet does is <url-pattern>/theController</url-pattern>will set the name that will be used to call the servlet from the front end (eg: form) through the URL. Therefore when you reference the servlet in the front end, in order to ensure that the request goes to the servlet "ControllerA", it should refer the specified URL Pattern "theController" from the form.
eg:
<form action="theController" method="POST">
</form>
If you're using IntelliJ, this is what fixed it for me:
Go to the Tomcat configuration:
Configuration > Deployment Tab
Scroll down and add / to the Application Context dropdown
Solution for HTTP Status 404 in NetBeans IDE:
Right click on your project and go to your project properties, then click on run, then input your project relative URL like index.jsp.
Project->Properties
Click on Run
Relative URL:/index.jsp (Select your project root URL)
My issue was that my method was missing the #RequestBody annotation. After adding the annotation I no longer received the 404 exception.
Do the following two steps. I hope, it will solve the "404 not found" issue in tomcat server during the development of java servlet application.
Step 1: Right click on the server(in the server explorer tab)->Properties->Switch Location from workspace metadata to tomcat server
Step 2: Double Click on the server(in the server explorer tab)->Select Use tomcat installation option inside server location menu
I removed the old web library such that are spring framework libraries. And build a new path of the libraries. Then it works.
An old thread, but since I didn't find it elsewhere, here is one more possibility:
If you're using servlet-api 3.0+, then your web.xml must NOT include metadata-complete="true" attribute
This tells tomcat to map the servlets using data given in web.xml instead of using the #WebServlet annotation.
First of all, run your IDE as Admin. After that, right click the project folder -> Project Facets and make sure that the Java Version is set correct. On my PC. (For Example 1.8) Now it should work.
Don't just start your server, for example Wildfly, using the cmd. It has to be launched within the IDE and now visit your localhost URL. Example: http://localhost:8080/HelloWorldServlet/HelloWorld
The fix that worked for me is(if you are using Maven): Rightclick your project, Maven -> Update project. This might give you some other error with the JDK and other Libraries(in my case, MySQL connector), but once you fix them, your original problem should be fixed!
If you would like to open a servlet with javascript without using 'form' and 'submit' button, here is the following code:
var button = document.getElementById("<<button-id>>");
button.addEventListener("click", function() {
window.location.href= "<<full-servlet-path>>" (eg. http://localhost:8086/xyz/servlet)
});
Key:
1) button-id : The 'id' tag you give to your button in your html/jsp file.
2) full-servlet-path: The path that shows in the browser when you run the servlet alone
Mapping in web.xml is what i have done :-
If there's another package made for new program then we must mention :-
packagename.filename between opening and closing of servlet-class tag in xml file.
If you are mapping your files in xml and they are not working or showing errors , then comment on the annotation line of code in the respective files.
Both methods dont work with one another , so either i use annotation method of files mentioned when we create servlet or the way of mapping , then i delete or comment the annotation line. Eg:
<servlet>
<servlet-name>s1</servlet-name>
<servlet-class>performance.FirstServ</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>s1</servlet-name>
<url-pattern>/FirstServ</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>s2</servlet-name>
<servlet-class>performance.SecondServ</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>s2</servlet-name>
<url-pattern>/SecondServ</url-pattern>
</servlet-mapping>
Commenting the annotation line of code in the respective file,if mapping in xml is done.
//#WebServlet("/FirstServ")
//#WebServlet("/SecondServ")
If someone is here who is using MySQL and felt that the code was working the previous day and now it doesn't, then I guess you must open MySQL CLI or MySQL Workbench and just make the connection to the database once. Once it gets connected, then the database also gets connected to the Java Application. I used to get the Hibernate Dialect error stating something wrong with com.mysql.jdbc.Driver. I think MySQL in some computers has a startup problem. This solved for me.
If you are a student and new to Java there might be some issue going on with your web.xml file.
Try removing the web.xml file.
Secondly check that your path variables are properly set or not.
Restart tomcat server Or your PC.
Your problem will be surely solved.
I was facing this issue too, I was receiving a 404 when accessing a URL pattern that I knew was linked to a Servlet. The reason is because I had 2 Servlets with their #WebServlet name parameter set as the same string.
#WebServlet(name = "ServletName", urlPatterns = {"/path"})
public class ServletName extends HttpServlet {}
#WebServlet(name = "ServletName", urlPatterns = {"/other-path"})
public class OtherServletName extends HttpServlet {}
Both of the name parameters are the same. If you're using the name parameter, make sure they are unique compared to all other Servlets on your application.
I had the same issue. Tried all of this but didn't help. I managed to solve this issue by adding element tags to beginning and end of the xml file. ill leave my xml file below for reference.
<?xml version="1.0" encoding="UTF-8"?>
<element>
<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">
<servlet>
<servlet-name>InsertServlet</servlet-name>
<servlet-class>com.worklog.InsertServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>InsertServlet</servlet-name>
<url-pattern>/insert</url-pattern>
</servlet-mapping>
</web-app>
</element>
I was having the same issue. I was developing a mvc based REST API where there was no explicit html configuration or files. The API was using Swagger to generate a user interface. The problem started when I introduced Swagger version "3.0.0". I reverted back to Swagger "2.9.2" This solved my problem.
<!-- Swagger -->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.9.2</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.9.2</version>
</dependency>
Please check context root cannot be empty.
If you're using eclipse:
right click, select properties, then web project settings. Check the context root cannot be empty

Testng listener to comply with Apache Ant JUnit XML Schema

As part of a testng automation test suite I would like to automatically push results from jenkins to testrail. I currently have this plugin installed on my jenkins server: https://github.com/jenkinsci/testrail-plugin
The read me states the output must comply with the junit schema: https://github.com/windyroad/JUnit-Schema/blob/master/JUnit.xsd
I have reference How do I get one junit report from TestNG for all my test cases? and added
<listeners>
<listener class-name="org.testng.reporters.JUnitXMLReporter"></listener>
</listeners>
to my listeners; however, this does not seem to create a file in the correct format as this causes jenkins to fail with the message :
Uploading results to TestRail.
Error pushing results to TestRail
Posting to index.php?/api/v2/add_results_for_cases/236 returned an error! Response from TestRail is:
{"error":"Field :results cannot be empty (one result is required)"}
Build step 'TestRail Plugin' marked build as failure
Finished: FAILURE
I am wondering if there is a different listener I should be using instead.
Thank you for the help.
I used the xsd file that was shared in the question to create a TestNG reporter that complies with the xsd.
To consume this reporter, please add a dependency as below
<dependency>
<groupId>com.rationaleemotions</groupId>
<artifactId>junitreport</artifactId>
<version>1.0.0</version>
</dependency>
This reporter makes use of the service loader approach to wire in itself. So it doesn't need to be added explicitly via the <listeners> tag (or) the #Listeners annotation.
Details can be found here

RDF4J RIO UnsupportedRDFormatException when adding data to an HTTPRepository using a stand-alone application

I have an HTTPRepository initialised with a the URL to the repository. I use a RepositoryConnection to retrieve and add (weather) data to the repository. The data is retrieved from a web service, then transformed into RDF statements, and added to the repository. This is done periodically by a stand-alone application.
When I run this application within IntelliJ, everything works fine.
To run this application on a server I created a jar file (containing all dependencies). The application starts as expected and is able to retrieve data from the repository.
However, when the application tries to write data to the repository I get an UnsupportedRDFormatException:
org.eclipse.rdf4j.rio.UnsupportedRDFormatException: Did not recognise RDF format object BinaryRDF (mimeTypes=application/x-binary-rdf; ext=brf)
at org.eclipse.rdf4j.rio.Rio.lambda$unsupportedFormat$0(Rio.java:568) ~[weatherData-1.0-SNAPSHOT-jar-with-dependencies.jar:na]
at java.util.Optional.orElseThrow(Optional.java:290) ~[na:1.8.0_111]
at org.eclipse.rdf4j.rio.Rio.createWriter(Rio.java:134) ~[weatherData-1.0-SNAPSHOT-jar-with-dependencies.jar:na]
at org.eclipse.rdf4j.rio.Rio.write(Rio.java:371) ~[weatherData-1.0-SNAPSHOT-jar-with-dependencies.jar:na]
at org.eclipse.rdf4j.rio.Rio.write(Rio.java:324) ~[weatherData-1.0-SNAPSHOT-jar-with-dependencies.jar:na]
at org.eclipse.rdf4j.repository.http.HTTPRepositoryConnection.addModel(HTTPRepositoryConnection.java:588) ~[weatherData-1.0-SNAPSHOT-jar-with-dependencies.jar:na]
at org.eclipse.rdf4j.repository.http.HTTPRepositoryConnection.flushTransactionState(HTTPRepositoryConnection.java:662) ~[weatherData-1.0-SNAPSHOT-jar-with-dependencies.jar:na]
at org.eclipse.rdf4j.repository.http.HTTPRepositoryConnection.commit(HTTPRepositoryConnection.java:326) ~[weatherData-1.0-SNAPSHOT-jar-with-dependencies.jar:na]
at org.eclipse.rdf4j.repository.base.AbstractRepositoryConnection.conditionalCommit(AbstractRepositoryConnection.java:366) ~[weatherData-1.0-SNAPSHOT-jar-with-dependencies.jar:na]
at org.eclipse.rdf4j.repository.base.AbstractRepositoryConnection.add(AbstractRepositoryConnection.java:431) ~[weatherData-1.0-SNAPSHOT-jar-with-dependencies.jar:na]
at nl.wur.fbr.data.weather.WeatherApp.retrieveData(WeatherApp.java:122) ~[weatherData-1.0-SNAPSHOT-jar-with-dependencies.jar:na]
at nl.wur.fbr.data.weather.WeatherData$WeatherTask.run(WeatherData.java:105) [weatherData-1.0-SNAPSHOT-jar-with-dependencies.jar:na]
at java.util.TimerThread.mainLoop(Timer.java:555) [na:1.8.0_111]
at java.util.TimerThread.run(Timer.java:505) [na:1.8.0_111]
The source code in which the error occurs is:
public void retrieveData(){
logger.info("Retrieving data for weather for app: "+ID+" ");
RepositoryConnection connection = null;
ValueFactory vf = SimpleValueFactory.getInstance();
try {
connection = repository.getConnection();
// Retrieving the locations from the repository (no problem here).
List<Location> locations = this.retrieveLocations(connection);
List<Statement> statements = new ArrayList<>();
// Retrieving weather data from each location and transforming it to statements.
for(Location location : locations){
List<Weather> retrievedWeather = weatherService.retrieveWeatherData(location.name,location.latitude,location.longitude);
for(Weather weather : retrievedWeather){
BNode phenomenon = vf.createBNode();
statements.add(vf.createStatement(location.ID,WEATHER.HAS_WEATHER,phenomenon,rdfStoreGraph));
statements.addAll(weather.getStatements(phenomenon,vf,rdfStoreGraph));
statements = this.correctOMIRIs(statements,vf);
}
}
// Adding data retrieved from the weather API
// This is where the exception happens.
connection.add(statements,rdfStoreGraph);
} catch (Exception e) {
logger.error("Could not retrievedata for weather app: '"+ID+"' because no monitor locations could be found.",e);
} finally {
if(connection != null){
connection.close();
}
}
}
The HTTPRespository is initialised as so:
repository = new HTTPRepository(rdfStore.toString());
((HTTPRepository)repository).setPreferredRDFFormat(RDFFormat.BINARY);
((HTTPRepository)repository).setPreferredTupleQueryResultFormat(TupleQueryResultFormat.BINARY);
I've tried changing the formats to TURTLE. But it makes no difference.
Can you tell me how to solve this?
NB. Both the RDF4J server and library have version 2.0.1 (rdf4j).
To run this application on a server I created a jar file (containing all dependencies).
There's your problem: you created a "fat jar" and probably haven't properly merged SPI registry files.
RDF4J's Rio parsers (and several other modules as well) use Java's Service Provider Interface (SPI) mechanism to register themselves. This mechanism relies on a text file in META-INF\services in the jar file containing the fully-qualified name of each parser implementation.
The problem comes when you merge jars: each Rio parser jar has a registry file with the same name, but different contents. If you are using something like the maven assembly plugin to create the fat jar, each registry file gets overwritten by the next one. The consequence is that at the end, RDF4J can only find one parser - the one whose registry file was added last to the fat jar.
The solution is to either not create a fat jar at all, or if you must, use a different technique to create it, which merges the registry files rather than overwriting them. The maven shade plugin has a good config option for this: the ServicesResourceTransformer.
I am refloating this post because I got stucked with this for several hours. Finally, I could generate an executable jar by using maven shade plugin with the following configuration:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.4</version>
<configuration>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>${fully.qualified.main.class}</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
I used the shaded plugin with the ManifestResourceTransformer for creating the executable jar indicating the main class of my project, and with the ServicesResourceTransformer for dealing with the RDF4J package naming in order to avoid that one parser overrides the previous one. Also, I had to include the filter section to avoid JNI errors derived from package signatures.
I hope this is useful for someone.
Greetings.

CDI testing with Arquillian

3 days ago I completed the Arquillian "getting started" guide and decided that this would be a good thing to use for unit testing of my part of a CQRS system.
Unfortunately this has proved a little less than straight forwards. I have googled for the past 3 days and the issue it not resolved by any of the solutions that have worked for others.
I am coming to the conclusion that the problem is with my code though I dont see how.
My task is to write an event listener that listens to an ActiveMQ topic for events and then updates the "view" in a Mongo DB.
There will be many events in the system so it seemed reasonable to me to create an abstract base class that all event listeners extend.
This base class contains the Mongo client and registers to listen to the topic. It uses an over loaded getter for the listener name which it uses as a bean reference in a camel route. The listener client ID is generated from a static long which is incremented on each listener registration. This ensures that every listener get to see every event posted to the topic. Intention is to later add a filter to reduce the number of event received.
I have built this code and driven it from a timer generating event topic posts and it all works fine.
The trouble with that is a quality requirement to have cobertura report 80% code coverage by unit tests.
My test application is not a unit test so my code coverage is 0%.
I have come to Arquillian via a couple of other methods of unit testing in CDI but Arquillian does seem to be the best option if I could only get it to work.
The error I am getting is:
java.lang.IllegalStateException: Could not find beans for Type=class org.apache.deltaspike.core.impl.scope.window.WindowBeanHolder and qualifiers:[]
I have included deltaspike in the pom, I have added it to the shrinkwrap deployment
POM extract
<dependency>
<groupId>org.apache.deltaspike.core</groupId>
<artifactId>deltaspike-core-api</artifactId>
<version>${deltaspike.version}</version>
</dependency>
<dependency>
<groupId>org.apache.deltaspike.core</groupId>
<artifactId>deltaspike-core-impl</artifactId>
<version>${deltaspike.version}</version>
</dependency>
<dependency>
<groupId>org.jboss.shrinkwrap.resolver</groupId>
<artifactId>shrinkwrap-resolver-impl-maven</artifactId>
<version>2.0.0</version>
</dependency>
Test class
#RunWith(Arquillian.class)
public class ListenerTest {
AbstractEventListener listener = null ;
WindowBeanHolder w = new WindowBeanHolder();
#Deployment
public static WebArchive createDeployment() {
return ShrinkWrap.create(WebArchive.class).addAsLibraries(Maven.resolver().loadPomFromFile("pom.xml")
.resolve("org.apache.deltaspike.core:deltaspike-core-api",
"org.apache.deltaspike.core:deltaspike-core-impl")
.withoutTransitivity().asFile())
.addAsWebInfResource("beans.xml");
}
#Test
public void testExecute() {
Assert.assertNotNull(listener);
}
}
My beams.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans 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/beans_1_1.xsd"
bean-discovery-mode="all">
</beans>
As you can see I have even tried adding the WindowBeanHolder to the code.
I have made many changes to the code over the last few days. I have not included the full pom etc as this may not be needed but can add if required.
If you have any suggestion as to where I can go from here many thanks in advance.
Only the org.apache.deltaspike packages are needed:
return ShrinkWrap.create(WebArchive.class)
.addClasses(HealthResource.class)
.addPackages(true, "org.apache.deltaspike")
.addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml");
Abstract the database layer by way of an interface. Provide a mongo impl for prod, but a unit-testable stateful "dummy" impl for testing.
Have all your code refer to the interface and inject (using reflection if necessary) the dummy impl to test your code prior to running your unit tests.

Debugging and troubleshooting Apache Karaf 3

So I've OSGI-ified a war file. It still works in Tomcat. I have all the requisite fields in the manifest and the libraries are all embedded for now. I'll externalize them later. There are two which are not OSGI enabled. The war file has log4j2 embedded BTW. It will be removed later.
The war file in question is 3 simple Jersey based REST/JSON services.
It starts and goes to Active state but I can't hit it with SoapUI where I expect to find it. The logs show it starting but that is all they show.
How can I squeeze more info out of Karaf so that I can properly figure out what is going on?
Is there something special I have to do in the Activator to get it to fire up?
Note: This is a simple REST / JSON service that wraps WURFL. By license, it's Open Source but it hasn't been released yet.
karaf#root()> bundle:headers MobileWURFL
MobileWURFL Maven Webapp (104)
-------------------------------
Manifest-Version = 1.0
Bnd-LastModified = 1395276484402
Archiver-Version = Plexus Archiver
Tool = Bnd-2.1.0.20130426-122213
Embed-Directory = WEB-INF/lib
Embedded-Artifacts = WEB-INF/lib/org.osgi.core-4.3.0.jar;g="org.osgi";a="org.osgi.core";v="4.3.0",WEB-INF/lib/org.osgi.compendium-1.4.0.jar;g="org.apache.felix";a="org.osgi.compend
ium";v="1.4.0",WEB-INF/lib/org.osgi.core-1.4.0.jar;g="org.apache.felix";a="org.osgi.core";v="1.4.0",WEB-INF/lib/javax.servlet-1.0.0.jar;g="org.apache.felix";a="javax.servlet";v="1.
0.0",WEB-INF/lib/org.osgi.foundation-1.2.0.jar;g="org.apache.felix";a="org.osgi.foundation";v="1.2.0",WEB-INF/lib/servlet-api-2.5.jar;g="javax.servlet";a="servlet-api";v="2.5",WEB-
INF/lib/log4j-api-2.0-rc1.jar;g="org.apache.logging.log4j";a="log4j-api";v="2.0-rc1",WEB-INF/lib/log4j-core-2.0-rc1.jar;g="org.apache.logging.log4j";a="log4j-core";v="2.0-rc1",WEB-
INF/lib/disruptor-3.0.1.jar;g="com.lmax";a="disruptor";v="3.0.1",WEB-INF/lib/commons-lang-2.6.jar;g="commons-lang";a="commons-lang";v="2.6",WEB-INF/lib/log4j-slf4j-impl-2.0-rc1.jar
;g="org.apache.logging.log4j";a="log4j-slf4j-impl";v="2.0-rc1",WEB-INF/lib/slf4j-api-1.7.5.jar;g="org.slf4j";a="slf4j-api";v="1.7.5",WEB-INF/lib/commons-collections-3.2.1.jar;g="co
mmons-collections";a="commons-collections";v="3.2.1",WEB-INF/lib/wurfl-1.5.1.jar;g="net.sourceforge.wurfl";a="wurfl";v="1.5.1",WEB-INF/lib/json-20140107.jar;g="org.json";a="json";v
="20140107",WEB-INF/lib/jersey-server-1.8.jar;g="com.sun.jersey";a="jersey-server";v="1.8",WEB-INF/lib/asm-3.1.jar;g="asm";a="asm";v="3.1",WEB-INF/lib/jersey-core-1.8.jar;g="com.su
n.jersey";a="jersey-core";v="1.8"
Built-By = Coder_Guy
Embed-Dependency = *;scope=compile|runtime
Embed-Transitive = true
Webapp-Context = MobileWURFL
Web-ContextPath = MobileWURFL
Build-Jdk = 1.7.0_51
Created-By = Apache Maven Bundle Plugin
Bundle-Name = MobileWURFL Maven Webapp
Bundle-SymbolicName = MobileWURFL
Bundle-Version = 0.0.1.SNAPSHOT
Bundle-ManifestVersion = 2
Bundle-ClassPath = .,WEB-INF/classes,WEB-INF/lib/org.osgi.core-4.3.0.jar,WEB-INF/lib/org.osgi.compendium-1.4.0.jar,WEB-INF/lib/org.osgi.core-1.4.0.jar,WEB-INF/lib/javax.servlet-1.0
.0.jar,WEB-INF/lib/org.osgi.foundation-1.2.0.jar,WEB-INF/lib/servlet-api-2.5.jar,WEB-INF/lib/log4j-api-2.0-rc1.jar,WEB-INF/lib/log4j-core-2.0-rc1.jar,WEB-INF/lib/disruptor-3.0.1.ja
r,WEB-INF/lib/commons-lang-2.6.jar,WEB-INF/lib/log4j-slf4j-impl-2.0-rc1.jar,WEB-INF/lib/slf4j-api-1.7.5.jar,WEB-INF/lib/commons-collections-3.2.1.jar,WEB-INF/lib/wurfl-1.5.1.jar,WE
B-INF/lib/json-20140107.jar,WEB-INF/lib/jersey-server-1.8.jar,WEB-INF/lib/asm-3.1.jar,WEB-INF/lib/jersey-core-1.8.jar
As you are using a OSGi-fied war the war-extender of Pax Web will kick in. Therefore no activator needed. For debugging just start the karaf container with karaf debug, attach your debuger to port 8787.
Depending on your embedded jars there might be an issue with those, for example a servlet.jar or similar will result in errors with deployment. Also possible the log4j2.jar could cause an issue.
What's the result of bundle:header for this war?
With the command
web:list
you also receive the info of the state of the web bundle.
UPDATE:
It is right there in your Bundle-ClassPath. The servlet jar is not allowed to be in a WAR, per spec by the way. In OSGi it collides with the packages provided by Pax-Web. In a Tomcat, the servlet.jar is already loaded by the container therefore it does work, as First-Come-First-Serve is used by a classloader. With OSGi the first Servlet class is found inside the War and therefore the resolver doesn't use the one provided by Pax Web. It is essential that you remove that jar.
And I think adding those osgi jars doesn't help any either, this will most likely collide with the bundles provided by the container.
I strongly suggest using the maven-bundle-plugin to generate this war, so the imports are properly created. Or just neglect all OSGi meta information and deploy a standard WAR. If you use the following type URL:
webbundle:mvn:groupID/artifactID/version/war?Web-ContextPath=Mobile-WURFL
It will generate a proper OSGi Manifest for your war.