Cơ bản về Cấu hình Tomcat
Để chạy được 1 ứng dụng web viết bằng JSP hoặc Servlet bạn cần 1 web server để host các trang của bạn. Có rất nhat62 Webserver khác nhau dùng cho việc này nhưng có lẽ Tomcat là 1 webserver đơn giản, dễ sử dụng nhất. Bài viết này sẽ hướng dẫn các bạn cách chúng ta có thể sử dụng Tomcat làm 1 web server và cách chúng ta triển khai các trang web của chúng ta lên đấy.
Đầu tiên, bạn hãy download phần mềm Apache Tomcat tại http://tomcat.apache.org/. Tôi nghĩ là bạn nên download bản zip để khỏi phải cài đặt.
Sau khi download thành công, giải nén ra 1 thư mục nào đó, giả sử là (C:\javaSofts) bạn cần làm 1 vài bước để có thể chạy Tomcat.
1> Tất nhiên máy bạn phải cài đặt JDK
2> Bạn thêm 1 biến môi trường có tên JAVA_HOME và có giá trị là đường dẫn đến thư mục cài đặt JDK
3> Trong Tùy biến môi trường PATH, bạn hiệu chỉnh lại và thêm vào ;.;%JAVA_HOME%\bin;
Bây giờ bạn vào thư mục bin của thư mục bạn đã giải nén Tomcat(C:\javasofts\apache-tomcat-6.0.18\bin), chạy tập tin startup.bat. OK, Nếu việc thực thi thành công, bạn sẽ có cửa sổ sau(nhớ đừng tắt nó nhé)

Bây giờ bạn mở trình duyệt lên, gõ vào URL sau http://localhost:8080/
Kết quả sẽ như sau

Mẹo: bạn nên tạo 1 shortcut của tập tin startup.bat ra desktop, sau đó nhấn chuột phải lên shortcut này, chọn properties. Bạn gắn 1 phím tắt cho nó trong mục Shortcut Ket là tổ hợp phím nào đó(ví dụ Ctrl-Alt-J). Nhấn OK. Bây giờ mỗi lần muốn start Tomcat bạn chỉ cần nhấn tổ hợp phím Ctrl-Alt-J trong bất kỳ đâu.
Các ứng dụng web của bạn sau này đều phải đặt trong thư mục webapps của tom cat(E:\javasofts\apache-tomcat-6.0.18\webapps).
Bây giờ bạn thử tạo 1 dự án HelloWorld nhé:
Trong thư mục webapps, bạn tạo thư mục HelloWorld.
Trong thư mục HelloWorld bạn tạo 1 file có tên index.jsp có nội dung
| <html> <head> <title>.:Hello JSP:.</title> </head> <body> <h1>Hello JSP world!</h1> <h2>Current Time: <%= new java.util.Date()%></h2> </body> </html> |
Bây giờ bạn mở trình duyệt, đi đến địa chỉ http://localhost:8080/HelloWorld/index.jsp
Kết quả như sau:

