Deploying my GWT Application on Tomcat Server - gwt

I want to setup a GWT application (Version 2.0.0) with many dependencys in my local Tomcat Server. I started to write a maven2 build script for deploying and packaging of the application.
I wrote a maven2 script which works really fine in my eyes, but I get an error when trying to deploy the out coming war on my tomcat.
2011-04-21 18:14:13,951 ERROR org.apache.catalina.startup.ContextConfig - Parse error in application web.xml file at jndi:/localhost/quickfinder.ui-1.0-SNAPSHOT/WEB-INF/web.xml
org.xml.sax.SAXParseException: The markup declarations contained or pointed to by the document type declaration must be well-formed.
The web.xml is look like the following:
here and my maven2 script looks like this:
here
After compiling and linking and the other stuff my "deploy" directory (named war) looks like:
|-AnswerPanel.css
|-common.css
|-DomainListPanel.css
|-glossary.css
|-glossary.html
|-images
|-META-INF
|-MulitpleChoiceEditPanel.css
|-MultipleChoiceDisclosurePanel.css
|-NaviPanel.css
|-QuestionnairePanel.css
|-quickfinder
|-Quickfinder.css
|-Quickfinder.html
|-quickfinderportlet
|-QuickfinderPortlet.html
|-styles-css2.css
|-styles-css3.css
|-WEB-INF
|--lib
Under lib in the WEB-INF directory, all needed library's are available. The Project has got some RPC calls and so on.
With mvn compile war:war a .war file and a folder named #artifactId#-SNAPSHOT-1.00 are created under /target.
I don't know how to handle with this error form tomcat, or is there a logical mistake in the pom.xml.
BR,
mybecks

Your web.xml is not well-formed: fix the below section
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd" [
<!ENTITY GlossaryWebXml SYSTEM "glossary.web.xml"> -->
]>

I would suggest to add maven-xml-plugin to your validate phase. It will check your web.xml automatically.

Related

nullPointerException when deploy webLogic 12c application

