Topic
  • 4 replies
  • Latest Post - ‏2013-03-29T13:28:21Z by Tim_L
Tim_L
Tim_L
12 Posts

Pinned topic Compiling new .java file in a project

‏2013-03-28T17:27:12Z |
I have added a new java file to my WEF project however when I try and use it the browser tells me the corresponding .class file doesn't exist. What do I need to do to get that to compile with my project?
Updated on 2013-03-29T13:28:21Z at 2013-03-29T13:28:21Z by Tim_L
  • mburati
    mburati
    425 Posts

    Re: Compiling new .java file in a project

    ‏2013-03-28T17:39:40Z  
    A J2EE web app and/or portlet app is going to try to load classes from jars in WEB-INF/lib and classes from WEB-INF/classes. That's not WEF specific.

    WEF adds its own classloader that also knows about WEB-INF/work/lib and WEB-INF/work/classes in the deployed WAR, and can dynamically reload changed classes under WEB-INF/work/classes, to make development/testing easier/quicker. it's best for deployed apps to package classes in jars, but for development the classes folder should work. By default WEF projects have a WEB-INF/work/source folder that will compile into WEB-INF/work/classes which you can use for your dev/testing purposes prior to packaging your classes in a jar.

    I hope that info helps,
    ..Mike Burati
    http://www-10.lotus.com/ldd/pfwiki.nsf/
    The postings on this site are my own and do not necessarily represent the positions, strategies, or opinions of IBM.
  • Tim_L
    Tim_L
    12 Posts

    Re: Compiling new .java file in a project

    ‏2013-03-28T17:55:45Z  
    Yes, I understand that does help. I have my source files in the WEB-INF/work/source folder in my project, however the class files aren't being created when I build, clean, or publish my application. Is there a way to force those to be created?

    The file in question is a servlet which is referenced in the standalone.web.xml and the portlet.standard.web.xml files.
  • mburati
    mburati
    425 Posts

    Re: Compiling new .java file in a project

    ‏2013-03-28T18:25:24Z  
    • Tim_L
    • ‏2013-03-28T17:55:45Z
    Yes, I understand that does help. I have my source files in the WEB-INF/work/source folder in my project, however the class files aren't being created when I build, clean, or publish my application. Is there a way to force those to be created?

    The file in question is a servlet which is referenced in the standalone.web.xml and the portlet.standard.web.xml files.
    The WEF dynamic classloader is used by WEF portlets/webapps to execute WEF specific actions, so those WEF objects can find classes in those WEF specific (work/...) locations.

    The Appserver/Portlet Container only knows about WEB-INF/lib and WEB-INF/classes so it's only going to try to load servlets/portlets from those locations.

    Try packaging your servlet class(es) into a jar and put them in WEB-INF/lib

    Is there something you need to do as a servlet that you don't think you can do with WEF? It's not typical to need to build your own servlet when using WEF.

    I hope that info helps,
    ..Mike Burati
    http://www-10.lotus.com/ldd/pfwiki.nsf/
    The postings on this site are my own and do not necessarily represent the positions, strategies, or opinions of IBM.
  • Tim_L
    Tim_L
    12 Posts

    Re: Compiling new .java file in a project

    ‏2013-03-29T13:28:21Z  
    Putting a JAR file in the WEB-INF\lib seemed to work. I didn't realize how the compile worked, so that you for clarifying.