I have a common GWT application that is using (trying to) Rocket-Framework to implement a CometServerServlet.
After I have registered my servlet in web.xml and my app.gwt.xml, like this:
App.gwt.xml:
<servlet path="/server" class="myapp.server.MyCometServlet"/>
web.xml
<servlet>
<servlet-name>myCometServlet</servlet-name>
<servlet-class>myapp.server.MyCometServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>myCometServlet</servlet-name>
<url-pattern>/myapp/server</url-pattern>
</servlet-mapping>
Jetty apparently doesn't find the CometServerServlet from which my MyCometServlet extends:
WARNING: Error starting handlers
java.lang.NoClassDefFoundError:
rocket/remoting/server/comet/CometServerServlet
Caused by:
java.lang.ClassNotFoundException:
rocket.remoting.server.comet.CometServerServlet
That is strange, because I've added the Rocket jar to my project.
Could someone explain why this error happened?
I could understand if I "registered" the servlet in a wrong way or something, but at what point Jetty (or who?) looks for the CometServerServlet and fails at finding it?
Adding the jar to your project (e.g. in some IDE) will remove compilation errors, because the jar can be found at compile time.
But Jetty needs the library at runtime, and the usual way to provide it, is by putting it in the WEB-INF/lib folder of your project.
Of course, make sure to redeploy the app afterwards (e.g. if you're using Dev Mode, click refresh in the "Development Mode" view).
Related
Just setup an eclipse project using Maven webapp architype. I created a servlet file and that got added to the resources folder under src/main/
When I run the app tomcat gives an error:
Error instantiating servlet class com.ABCompany.Demo.SampleDemo. java.lang.ClassNotFoundException: com.ABCompany.Demo.SampleDemo
The file is under the folder src/main/resources/com/ABCompany/Demo/SampleDemo.java
My web.xml is below.
<web-app>
<display-name>Demo Example</display-name>
<servlet>
<servlet-name>SampleDemo</servlet-name>
<display-name>SampleDemo</display-name>
<description></description>
<servlet-class>com.ABCompany.Demo.SampleDemo</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>SampleDemo</servlet-name>
<url-pattern>/SampleDemo</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
Reading in the question:
The file is under the folder src/main/resources/com/ABCompany/Demo/SampleDemo.java
Java source files, should go under src/main/java
src/main/java/com/ABCompany/Demo/SampleDemo.java
Other files, like properties, HTML/CSS files, images, templates, etc. Are normally placed in the src/main/resources. As they do not need to be compiled, just copied over into the build directory. So they can be used for running the application, or for packaging (creating a jar).
TIP: Package names, should not contains capitals, by confention. So prevered is com.abcompany.demo.
TIP: Also read How to create a Web Application Project with Maven which uses a Maven archetype, for setting it all up!
I had the same problem.
My solution is:
When the project is created please create the java folder under src/main manually, it is because the maven-archetype-webapp doesn't create the src/main/java by default.
Before: src/main
After: src/main/java
image:java folder manually created
When the first step is ready then you can create all the servlets that you need, please make sure that you create all your classes and servlets under src/main/java.
The problem is because the servlet was created under src/main/resources that means that all your .java files was packaged as a resource and not as .class compiled.
Hi all I am working on Eclipse 6.0.36 and using tomcat server.I am having an error said "The requested resource is not available" error 404.I had seen other post on same question and this is the common error that many solution that I could find on google. But still cannot solve my problem.. I am also still new working on eclipse.If there any information that you need just ask me, before vote down.. there are so long codes that I need to show..
some says this might be caused by servlet command.My servlet,from web_bkup.xml files looks like this:
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>/faces/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>SourceCodeServlet</servlet-name>
<url-pattern>*.source</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
surely there is lack of information that I give and you all can ask for it. But if there any solution that you all can shared.Hopefully can solve my error
Since you have only given little information, I try to answer under a few assumptions.
The 404 tells you that Tomcat could not find the resource e-system.jsp. I now assume that you have a project PM_Portal in Eclipse that you have successfully deployed to the Tomcat server, meaning there were no severe errors in the Tomcat log files which stopped the web application from starting. I also assume that PM_Portal is the root context of your application.
From that information, getting a 404 after successfull deployment means that there either is no JSP file e-system.jsp in the /WebContent folder of the Eclipse PM_Portal project or the Deployment Assembly configuration for you project lacks a mapping for the /WebContent folder. In order to check this, you can right-click on the project folder and choose Properties. Open the Deployment Assembly property and check that /WebContent is mapped to the root folder / of the target deployment.
Hope this is helpful.
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>
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
I have set up my maven project using the m2e plugin in eclipse indigo, and transformed it to an eclipse dynamic web project using mvn eclipse:eclipse -Dwtpversion=1.5. I have managed to get the project up and running in tomcat7, except for my servlets, for which I cannot create the servlet mappings.
I have tried modifying the web.xml file but it throws a ClassNotFoundException. Directory Structure and web.xml :
(ROOT)
+src
+main
+resources
+DrawInitialMap.java
+webapp
(WebContent here)
<web-app>
<servlet>
<servlet-name>DrawInitialMap</servlet-name>
<servlet-class>(groupId).(artifactId).src.main.resources.DrawInitialMap</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>DrawInitialMap</servlet-name>
<url-pattern>/drawInitialMap.do</url-pattern>
</servlet-mapping>
(...)
</web-app>
While the #WebServlet annotation also fails to map the servlet :
#WebServlet(name="drawInitialMap", description="visualizes ttrp on html5 canvas", urlPatterns={"/drawInitialMap.do"})
Thank you in advance, and notify if you need any more of the code.
PS : Keep in mind that the servlet worked perfectly in Dynamic Web Project mode, without Maven
There are several issues.
You should stop using eclipse:eclipse. Instead, install WTP integration for M2E from Eclipse Marketplace
In Maven project, your DrawInitialMap should be in /src/main/classes folder. So, it will be compiled as per default Maven project conventions
The servlet-class element in web.xml requires full class name, i.e. no things like (groupId).(artifactId).src.main.resources.