www.webdeveloper.com
Results 1 to 11 of 11

Thread: war deployment

  1. #1
    Join Date
    Sep 2005
    Posts
    38

    war deployment

    Hi

    I have a war file called test.war which contains all my jsp page & web.xml.I have made a jar file called test.jar which contains all my classes. Then I copied these file to tomcat webapps folder.when I start the tomcat. test.war file got unzipped to folder test.Then I put test.jar inside the web-inf of test folder.I changed the web.xml to the following to know my class file
    are inside test.jar

    <?xml version="1.0" ?>
    <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
    <web-app>
    <servlet>
    <servlet-name>DBHandler</servlet-name>
    <servlet-class>test.jar/Sample.DBHandler</servlet-class> <--- to know where is class
    </servlet>
    <servlet-mapping>
    <servlet-name>DBHandler</servlet-name>
    <url-pattern>/DBHandler</url-pattern>
    </servlet-mapping>

    </web-app>

    But when I run the program It is showing error as package name not found. Can anyone tell me what to do.I know this is not the right way, to put my jar inside the web-inf.But I have to put my class files in JAR file only.& and my jsp page & web.xml inside war file.Can anyone tell me what to do.I know I have to modify the web.xml to say all the class r there inside the test.jar.How to do that.

  2. #2
    Join Date
    Dec 2002
    Location
    Calgary, Canada
    Posts
    6,120
    u don't need to do this

    <servlet-class>test.jar/Sample.DBHandler</servlet-class>

    instead do this

    <servlet-class>Sample.DBHandler</servlet-class>

    and make sure that u include the jar file inside ur war file so that u do not have to copy it afterwards.
    WEB-INF/*.jar
    /web.xml
    and then servlet mapping if any required inside of the web.xml
    Cheers

    Khalid

    Message Posting Guidelines In These Forums, Please read these before posting any question.
    Web site: webapplikations.com
    Web Resources Page:Web Resources

  3. #3
    Join Date
    Sep 2005
    Posts
    38
    Hi

    Ihave done that. But it show the same error.package Sample not found.The test folder has the following structure.

    TEST
    +META-INF
    +WEB-INF
    + web.xml
    + test.jar
    +register.jsp
    +process.jsp

    The web.xml has the following

    <?xml version="1.0" ?>
    <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
    <web-app>
    <servlet>
    <servlet-name>DBHandler</servlet-name>
    <servlet-class>Sample.DBHandler</servlet-class>
    </servlet>
    <servlet-mapping>
    <servlet-name>DBHandler</servlet-name>
    <url-pattern>/DBHandler</url-pattern>
    </servlet-mapping>

    </web-app>

    Can u tell me what to do.

  4. #4
    Join Date
    Dec 2002
    Location
    Calgary, Canada
    Posts
    6,120
    yes except one t hing that I forgot to mention that put the jar file in the lib directory under WEB-INF folder so that it looks like this

    WEB-INF/
    /web.xml
    /lib
    /lib/*.jar

    my bad wasn't thinking straight..:-)
    Cheers

    Khalid

    Message Posting Guidelines In These Forums, Please read these before posting any question.
    Web site: webapplikations.com
    Web Resources Page:Web Resources

  5. #5
    Join Date
    Sep 2005
    Posts
    38
    Hi

    Thanks for your replay.I did that. I put test.jar in lib folder of web-inf.
    WEB-INF/
    /web.xml
    /lib/test.jar
    But same error is comming as

    D:\Program Files\Apache Group\Tomcat 4.1\work\Standalone\localhost\test\process_jsp.java:43: package Sample does not exist
    Sample.FormBean formHandler = null;
    ^



    An error occurred at line: 4 in the jsp file: /process.jsp

    Generated servlet error:
    D:\Program Files\Apache Group\Tomcat 4.1\work\Standalone\localhost\test\process_jsp.java:45: package Sample does not exist
    formHandler = (Sample.FormBean) pageContext.getAttribute("formHandler", PageContext.REQUEST_SCOPE);
    ^

    Can u tell me what to do.I have put all my classes in test.jar.The jsp is in test.war.When tomcat started. the test.war is unzipping to the test folder .When I looked it has the test.jar in lib dir of web-inf.Do I have to say anything in web.xml to say that classes are there in lib.

  6. #6
    Join Date
    Dec 2002
    Location
    Calgary, Canada
    Posts
    6,120
    did u do an import of file in question in the jsp page?
    you want to do that too in addition to the directory structure.
    Cheers

    Khalid

    Message Posting Guidelines In These Forums, Please read these before posting any question.
    Web site: webapplikations.com
    Web Resources Page:Web Resources

  7. #7
    Join Date
    Sep 2005
    Posts
    38
    Hi

    I did that. The first jsp page is comming .That page will call process.jsp.In that we call the class.The code of process.jsp page is

    <%@ page import="java.util.*" %>
    <%@ page import="Sample.FormBean" %>



    <jsp:useBean id="formHandler" class="Sample.FormBean" scope="request">
    <jsp:setProperty name="formHandler" property="*"/>
    </jsp:useBean>

    <% if (formHandler.validate()) {
    %>
    <jsp:forward page="DBHandler" />

    <%
    }else {
    %>
    <jsp:forward page="retry.jsp"/>
    <%
    }
    %>


    It is showing the same errror.

    D:\Program Files\Apache Group\Tomcat 4.1\work\Standalone\localhost\test\process_jsp.java:8: package Sample does not exist
    import Sample.FormBean;
    ^
    D:\Program Files\Apache Group\Tomcat 4.1\work\Standalone\localhost\test\process_jsp.java:45: package Sample does not exist
    Sample.FormBean formHandler = null;
    ^



    An error occurred at line: 5 in the jsp file: /process.jsp

    Generated servlet error:
    D:\Program Files\Apache Group\Tomcat 4.1\work\Standalone\localhost\test\process_jsp.java:47: package Sample does not exist
    formHandler = (Sample.FormBean) pageContext.getAttribute("formHandler", PageContext.REQUEST_SCOPE);
    ^



    An error occurred at line: 5 in the jsp file: /process.jsp

    Generated servlet error:
    D:\Program Files\Apache Group\Tomcat 4.1\work\Standalone\localhost\test\process_jsp.java:50: package Sample does not exist
    formHandler = (Sample.FormBean) java.beans.Beans.instantiate(this.getClass().getClassLoader(), "Sample.FormBean");
    ^
    4 errors

    Can u tell me what to do.

  8. #8
    Join Date
    Dec 2002
    Location
    Calgary, Canada
    Posts
    6,120
    zip up all of ur project and upload it here or email it to me..I will take a look
    Cheers

    Khalid

    Message Posting Guidelines In These Forums, Please read these before posting any question.
    Web site: webapplikations.com
    Web Resources Page:Web Resources

  9. #9
    Join Date
    Sep 2005
    Posts
    38
    Hi Khalid,

    Thanks a lot.It worked.When I unzipped the jar file.It comming as
    WEB-INF/classes/Sample/DBHandler.class. So I made jar which starts from Package name Sample.Then I put it into lib. import the class name in jsp.then it is working.Thanks for your very fast responses and help once again.

    Thanks & Regards,
    Daina

  10. #10
    Join Date
    Dec 2002
    Location
    Calgary, Canada
    Posts
    6,120
    glad to be of a help....:-)
    I knew what I had told u to do was correct and u shouldnt have any problem with that...did not know ur jar file had a diff directory structure then what u are trying...heheheh
    Cheers

    Khalid

    Message Posting Guidelines In These Forums, Please read these before posting any question.
    Web site: webapplikations.com
    Web Resources Page:Web Resources

  11. #11
    Join Date
    Sep 2005
    Posts
    38
    Hi Khalid

    Sorry.My mistake.I didn't look the directory structure.When I unzipped it.I saw that.Thanks for your help again...............

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles