Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Virgo » Problems registering two servlets in a WAB
Problems registering two servlets in a WAB [message #754675] Thu, 03 November 2011 20:14 Go to next message
Carlos Salinas is currently offline Carlos Salinas
Messages: 32
Registered: March 2011
Location: Avd. de la Argentina 132,...
Member
Hi all,

I am trying to integrate in Virgo the Atmosphere Framework, a Comet Application framework by Sun. To have support a web app by Atmosphere, you need to define in the web.xml one servlet apart yours, besides another config settings. As in the following example.


<!-- Comet Application features configuration through Atmosphere framework -->
	<servlet>
		<description>Atmosphere Servlet</description>
		<servlet-name>AtmosphereServlet</servlet-name>
		<servlet-class>org.atmosphere.cpr.AtmosphereServlet</servlet-class>
		<!-- prevent deadlocks -->
		<!-- <init-param> <param-name>org.atmosphere.disableOnStateEvent</param-name> 
			<param-value>true</param-value> </init-param> -->
		<!-- <init-param> <param-name>org.atmosphere.useWebSocket</param-name> 
			<param-value>true</param-value> </init-param> -->
		<!--<init-param> <param-name>org.atmosphere.useNative</param-name> <param-value>true</param-value> 
			</init-param> <init-param> <param-name>org.atmosphere.useBlocking</param-name> 
			<param-value>true</param-value> </init-param> -->
		<load-on-startup>1</load-on-startup>
		<!--Uncomment if you want to use Servlet 3.0 Async Support -->
		<async-supported>true</async-supported>
	</servlet>

	<servlet-mapping>
                <servlet-name>AtmosphereServlet</servlet-name>
                <url-pattern>/server-push</url-pattern>
        </servlet-mapping>
    
	<servlet>
		<servlet-name>Vaadin Application Servlet</servlet-name>
		<servlet-class>com.vaadin.osgi.spring.SpringCometApplicationOSGiServlet</servlet-class>
		<init-param>
			<description>Vaadin application class to start</description>
			<param-name>application</param-name>
			<param-value>com.vaadin.osgi.spring.MyVaadinApplication</param-value>
		</init-param>
		<init-param>
			<param-name>widgetset</param-name>
			<param-value>com.vaadin.osgi.spring.gwt.CustomWidgetSet</param-value>
		</init-param>
		<init-param>
			<description>Vaadin application class to start</description>
			<param-name>version</param-name>
			<param-value>0.0.1.SNAPSHOT</param-value>
		</init-param>
		<init-param>
			<description>Vaadin application class to start</description>
			<param-name>bean</param-name>
			<param-value>myVaadinApplication</param-value>
		</init-param>
		<load-on-startup>2</load-on-startup>
        <async-supported>true</async-supported>
	</servlet>
	
	<servlet-mapping>
		<servlet-name>Vaadin Application Servlet</servlet-name>
		<url-pattern>/*</url-pattern>
	</servlet-mapping>



The AtmosphereServlet class is in another bundle and the other servlet, the SpringCometApplicationOSGiServlet is a subclass from another servlet that is also in another bundle. So i define in the MANIFEST.MF the necessary dependencies using the Import-Package header. But afterwards the WAB is started in the container, Virgo Generates a dump. So in log file appears the following error:

.......

03-nov-2011 20:34:21 org.apache.catalina.core.StandardContext loadOnStartup
GRAVE: Servlet /vaadin.spring threw load() exception
java.lang.ClassNotFoundException: org.atmosphere.cpr.AtmosphereServlet
"	at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1678)"
"	at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1523)"
"	at org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:415)"
"	at org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged(DefaultInstanceManager.java:397)"
"	at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:118)"
"	at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1099)"
"	at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1043)"
"	at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4957)"
"	at org.apache.catalina.core.StandardContext$3.call(StandardContext.java:5284)"
"	at org.apache.catalina.core.StandardContext$3.call(StandardContext.java:5279)"
"	at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)"
"	at java.util.concurrent.FutureTask.run(FutureTask.java:138)"
"	at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)"
"	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)"
"	at java.lang.Thread.run(Thread.java:680)"
03-nov-2011 20:34:21 org.apache.catalina.core.ApplicationContext log
INFO: Marking servlet Vaadin Application Servlet as unavailable
03-nov-2011 20:34:21 org.apache.catalina.core.StandardContext loadOnStartup
GRAVE: Servlet /vaadin.spring threw load() exception
java.lang.ClassNotFoundException: com.vaadin.terminal.gwt.server.SpringApplicationOSGiServlet
"	at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1678)"
"	at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1523)"
"	at java.lang.ClassLoader.defineClass1(Native Method)"
"	at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)"
"	at java.lang.ClassLoader.defineClass(ClassLoader.java:615)"
"	at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)"
"	at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:2820)"
"	at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1150)"
"	at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1645)"
"	at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1523)"
"	at org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:415)"
"	at org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged(DefaultInstanceManager.java:397)"
"	at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:118)"
"	at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1099)"
"	at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1043)"
"	at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4957)"
"	at org.apache.catalina.core.StandardContext$3.call(StandardContext.java:5284)"
"	at org.apache.catalina.core.StandardContext$3.call(StandardContext.java:5279)"
"	at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)"
"	at java.util.concurrent.FutureTask.run(FutureTask.java:138)"
"	at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)"
"	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)"
"	at java.lang.Thread.run(Thread.java:680)"
Bundle com.vaadin.osgi.spring_0.0.1.SNAPSHOT, Service 257, ServiceEvent REGISTERED
E0001I Started web bundle 'com.vaadin.osgi.spring' version '0.0.1.SNAPSHOT' with context path '/vaadin.spring'.
E0003I Dump 'serviceability/dump/2011-11-03-20-34-857' generated
Thread context class loader 'KernelBundleClassLoader: [bundle=com.vaadin.osgi.spring_0.0.1.SNAPSHOT]' popped and set to 'BundleDelegatingClassLoader for [spring-osgi-extender (org.springframework.osgi.extender)]'

 
.......


Why cannot Apache Catalina load the defined servlets?

Than you.
Re: Problems registering two servlets in a WAB [message #754784 is a reply to message #754675] Fri, 04 November 2011 10:51 Go to previous messageGo to next message
Glyn Normington is currently offline Glyn Normington
Messages: 1222
Registered: July 2009
Senior Member
I've asked Violeta to comment, but meanwhile, please check out this FAQ.
Re: Problems registering two servlets in a WAB [message #754788 is a reply to message #754784] Fri, 04 November 2011 11:10 Go to previous messageGo to next message
Carlos Salinas is currently offline Carlos Salinas
Messages: 32
Registered: March 2011
Location: Avd. de la Argentina 132,...
Member
Hi Glyn,

thank u for ur reply. I was aware of the Virgo in version 3.0.0 is suited to the WAB manifest especification. But i will check if configuring Virgo to behave like Version 2.x i can workaround the problem at the moment.

Here is the MANIFEST.MF of the client wab owns the above web.xml:


Manifest-Version: 1.0
Export-Package: VAADIN.widgetsets.com.vaadin.osgi.spring.gwt.CustomWid
getSet;version="0.0.1.SNAPSHOT",VAADIN.widgetsets.com.vaadin.osgi.spr
ing.gwt.CustomWidgetSet.ie6pngfix;version="0.0.1.SNAPSHOT",VAADIN.wid
getsets.com.vaadin.osgi.spring.gwt.CustomWidgetSet.resources;version=
"0.0.1.SNAPSHOT",com.vaadin.osgi.spring;version="0.0.1.SNAPSHOT";uses
:="com.vaadin,com.vaadin.terminal.gwt.server,javax.servlet,javax.serv
let.http,org.osgi.service.event,org.springframework.beans.factory.ann
otation"
Unversioned-Imports: *
Bundle-Classpath: WEB-INF/classes
Built-By: carlos
Bundle-Name: Vaadin OSGi Spring Application
Import-Library: org.springframework.spring;version="[3.0.5.RELEASE,3.0
.5.RELEASE]"
Created-By: Apache Maven
Web-ContextPath: vaadin.spring
Build-Jdk: 1.6.0_26
Bundle-Version: 0.0.1.SNAPSHOT
Bundle-ManifestVersion: 2
Import-Package: com.vaadin,com.vaadin.event,com.vaadin.osgi.spring.ser
vice,com.vaadin.terminal.gwt.server,com.vaadin.ui,javax.servlet,javax
.servlet.http,org.atmosphere.cpr,org.osgi.service.event,org.springfra
mework.beans.factory.annotation,org.vaadin.addons.serverpush
Bundle-SymbolicName: com.vaadin.osgi.spring
Archiver-Version: Plexus Archiver


Re: Problems registering two servlets in a WAB [message #754842 is a reply to message #754788] Fri, 04 November 2011 15:11 Go to previous messageGo to next message
Carlos Salinas is currently offline Carlos Salinas
Messages: 32
Registered: March 2011
Location: Avd. de la Argentina 132,...
Member
Hi again,

Unfortunely switching the WABHeaders property to defaulted value cannot resolve my problem
I expect any aid from Violeta Sad .

Thank u.
Re: Problems registering two servlets in a WAB [message #755002 is a reply to message #754842] Sun, 06 November 2011 15:49 Go to previous messageGo to next message
Violeta Georgieva is currently offline Violeta Georgieva
Messages: 242
Registered: October 2010
Senior Member
Hi,

The exceptions that you posted above are very strange - there I can see only the Tomcat classes but not the Gemini Web classes. Gemini Web is responsible for web applications/web application bundles deployment. Moreover I can see that the exception is thrown by the org.apache.catalina.loader.WebappClassLoader whereas we are using OSGi aware classloaders.

Quote:
java.lang.ClassNotFoundException: org.atmosphere.cpr.AtmosphereServlet
" at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1678)"


Is it possible for you to extract some small example that I can use to check what's going on there.
For me it is clear that "someone" wants to use pure tomcat classloading.

Regards
Violeta
Re: Problems registering two servlets in a WAB [message #755559 is a reply to message #755002] Tue, 08 November 2011 19:46 Go to previous messageGo to next message
Carlos Salinas is currently offline Carlos Salinas
Messages: 32
Registered: March 2011
Location: Avd. de la Argentina 132,...
Member
Hi Violeta,

My apologies for lasting answering the post about Servlet registering problem in the Virgo Forum, But i tried twice to attach a example project in a post as u asked me, but i cannot upload it.
Is there any way to pass you the examples u need to check in more detail the failure i detailed in the forum?


thank u.
regards.
Re: Problems registering two servlets in a WAB [message #755780 is a reply to message #755559] Wed, 09 November 2011 15:07 Go to previous messageGo to next message
Violeta Georgieva is currently offline Violeta Georgieva
Messages: 242
Registered: October 2010
Senior Member
Hi,

Is it possible to make it available through github?

Regards
Violeta
Re: Problems registering two servlets in a WAB [message #756475 is a reply to message #755780] Sun, 13 November 2011 20:42 Go to previous messageGo to next message
Carlos Salinas is currently offline Carlos Salinas
Messages: 32
Registered: March 2011
Location: Avd. de la Argentina 132,...
Member
Hi Violeta,

I have done a sample project with Atmosphere framework inside the wab, allowing u check the failure with more detail and quicker. I also uploaded the project in github.

com.thingtrack.com.vaadin.addons.osgi
(Vaadin's Fragment Bundle)
com.thingtrack.com.vaadin.sample.comet (The sample with atmosphere framework)

To deploy and run the sample, u might before deploy the first project together with the vaadin library in the VIRGO_SERVER/repository/usr and edit VIRGO_SERVER/config/org.eclipse.virgo.kernel.userregion.properties with the following line at then end of the file.

initialArtifacts=......., repository:bundle/com.vaadin/6.6.6


My gihub user.name is carlos-salinas.

Please let me know if u have any problem.
Thanks

[Updated on: Sun, 13 November 2011 20:44]

Report message to a moderator

Re: Problems registering two servlets in a WAB [message #756476 is a reply to message #754675] Sun, 13 November 2011 20:47 Go to previous messageGo to next message
Carlos Salinas is currently offline Carlos Salinas
Messages: 32
Registered: March 2011
Location: Avd. de la Argentina 132,...
Member
Hi again,
these are the Git repospitories:

git://github.com/carlos-salinas/com.thingtrack.com.vaadin.sample.comet.git
git://github.com/carlos-salinas/com.thingtrack.com.vaadin.addons.osgi.git

[Updated on: Mon, 14 November 2011 08:33]

Report message to a moderator

Re: Problems registering two servlets in a WAB [message #757402 is a reply to message #756476] Fri, 18 November 2011 09:43 Go to previous messageGo to next message
Carlos Salinas is currently offline Carlos Salinas
Messages: 32
Registered: March 2011
Location: Avd. de la Argentina 132,...
Member
Hi Violeta,

Have u had any progess in the Atmophere framework deployment?
Re: Problems registering two servlets in a WAB [message #757632 is a reply to message #757402] Sun, 20 November 2011 16:59 Go to previous messageGo to next message
Violeta Georgieva is currently offline Violeta Georgieva
Messages: 242
Registered: October 2010
Senior Member
Hi,

Here is what I succeeded to do (I used 'mvn clean install' to build the two projects):

1. In order to build git://github.com/carlos-salinas/com.thingtrack.com.vaadin.addons.osgi.git I commented the dependency below (the build was successful so I think that it is not so important?):

<dependency>
<groupId>org.springframework.osgi</groupId>
<artifactId>log4j.osgi</artifactId>
<version>1.2.15-SNAPSHOT</version>
<scope>test</scope>
</dependency>

2. In order to run the war without error messages in the logs I did the following:
2.1 I removed META-INF/context.xml as we do not support custom classloaders and attributes for them.
2.2 I removed the import-package - org.vaadin.addons.serverpush, as the jar that contains this package is actually in WEB-INF/lib folder
2.3 I added as import-package - com.vaadin.terminal
2.4 I added the jar files below to WEB-INF/lib:
2.4.1 atmosphere-compat-jbossweb-0.8.0-RC2.jar
2.4.2 atmosphere-compat-weblogic-0.8.0-RC2.jar
2.4.3 atmosphere-compat-jetty-0.8.0-RC2.jar

When I request the application I receive empty page (see attachment).
In the log files there are no errors, you can see what I have in the access log (see attachment)

Regards
Violeta
Re: Problems registering two servlets in a WAB [message #758226 is a reply to message #757632] Tue, 22 November 2011 11:43 Go to previous messageGo to next message
Carlos Salinas is currently offline Carlos Salinas
Messages: 32
Registered: March 2011
Location: Avd. de la Argentina 132,...
Member
Hi Violeta,

my apologies i have seen i forgot to add a button to check the server pushing works. I have just updated the code in github for that, besides i updated another resources in the project to fit some problems u mentioned in ur last post, as the serverpush jar import-package and so on.

I also check the sample removing the context.xml and now it deploys without errors. but when i push the added button i dont receive the serverpush update in the interface, as it should. In the log there is the following:


Exception in thread "Thread-80" java.lang.NoClassDefFoundError: org/atmosphere/cpr/BroadcasterFactory 
at org.vaadin.addons.serverpush.ServerPushBroadcasterFactory.getBroadcaster(ServerPushBroadcasterFactory.java:60) 
at org.vaadin.addons.serverpush.ServerPushBroadcasterFactory.broadcastForApplication(ServerPushBroadcasterFactory.java:78) 
at org.vaadin.addons.serverpush.ServerPushBroadcasterFactory.broadcastForApplication(ServerPushBroadcasterFactory.java:68) 
at org.vaadin.addons.serverpush.ServerPushCommunicationManager$1.run(ServerPushCommunicationManager.java:76) 
Caused by: org.eclipse.virgo.kernel.osgi.framework.ExtendedClassNotFoundException: org.atmosphere.cpr.BroadcasterFactory in KernelBundleClassLoader: [bundle=com.vaadin.osgi.spring_0.0.1.SNAPSHOT] 
at org.eclipse.virgo.kernel.userregion.internal.equinox.KernelBundleClassLoader.loadClass(KernelBundleClassLoader.java:138) 
at java.lang.ClassLoader.loadClass(ClassLoader.java:247) 
... 4 more                                 
Caused by: java.lang.ClassNotFoundException: org.atmosphere.cpr.BroadcasterFactory 
at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:513) 
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:429) 
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:417) 
at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107) 
at org.eclipse.virgo.kernel.userregion.internal.equinox.KernelBundleClassLoader.loadClass(KernelBundleClassLoader.java:134) 
... 5 more 



But this class, org.atmosphere.cpr.BroadcasterFactory, it is the atmosphere-runtime jar that it also inside the classpath.
I think the problem could come from the context.xml file, because it defines a loader component with the delegate attribute to true, so setting to true, as u know, the class loader will follow the standard Java2 delegation model. But i dont know what implies to the OSGi-fy Tomcat.

Could i embed the context.xml in the tomcat-server.xml as in a tradicional server.xml? If it is possible how would we do it?

Thanks again Violeta
Re: Problems registering two servlets in a WAB [message #758582 is a reply to message #758226] Wed, 23 November 2011 18:26 Go to previous messageGo to next message
Violeta Georgieva is currently offline Violeta Georgieva
Messages: 242
Registered: October 2010
Senior Member
Ok

I got the latest sources and built them.
I added again the three additional jar files mentioned in my previous post.
I removed the context.xml from the web application.

Here is what I can see in the browser - see attachment

Note: I forgot to mention in my previous post that WABHeaders=defaulted

Could you please verify that the response that I received is the one that you expect?

Regards
Violeta
Re: Problems registering two servlets in a WAB [message #758727 is a reply to message #758582] Thu, 24 November 2011 12:19 Go to previous messageGo to next message
Carlos Salinas is currently offline Carlos Salinas
Messages: 32
Registered: March 2011
Location: Avd. de la Argentina 132,...
Member
Hi Violeta,

yes, the result u have to see is the last message 'this label was pushed to client' after a few seconds. It is pushed by the server after a thread slept during a few seconds.

I check the same in my Virgo configuration but i still have the same error.
How did u do to amke the project works?
Re: Problems registering two servlets in a WAB [message #758792 is a reply to message #758727] Thu, 24 November 2011 15:04 Go to previous message
Violeta Georgieva is currently offline Violeta Georgieva
Messages: 242
Registered: October 2010
Senior Member
Here are my steps:

1. Unzip Virgo 3.0.1
2. Change WABHeaders=defaulted (Virgo-Home/repository/ext/org.eclipse.virgo.web.properties)
3. Build the both projects provided by you
4. Put in Virgo-Home/repository/usr:
4.1. vaadin-6.6.6.jar
4.2. com.thingtrack.com.vaadin.addons.osgi-0.0.1.SNAPSHOT.jar
5. Add in Virgo-Home/config/org.eclipse.virgo.kernel.userregion.properties
repository:bundle/com.vaadin to the initialArtifacts
6. Start Virgo
7. Modify the web application
7.1. Removed context.xml
7.2. Added atmosphere-compat-jbossweb-0.8.0-RC2.jar to WEB-INF/lib
7.3. Added atmosphere-compat-weblogic-0.8.0-RC2.jar to WEB-INF/lib
7.4. Added atmosphere-compat-jetty-0.8.0-RC2.jar to WEB-INF/lib
8. Put the application in pickup
9. Request it Wink

Please check in the console that the deployed bundle has in the Bundle-Classpath you have listed all jar files from WEB-INF/lib

Here is what I can see on my system
osgi> h 118
Bundle headers:
 Archiver-Version = Plexus Archiver
 Build-Jdk = 1.6.0_25
 Bundle-Classpath = WEB-INF/classes,WEB-INF/lib/serverpush-1.0.6.jar,WEB-INF/lib/atmosphere-gwt-client-0.8.0.RC2.jar,WEB-INF/lib/atmosphere-gwt-server
-0.8.0.RC2.jar,WEB-INF/lib/atmosphere-gwt-common-0.8.0.RC2.jar,WEB-INF/lib/gwt-servlet-2.3.0.jar,WEB-INF/lib/atmosphere-runtime-0.8.0.RC2.jar,WEB-INF/
lib/atmosphere-compat-tomcat-0.8.0.RC2.jar,WEB-INF/lib/slf4j-api-1.6.1.jar,WEB-INF/lib/atmosphere-compat-jbossweb-0.8.0-RC2.jar,WEB-INF/lib/atmosphere
-compat-jetty-0.8.0-RC2.jar,WEB-INF/lib/atmosphere-compat-tomcat-0.8.0-RC2.jar,WEB-INF/lib/atmosphere-compat-weblogic-0.8.0-RC2.jar,WEB-INF/lib/atmosp
here-gwt-client-0.8.0-RC2.jar,WEB-INF/lib/atmosphere-gwt-common-0.8.0-RC2.jar,WEB-INF/lib/atmosphere-gwt-server-0.8.0-RC2.jar,WEB-INF/lib/atmosphere-r
untime-0.8.0-RC2.jar
 Bundle-ManifestVersion = 2
 Bundle-Name = Vaadin OSGi Spring Application

[Updated on: Thu, 24 November 2011 15:10]

Report message to a moderator

Previous Topic:Dynamic class loading in fragment
Next Topic:Snaps 3.0.1.RELEASE maven repo
Goto Forum:
  


Current Time: Wed Oct 22 23:19:52 GMT 2014

Powered by FUDForum. Page generated in 0.03436 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software