when i deploy my first web app on webLogic i get this error:
weblogic.application.ModuleException: java.lang.NullPointerException
at weblogic.application.internal.ExtensibleModuleWrapper.prepare(ExtensibleModuleWrapper.java:114)
at weblogic.application.internal.flow.ModuleListenerInvoker.prepare(ModuleListenerInvoker.java:100)
at weblogic.application.internal.flow.ModuleStateDriver$1.next(ModuleStateDriver.java:172)
at weblogic.application.internal.flow.ModuleStateDriver$1.next(ModuleStateDriver.java:167)
at weblogic.application.utils.StateMachineDriver$ParallelChange.run(StateMachineDriver.java:80)
Truncated. see log file for complete stacktrace
Caused By: java.lang.NullPointerException
at weblogic.servlet.internal.WebAnnotationProcessor.processMultipartConfigAnnotation(WebAnnotationProcessor.java:286)
at weblogic.servlet.internal.AnnotationProcessingManager.processAnnotationForClasses(AnnotationProcessingManager.java:169)
at weblogic.servlet.internal.AnnotationProcessingManager.processAnnotations(AnnotationProcessingManager.java:114)
at weblogic.servlet.internal.AnnotationProcessingManager.processAnnotationsOutsideWebFragment(AnnotationProcessingManager.java:141)
at weblogic.servlet.internal.AnnotationProcessingManager.processAnnotations(AnnotationProcessingManager.java:102)
Truncated. see log file for complete stacktrace
I had this problem and resolved it by removing JSF 2.2 Mojarra 2.2.0 from the application libraries. It only needs to be in the classpath.
In Eclipse, edit properties for the project, go to Project Facets-->Java Server Faces and uncheck "Include libraries with this application" and Apply change.
I deploy from Eclipse (OEPE), same problem here without JSF. Here is what solved my problem:
Quit Eclipse
Delete the workspace's .metadata folder
Launch Eclipse
The same solution worked on NetBeans8. From projects, go to your war project, right click over Libraries > JSF2.2 and click Remove. Rebuild the project and deploy. Remember to deploy as shared library the JSF on WLS.
This seems to be a duplicate of Maven generated ear file fails during deploying weblogic server. Some details about the solution can be found in this post https://roundwheeltech.wordpress.com/2016/06/15/deploying-a-jsf-2-2-to-weblogic-12-1-3/.
Because WebLogic 12.1.3 ships with JSF 2.1, the required JSF jars have to be bundles within the WAR file (specified as dependencies in pom.xml). WebLogic must also be instructed to use the libraries packaged in the WAR file instead of the ones that are provided by the container.
I had the exact same NPE. It was started by an instantiation of an factory that went wrong. I had to remote debug in to find this. An exception in the initialisation of the factory is swallowed and we don't get the real exception.
In my case the problem was antlr.Token and antlr.CommonToken not arriving from the same source. This gave me an ClassCastException. I solved it by moving all libraries from the ear to war to get more control over them.
Edit the file web.xml and put:
<welcome-file-list>
<welcome-file>faces/index.xhtml</welcome-file>
</welcome-file-list>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>/faces/*</url-pattern>
</servlet-mapping>

How to fix "Can not find the tag library descriptor" in eclipse 4.3 for my custom EL function

setup:
eclipse 4.3 with tomcat7 (running on localhost port 8080) configured as my test server.
my EL class (folder structure: http://i.imgur.com/ogOsCZM.jpg) created using New => Java project in eclipse
package org.flinders.mycustomutilities;
//import java.lang.StringBuilder;
public class MyCustomUtilities {
public static String Hello(String name) {
return "Heya " + name;
}
}
The class was then exported into a JAR file and imported into my maven repository. It was then imported to my spring mvc project using this entry in pom.xml:
<dependency>
<groupId>org.flinders.mycustomutilities</groupId>
<artifactId>MyCustomUtilities</artifactId>
<version>0.0.1</version>
</dependency>
I'm not getting any errors in Eclipse's Maven POM editor.
my TLD file (stored in D:\work\eclipse\java.metadata.plugins\org.eclipse.wst.server.core\tmp1\wtpwebapps\ROOT\WEB-INF which seems to be the working folder for tomcat)
<?xml version="1.0" encoding="UTF-8" ?>
<taglib
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-jsptaglibrary_2_1.xsd"
version="2.1">
<tlib-version>1.0</tlib-version>
<short-name>mytaglib</short-name>
<uri>org.flinders.mycustomutilities</uri>
<function>
<name>Hello</name>
<function-class>org.flinders.mycustomutilities.MyCustomUtilities</function-class>
<function-signature>java.util.String Hello(java.util.String)</function-signature>
</function>
</taglib>
not really sure what to put in the URI tag for my setup.
This is how I'm importing my custom EL function in my JSP file
<%# taglib uri="WEB-INF/mytaglib.tld" prefix="mine" %>
I've also tried
<%# taglib uri="/WEB-INF/mytaglib.tld" prefix="mine" %>
but eclipse just can't see it. I have started tomcat via eclipse just in case that is required without any positive outcome. Still getting the error mentioned above.
Any ideas? I've been searching for examples on the net but they don't really give complete/working examples.
thanks!
My problem is that I was placing the tld file in the wrong place. I am importing the class/jar into my spring web mvc project. But I was putting the TLD file in the "ROOT" WEB-INF. I should've placed it in the WEB-INF for my web project. All working now thanks to all those who looked at it.

Spring context:component-scan fails to find components in another Eclipse project dependency referenced in POM

I am working on a GWT web application split across two Eclipse Projects (myclient & myservice).
The myclient project references the myservice project via a dependency in the POM.
<dependency>
<groupId>com.myproject</groupId>
<artifactId>myservices</artifactId>
<version>1.0.0</version>
</dependency>
The myclient project has a WAR directory src/main/webapp. The output folder for the myclient project is src/main/webapp/WEB-INF/classes.
The myclient project has a Spring descriptor application-context.xml with the following
<context:component-scan base-package="com.myproject.myclient, com.myproject.myservices"/>
and the web.xml
<web-app>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/application-context.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<listener>
<listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
</listener>
...
</web-app>
I have several files in the myservices project annotated as spring #Component, #Service, #Configuration but these are not picked up by the component scan when I run the GWT application in Eclipse. As a test I experimented with placing an #Component in the myclient project and this was successfully created.
I believe the following log entry during application startup indicates the source of the problem
org.springframework.core.io.support.PathMatchingResourcePatternResolver - Resolved location pattern [classpath*:com/myproject/myservices/**/*.class] to resources []
the location pattern for the myclient project resolves to all the resources on the classpath but for myservices no resources are found.
I experimented with building the myservices project JAR and placing this JAR into the src/main/webapp/WEB-INF/lib folder of the myclient project. When I do this the component scanning works. However for development I don't want to have to build and copy a JAR everytime I make changes to the myservices project. I imagine that the component scanning should work on a project referenced through the POM without having to the build that project but after much experimenting I have been unable to get this working.
Be sure that in the deployment assembly (right click your web project and select "deployment assembly" of your myclient project it is configured to deploy the jar that is outputted by the myservices project. If you are using maven, the m2e, m2e-wtp project configurators should do this deployment assembly setup automatically.
Once you have deployment assembly settings properly configured, now when you deploy a project to your server using the Eclispe server adapter publish mechanism, everything should get deployed and the myservices jar would get placed in the right spot for your myclient project.
But make sure you the latest version of m2e-wtp installed. This way your configuration in your pom.xml and deployment assembly will get correctly configured.
Try splitting your application-context.xml into 2 separate files:
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:service-context.xml,classpath:client-context.xml</param-value>
</context-param>
myservices/src/main/resources/service-context.xml:
<context:component-scan base-package="com.myproject.myservices"/>
myclient/src/main/resources/client-context.xml:
<context:component-scan base-package="com.myproject.myclient"/>
Try this :
<context:component-scan base-package="com.myproject"/>
Please check the following things:
Is your serviceproject present "only" as jar or is the whole project available via workspace resolution. This can be checked via maven-context-menue (Disable/Enable Workspaceresolution)
The layout of the webapp under src/main/webapp is okay. BUT do i get you right that all classes are copied there? If so, you should make sure everything is under target directory. So please check whether a maven call "clean package" generates a webappstructure under the target folder and all required libs (e.g. myservice) exist under target\$your-webarchivename\WEB-INF\lib
Check that packaging in myservice pom.xml is set to jar (you probably have this, right?)
it's obvious that your service jar is not included in your client project's build path. this is the only root cause.
Make sure 3 points:
you have run mvn clean install under your service project which has correct pom.xml.
you have run mvn eclipse:eclipse under your client project. this will pull out all your dependency project.
check your client eclipse project's build path dialog. is there your service jar in the list? Make sure this
You better once look this tutorial
http://fusesource.com/docs/framework/2.2/deploy_guide/CXFServletDeploySpring.html

failed to run wicket examples on tomcat7

I downloaded wicket examples 1.6.0 and built successfully in netbeans7.2. but got errors when I tried to deploy on tomcat 7:
Cannot deploy the module. The context.xml file seems to be broken. Check whether it is well-formed and valid.
The module has not been deployed.
See the server log for details.
at
org.netbeans.modules.j2ee.deployment.devmodules.api.Deployment.deploy(Deployment.java:210)
at
org.netbeans.modules.maven.j2ee.ExecutionChecker.performDeploy(ExecutionChecker.java:178)
at
org.netbeans.modules.maven.j2ee.ExecutionChecker.executionResult(ExecutionChecker.java:130)
at
org.netbeans.modules.maven.execute.MavenCommandLineExecutor.run(MavenCommandLineExecutor.java:212)
at
org.netbeans.core.execution.RunClassThread.run(RunClassThread.java:153)
heres the contents in context.xml:
<?xml version="1.0" encoding="UTF-8"?>
<Context>
<!-- <Loader className="org.atmosphere.util.AtmosphereClassloader"/> -->
<Loader delegate="true"/>
</Context>
I prefer to run wicket in eclipse as it negates the requirement to mess around with an external tomcat instance.
If you are comfortable with eclipse and maven i would download wicket 1.6 example archetype via maven, import into eclipse and then in the test directory you can run the run.java class to get an internal jetty server host wicket for you.
this should get you started quickly without having to wrestle with tomcat configurations too.
Not really an answer but an alternative route to the same end point
Add parameter path to context tag, same path that app will be served:
<?xml version="1.0" encoding="UTF-8"?>
<Context path="/application-path-name/">
<!-- <Loader className="org.atmosphere.util.AtmosphereClassloader"/> -->
<Loader delegate="true"/>
</Context>
Answer obtained from this question.

freemarker.runtime - Template processing error: "No mapping defined for http://www.springframework.org/security/tags"

Spring-security:3.0.2
Freemarker:2.3.19
I want to use springSecurity tags in freemarker, but it throws this errors:
[16 14:10:46,349 ERROR] [btpool0-0] freemarker.runtime - Template processing error: "No mapping defined for http://www.springframework.org/security/tags"
No mapping defined for http://www.springframework.org/security/tags
The problematic instruction:
==> assignment: security=JspTaglibs["http://www.springframework.org/security/tags"] [on line 1, column 1 in macro/header.ftl]
in user-directive page.bodytemplate [on line 6, column 1 in items.ftl]
ftl:
<#assign security=JspTaglibs["http://www.springframework.org/security/tags"] />
pom.xml
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-taglibs</artifactId>
<version>3.0.2.RELEASE</version>
</dependency>
if the problems happen with tomcat7-maven-plugin and not with jetty-maven-plugin you most likely suffer from the not fully initialized servlet context of tomcat7.
Instead of "tomcat:run", do "tomcat:run-war"
the latter makes sure that your web app is (almost) fully being build and bootstrapped, like having jars in /WEB-INF/libs. freemarker's scanning logic for tlds will work like a charm.
It seems like a tag library which you want to download contains the tag org.springframework.security.taglibs.authz.AclTag.
The last version of Spring Security taglibs (which had this class) was the 2.0.7 release, hence the problem.
You can change you spring to 2.0 version. Or you can download security.tld from https://src.springframework.org/svn/spring-security/branches/spring-2.5-integration-branch/taglibs/src/main/resources/META-INF/security.tld and use it on freemarker template like this: <#assign security=JspTaglibs["/WEB-INF/tlds/security.tld"] />
By the way I really don't understand why http://www.springframework.org/security/tags doesn't work... I have tried to use it like you, and I have faced the same issue.
I encountered this error when switched to run-jetty-run maven module.
Module jetty:run didn't had this error.
This helped me:
Download spring-security.tld file and put it in webapp/WEB-INF/tld folder
Add this code to web.xml:
<jsp-config>
<taglib>
<taglib-uri>http://www.springframework.org/security/tags</taglib-uri>
<taglib-location>/WEB-INF/tld/spring-security.tld</taglib-location>
</taglib>
</jsp-config>
The reason why this doesn't work has to do with the Servlet container (and maybe the spec). If you're associating taglibs by the namespace it will only do that automatically if the JAR is in the WEB-INF/lib folder.
If you move the spring-security-taglibs.jar into the WEB-INF/lib folder, it will work.