我只是将所有的java类移到一个包(SSP),因为我已经将它们放在默认的包uo中,现在我的应用程序将不再部署到tomcat....
我使用:
03-Dec-2015 09:53:13.330 SEVERE [http-nio-8080-exec-4] org.apache.catalina.core.StandardContext.listenerStart Exception sending context initialized event to listener instance of class SSP.Startup java.lang.NullPointerException
at SSP.Load_config.getPropValues_db_user_pw(Load_config.java:89)
at SSP.Roles_rights.get_roles_rights(Roles_rights.java:52)
at SSP.Roles_rights.getInstance(Roles_rights.java:35)
at SSP.Startup.contextInitialized(Startup.java:21)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4738)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5181)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:725)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:701)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:717)
at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:586)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:460)
at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1586)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:300)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819)
at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801)
at org.apache.catalina.manager.ManagerServlet.check(ManagerServlet.java:1460)
at org.apache.catalina.manager.ManagerServlet.deploy(ManagerServlet.java:906)
at org.apache.catalina.manager.ManagerServlet.doGet(ManagerServlet.java:344)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:622)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:291)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.filters.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:108)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:217)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:614)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:142)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:616)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:518)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1091)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:673)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1500)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1456)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:745)
FAIL - Deployed application at context path /Self-Service-Portal but context failed to start
D:\Dropbox\Bachelor\Java Projects\Self-Service-Portal\nbproject\build-impl.xml:1157: The module has not been deployed.
72: public String getPropValues_db_user_pw() throws IOException {
73: try {
74: Properties prop = new Properties();
75: String propFileName = "db_settings.properties";
76: inputStream = getClass().getClassLoader().getResourceAsStream(propFileName);
77
78: if (inputStream != null) {
79: prop.load(inputStream);
80: } else {
81: throw new FileNotFoundException("property file '" + propFileName + "' not found in the classpath");
82: }
83:
84: // compose result string (ip:port)
85: result = prop.getProperty("db_passwd");
86: } catch (Exception e) {
87: System.out.println("Exception: " + e);
88: } finally {
89: if (inputStream != null) {
90: inputStream.close();
91: }
92: }
93: return result;
94: }
40: public void get_roles_rights(){
41:
42: // Get roles & rigths from db
43: // variables
44: JDBCConnection database_connection = null;
45: ResultSet m_ResultSet = null;
46:
47: // load standard db-user from config file
48: Load_config properties = new Load_config();
49:
50: // connect to postgreSQL Database
51: try {
52: database_connection = new JDBCConnection("Self-Service-Portal", properties.getPropValues_db_user(), properties.getPropValues_db_user_pw());
53: } catch (IOException ex) {
54: Logger.getLogger(User_management.class.getName()).log(Level.SEVERE, null, ex);
55: }
.......
114: }
ssp.roles_rights.getInstance(roles_rights.java:35)
24: public class Roles_rights {
25:
26: public List<List<Integer>> oe_fac_roles_rights = new ArrayList<List<Integer>>(4);
27:
28: private static Roles_rights instance = null;
29: private Roles_rights() {
30: // Exists only to defeat instantiation.
31: }
32: public static Roles_rights getInstance() {
33: if(instance == null) {
34: instance = new Roles_rights();
35: instance.get_roles_rights();
36: }
37: return instance;
38: }
39:
40: public void get_roles_rights(){
......
114: }
115: }
ssp.startup.ContextInitialized(startup.java:21)
16: public class Startup implements javax.servlet.ServletContextListener {
17:
18: @Override
19: public void contextInitialized(ServletContextEvent sce) {
20: // create singleton object to get all roles/rights from db
21: Roles_rights tmp = Roles_rights.getInstance();
22: }
23:
24: @Override
25: public void contextDestroyed(ServletContextEvent sce) {
26: throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
27: }
28: }
以防万一我再提供一些信息:
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="Self-Service-Portal" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee">
<servlet>
<servlet-name>Login</servlet-name>
<servlet-class>SSP.Login</servlet-class>
</servlet>
<servlet>
<servlet-name>Usermode</servlet-name>
<servlet-class>SSP.Usermode</servlet-class>
</servlet>
<servlet>
<servlet-name>Echo_usermode</servlet-name>
<servlet-class>SSP.Echo_usermode</servlet-class>
</servlet>
<servlet>
<servlet-name>User_management</servlet-name>
<servlet-class>SSP.User_management</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Login</servlet-name>
<url-pattern>/portal.html</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Usermode</servlet-name>
<url-pattern>/usermode/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Echo_usermode</servlet-name>
<url-pattern>/echo_usermode</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>User_management</servlet-name>
<url-pattern>/user_management/*</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
<listener>
<listener-class>SSP.Startup</listener-class>
</listener>
cvc-elt.1: Cannot find the declaration of element 'web-app'
有没有人知道为什么我的应用程序不会部署,仅仅因为我的类现在在包SSP中,而不是在默认包中,因为我在web.xml中调整了包更改??
问候Alkahna
您可以尝试关闭inputstream,即使它是空的。考虑改为try-with-resource。或者在关闭inputStream之前,至少检查它是否为!=null
。
73: try {
76: inputStream = getClass().getResourceAsStream(propFileName);
77
78: if (inputStream != null) {
80: } else {
82: }
83:
88: } finally {
89: inputStream.close(); //Might be null -> cause of your error
90: }
至于它为null的原因:检查属性文件是否部署到了您认为应该部署的位置。尝试使用getClass().getResourceAsstream()
而不是使用classloader方法。尝试使用绝对路径/ssp/db_settings.properties
。
我正在运行一个嵌入式hazelcast部署,并存储一个,其中映射中的值类型是我的自定义类。 它的一个字段是接口。
我需要将我的应用程序从sqlite移动到MySQL。我跟着那个向导 http://help.nitrous.io/mysql/ 安装了mysql,这是我的yaml文件 当我尝试执行时,我会遇到以下错误 无法通过套接字“/var/run/mysqld/mysqld.sock”连接到本地MySQL服务器(2) 无法为{“adapter”=>“mysql2”,“encoding”=>“utf8”,“da
我正试图将运行在tomcat上的现有应用程序更改为SpringBoot。它一直运行到真正的SpringBoot启动。我有一个类似的应用程序运行在SpringBoot上。这就是我知道它一直运行到Springboot的原因。 我的主要方法: 我尝试使用@componentscan运行main方法,该方法具有如下所示的basePackages: 这无济于事。我尝试在main类的顶部添加@SpringBo
我最近迁移了一个现有的rails 3.2.3应用程序到rails4.0.0.rc2。我已经做了所有必要的改变,并能够使它在我的本地工作良好。但是当我把这个推到heroku——“git推heroku大师”时,它说没有推到一些裁判。下面是堆栈痕迹- ----- ! 推送被拒绝,未能编译Ruby/Rails应用程序 我也在我的本地网站上使用postgres,而且效果很好。此应用程序以前部署在heroku
我正在docker容器中运行一个简单的spring boot应用程序。在启动时,是否从或应用程序将始终在以下时间点挂起: 这里有一个问题,我只能在数字海洋(1CPU,1GB MEM)的Ubuntu 14.04盒子上重现这个,即使它在容器中运行。在我的本地机器上,一切都运行良好。 Dockerfile文件: 我尝试过的事情 给JVM更多内存(占机器总数的75%) 按这里建议的方式停止库 我能接触到的
我已经构建了一个Springboot应用程序,其中包括AngLuar5。我有一个gradle构建脚本,它将angular文件加载到我的springboot项目中,这些文件位于springboot项目的resources/static下。当我启动我的应用程序时,angular的路由不再工作,我得到了 错误:无法匹配任何路由。URL段:“访问” 我的项目结构: 如果我打字 www.mysite.com