Chúc bạn thành công !
New_member said
Chào Anh!
Em đã thực hiện theo hướng dẫn của Anh nhưng báo lỗi sau khi chạy index.jsp:
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: Unable to compile class for JSP:
An error occurred at line: 22 in the generated java file
The method getJspApplicationContext(ServletContext) is undefined for the type JspFactory
Đây là lỗi gì ạ?
em chạy trên eclipse cũng bị lỗi tương tự.
Mong Anh hướng dẫn.
Xin cảm ơn.
vovanhai said
Biết đâu bản TOmcat của bạn bị lỗi. Down lại rồi giải nén. Thử lại.
khanh said
anh ơi cấu hình cơ bản như vậy chỉ chạy được 2h apache lại chết!!
Đinh Tiến Tình said
Mình xin bổ sung thêm một chút về cấu hình Tomcat của thầy Hải.Đối với các bạn lần đầu làm quen với Tomcat có thể nên cấu hình như sau :
-1.chuột phải lên My Computer -> chọn thẻ ‘Properties’->chọn ‘Advanced’ tab->chọn ‘Environtment Variables’
-2.chọn New trong mục ‘User Variable…’ điền vào các giá trị sau:
muc ‘variable name’ điền CATALINA_HOME,mục ‘variable value’ điền : đường dẫn đến thư mục Tomcat(ví dụ :C:\apache-tomcat-6.0.20).lưu ý là các giá trị không có dấu nháy(‘)-> ok.
-3.làm lại thao tác 2 với giá trị mới là : mục name : CATALINA_BASE , mục value :đường dẫn đến thư mục Tomcat -> ok.
-4.Vẫn trong cửa sổ ‘Environment Variable’,trong ‘System Variable’,các bạn tìm biến ‘Path’, chọn edit thêm vào cuối,đường dẫn đến thư mục ‘bin’ của tomcat (ví dụ : C:\apache-tomcat-6.0.20\bin),nhớ thêm dấu chấm phẩy ở phía trước nhé(;).
hi vọng giúp được các bạn tránh 1 số lỗi khi chạy tomcat.
còn 1 số cấu hình nâng cao hơn các bạn thử search trên google khi đã làm quen với nó rồi nhé.
chúc may mắn.
pham quoc vuong said
Em chao Thay!
thay co the sua giup e loi tomcat nay duoc khong?
em dang lam do an bang struts
HTTP Status 500 –
——————————————————————————–
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: java.lang.NullPointerException
org.apache.struts.action.RequestProcessor.processException(RequestProcessor.java:520)
org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:427)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:228)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)
org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:449)
javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:390)
root cause
java.lang.NullPointerException
faq.select_faqAction.execute(select_faqAction.java:61)
org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:425)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:228)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)
org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:449)
javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:390)
note The full stack trace of the root cause is available in the Apache Tomcat/6.0.18 logs.
vovanhai said
Lỗi |NullPointerExeption kìa. Kiểm tra xem code có chỗ nào kết quả là 1 đối tượng null không.
AJAXPro said
Xin được hỏi anh một vấn đề mà tôi đang gặp trục trặc dưới đây.
Tôi có đoạn code của file index.jsp dưới đây, nằm trong thư mục webapps/demo:
Kết quả trả về không phải là webapps/demo/test.txt như tôi mong muốn mà luôn là giá trị của CATALINA_HOME. Làm thế nào để read/write file vào đúng thư mục mà mình đang đứng nhỉ?
AJAXPro said
Tôi xin gõ lại đoạn code đã bị mất ở trên:
java.io.File f = new java.io.File(“test.txt”);
out.println(f.getAbsolutePath());
xin hoi said
Anh ơi cho em hỏi trong phần Tomcat minh đưa file servlet vào đâu để nó có thể điều khiển trang JSP ạ
vovanhai said
Đưa nó vào Tên_Project\WEB-INF\classes\.
aloha said
Bạn ơi cho hỏi mình đã cài tomcat và chạy thành công nhưng trên máy khác truy cập vào thì không được. Vậy đó là lỗi gì vậy?
Daniel said
Thầy ơi, cho em hỏi, sau khi làm em chạy được như thầy nói, nhưng một lúc sau khi em mở lại cửa sổ startup.bat. Nó xuất hiện rồi lại…mất tiêu???
Võ Văn Hải said
coi lại cái biến môi trường JAVA_HOME
Võ Văn Hải said
coi cái firewall, virus program,…
T13TIN said
Chào Anh
Cho tôi hỏi Tomcat của tôi có vấn đề thế này: Hệ thống chạy bình thường nhưng thỉnh thoảng lại stop. Tôi phải shutdown Tomcat rồi start lại thì nó chạy.
Xin hỏi lỗi này là do đâu vậy?
Võ Văn Hải said
Các sản phẩm free của thế giới java hay bị lỗi này. Bạn thường xuyên “clean” nó thì nó mới trơn tru. Cu thể: trong Tomcat lâu ngày bạn chạy nhiều chương trình thì nó tạo các thư mục rác chứa trong thư mục: %TOMCAT_HOME%\work\Catalina\localhost. Bạn vào đó xóa sạch đi. Khởi động lại Tomcat.
superthin85 said
Chào anh.
Rất cảm ơn về những bài hướng dẫn rất bổ ích của anh. Số là cái Tomcat của tôi cũng bị y trang bạn Daniel.
Anh có cách nào hướng dẫn cụ thể cách khắc phục giùm với.
Cảm ơn nhiều.
Mai Thanh said
cảm ơn Thầy lất lất là nhìu
Nguyen Duc Thuan said
HTTP Status 500 ---------------------------------------------------------------------------------
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: Unable to compile class for JSP
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:594)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
root cause
java.io.FileNotFoundException: C:\Program Files\Apache Software Foundation\Apache Tomcat 6.0.20\work\Catalina\localhost\Hello\org\apache\jsp\index_jsp.java (The system cannot find the path specified)
java.io.FileOutputStream.open(Native Method)
java.io.FileOutputStream.(FileOutputStream.java:179)
java.io.FileOutputStream.(FileOutputStream.java:70)
org.apache.jasper.compiler.Compiler.setupContextWriter(Compiler.java:276)
org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:215)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:332)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:312)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:299)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:586)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
note The full stack trace of the root cause is available in the Apache Tomcat/6.0.20 logs.
Thầy giúp em fix lỗi này được không ạ. Em cảm ơn thấy!
Võ Văn Hải said
Lỗi tồn tại trong trang JSP nên không biên dịch được.
Đừng có để tomcat vào program file, bạn theo cách của tôi, download bản portable, giải nén ở ổ D chẳng hạn là OK.
Quang Trung said
Dạ e chào thầy !
E đang thực hiện bài tập làm web bằng mô hình 3 lớp trong Java. Chương trình hoàn thiện không bị lỗi gì hết . Lúc đầu e chạy thì ra được . Nhưng sau đó bị lỗi HTTP 404 ” unknown resource ” không thầy . Thầy giúp e với ạ , e đã cài lại TOMCAT nhưng vẫn bị lỗi này ạ !
E chân thành cảm ơn thầy !
Võ Văn Hải said
Lỗi này em ghi như thế biết đâu mà đoán chứ. Em đóng gói app của em lại thành file war rồi down tomcat portable mới về, copy file war vào thư mục webapps của tomcat sau đó start tomcat rồi truy xuất lại xem sao.
Quang Trung said
HTTP Status 404 – /BookStore/vd_view1
——————————————————————————–
type Status report
message /BookStore/vd_view1
description The requested resource (/BookStore/vd_view1) is not available.
——————————————————————————–
Apache Tomcat/6.0.29
dạ e làm lại thì có lúc bị , lúc không bị ạ!!
Duy Linh said
Em đang tìm hiểu về uPortal connect with Sakai mà em không thể nào cài 2 thứ đó trên 1 máy được, em cài build và deploy uPortal chạy OK, tiếp tục build Sakai thì nó lại chiếm cổng 8080 của uPortal đang chạy-> cuối cùng chỉ có 1 trong 2 cái chạy cổng 8080, em thấy trên 1 video sakai có thể chạy cổng 8081 mà em tìm hiểu mấy ngày cxng không biết chỉnh nó như thế nào. Thầy Hải có giúp em được không
Võ Văn Hải said
chưa thử cái này bao giờ. Bạn nào đã làm rồi hãy giúp bạn ấy!
Võ Văn Hải said
Chưa triển khai được làm sao mà chạy.
Quang Trung said
dạ , thầy có thể hướng dẫn rỏ hơn chút cho e được không ạ!? dạ , e chưa hiểu ạ!? triển khai cái nào ạ !?
Phuong said
Thầy ơi e dùng tomcat tích hợp sẵn khi cài netbean nên không cần phải config gì đúng không ạ?
Nhưng khi em khởi động tomcat bằng startup.bat thì nó báo lỗi ghê quá, vậy là sao ạ?
Phuong said
Thầy ơi em sử dụng tomcat tích hợp sẵn khi cài netbean, như vậy thì không cần phải config gì đúng không ạ. Khi em chạy tomcat trong netbean thì vẫn bình thường, nhưng tắt netbean rồi, chạy bằng startup.bat thì nó lỗi tùm lum. Nó bị sao vậy ạ?
java.util.logging.ErrorManager: 4
java.io.FileNotFoundException: C:\Program Files\Apache Software Foundation\Apach
e Tomcat 6.0.26\logs\catalina.2011-03-31.log (Access is denied)
...INFO: Server startup in 993 ms
Võ Văn Hải said
Làm ơn đọc kỹ lại hướng dẫn
Võ Văn Hải said
Như tôi đã nói. Bạn phải cấu hình JAVA_HOME var, trong Path var, thêm %JAVA_HOME%\bin. sau đó mới chạy.
Tuy nhiên bạn chạy Tomcat lỗi như vậy vì Win7/Vista bảo vệ thư mục Program Files rất kỹ nên không chạy được. Bạn làm theo hướng dẫn: download Tomcat về và giải nén nó ra đĩa nào đó (không ở trong Program Files) là OK.
Nguyễn Hùng said
Anh cho em hỏi là cho em hỏi là khi em start service trên tomcat thì nó báo lỗi thế này:
Too much memory allocated : 1022496
The service is exited
Em đã set các biến như sau:
ANT_HOME=C:\source_code\apache-ant-1.8.2
CATALINA_HOME=C:\source_code\apache-tomcat-7.0.11
CATALINA_OPTS=-Xms64m -Xmx128m
JAVA_HOME=C:\Program Files\Java\jdk1.6.0_24
Em đang làm btập thực hiện cuộc gọi SIP giữa 2 máy thông qua server tomcat mà lần nào bắt đầu nó cũng báo thế
Võ Văn Hải said
trog file server.xml bạn xem thử có cấp bộ nhớ cho nó quá lớn không? sửa lại ít chút!
Duy Linh said
Thầy ơi em cài được sakai chạy trong cổng 8081 nhưng cài lại win sửa file server.xml trong tomcat\conf từ 8080 sang 8081 khi start thì nó start port 8081 mà chạy gõ locahost:8081 lại không chạy gõ localhost:8080 mới chạy em cũng không hiểu lun. Trước khi cài lại máy chạy bình thường. Thầy có gặp tình huống này chưa giúp em với (help me)
Nguyễn Hùng said
Em đã thử vào file server.xml nhưng không thấy cài đặt bộ nhớ ở đâu cả.Anh có thể hướng dẫn cụ thể hơn ko,vì em thấy trong file này toàn là config port mà
Võ Văn Hải said
Sorry. Tôi nhầm. Muốn cấp thêm bộ nhớ cho tomcat, bạn làm như sau:
Võ Văn Hải said
CHưa thấy. Có lẽ em xem lại thuộc tính redirectPort thử xem sao.
Nguyễn Hùng said
Em có thử theo hướng dẫn của anh, nhưng vẫn không chạy dc, tomcat của em gặp vấn đề rất kì quặc là:
khi nhấn nút start service thì nút start bị mờ đi,và nút stop nổi lên(có thể nhấn stop)
nhưng khi kích vào nút service details thì nó vẫn báo lỗi:
too much memory allocated
the servicce is existed
sau đó quay lại màn hình thì service đã dừng(nút stop mờ đi và nút start nổi lên (nên em nghĩ là service chưa hoạt động)
anh có thể xem giùm em ở 2 link ảnh này
http://cB8.upanh.com/21.272.28217667.e990/untitled.jpg
http://cB1.upanh.com/21.273.28218770.yji0/untitled2.jpg
Duy Linh said
Em lại gặp vấn đề với tomcat 5.5.33 nó không chạy được localhost:8080 trong khi tomcat 5.0, 6.x, 7.x lại chạy tốt. Vẫn start port ok mà gõ localhost:8080 thì không thấy gì hết. Thầy có thể giúp em không? Em restart máy lại nhiều lần mà nó vẫn vậy.
Võ Văn Hải said
Tại sao phải dùng đúng với phiên bản 5.5.53 đó nhỉ!
EM thử cài lại bản mới xem sao!
hung said
Em xin chào Thầy Hải!
Thầy cho em hỏi khi em chạy file jsp này thì báo lỗi , em đã sữa nhiều chổ mà không hết, mong thầy coi dùm em. Em xin cảm ơn thầy.
In-place deployment at C:\Program Files\Java\javaSofts\apache-tomcat-7.0.12\webapps\HelloWorld\vidung\build\web
Deployment is in progress…
deploy?config=file%3A%2FC%3A%2FUsers%2FUSER%2FAppData%2FLocal%2FTemp%2Fcontext7140656883408497314.xml&path=/
http://localhost:8080/manager/deploy?config=file%3A%2FC%3A%2FUsers%2FUSER%2FAppData%2FLocal%2FTemp%2Fcontext7140656883408497314.xml&path=/
C:\Program Files\Java\javaSofts\apache-tomcat-7.0.12\webapps\HelloWorld\vidung\nbproject\build-impl.xml:683: The module has not been deployed.
BUILD FAILED (total time: 37 seconds)
hung said
hi cac ban!
Ban nao co ban tomcat share cho minh voi sau minh down ma van file thu muc classes.
xin cam on!
Võ Văn Hải said
Bạn không nên để tomcat trong “program files”. copy bản portable tôi đề cập lên 1 thư mục nào đó rồi tham chiếu trong IDE mà xài.
tuan anh said
em lam web java chay tren tomcat
khi chay tren netbean thi chay rat binh thuong, nhung khi em tat netbean chay tren tomcat thi lai co loi xay ra.
Theo cach thay chi thi giai nen no ra nguoi programfile, nhung nhu the thi cung nhu chay tren netbean rui thay
Co cach nao ma cho no chay tren TomCat khong vay.
org.apache.jasper.JasperException: Unable to compile class for JSP:
An error occurred at line: 6 in the generated java file
Only a type can be imported. model.pojo.Mall resolves to a package
An error occurred at line: 8 in the generated java file
Only a type can be imported. model.pojo.Mall resolves to a package
An error occurred at line: 32 in the jsp file: /shop_2/web/mall.jsp
Mall cannot be resolved to a type
29: event
30:
31: <%
32: ArrayList list = (ArrayList) request.getAttribute(“listMall”);
33: for (int i = 0; i < list.size(); i++) {
34: Mall m = list.get(i);
35:
An error occurred at line: 34 in the jsp file: /shop_2/web/mall.jsp
Mall cannot be resolved to a type
31: <%
32: ArrayList list = (ArrayList) request.getAttribute(“listMall”);
33: for (int i = 0; i
37:
Stacktrace:
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:95)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:457)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:374)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:352)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:339)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:594)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:344)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:391)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
Võ Văn Hải said
Em dùng netbean viết, xong em build. Vào thư mục dist của nó trên đĩa, copy file jar rồi paste nó vào thư mục wbapps của tomcat. sau đó khởi động tomcat, bạn sẽ có ứng dụng web được triển khai và có thể truy xuất.
chamhoc said
Thầy ơi, thầy nói rõ cụ thể lại bước 2 và bước 3 được ko ạ ? E ko hiểu về bước 2, b3 lắm:
2> Bạn thêm 1 biến môi trường có tên JAVA_HOME và có giá trị là đường dẫn đến thư mục cài đặt JDK
3> Trong Tùy biến môi trường PATH, bạn hiệu chỉnh lại và thêm vào ;.;%JAVA_HOME%\bin;
Mong thầy nói rõ chi tiết 2 biết trên giúp e với. Thanks thầy nhiều.
chamhoc said
àh, sau 15 phút đã hiểu hết rồi. Thanks thầy nhiều.
Nó chạy rồi
TranNam said
Cứu Cứu Cứu với. Thầy ơi !
Em đã làm và chạy OK rồi, xong rồi e quay lại bước :
(Mẹo: bạn nên tạo 1 shortcut của tập tin startup.bat ra desktop, sau đó nhấn chuột phải lên shortcut này, chọn properties. Bạn gắn 1 phím tắt cho nó trong mục Shortcut Key là tổ hợp phím nào đó(ví dụ Ctrl-Alt-J))
Ý em là trong bước này em muốn thay đổi biểu tượng startup.bat, trở thành 1 biểu tượng khác, và tất cả những gì .bat cũng thay đổi theo biểu tượng mới.
Sau khi thay đổi biểu tượng thì nó ko chạy nữa (Cho dù nhấn tổ hợp phím, hay là click vào biểu tượng startup.bat) chán thiệt.
Xóa đi rồi down bản khác về, nó cũng ra lại biểu tượng đó, chứ ko là biểu tượng cũ, giờ phải làm sao hả thầy ? Thầy chỉ cách cho e nhé. Thanks Thầy.
Võ Văn Hải said
Bạn xem ở đây
vui_ve_nao said
Chào anh, em đang tìm hiểu cơ chế logging của tomcat, em dùng tomcat 6
Em thấy trong thư mục cài đặt Tomcat (C:\Program Files\Apache Software Foundation\Tomcat 6.0\logs) thì file log của nó không giống như các webserver khác, toàn là java
Em muốn biết khi truy cập 1 trang web thì nó lưu log khi mình mở trang nào, POST/GET, trình duyệt sử dụng, IP, v.v… thì xem ở đâu ạ?
chung said
JAVA_HOME=C:\Program Files\Java\jdk1.6.0_24
bien = CATALINA_HOME va duong dan toi tomcat
Minh tuan said
Thầy cho em hỏi mới đầu thì tomcat chạy bình thường , sau khi em khơi động lại thì nó báo lỗi này
thầy chỉ em cách fix với
thank thầy
init:
deps-module-jar:
deps-ear-jar:
deps-jar:
Created dir: D:\web server\WebApplication1\build\web\WEB-INF\classes
Created dir: D:\web server\WebApplication1\build\web\META-INF
Copying 1 file to D:\web server\WebApplication1\build\web\META-INF
Copying 3 files to D:\web server\WebApplication1\build\web
library-inclusion-in-archive:
library-inclusion-in-manifest:
Created dir: D:\web server\WebApplication1\build\empty
compile:
compile-jsps:
Starting Tomcat process…
Waiting for Tomcat…
Starting of Tomcat failed.
D:\web server\WebApplication1\nbproject\build-impl.xml:683: Deployment error:
Starting of Tomcat failed.
See the server log for details.
BUILD FAILED (total time: 23 seconds)
Khoa said
Cảm ơn thầy rất nhiều.
MyNhi said
Mình bị lỗi dưới đây mà không biết sao hết , mong bạn giúp mình với ! Cám ơn bạn nhiều.
HTTP Status 500 –
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: /index.jsp (line: 6, column: 1) Page directive must not have multiple occurrences of pageencoding
org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:41)
org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:407)
org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:102)
org.apache.jasper.compiler.Validator$DirectiveVisitor.visit(Validator.java:194)
org.apache.jasper.compiler.Node$PageDirective.accept(Node.java:590)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2376)
org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2428)
org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2434)
org.apache.jasper.compiler.Node$Root.accept(Node.java:475)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2376)
org.apache.jasper.compiler.Validator.validateDirectives(Validator.java:1749)
org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:194)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:372)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:352)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:339)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:601)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:344)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:389)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:333)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
note The full stack trace of the root cause is available in the Apache Tomcat/7.0.16 logs.
Võ Văn Hải said
Bạn xem lại directive @page tại dòng 6 cột 1 có bị trùng với 1 cái directive nào đã khai báo chưa?
Võ Văn Hải said
có khi Tomcat Server bị lỗi. EM download bản khác về thử.
hieu said
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
java.lang.NullPointerException
CL.PictureCO.processRequest(PictureCO.java:142)
CL.PictureCO.doGet(PictureCO.java:164)
javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:393)
note The full stack trace of the root cause is available in the Apache Tomcat/6.0.26 logs.
kiem tra dum em cai loi nay voi thay. hieurobin@yahoo.com
Đỗ Văn Phương said
Thưa thầy,
Em có gặp 1 vấn đề nhỏ mong nhận được sự giúp đỡ của thầy :
Em đã cài Tomcat và JDK để chạy rồi , cũng đã set biến môi trường theo hướng dẫn của thầy tại bài viết này nhưng khi duyệt web vẫn không được. Em load 1 file index.jsp đơn giản , nội dung :
.:Hello JSP:.
Hello JSP world!
Current Time:
Và trình duyệt báo lỗi :
HTTP Status 500 -
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: Unable to compile class for JSP
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:97)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:346)
org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:414)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:472)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:451)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:439)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:511)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:295)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
root cause
Unable to find a javac compiler;
com.sun.tools.javac.Main is not on the classpath.
Perhaps JAVA_HOME does not point to the JDK
org.apache.tools.ant.taskdefs.compilers.CompilerAdapterFactory.getCompiler(CompilerAdapterFactory.java:106)
org.apache.tools.ant.taskdefs.Javac.compile(Javac.java:935)
org.apache.tools.ant.taskdefs.Javac.execute(Javac.java:764)
org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:382)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:472)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:451)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:439)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:511)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:295)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
note The full stack trace of the root cause is available in the Apache Tomcat/5.0.28 logs.
Apache Tomcat/5.0.28
Đọc qua lỗi em cũng hiểu là do không tìm được công cụ biên dịch. Tuy nhiên em không biết vì sao , mong thầy giúp đỡ . Cảm ơn thầy rất nhiều .
àh , khi em truy cập http://localhost:8080/ vẫn ok. Còn khi truy cập http://localhost:8080/hello/index.jsp ( file index với nội dung như trên ) thì lại bị lỗi đó .
Võ Văn Hải said
File jsp của em bị lỗi rồi. Em thử lại 1 trang khác đi.
Võ Văn Hải said
Lỗi ở dòng 142 file PictureCO.java. Và lỗi ở đây là NullPointerException. Bạn xem đối tượng bạn dùng ở chỗ đó có init (new chưa) hoặc load thành công không.
Đỗ Văn Phương said
Cảm ơn thầy rất nhiều, em đã fix được rồi ạ .
van said
anh ơi cho em hỏi, hùi đó e xài win 64bit, làm như anh thì chạy ok, em mới cài lại win 32bit, cũng làm như vậy, nhưng khi chạy file startup thì hiện lên màn hình đen, start server lên rồi tự detroy lun, e ko vô đc localhost, vậy nó bị sao hả anh. em có chụp lại lỗi, như ko bit gửi lên thế nào.
van said
khi start server thì hiện lên như sau:
Sep 30, 2011 9:31:59 PM org.apache.catalina.core.AprLifecycleListener init
INFO: Loaded APR based Apache Tomcat Native library 1.1.22.
Sep 30, 2011 9:32:00 PM org.apache.catalina.core.AprLifecycleListener init
INFO: APR capabilities: IPv6 [false], sendfile [true], accept filters [false], random [true].
Sep 30, 2011 9:32:02 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-apr-8080"]
Sep 30, 2011 9:32:02 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["ajp-apr-8009"]
Sep 30, 2011 9:32:02 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 5127 ms
Sep 30, 2011 9:32:03 PM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Sep 30, 2011 9:32:03 PM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.20
Sep 30, 2011 9:32:03 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory docs
Sep 30, 2011 9:32:03 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory examples
Sep 30, 2011 9:32:04 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory host-manager
Sep 30, 2011 9:32:04 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory manager
Sep 30, 2011 9:32:04 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory ROOT
Sep 30, 2011 9:32:04 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-apr-8080"]
Sep 30, 2011 9:32:04 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-apr-8009"]
Sep 30, 2011 9:32:04 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 1845 ms
Sep 30, 2011 9:32:04 PM org.apache.catalina.core.StandardServer await
SEVERE: StandardServer.await: create[localhost:8005]:
java.net.SocketException: Permission denied: listen failed
at java.net.DualStackPlainSocketImpl.listen0(Native Method)
at java.net.DualStackPlainSocketImpl.socketListen(Unknown Source)
at java.net.PlainSocketImpl.socketListen(Unknown Source)
at java.net.AbstractPlainSocketImpl.listen(Unknown Source)
at java.net.ServerSocket.bind(Unknown Source)
at java.net.ServerSocket.(Unknown Source)
at org.apache.catalina.core.StandardServer.await(StandardServer.java:422)
at org.apache.catalina.startup.Catalina.await(Catalina.java:709)
at org.apache.catalina.startup.Catalina.start(Catalina.java:654)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:322)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:450)
Sep 30, 2011 9:32:04 PM org.apache.coyote.AbstractProtocol pause
INFO: Pausing ProtocolHandler ["http-apr-8080"]
Sep 30, 2011 9:32:05 PM org.apache.coyote.AbstractProtocol pause
INFO: Pausing ProtocolHandler ["ajp-apr-8009"]
Sep 30, 2011 9:32:06 PM org.apache.catalina.core.StandardService stopInternal
INFO: Stopping service Catalina
Sep 30, 2011 9:32:07 PM org.apache.coyote.AbstractProtocol stop
INFO: Stopping ProtocolHandler ["http-apr-8080"]
Sep 30, 2011 9:32:07 PM org.apache.coyote.AbstractProtocol stop
INFO: Stopping ProtocolHandler ["ajp-apr-8009"]
Sep 30, 2011 9:32:07 PM org.apache.coyote.AbstractProtocol destroy
INFO: Destroying ProtocolHandler ["http-apr-8080"]
Sep 30, 2011 9:32:07 PM org.apache.coyote.AbstractProtocol destroy
INFO: Destroying ProtocolHandler ["ajp-apr-8009"]
theo như e thấy thì đã start đc server, lỗi ở dòng: java.net.SocketException: Permission denied: listen failed
như vậy thì sửa làm sao ạ.
Võ Văn Hải said
Bạn dùng command-line gõ lệnh : “netstat -a” xem thử có cái chương trình nào chiếm cổng 8080 chưa.
Võ Văn Hải said
có lẽ bạn chưa tạo biến môi trường JAVA_HOME
bichvan said
Em chào thầy..thầy có thể cho em hỏi
Em đang làm 1 bài tập về gomba webservice.. em tạo 1 project web, và down gomba_0.8.0 về nhưng chẳng biết add vào project và thao tác với gomba như thế nào cả..em nhờ thầy hướng dẫn cho em.
Cảm ơn thầy nhiều
Võ Văn Hải said
Tôi không biết gomba là cái gì hết em ơi. Em thử tự down cái manual của nó mà làm thử.
Tuan Vo Anh said
init:
deps-module-jar:
deps-ear-jar:
deps-jar:
library-inclusion-in-archive:
library-inclusion-in-manifest:
compile:
compile-jsps:
Undeploying …
undeploy?path=/_qeqwe
OK – Undeployed application at context path /_qeqwe
In-place deployment at D:\apache-tomcat-7.0.22-windows-x64\apache-tomcat-7.0.22\webapps\ưqeqwe\build\web
Deployment is in progress…
deploy?config=file%3A%2FC%3A%2FUsers%2FVOANHT%7E1%2FAppData%2FLocal%2FTemp%2Fcontext5403147387685437166.xml&path=/_qeqwe
FAIL – Deployed application at context path /_qeqwe but context failed to start
D:\apache-tomcat-7.0.22-windows-x64\apache-tomcat-7.0.22\webapps\ưqeqwe\nbproject\build-impl.xml:721:
The module has not been deployed.
at org.netbeans.modules.j2ee.deployment.devmodules.api.Deployment.deploy(Deployment.java:210)
at org.netbeans.modules.j2ee.ant.Deploy.execute(Deploy.java:106)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
at sun.reflect.GeneratedMethodAccessor71.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.Target.execute(Target.java:390)
at org.apache.tools.ant.Target.performTasks(Target.java:411)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1399)
at org.apache.tools.ant.Project.executeTarget(Project.java:1368)
at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
at org.apache.tools.ant.Project.executeTargets(Project.java:1251)
at org.apache.tools.ant.module.bridge.impl.BridgeImpl.run(BridgeImpl.java:284)
at org.apache.tools.ant.module.run.TargetExecutor.run(TargetExecutor.java:539)
at org.netbeans.core.execution.RunClassThread.run(RunClassThread.java:153)
BUILD FAILED (total time: 1 second)
———————————————
Lỗi này là lỗi gì vậy thầy ơi??
(
Em đã làm như thầy hướng dẩn, nhưng khi test thử thì bị lỗi này
Phan Đăng Hưng (nick swenteiger7) said
Em chào thầy Hải. Cả đêm thứ 7 hôm qua em mport cái myFaces vào thì nó lúc import vào lib xong server cứ thông bao kết quả là the module hasn’t been deployed. Em đặt Tomcat tại ổ D như thầy hướng dẫn thì nó ra là lỗi ở build.xml.
Em xin gửi ảnh hệ thống ở đây ạ. Cả tối hôm qua import myFaces vào mà ko nổi. Em cũng làm các bước như trên mạng họ hướng dẫn nhưng làm xong thì…. lại ko run được (hình như là do chỉnh web.xml), chán nản kinh khủng.
Thầy ơi thầy đã gặp vấn đề này bao h chưa ạ
1. Lúc đầu e ko tham chiếu đến thư viện tomahawk nó chạy bình thường. Thêm cái tomahawk thì lỗi. Làm đúng như cấu hình tomahawk ở đây (http://myfaces.apache.org/tomahawk/extensionsFilter.html) thì nó càng ko chạy được project nên em rất sợ
2. Khi em bỏ cái tham chiếu đến library của tomahawk nó ra cái lỗi này: http://i970.photobucket.com/albums/ae190/swenteiger7/loi1_bolibrary.png. Em ko hiểu là em có để lib ở trong WEB-INF đâu mà nó cứ chỉ vào chỗ đấy.
3. Em đã chuyển TomCat sang ổ D nhưng ko ăn thua.
Thầy đã bao giờ bị thế này chưa ạ
. Em ko hiểu nổi nữa, gần 1/2 ngày mà config ko nên thân, chán nản và bực mình kinh khủng, Thầy giúp e với. Em cám ơn thầy trước ạ.
Võ Văn Hải said
Thử nhấn chuột phải lên project, chọn clean. vào thư mục source của em (explorer) xóa thư mục build đi thử xem sau đó build lại.
Tai said
Em vừa cài tomcat theo như hướng dấn trên.Nhưng đến lúc thử file index thì bị lỗi này.Thầy fix hộ e :-< k bik bị gì :-< có cần thiết phải tạo file index = netbean hay eslipse k ? e tạo = file txt .
HTTP Status 404 – /HelloWorld/index.jsp
type Status report
message /HelloWorld/index.jsp
description The requested resource (/HelloWorld/index.jsp) is not available.
Apache Tomcat/6.0.33
Võ Văn Hải said
Em coi server thử nó có chạy chưa. Có lẽ là chưa chạy.
Tai said
server e start rồi mà vẫn thế
.Ngoài tomcat e còn cài appserv
dinh phi said
thay sửa giúp em lỗi này với thanks thầy
E:\BAI HOC\lap trinh ung dung mang\BAI TAP\aaaaaaaa\nbproject\build-impl.xml:721:
The module has not been deployed.
at org.netbeans.modules.j2ee.deployment.devmodules.api.Deployment.deploy(Deployment.java:210)
at org.netbeans.modules.j2ee.ant.Deploy.execute(Deploy.java:106)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
at sun.reflect.GeneratedMethodAccessor57.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.Target.execute(Target.java:390)
at org.apache.tools.ant.Target.performTasks(Target.java:411)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1399)
at org.apache.tools.ant.Project.executeTarget(Project.java:1368)
at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
at org.apache.tools.ant.Project.executeTargets(Project.java:1251)
at org.apache.tools.ant.module.bridge.impl.BridgeImpl.run(BridgeImpl.java:284)
at org.apache.tools.ant.module.run.TargetExecutor.run(TargetExecutor.java:539)
at org.netbeans.core.execution.RunClassThread.run(RunClassThread.java:153)
pham chiến said
em chạy tomcat va CMD hiện lên hai dòng này, đã hiệu chỉnh lại Environmental Variables thêm biên JAVA_HOME và lấy đường dẫn về bộ cài JDK rồi nhưng tomcat vẫn không chạy mong anh giúp em với nha mail: phamdinhchien.105@gmail.com
Neither the JAVA_HOME nor the JRE_HOME environment variable is defined
At least one of these environment variable is needed to run this program
Võ Văn Hải said
“Neither the JAVA_HOME nor the JRE_HOME environment variable is defined. At least one of these environment variable is needed to run this program”
Bạn xem kỹ lại JAVA_HOME của bạn chỉ đúng vào thư mục bạn cài đặt JDK không.
Trung Trần said
Thầy cho em hỏi là nếu em cài Appserv rồi thì có cần thiết cài Apache tomcat không ạ, Vì em thấy trong Appserv cũng đã có Apache rồi.
Nguyen Trong Minh said
Chao thay!
Em la nguoi ngoai dao, chi su dung thoi. Em dung mang noi bo xi nghiep the kiem tra an toan. Hai hom dau chay tot, den hom thu 3 thi bao loi the nay:
HTTP Status 500 –
——————————————————————————–
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
javax.servlet.ServletException
ru.bitel.action.TilesRequestProcessor.processException(TilesRequestProcessor.java:142)
org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:423)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:226)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1164)
org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:397)
javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
ru.bitel.satellite.filter.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:67)
ru.bitel.satellite.filter.OneUserFilter.doFilter(OneUserFilter.java:120)
ru.bitel.satellite.filter.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:67)
root cause
java.lang.NullPointerException
ru.bitel.action.DispatchGuestActionBase.getUserLocale(DispatchGuestActionBase.java:406)
ru.bitel.action.DispatchGuestActionBase.execute(DispatchGuestActionBase.java:44)
org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:421)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:226)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1164)
org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:397)
javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
ru.bitel.satellite.filter.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:67)
ru.bitel.satellite.filter.OneUserFilter.doFilter(OneUserFilter.java:120)
ru.bitel.satellite.filter.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:67)
note The full stack trace of the root cause is available in the Apache Tomcat/5.5.9 logs.
——————————————————————————–
Apache Tomcat/5.5.9
Thay xem co the giup em tung buoc mot de khac phuc duoc khong?
Em cam on thay nhieu!
Võ Văn Hải said
Xem như vậy thật khó để hướng dẫn. Lỗi là java.lang.NullPointerException nhưng không biết web-app của bạn làm thế nào sao mà fix được.