转到正文

凡搜博客

凡搜诚品,让搜索成为一种狂热

问题:

Server Tomcat v6.0 at localhost was unable to start within 45 seconds. If the server requires more time, try increasing the timeout in the server editor.

解决:

在servers view里,双击你要设置的server,会打开该server的设置窗口,在右上部有Timeouts的设置部分,设置timeout就在这里了,呵呵,关键是双击哦。

Reference:

http://www.iteye.com/topic/961383

在做struts+hibernate+spring项目时,启动程序后,发现错误 :

org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from ServletContext resource [/WEB-INF/applicationContext.xml]; nested exception is java.io.FileNotFoundException: Could not open ServletContext resource [/WEB-INF/applicationContext.xml]

这是因为程序默认会在WEB-INF目录下查找applicationContext.xml文件,而现在程序找不到了,所以报错了。

解决方法有两个:

1. 把applicationContext.xml文件人工拷贝到WEB-INF目录下。

2. 在配置文件中指定applicationContext.xml文件的位置:修改web.xml文件,添加行:

<context-param>
	<param-name>contextConfigLocation</param-name>
	<param-value>classpath:applicationContex*.xml</param-value>
</context-param >

推荐使用方法2。

我们用Eclipse来写JEE程序时,例如Dynamic WEB Project,我们通常会按Eclipse提供给我们的选项来生成。默认情况下,class是生成在根目录的build目录下的。

但是,我们有时想要更改Eclipse提供给我扪的默认方式,比如,我们想要把程序生成的class放在 webcontent/web-inf/目录下。我们可以通过以下方式来实现这个目标:

修改程序根目录下的.classpath文件,将

<classpathentry kind=”output” path=”build/classes”/>

该行更改为:

<classpathentry kind=”output” path=”WebContent/WEB-INF/classes”/> 即可。

【特别注意,新写的路径 “WebContent/WEB-INF/classes”,大小写必须是正确的,否则Eclipse就无法成功编译java文件生成class文件。比如,若写成”WebContent/web-inf/classes”,JAVA项目就无法成功编译】

java.lang.SuppressWarnings是J2SE 5.0中標準的Annotation型態之一,它對編譯器說明某個方法中若有警示訊息,則加以抑制,不用在編譯完成後出現警訊。

在這邊到說明SuppressWarnings的功能,考慮下面這個類別:

SomeObject.java

import java.util.*;

public class SomeObject {
    public void doSomething() {
        Map map = new HashMap();
        map.put("some", "thing");
    }
}

在J2SE 5.0中加入了集合物件的Generics支援,並建議您明確的指定集合物件將內填的物件之型態,在上面這個類別中使用Map時並沒有指定內填物件之型 別,在編譯時會出現以下的訊息:
Note: SomeObject.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.

继续阅读

刚开始使用Spring AOP,可能会出现运行错误,下面是 它的 错误再现:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘org.springframework.aop.config.internalAutoProxyCreator’: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.aop.aspectj.annotation.AnnotationAwareAspectJAutoProxyCreator]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: org/aopalliance/intercept/MethodInterceptor

错误原因:由于Spring AOP实现了AOP联盟约定的接口,而Spring框架并不提供该接口的源代码,因此 ,程序缺少的jar是aopalliance-1.0.jar

Reference:

http://womajiaozhu.blog.163.com/blog/static/490983592010593924880/

Exception in thread “main” java.lang.NoClassDefFoundError: javax/persistence/EntityListeners
at org.hibernate.cfg.annotations.reflection.JPAMetadataProvider.getDefaults(JPAMetadataProvider.java:96)
at org.hibernate.annotations.common.reflection.java.JavaReflectionManager.getDefaults(JavaReflectionManager.java:226)
at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1355)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1826)
at StudentTest.main(StudentTest.java:17)

原因:没有引入hibernate-distribution-3.6.0.Final\lib\jpa下面的hibernate-jpa-2.0-api-1.0.0.Final.jar

Reference:

http://blog.163.com/zhihui20080313@126/blog/static/101281983201010154734180/

Reason:
some characters cannot be mapped using “ISO-8859-1″ character encoding.
Either change the encoding or remove the characters which are not supported
by the “ISO-8859-1″ character encoding.

解决办法:
菜单->Window->Preferences->General->Content Types->Text->Java Properties File设置Default encoding,把ISO-8859-1改为UTF-8  然后update.

按以上的的方法保存成UTF确实能在Eclipse中使得不会出现乱码,但如果是Struts的资源属性文件,被读取到jsp页面上时,仍然会是乱码,只是,会是另一些乱码,这是因为java对文件进行了2次编码。

有的人提出用JDK自带的native2ascii进行编码转换,而这样会显得比较麻烦。所以,最好的办法就是使用PropertiesEditor,它会使你再不为properties属性文件中文乱码而烦心。

PropertiesEditor比较好的解决了这个问题,具体下载地址是:http://propedit.sourceforge.jp/index_en.html
如何安装文档的地址是:http://propedit.sourceforge.jp/howto_eclipseplugin_install_en.html

方法1:

用External run的方法:

可以reference

http://kimho.iteye.com/blog/932175http://dev.firnow.com/course/3_program/java/javajs/20100719/461213.html

方法2:

用EasyExplorer插件:http://www.dnbcw.com/biancheng/java/paou243562.html

凡搜网简洁版 凡搜网Google_Site_Map 凡搜网Baidu_Site_Map ?