修正SelfService工程在myeclipse下的布署问题

 

 

修正 SelfService 工程在 myeclipse 下的布署问题

一、        将工程的描述文件改为 web 以及修正文件错误的描述 .

1)          .classpath 文件改 class 输出路径为 <classpathentry kind="output" path="webapps/selfservice.war/WEB-INF/classes"/

2)          .mymetadata 文件改为

 

<?xml version="1.0" encoding="UTF-8"?>

<project-module

  type="WEB"

  name="YP2G_SelfService"

  id="myeclipse.1277478501328"

  context-root="/selfservice"

  j2ee-spec="1.5"

  archive="YP2G_SelfService.war">

  <attributes>

    <attribute name="webrootdir" value="/webapps/selfservice.war" />

  </attributes>

</project-module>

 

主要有三个地方

1.type 设为 WEB,

2.context-root 一定要改成 war 包的名字 , 否则它会以工程名作为 war 包名 . 另外 archive= 无关紧要。实际布署时是不看这个参数的。

3.webrootdir 设置 web 根目录

 

3) .project 文件增加 web 相关的修改。这一步不是必需的。

 

<?xml version="1.0" encoding="UTF-8"?>

<projectDescription>

         <name>YP2G_SelfService</name>

         <comment></comment>

         <projects>

                   <project>selfservice</project>

         </projects>

         <buildSpec>

                   <buildCommand>

                            <name>com.genuitec.eclipse.j2eedt.core.WebClasspathBuilder</name>

                            <arguments>

                            </arguments>

                   </buildCommand>

                   <buildCommand>

                            <name>org.eclipse.jdt.core.javabuilder</name>

                            <arguments>

                            </arguments>

                   </buildCommand>

                   <buildCommand>

                            <name>com.genuitec.eclipse.j2eedt.core.J2EEProjectValidator</name>

                            <arguments>

                            </arguments>

                  </buildCommand>

                   <buildCommand>

                            <name>com.genuitec.eclipse.j2eedt.core.DeploymentDescriptorValidator</name>

                            <arguments>

                            </arguments>

                   </buildCommand>

                   <buildCommand>

                            <name>org.eclipse.wst.validation.validationbuilder</name>

                            <arguments>

                            </arguments>

                   </buildCommand>

                   <buildCommand>

                            <name>com.genuitec.eclipse.ast.deploy.core.DeploymentBuilder</name>

                            <arguments>

                            </arguments>

                   </buildCommand>

         </buildSpec>

         <natures>

                   <nature>com.genuitec.eclipse.ast.deploy.core.deploymentnature</nature>

                   <nature>com.genuitec.eclipse.j2eedt.core.webnature</nature>

                   <nature>org.eclipse.jdt.core.javanature</nature>

         </natures>

</projectDescription>

二、      解决通过 myeclipse 布署连接 db2 的问题

通过 myeclipse 布署,它的工作目录和运行环境都是在 myeclipse 下,因此导致连接不上 db2( 可能过程中用到了 db2 的环境变量 ).

因此如果我们是通过本地客户端去连接 db2 则需将客户端的 db2jdbc.dll 文件拷到当前 jre bin 目录下。

比如我的 db2 客户端目录是 E:/Program Files/IBM/SQLLIB/BIN,db2jdbc.dll 文件就在该目录下。

如果是用 myeclipse 启动,我的 myeclpse 安装路径是 E:/Program Files/MyEclipse 6.6/, 则将 db2jdbc.dll 文件拷到 E:/Program Files/MyEclipse 6.6/jre/bin .

 

另外注意, db2 的驱动包要使用 db2java.zip, 不要使用或改成 db2java.jar.

三、 myeclipse 下启动工程时的内存溢出

很可能是报 java.lang.OutOfMemoryError: PermGen space PermGen 是指永久区内存,它是用来存放 class 的内存区,如果装载了大量的第三方包就有可能会出现内存不够。这个和堆内存是分开的。因此可能堆内存够,但 PermGen 内存不够,同样会报错。

解决办法:加大永久区内存。 Myeciplse - > performence -> server -> jboss4 -> jdk 下的 Optional Java VM arguments 里加入 -Xms256m -Xmx768m -XX:PermSize=64M -XX:MaxPermSize=128m

后面的 -XX:PermSize=64M -XX:MaxPermSize=128m 是指定永久区内存。

四、      以开发模式布署工程

需确保布署文件夹以 .war 后缀结尾。否则 jboss 会去 deploy 工程里有 rar 文件。如果前面的 .mymetadata 文件作过修改则无此问题 .

也可以通过工程右键 ->performance->myeclipse->Web->Context Root 下修改。

五、      工程引包

工程引包时建议不要把不相关的包全部引进来,这样很容易出现类装载问题,而且不容易排查。如果只引需要用的包,这样会很清晰,也容易排查问题。目录有很多版本号不一样的包 , 比如 spring ,感觉一般都是 2.x . 如果从名字上看不出版本号,通过看 jar 包里 META-INF 下面的 MANIFEST.MF 文件。正规的打包都会将版本信息加入进来。

 

javamail.jar,jta.jar 包在工程中没有用到,但引入它们将导致事物管理器错误。这种错误不好判断原因,有时候只能一个个包排查。

org.springframework.beans.factory.access.BootstrapException: Unable to return specified BeanFactory instance: factory key [beanRefFactory], from group

  with resource name [classpath*:springContext/beanRefFactory.xml]; nested exception is org.springframework.beans.factory.BeanCreationException: Error

creating bean with name 'beanRefFactory' defined in URL [jar:file:/E:/web/jboss-4.0.3SP1/server/default/deploy/selfservice.war/WEB-INF/lib/biz-v2.0-li

b.jar!/springContext/beanRefFactory.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Coul

d not instantiate bean class [org.springframework.context.support.ClassPathXmlApplicationContext]: Constructor threw exception; nested exception is or

g.springframework.beans.factory.BeanCreationException: Error creating bean with name 'serviceTransactionInterceptor' defined in class path resource [s

pringContext/daoServiceContext.xml]: Cannot resolve reference to bean 'transactionManager' while setting bean property 'transactionManager'; nested ex

ception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager' defined in class path resource

[springContext/systemContext.xml]: Invocation of init method failed; nested exception is org.springframework.transaction.TransactionSystemException: J

TA TransactionManager is not available at JNDI location [java:/TransactionManager]; nested exception is org.springframework.jndi.TypeMismatchNamingExc

eption: Object of type [class org.jboss.tm.TxManager] available at JNDI location [java:/TransactionManager] is not assignable to [javax.transaction.Tr

ansactionManager]

六、      布署打包策略

为了确保布署时只布署了 classpath 引用的包,以免将一些无用的包布署到 jboss 下,导致出现第五点提到的问题。

我们可以修改布署策略。方法如下

工程右键 ->performence->MyEclipse->Web->Deplyment 下的 Library Deployment Policies

取消默认的布署设置选项 , Use workbench default settings 选项的去掉 , 只选择 Jars on Web project build-pah.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值