WAR file servlet access: ClassNotFoundException










0















After much reading of examples online I created a WAR file with a web.xml containing:



<servlet> <description>This is a servlet host for the
transformer</description> <display-name>Transformer</display-name>
<servlet-name>transformer</servlet-name>
<servlet-class>com.pepsi.transformer.TransformerServlet</servlet-class>
<load-on-startup>1</load-on-startup> </servlet>


And then in my .java file I have:



package com.pepsi.transformer;
...
public class TransformerServlet extends HttpServlet {
...


Then I built my ant script to stuff the TransformerServlet.class file into the WEB-INF/classes part of the WAR file. I have inspected it afterwords and found the .class file was there exactly as intended.



So ... then why do I see this error when I try to hit the doGet from the browser?




00000099 annotation W
com.ibm.ws.webcontainer.annotation.WASAnnotationHelper collectClasses
SRVE8000W: Skipped class that failed to initialize for annotation
scanning. java.lang.ClassNotFoundException:
com.pepsi.transformer.TransformerServlet at
jav.lang.ClassforNameImpl(Native Method) ...




Did I overspecify the package? Should the classes folder contain un-compiled .java files? Does it need an init method? Does something else on the server need to know about this class file?










share|improve this question



















  • 2





    When you say you put TransformerServlet.class into the WEB-INF/classes did you put it directly in that folder? i.e. is it WEB-INF/classes/TransformerServlet.class or is it WEB-INF/classes/com/pepsi/transformer/TransformerServlet.class

    – Alasdair
    Nov 16 '18 at 1:01











  • I'd really suggest you to use any Java EE IDE, like Eclipse. It will create all that for you when you will create simple dynamic web project. Also unless required, it is much easier to use @WebServlet annotation instead of defining servlet in web.xml. Go to the developer.ibm.com/wasdev/downloads/… and follow instructions to download and configure Eclipse with WebSphere Liberty.

    – Gas
    Nov 16 '18 at 13:52











  • @Alasdair: Looks like they were going into WEB-INF and not WEB-INF/classes. Should they go into separate directories for each token in the fully qualified package name?

    – micahhoover
    Nov 19 '18 at 13:41






  • 1





    Yes. Each token in the package name has to map to a directory name in a path.

    – Alasdair
    Nov 19 '18 at 15:03











  • With Ant, you want to use the <war> task and its <classes> element to point at the root of the package hierarchy directory.

    – dbreaux
    Nov 20 '18 at 20:01















0















After much reading of examples online I created a WAR file with a web.xml containing:



<servlet> <description>This is a servlet host for the
transformer</description> <display-name>Transformer</display-name>
<servlet-name>transformer</servlet-name>
<servlet-class>com.pepsi.transformer.TransformerServlet</servlet-class>
<load-on-startup>1</load-on-startup> </servlet>


And then in my .java file I have:



package com.pepsi.transformer;
...
public class TransformerServlet extends HttpServlet {
...


Then I built my ant script to stuff the TransformerServlet.class file into the WEB-INF/classes part of the WAR file. I have inspected it afterwords and found the .class file was there exactly as intended.



So ... then why do I see this error when I try to hit the doGet from the browser?




00000099 annotation W
com.ibm.ws.webcontainer.annotation.WASAnnotationHelper collectClasses
SRVE8000W: Skipped class that failed to initialize for annotation
scanning. java.lang.ClassNotFoundException:
com.pepsi.transformer.TransformerServlet at
jav.lang.ClassforNameImpl(Native Method) ...




Did I overspecify the package? Should the classes folder contain un-compiled .java files? Does it need an init method? Does something else on the server need to know about this class file?










share|improve this question



















  • 2





    When you say you put TransformerServlet.class into the WEB-INF/classes did you put it directly in that folder? i.e. is it WEB-INF/classes/TransformerServlet.class or is it WEB-INF/classes/com/pepsi/transformer/TransformerServlet.class

    – Alasdair
    Nov 16 '18 at 1:01











