users@tyrus.java.net

Re: same classes in multiple jars

From: Johan Vos <johan_at_lodgon.com>
Date: Mon, 25 Feb 2013 12:37:55 +0100

Apparently, the modules in Glassfish4b77 have this:

bieke-johan:/opt/glassfish4b77/glassfish/modules> jar tvf
tyrus-spi.jar | grep SPIEndpoint
  1887 Tue Feb 12 22:32:42 CET 2013 org/glassfish/tyrus/spi/SPIEndpoint.class

bieke-johan:/opt/glassfish4b77/glassfish/modules> jar tvf
tyrus-core.jar | grep SPIEndpoint
  1887 Tue Feb 12 22:32:42 CET 2013 org/glassfish/tyrus/spi/SPIEndpoint.class

This is the downloaded version of Glassfish4-b77, so I didn't change
anything in those jar files. But even when I build them manually based
on the tyrus trunk, those 2 jar files contain the SPIEndpoint.class

Hope this helps,

- Johan

2013/2/25 Pavel Bucek <pavel.bucek_at_oracle.com>:
> true, but I don't see any tyrus version which would introduce this state
> (having SPIEndpoint in 2 jar files).
>
>
>
> On 2/25/13 10:34 AM, Johan Vos wrote:
>>
>> I think the main issue is that SPIEndpoint.class is both in
>> tyrus-core.jar and tyrus-spi.jar. In the tyrus trunk, this is still
>> the case:
>>
>> find . -name SPIEndpoint.class
>> ./core/target/classes/org/glassfish/tyrus/spi/SPIEndpoint.class
>> ./spi/target/classes/org/glassfish/tyrus/spi/SPIEndpoint.class
>>
>> These classes are in tyrus-core.jar and tyrus-spi.jar, and both are in
>> the glassfish/modules directory.
>> If for some reason both classes are loaded (2 threads resolving 2
>> other classes), I can see why a VerifyError is generated.
>>
>> I think SPIEndpoint should either be in tyrus-core or in tyrus-spi,
>> but not in both?
>>
>> - Johan
>>
>> 2013/2/25 Pavel Bucek <pavel.bucek_at_oracle.com>:
>>>
>>> Cannot reproduce with current glassfish trunk:
>>>
>>> [#|2013-02-25T10:12:13.300+0100|INFO|glassfish
>>>
>>> 4.0|org.glassfish.tyrus.servlet.TyrusServletContainerInitializer|_ThreadID=82;_ThreadName=admin-listener(1);_TimeMillis=1361783533300;_LevelValue=800;|Registering
>>> WebSocket filter for url pattern /*|#]
>>>
>>> [#|2013-02-25T10:12:13.393+0100|INFO|glassfish
>>>
>>> 4.0|javax.enterprise.web|_ThreadID=82;_ThreadName=admin-listener(1);_TimeMillis=1361783533393;_LevelValue=800;_MessageID=AS-WEB-GLUE-00324;|Loading
>>> application [chatserver-1.0-SNAPSHOT] at [/chatserver-1.0-SNAPSHOT]|#]
>>>
>>> [#|2013-02-25T10:12:13.437+0100|INFO|glassfish
>>>
>>> 4.0|javax.enterprise.system.core|_ThreadID=82;_ThreadName=admin-listener(1);_TimeMillis=1361783533437;_LevelValue=800;|chatserver-1.0-SNAPSHOT
>>> was successfully deployed in 1,748 milliseconds.|#]
>>>
>>> So.. not sure what should we do now. Can you by any chance try glassfish
>>> trunk?
>>>
>>> Pavel
>>>
>>>
>>> On 2/25/13 10:00 AM, Johan Vos wrote:
>>>>
>>>> See attachment (hope it gets accepted by the mailinglist).
>>>>
>>>> - Johan
>>>>
>>>> 2013/2/25 Pavel Bucek <pavel.bucek_at_oracle.com>:
>>>>>
>>>>> Can you please attach generated war file as well?
>>>>>
>>>>>
>>>>> On 2/25/13 9:45 AM, Johan Vos wrote:
>>>>>>
>>>>>> No, I have only one dependency (scope provided) and that is on the
>>>>>> websocket spec, not on tyrus:
>>>>>>
>>>>>> </dependency>
>>>>>> <dependency>
>>>>>> <groupId>javax.websocket</groupId>
>>>>>> <artifactId>javax.websocket-api</artifactId>
>>>>>> <version>1.0-b12</version>
>>>>>> <scope>provided</scope>
>>>>>> </dependency>
>>>>>>
>>>>>> The war file contains a single class only, here is the source (the
>>>>>> .war file is less than 5K):
>>>>>>
>>>>>> package com.lodgon.websocket.samples.chatserver;
>>>>>>
>>>>>> import java.io.IOException;
>>>>>> import javax.websocket.Session;
>>>>>> import javax.websocket.WebSocketMessage;
>>>>>> import javax.websocket.WebSocketOpen;
>>>>>> import javax.websocket.server.WebSocketEndpoint;
>>>>>>
>>>>>> /**
>>>>>> *
>>>>>> * @author johan
>>>>>> */
>>>>>>
>>>>>>
>>>>>>
>>>>>> @WebSocketEndpoint(value="/websocket")//,configuration=DefaultServerConfiguration.class)
>>>>>> public class ChatServer {
>>>>>>
>>>>>> @WebSocketOpen
>>>>>> public void onOpen (Session session) {
>>>>>> System.out.println("opening endpoint for session
>>>>>> "+session);
>>>>>> }
>>>>>>
>>>>>> @WebSocketMessage
>>>>>> public String onMessage(String obj, Session session) throws
>>>>>> IOException {
>>>>>> System.out.println("On message: "+obj);
>>>>>> session.getRemote().sendString("A1");
>>>>>> System.out.println("Done sending A1 back to
>>>>>> "+session.getRemote());
>>>>>> return "B1";
>>>>>> }
>>>>>>
>>>>>>
>>>>>> 2013/2/25 Pavel Bucek <pavel.bucek_at_oracle.com>:
>>>>>>>
>>>>>>> Hi Johan,
>>>>>>>
>>>>>>> are you sure you don't include any of tyrus* jars in your war file?
>>>>>>>
>>>>>>> Pavel
>>>>>>>
>>>>>>>
>>>>>>> On 2/25/13 9:29 AM, johan_at_lodgon.com wrote:
>>>>>>>>
>>>>>>>> I had a weird java.lang.VerifyError on my laptop with glassfish4-b77
>>>>>>>> that prevented me from deploying @WebsocketEndpoints. However, same
>>>>>>>> application runs fine on exactly the same glassfish4-b77 on my
>>>>>>>> desktop.
>>>>>>>> Here is the error on the laptop:
>>>>>>>>
>>>>>>>> [#|2013-02-25T09:19:22.282+0100|SEVERE|glassfish
>>>>>>>>
>>>>>>>>
>>>>>>>> 4.0|javax.enterprise.web|_ThreadID=1;_ThreadName=main;_TimeMillis=13617
>>>>>>>> 80362282;_LevelValue=1000;|WebModule[/chatserver]Exception starting
>>>>>>>> filter WebSocket filter
>>>>>>>> java.lang.VerifyError: (class:
>>>>>>>> org/glassfish/tyrus/server/TyrusServerContainer, method: deploy
>>>>>>>> signature: (Lorg/glassfish/tyrus/EndpointWrapper;)V) Incompatible
>>>>>>>> argument to function
>>>>>>>> at
>>>>>>>>
>>>>>>>>
>>>>>>>> org.glassfish.tyrus.server.ServerContainerFactory.create(ServerContaine
>>>>>>>> rFactory.java:119)
>>>>>>>> at
>>>>>>>>
>>>>>>>>
>>>>>>>> org.glassfish.tyrus.servlet.TyrusServletFilter.init(TyrusServletFilter.
>>>>>>>> java:97)
>>>>>>>> at
>>>>>>>>
>>>>>>>>
>>>>>>>> org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationF
>>>>>>>> ilterConfig.java:275)
>>>>>>>> at
>>>>>>>>
>>>>>>>>
>>>>>>>> org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilt
>>>>>>>> erConfig.java:131)
>>>>>>>> ...
>>>>>>>>
>>>>>>>> I then started glassfish with -verbose:class in order to see where
>>>>>>>> all
>>>>>>>> the classes come from. This is a snippet of my laptop log:
>>>>>>>> [Loaded org.glassfish.tyrus.server.TyrusServerContainer from
>>>>>>>> file:/opt/glassfish4b77/glassfish/modules/tyrus-server.jar]
>>>>>>>> [Loaded org.glassfish.tyrus.spi.SPIEndpoint from
>>>>>>>> file:/opt/glassfish4b77/glassfish/modules/tyrus-spi.jar]
>>>>>>>> [Loaded org.glassfish.tyrus.spi.SPIEndpoint from
>>>>>>>> file:/opt/glassfish4b77/glassfish/modules/tyrus-core.jar]
>>>>>>>> [Loaded org.glassfish.tyrus.EndpointWrapper from
>>>>>>>> file:/opt/glassfish4b77/glassfish/modules/tyrus-core.jar]
>>>>>>>> [Loaded java.lang.VerifyError from /opt/jdk1.7.0_09/jre/lib/rt.jar]
>>>>>>>> [Loaded java.lang.Throwable$PrintStreamOrWriter from
>>>>>>>> /opt/jdk1.7.0_09/jre/lib/rt.jar]
>>>>>>>>
>>>>>>>> SPIEndpoint is loaded twice from 2 different jars (tyrus-core and
>>>>>>>> tyrus-spi). The desktop log shows that SPIEndpoint is loaded only
>>>>>>>> once,
>>>>>>>> from tyrus-core.jar.
>>>>>>>> This seems like a packaging issue?
>>>>>>>>
>>>>>>>> - Johan
>>>>>>>>
>>>>>>>>
>>
>