You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Kok How Teh <fu...@gmail.com> on 2018/12/10 03:10:10 UTC

Error running the application as WAR in tomcat 9

Hi;
   I use Spring Boot to develop GraphQL applications. However, when the
application is packaged as WAR and deployed to Tomcat 9, it throws
illegalstate exception. I have tried the workaround by adding a
ServletContextAware bean but it doesn't help on Tomcat 9. I have filed 2
issues in separate github projects:

https://github.com/eh3rrera/graphql-java-spring-boot-example/issues/10#issuecomment-445095690

https://github.com/graphql-java-kickstart/graphql-spring-boot/issues/165

It's reported that the exception is only specific to Tomcat 9. Any advice
and insight is appreciated.

Regards,
KH

Re: Error running the application as WAR in tomcat 9

Posted by Mark Thomas <ma...@apache.org>.
On 16/12/2018 11:51, Kok How Teh wrote:
> I get this on the page:
> 
> org.apache.tomcat.websocket.server.WsServerContainer@7d9225a7

Then it is working correctly.

Mark


> 
> On Sun, Dec 16, 2018 at 12:27 AM Mark Thomas <ma...@apache.org> wrote:
> 
>> On 15/12/2018 12:15, Kok How Teh wrote:
>>> Can you share with  me your JSP for test? Thanks.
>>
>> It was in a previous mail in this thread:
>>
>> <snip/>
>>
>>>>>> A web app with a single JSP (below) deployed to a clean Tomcat 9.0.x
>>>>>> install shows this is the case.
>>>>>>
>>
>>
>> === start JSP ===
>> <%= application.getAttribute("javax.websocket.server.ServerContainer") %>
>> === end JSP ===
>>
>>
>> <snip/>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>>
>>
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Error running the application as WAR in tomcat 9

Posted by Kok How Teh <fu...@gmail.com>.
I get this on the page:

org.apache.tomcat.websocket.server.WsServerContainer@7d9225a7

On Sun, Dec 16, 2018 at 12:27 AM Mark Thomas <ma...@apache.org> wrote:

> On 15/12/2018 12:15, Kok How Teh wrote:
> > Can you share with  me your JSP for test? Thanks.
>
> It was in a previous mail in this thread:
>
> <snip/>
>
> >>>> A web app with a single JSP (below) deployed to a clean Tomcat 9.0.x
> >>>> install shows this is the case.
> >>>>
>
>
> === start JSP ===
> <%= application.getAttribute("javax.websocket.server.ServerContainer") %>
> === end JSP ===
>
>
> <snip/>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

Re: Error running the application as WAR in tomcat 9

Posted by Mark Thomas <ma...@apache.org>.
On 15/12/2018 12:15, Kok How Teh wrote:
> Can you share with  me your JSP for test? Thanks.

It was in a previous mail in this thread:

<snip/>

>>>> A web app with a single JSP (below) deployed to a clean Tomcat 9.0.x
>>>> install shows this is the case.
>>>>


=== start JSP ===
<%= application.getAttribute("javax.websocket.server.ServerContainer") %>
=== end JSP ===


<snip/>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Error running the application as WAR in tomcat 9

Posted by Kok How Teh <fu...@gmail.com>.
Can you share with  me your JSP for test? Thanks.

On Fri, Dec 14, 2018 at 7:50 PM Mark Thomas <ma...@apache.org> wrote:

> On 14/12/2018 11:15, Kok How Teh wrote:
> >> Have you configued "containerSciFilter" on the Context?
> > No. I don't
> >
> >> Have you removed any JARs from Tomcat's lib directory?
> > These are what I have in the lib:
> >
> > /opt/tomcat/latest/lib 2114 $ ls
> > annotations-api.jar  catalina.jar              ecj-4.7.3a.jar  jasper.jar
> >     servlet-api.jar    tomcat-dbcp.jar     tomcat-i18n-ja.jar
> > tomcat-jni.jar        tomcat-websocket.jar
> > catalina-ant.jar     catalina-storeconfig.jar  el-api.jar
> > jaspic-api.jar  tomcat-api.jar     tomcat-i18n-es.jar  tomcat-i18n-ru.jar
> > tomcat-util.jar       websocket-api.jar
> > catalina-ha.jar      catalina-tribes.jar       jasper-el.jar
>  jsp-api.jar
> >    tomcat-coyote.jar  tomcat-i18n-fr.jar  tomcat-jdbc.jar
> >  tomcat-util-scan.jar
> >
> >> Are you using embedded without the WebSocket JAR?
> > How do I check this?
>
> Given the above, this does not apply to you.
>
> Time to create the simplest possible test case that demonstrates this
> problem on a clean Tomcat 9.0.14 install. I suggest starting with the
> JSP I used for my test. You'll probably figure out what the problem is
> by creating the test case.
>
> Mark
>
>
> >
> > On Fri, Dec 14, 2018 at 4:38 PM Mark Thomas <ma...@apache.org> wrote:
> >
> >> On 14/12/2018 00:34, Kok How Teh wrote:
> >>> I filed a bug at Spring JIRA and this is the response I get (
> >>> https://jira.spring.io/browse/SPR-17599):
> >>>
> >>> There seems to be a misunderstanding in that conversation on the Tomcat
> >>> mailing list: It's not that we can't find the class of the name
> >>> javax.websocket.server.ServerContainer, it's the *ServletContext
> >>> attribute* with
> >>> name "javax.websocket.server.ServerContainer" that we can't find. In
> >> other
> >>> words, we can't find a pre-initialized WebSocket container instance.
> >>>
> >>> So the root of the problem you can easily reproduce without Spring:
> >> Simply
> >>> implement a Servlet and check the return value of
> >>>
> >>
> getServletContext().getAttribute("javax.websocket.server.ServerContainer")
> >>> ...
> >>
> >> Tomcat creates that automatically unless you explicitly disable the
> >> ServletContainerInitializer.
> >>
> >> A web app with a single JSP (below) deployed to a clean Tomcat 9.0.x
> >> install shows this is the case.
> >>
> >> === start JSP ===
> >> <%= application.getAttribute("javax.websocket.server.ServerContainer")
> %>
> >> === end JSP ===
> >>
> >> Have you configued "containerSciFilter" on the Context?
> >>
> >> Have you removed any JARs from Tomcat's lib directory?
> >>
> >> Are you using embedded without the WebSocket JAR?
> >>
> >> Mark
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> >> For additional commands, e-mail: users-help@tomcat.apache.org
> >>
> >>
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

Re: Error running the application as WAR in tomcat 9

Posted by Mark Thomas <ma...@apache.org>.
On 14/12/2018 11:15, Kok How Teh wrote:
>> Have you configued "containerSciFilter" on the Context?
> No. I don't
> 
>> Have you removed any JARs from Tomcat's lib directory?
> These are what I have in the lib:
> 
> /opt/tomcat/latest/lib 2114 $ ls
> annotations-api.jar  catalina.jar              ecj-4.7.3a.jar  jasper.jar
>     servlet-api.jar    tomcat-dbcp.jar     tomcat-i18n-ja.jar
> tomcat-jni.jar        tomcat-websocket.jar
> catalina-ant.jar     catalina-storeconfig.jar  el-api.jar
> jaspic-api.jar  tomcat-api.jar     tomcat-i18n-es.jar  tomcat-i18n-ru.jar
> tomcat-util.jar       websocket-api.jar
> catalina-ha.jar      catalina-tribes.jar       jasper-el.jar   jsp-api.jar
>    tomcat-coyote.jar  tomcat-i18n-fr.jar  tomcat-jdbc.jar
>  tomcat-util-scan.jar
> 
>> Are you using embedded without the WebSocket JAR?
> How do I check this?

Given the above, this does not apply to you.

Time to create the simplest possible test case that demonstrates this
problem on a clean Tomcat 9.0.14 install. I suggest starting with the
JSP I used for my test. You'll probably figure out what the problem is
by creating the test case.

Mark


> 
> On Fri, Dec 14, 2018 at 4:38 PM Mark Thomas <ma...@apache.org> wrote:
> 
>> On 14/12/2018 00:34, Kok How Teh wrote:
>>> I filed a bug at Spring JIRA and this is the response I get (
>>> https://jira.spring.io/browse/SPR-17599):
>>>
>>> There seems to be a misunderstanding in that conversation on the Tomcat
>>> mailing list: It's not that we can't find the class of the name
>>> javax.websocket.server.ServerContainer, it's the *ServletContext
>>> attribute* with
>>> name "javax.websocket.server.ServerContainer" that we can't find. In
>> other
>>> words, we can't find a pre-initialized WebSocket container instance.
>>>
>>> So the root of the problem you can easily reproduce without Spring:
>> Simply
>>> implement a Servlet and check the return value of
>>>
>> getServletContext().getAttribute("javax.websocket.server.ServerContainer")
>>> ...
>>
>> Tomcat creates that automatically unless you explicitly disable the
>> ServletContainerInitializer.
>>
>> A web app with a single JSP (below) deployed to a clean Tomcat 9.0.x
>> install shows this is the case.
>>
>> === start JSP ===
>> <%= application.getAttribute("javax.websocket.server.ServerContainer") %>
>> === end JSP ===
>>
>> Have you configued "containerSciFilter" on the Context?
>>
>> Have you removed any JARs from Tomcat's lib directory?
>>
>> Are you using embedded without the WebSocket JAR?
>>
>> Mark
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>>
>>
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Error running the application as WAR in tomcat 9

Posted by Kok How Teh <fu...@gmail.com>.
> Have you configued "containerSciFilter" on the Context?
No. I don't

> Have you removed any JARs from Tomcat's lib directory?
These are what I have in the lib:

/opt/tomcat/latest/lib 2114 $ ls
annotations-api.jar  catalina.jar              ecj-4.7.3a.jar  jasper.jar
    servlet-api.jar    tomcat-dbcp.jar     tomcat-i18n-ja.jar
tomcat-jni.jar        tomcat-websocket.jar
catalina-ant.jar     catalina-storeconfig.jar  el-api.jar
jaspic-api.jar  tomcat-api.jar     tomcat-i18n-es.jar  tomcat-i18n-ru.jar
tomcat-util.jar       websocket-api.jar
catalina-ha.jar      catalina-tribes.jar       jasper-el.jar   jsp-api.jar
   tomcat-coyote.jar  tomcat-i18n-fr.jar  tomcat-jdbc.jar
 tomcat-util-scan.jar

> Are you using embedded without the WebSocket JAR?
How do I check this?

On Fri, Dec 14, 2018 at 4:38 PM Mark Thomas <ma...@apache.org> wrote:

> On 14/12/2018 00:34, Kok How Teh wrote:
> > I filed a bug at Spring JIRA and this is the response I get (
> > https://jira.spring.io/browse/SPR-17599):
> >
> > There seems to be a misunderstanding in that conversation on the Tomcat
> > mailing list: It's not that we can't find the class of the name
> > javax.websocket.server.ServerContainer, it's the *ServletContext
> > attribute* with
> > name "javax.websocket.server.ServerContainer" that we can't find. In
> other
> > words, we can't find a pre-initialized WebSocket container instance.
> >
> > So the root of the problem you can easily reproduce without Spring:
> Simply
> > implement a Servlet and check the return value of
> >
> getServletContext().getAttribute("javax.websocket.server.ServerContainer")
> > ...
>
> Tomcat creates that automatically unless you explicitly disable the
> ServletContainerInitializer.
>
> A web app with a single JSP (below) deployed to a clean Tomcat 9.0.x
> install shows this is the case.
>
> === start JSP ===
> <%= application.getAttribute("javax.websocket.server.ServerContainer") %>
> === end JSP ===
>
> Have you configued "containerSciFilter" on the Context?
>
> Have you removed any JARs from Tomcat's lib directory?
>
> Are you using embedded without the WebSocket JAR?
>
> Mark
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

Re: Error running the application as WAR in tomcat 9

Posted by Mark Thomas <ma...@apache.org>.
On 14/12/2018 00:34, Kok How Teh wrote:
> I filed a bug at Spring JIRA and this is the response I get (
> https://jira.spring.io/browse/SPR-17599):
> 
> There seems to be a misunderstanding in that conversation on the Tomcat
> mailing list: It's not that we can't find the class of the name
> javax.websocket.server.ServerContainer, it's the *ServletContext
> attribute* with
> name "javax.websocket.server.ServerContainer" that we can't find. In other
> words, we can't find a pre-initialized WebSocket container instance.
> 
> So the root of the problem you can easily reproduce without Spring: Simply
> implement a Servlet and check the return value of
> getServletContext().getAttribute("javax.websocket.server.ServerContainer")
> ...

Tomcat creates that automatically unless you explicitly disable the
ServletContainerInitializer.

A web app with a single JSP (below) deployed to a clean Tomcat 9.0.x
install shows this is the case.

=== start JSP ===
<%= application.getAttribute("javax.websocket.server.ServerContainer") %>
=== end JSP ===

Have you configued "containerSciFilter" on the Context?

Have you removed any JARs from Tomcat's lib directory?

Are you using embedded without the WebSocket JAR?

Mark

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Error running the application as WAR in tomcat 9

Posted by Kok How Teh <fu...@gmail.com>.
I filed a bug at Spring JIRA and this is the response I get (
https://jira.spring.io/browse/SPR-17599):

There seems to be a misunderstanding in that conversation on the Tomcat
mailing list: It's not that we can't find the class of the name
javax.websocket.server.ServerContainer, it's the *ServletContext
attribute* with
name "javax.websocket.server.ServerContainer" that we can't find. In other
words, we can't find a pre-initialized WebSocket container instance.

So the root of the problem you can easily reproduce without Spring: Simply
implement a Servlet and check the return value of
getServletContext().getAttribute("javax.websocket.server.ServerContainer")
...


People

   - Assignee:[image: juergen.hoeller] Juergen HoellerReporter:[image:
   khteh] Teh Kok HowLast updater:Juergen Hoeller


   - Votes:0 Vote for this issueWatchers:2 Start watching this issue



Dates

   - Created:YesterdayUpdated:YesterdayDays since last comment:10 hours, 48
   minutes ago


On Mon, Dec 10, 2018 at 11:41 PM Christopher Schultz <
chris@christopherschultz.net> wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA256
>
> KH,
>
> On 12/9/18 22:10, Kok How Teh wrote:
> > Hi; I use Spring Boot to develop GraphQL applications. However,
> > when the application is packaged as WAR and deployed to Tomcat 9,
> > it throws illegalstate exception. I have tried the workaround by
> > adding a ServletContextAware bean but it doesn't help on Tomcat 9.
> > I have filed 2 issues in separate github projects:
> >
> > https://github.com/eh3rrera/graphql-java-spring-boot-example/issues/10
> #issuecomment-445095690
> <https://github.com/eh3rrera/graphql-java-spring-boot-example/issues/10#issuecomment-445095690>
> >
> >
> > https://github.com/graphql-java-kickstart/graphql-spring-boot/issues/1
> 65
> >
> >  It's reported that the exception is only specific to Tomcat 9. Any
> > advice and insight is appreciated.
>
> Spring is throwing the exception. Tomcat ships with the
> javax.websocket.server.ServerContainer class.
>
> I don't believe there are any differences between Tomcat 8.5.x and
> 9.0.x when it comes to ClassLoader layout and class visibility.
>
> I'd ask Spring how they are performing that sanity check to see why
> they are throwing that exception.
>
> - -chris
> -----BEGIN PGP SIGNATURE-----
> Comment: Using GnuPG with Thunderbird - https://www.enigmail.net/
>
> iQIzBAEBCAAdFiEEMmKgYcQvxMe7tcJcHPApP6U8pFgFAlwOiT0ACgkQHPApP6U8
> pFj3AhAAjhGBIid6nN/KUBJiIeuNHGi6A3pzJ9Gn4T5irwWgqvUS+i3nDvc63Od6
> vOVsMab0HdVUhIrzGkSNAr/dhK2TaOET2taDR9Q9OcnGorYOJ8xaG2uV5++ydI9D
> xk3rWWeBKbIH/ESElSyU4oJ7FtdL/+3LIi77+HZL8KrF0OOkn4Ac/pYJkH5BDslx
> Tds5OIhCiUUtsP621sLvcarqN+Dqx3/2iJSQMz7qWmPp9fqpzvkLquZcQHRbcYq1
> D7yrKxkr1lrjydqeXIEotfwCPOkai2WH97rFKru2rwZNriUzFUmz6k7OOgXIACRY
> WDKlyaqCWVmZR9UgBQ5xnxVkVY/CTDJO0KkT0mFbAtAD1VDT2Vx88ShhZPXlQWQu
> PtKeDMSNvt0Wsz9sbaewaHMSyGDNd+P8P0KURtSymTw+3IOMDLSaIIr8KvJFKpN1
> XXpho2tusH7YJEsXx9e1VnPUND+si6uMW+fVT51f3fjUos5S5LVD6lUjYDI9kvtY
> LiqB0lflXYLgLU6zQYGGwadU2lGlM9skSza+EzEdLaN1HjMHrwAEtUOa4C5k60x/
> 3snuiWj98aMrjG3KK18KJLnVsx18QDxj6ptTg9kRaZbCOCrfNWzgyBcAYmtgPjV9
> cP2MheADzGXO9bIsDPu4aOjND96X64yPLueKVBQuY9qyAmKFLeA=
> =sXt5
> -----END PGP SIGNATURE-----
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

Re: Error running the application as WAR in tomcat 9

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

KH,

On 12/9/18 22:10, Kok How Teh wrote:
> Hi; I use Spring Boot to develop GraphQL applications. However,
> when the application is packaged as WAR and deployed to Tomcat 9,
> it throws illegalstate exception. I have tried the workaround by
> adding a ServletContextAware bean but it doesn't help on Tomcat 9.
> I have filed 2 issues in separate github projects:
> 
> https://github.com/eh3rrera/graphql-java-spring-boot-example/issues/10
#issuecomment-445095690
>
>  
> https://github.com/graphql-java-kickstart/graphql-spring-boot/issues/1
65
>
>  It's reported that the exception is only specific to Tomcat 9. Any
> advice and insight is appreciated.

Spring is throwing the exception. Tomcat ships with the
javax.websocket.server.ServerContainer class.

I don't believe there are any differences between Tomcat 8.5.x and
9.0.x when it comes to ClassLoader layout and class visibility.

I'd ask Spring how they are performing that sanity check to see why
they are throwing that exception.

- -chris
-----BEGIN PGP SIGNATURE-----
Comment: Using GnuPG with Thunderbird - https://www.enigmail.net/

iQIzBAEBCAAdFiEEMmKgYcQvxMe7tcJcHPApP6U8pFgFAlwOiT0ACgkQHPApP6U8
pFj3AhAAjhGBIid6nN/KUBJiIeuNHGi6A3pzJ9Gn4T5irwWgqvUS+i3nDvc63Od6
vOVsMab0HdVUhIrzGkSNAr/dhK2TaOET2taDR9Q9OcnGorYOJ8xaG2uV5++ydI9D
xk3rWWeBKbIH/ESElSyU4oJ7FtdL/+3LIi77+HZL8KrF0OOkn4Ac/pYJkH5BDslx
Tds5OIhCiUUtsP621sLvcarqN+Dqx3/2iJSQMz7qWmPp9fqpzvkLquZcQHRbcYq1
D7yrKxkr1lrjydqeXIEotfwCPOkai2WH97rFKru2rwZNriUzFUmz6k7OOgXIACRY
WDKlyaqCWVmZR9UgBQ5xnxVkVY/CTDJO0KkT0mFbAtAD1VDT2Vx88ShhZPXlQWQu
PtKeDMSNvt0Wsz9sbaewaHMSyGDNd+P8P0KURtSymTw+3IOMDLSaIIr8KvJFKpN1
XXpho2tusH7YJEsXx9e1VnPUND+si6uMW+fVT51f3fjUos5S5LVD6lUjYDI9kvtY
LiqB0lflXYLgLU6zQYGGwadU2lGlM9skSza+EzEdLaN1HjMHrwAEtUOa4C5k60x/
3snuiWj98aMrjG3KK18KJLnVsx18QDxj6ptTg9kRaZbCOCrfNWzgyBcAYmtgPjV9
cP2MheADzGXO9bIsDPu4aOjND96X64yPLueKVBQuY9qyAmKFLeA=
=sXt5
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org