  • I'd really suggest you to use any Java EE IDE, like Eclipse. It will create all that for you when you will create simple dynamic web project. Also unless required, it is much easier to use @WebServlet annotation instead of defining servlet in web.xml. Go to the developer.ibm.com/wasdev/downloads/… and follow instructions to download and configure Eclipse with WebSphere Liberty.

    – Gas
    Nov 16 '18 at 13:52











  • @Alasdair: Looks like they were going into WEB-INF and not WEB-INF/classes. Should they go into separate directories for each token in the fully qualified package name?

    – micahhoover
    Nov 19 '18 at 13:41






  • 1





    Yes. Each token in the package name has to map to a directory name in a path.

    – Alasdair
    Nov 19 '18 at 15:03











  • With Ant, you want to use the <war> task and its <classes> element to point at the root of the package hierarchy directory.

    – dbreaux
    Nov 20 '18 at 20:01













0












0








0








After much reading of examples online I created a WAR file with a web.xml containing:



<servlet> <description>This is a servlet host for the
transformer</description> <display-name>Transformer</display-name>
<servlet-name>transformer</servlet-name>
<servlet-class>com.pepsi.transformer.TransformerServlet</servlet-class>
<load-on-startup>1</load-on-startup> </servlet>


And then in my .java file I have:



package com.pepsi.transformer;
...
public class TransformerServlet extends HttpServlet {
...


Then I built my ant script to stuff the TransformerServlet.class file into the WEB-INF/classes part of the WAR file. I have inspected it afterwords and found the .class file was there exactly as intended.



So ... then why do I see this error when I try to hit the doGet from the browser?




00000099 annotation W
com.ibm.ws.webcontainer.annotation.WASAnnotationHelper collectClasses
SRVE8000W: Skipped class that failed to initialize for annotation
scanning. java.lang.ClassNotFoundException:
com.pepsi.transformer.TransformerServlet at
jav.lang.ClassforNameImpl(Native Method) ...




Did I overspecify the package? Should the classes folder contain un-compiled .java files? Does it need an init method? Does something else on the server need to know about this class file?










share|improve this question
















After much reading of examples online I created a WAR file with a web.xml containing:



<servlet> <description>This is a servlet host for the
transformer</description> <display-name>Transformer</display-name>
<servlet-name>transformer</servlet-name>
<servlet-class>com.pepsi.transformer.TransformerServlet</servlet-class>
<load-on-startup>1</load-on-startup> </servlet>


And then in my .java file I have:



package com.pepsi.transformer;
...
public class TransformerServlet extends HttpServlet {
...


Then I built my ant script to stuff the TransformerServlet.class file into the WEB-INF/classes part of the WAR file. I have inspected it afterwords and found the .class file was there exactly as intended.



So ... then why do I see this error when I try to hit the doGet from the browser?




00000099 annotation W
com.ibm.ws.webcontainer.annotation.WASAnnotationHelper collectClasses
SRVE8000W: Skipped class that failed to initialize for annotation
scanning. java.lang.ClassNotFoundException:
com.pepsi.transformer.TransformerServlet at
jav.lang.ClassforNameImpl(Native Method) ...




Did I overspecify the package? Should the classes folder contain un-compiled .java files? Does it need an init method? Does something else on the server need to know about this class file?







java servlets websphere






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 15 '18 at 21:17







micahhoover

















asked Nov 15 '18 at 21:08









micahhoovermicahhoover

1,28042443




1,28042443







  • 2





    When you say you put TransformerServlet.class into the WEB-INF/classes did you put it directly in that folder? i.e. is it WEB-INF/classes/TransformerServlet.class or is it WEB-INF/classes/com/pepsi/transformer/TransformerServlet.class

    – Alasdair
    Nov 16 '18 at 1:01











  • I'd really suggest you to use any Java EE IDE, like Eclipse. It will create all that for you when you will create simple dynamic web project. Also unless required, it is much easier to use @WebServlet annotation instead of defining servlet in web.xml. Go to the developer.ibm.com/wasdev/downloads/… and follow instructions to download and configure Eclipse with WebSphere Liberty.

    – Gas
    Nov 16 '18 at 13:52











  • @Alasdair: Looks like they were going into WEB-INF and not WEB-INF/classes. Should they go into separate directories for each token in the fully qualified package name?

    – micahhoover
    Nov 19 '18 at 13:41






  • 1





    Yes. Each token in the package name has to map to a directory name in a path.

    – Alasdair
    Nov 19 '18 at 15:03











  • With Ant, you want to use the <war> task and its <classes> element to point at the root of the package hierarchy directory.

    – dbreaux
    Nov 20 '18 at 20:01












  • 2





    When you say you put TransformerServlet.class into the WEB-INF/classes did you put it directly in that folder? i.e. is it WEB-INF/classes/TransformerServlet.class or is it WEB-INF/classes/com/pepsi/transformer/TransformerServlet.class

    – Alasdair
    Nov 16 '18 at 1:01











  • I'd really suggest you to use any Java EE IDE, like Eclipse. It will create all that for you when you will create simple dynamic web project. Also unless required, it is much easier to use @WebServlet annotation instead of defining servlet in web.xml. Go to the developer.ibm.com/wasdev/downloads/… and follow instructions to download and configure Eclipse with WebSphere Liberty.

    – Gas
    Nov 16 '18 at 13:52











  • @Alasdair: Looks like they were going into WEB-INF and not WEB-INF/classes. Should they go into separate directories for each token in the fully qualified package name?

    – micahhoover
    Nov 19 '18 at 13:41






  • 1





    Yes. Each token in the package name has to map to a directory name in a path.

    – Alasdair
    Nov 19 '18 at 15:03











  • With Ant, you want to use the <war> task and its <classes> element to point at the root of the package hierarchy directory.

    – dbreaux
    Nov 20 '18 at 20:01







2




2





When you say you put TransformerServlet.class into the WEB-INF/classes did you put it directly in that folder? i.e. is it WEB-INF/classes/TransformerServlet.class or is it WEB-INF/classes/com/pepsi/transformer/TransformerServlet.class

– Alasdair
Nov 16 '18 at 1:01





When you say you put TransformerServlet.class into the WEB-INF/classes did you put it directly in that folder? i.e. is it WEB-INF/classes/TransformerServlet.class or is it WEB-INF/classes/com/pepsi/transformer/TransformerServlet.class

– Alasdair
Nov 16 '18 at 1:01













I'd really suggest you to use any Java EE IDE, like Eclipse. It will create all that for you when you will create simple dynamic web project. Also unless required, it is much easier to use @WebServlet annotation instead of defining servlet in web.xml. Go to the developer.ibm.com/wasdev/downloads/… and follow instructions to download and configure Eclipse with WebSphere Liberty.

– Gas
Nov 16 '18 at 13:52





I'd really suggest you to use any Java EE IDE, like Eclipse. It will create all that for you when you will create simple dynamic web project. Also unless required, it is much easier to use @WebServlet annotation instead of defining servlet in web.xml. Go to the developer.ibm.com/wasdev/downloads/… and follow instructions to download and configure Eclipse with WebSphere Liberty.

– Gas
Nov 16 '18 at 13:52













@Alasdair: Looks like they were going into WEB-INF and not WEB-INF/classes. Should they go into separate directories for each token in the fully qualified package name?

– micahhoover
Nov 19 '18 at 13:41





@Alasdair: Looks like they were going into WEB-INF and not WEB-INF/classes. Should they go into separate directories for each token in the fully qualified package name?

– micahhoover
Nov 19 '18 at 13:41




1




1





Yes. Each token in the package name has to map to a directory name in a path.

– Alasdair
Nov 19 '18 at 15:03





Yes. Each token in the package name has to map to a directory name in a path.

– Alasdair
Nov 19 '18 at 15:03













With Ant, you want to use the <war> task and its <classes> element to point at the root of the package hierarchy directory.

– dbreaux
Nov 20 '18 at 20:01





With Ant, you want to use the <war> task and its <classes> element to point at the root of the package hierarchy directory.

– dbreaux
Nov 20 '18 at 20:01












0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53327918%2fwar-file-servlet-access-classnotfoundexception%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53327918%2fwar-file-servlet-access-classnotfoundexception%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Top Tejano songwriter Luis Silva dead of heart attack at 64

政党

天津地下鉄3号線