DeploymentException&在WebLogic Admin Server 11g上找不到类 [英] DeploymentException & Class Not Found on WebLogic Admin Server 11g
问题描述
相关: 将外部属性文件加载到在WebLogic 11上运行的EJB 3应用程序
使用Oracle Enterprise Pack for Eclipse,我创建了一个企业项目,并命名为:
PropertiesDemoEAR
还创建了一个PropertiesDemoEARWeb模块,其中我将此代码
(在PropertiesDemoEARWeb / Java Resources / src / com.project.util中):
package com.project.util;
public class PropertiesFileHandler extends ApplicationLifecycleListener {
private static final String FILE =C:/etc/error.properties;
public void preStart(ApplicationLifecycleEvent evt){
System.out.println(\\\
\\\
\t\tInside preStart()method\\\
\\\
);
InputStream is =
evt.getApplicationContext()。getAppClassLoader()。getResourceAsStream(FILE);
try {
属性convertedProps =
convertStreamToProperties(is);
String userMissingError =
convertedProps.getProperty(USER_MISSING_ERROR);
System.out.println(\\\
\\\
\t\tuserMissingError =
+ userMissingError +\\\
\\\
);
} catch(Throwable e){
e.printStackTrace();
}
}
public属性convertStreamToProperties(InputStream is)throws IOException {
System.out.println(\\\
\\\
\t\ tInside convertStreamToProperties()method\\\
\\\
);
属性props = new Properties();
if(is == null){
throw new FileNotFoundException(property file+ FILE +'not found);
} else {
props.load(is);
返回道具;
}
}
}
Inside PropertiesDemoEAR /EarContent/META-INF/weblogic-application.xml
我以声明方式添加了以下监听器:
<?xml version =1.0encoding =UTF-8?>
< wls:weblogic-application
xmlns:wls =http://xmlns.oracle.com/weblogic/weblogic-application>
<! - weblogic-version:10.3.5 - >
< wls:application-param>
< wls:param-name> webapp.encoding.default< / wls:param-name>
< wls:param-value> UTF-8< / wls:param-value>
< / wls:application-param>
< wls:listener>
< wls:listener-class>
com.project.util.PropertiesFileHandler
< / wls:listener-class>
< / wls:listener>
< / wls:weblogic-application>
右键单击PropertiesDemoEAR / Export / EAR文件/目的地:
C:\Oracle\Middleware\user_projects\domains\MyDomain\autodeploy
当我通过Eclipse运行WebLogic 11g时,我在控制台中收到此错误消息:
[ERROR] AdapterManager - ServletContainerAdapter管理器未正确初始化。
< oracle.tip.adapter.apps.AppsConnectionFactory>
ConnectionManager cm:weblogic.connector.outbound.ConnectionManagerImpl@12433e7-eis/Apps/Apps
ManagedConnectionFactory mcf:
oracle.tip.adapter.apps.AppsManagedConnectionFactory@4303022b
< 2011年6月30日5:50:24 PM PDT> <错误> <部署> < BEA-149265>
<执行部署请求
时出现故障,ID为'1309481424487'用于任务'0'。错误是:
'weblogic.management.DeploymentException:'
weblogic.management.DeploymentException:at
weblogic.application.internal.flow。
BaseLifecycleFlow $ CreateListenerAction.run(BaseLifecycleFlow.java:176)在
weblogic.security.acl.internal。
AuthenticateSubject.doAs(AuthenticatedSubject.java:321)at
weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)at
weblogic.application.internal.flow。
BaseLifecycleFlow $ BaseAction.invoke(BaseLifecycleFlow.java:104)at
weblogic.application.internal。
flow.HeadLifecycleFlow.createListener(HeadLifecycleFlow.java:117)
截断。查看日志文件以获取完整的stacktrace
导致:java.lang.ClassNotFoundException:
com.project.util.PropertiesFileHandler
at weblogic.utils .classloaders。
GenericClassLoader.findLocalClass(GenericClassLoader.java:297)
问题: p>
(1)我可能做错了什么?为什么找不到我的PropertiesFileHandler类?
(2)我的属性文件的位置(c:/etc/error.properties)是否适合或应该是在MyDomain目录中?
(3)是否有默认目录或只是简单的配置区域,WebLogic加载可在WebLogic中运行的任何应用程序可访问的属性文件? p>
得到它的工作...问题是我将其设置为Web项目而不是Oracle中的Java EE实用程序项目企业版Eclipse。
作为一个Web项目,将.class文件放在WEB-INF / classes中而不是APP-INF。
另外,需要将error.properties放在我的实际域中。
C:\Oracle\Middleware\user_projects\domains \MyDomain
关于我自己的问题:
是否有默认目录或只是简单的配置区那个WebLogi c加载在WebLogic中运行的任何应用程序可访问的属性文件?
如果-Dweblogic.ext.dirs未设置,则默认为$ DOMAIN / lib; $ WL_HOME / common / lib / ext; $ WL_HOME / server / lib / ext
所以如果你在$ DOMAIN / lib中存储error.properties,它将在CLASSPATH和您应该可以使用getResourceAsStream(error.properties)加载它
Related: Load external properties files into EJB 3 app running on WebLogic 11
Using Oracle Enterprise Pack for Eclipse, I created an Enterprise Project and named it:
PropertiesDemoEAR
Also created a PropertiesDemoEARWeb module in which I put this code
(inside PropertiesDemoEARWeb / Java Resources / src / com.project.util):
package com.project.util;
public class PropertiesFileHandler extends ApplicationLifecycleListener {
private static final String FILE = "C:/etc/error.properties";
public void preStart(ApplicationLifecycleEvent evt) {
System.out.println("\n\n\t\tInside preStart() method\n\n");
InputStream is =
evt.getApplicationContext().getAppClassLoader().getResourceAsStream(FILE);
try {
Properties convertedProps =
convertStreamToProperties(is);
String userMissingError =
convertedProps.getProperty("USER_MISSING_ERROR");
System.out.println("\n\n\t\tuserMissingError = "
+ userMissingError + "\n\n");
} catch (Throwable e) {
e.printStackTrace();
}
}
public Properties convertStreamToProperties(InputStream is) throws IOException {
System.out.println("\n\n\t\tInside convertStreamToProperties() method\n\n");
Properties props = new Properties();
if (is == null) {
throw new FileNotFoundException("property file '" + FILE + "' not found");
} else {
props.load(is);
return props;
}
}
}
Inside PropertiesDemoEAR/EarContent/META-INF/weblogic-application.xml
I added the following listener declaratively:
<?xml version="1.0" encoding="UTF-8"?>
<wls:weblogic-application
xmlns:wls="http://xmlns.oracle.com/weblogic/weblogic-application" >
<!--weblogic-version:10.3.5-->
<wls:application-param>
<wls:param-name>webapp.encoding.default</wls:param-name>
<wls:param-value>UTF-8</wls:param-value>
</wls:application-param>
<wls:listener>
<wls:listener-class>
com.project.util.PropertiesFileHandler
</wls:listener-class>
</wls:listener>
</wls:weblogic-application>
Right clicked on the PropertiesDemoEAR / Export / EAR file / Destination:
C:\Oracle\Middleware\user_projects\domains\MyDomain\autodeploy
When I run WebLogic 11g through Eclipse, I get this error message in the console:
[ERROR] AdapterManager - ServletContainerAdapter manager not initialized correctly.
<oracle.tip.adapter.apps.AppsConnectionFactory>
ConnectionManager cm: weblogic.connector.outbound.ConnectionManagerImpl@12433e7-eis/Apps/Apps
ManagedConnectionFactory mcf:
oracle.tip.adapter.apps.AppsManagedConnectionFactory@4303022b
<Jun 30, 2011 5:50:24 PM PDT> <Error> <Deployer> <BEA-149265>
<Failure occurred in the execution of deployment request
with ID '1309481424487' for task '0'. Error is:
'weblogic.management.DeploymentException: '
weblogic.management.DeploymentException: at
weblogic.application.internal.flow.
BaseLifecycleFlow$CreateListenerAction.run(BaseLifecycleFlow.java:176) at
weblogic.security.acl.internal.
AuthenticatedSubject.doAs(AuthenticatedSubject.java:321) at
weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120) at
weblogic.application.internal.flow.
BaseLifecycleFlow$BaseAction.invoke(BaseLifecycleFlow.java:104) at
weblogic.application.internal.
flow.HeadLifecycleFlow.createListener(HeadLifecycleFlow.java:117)
Truncated. see log file for complete stacktrace
Caused By: java.lang.ClassNotFoundException:
com.project.util.PropertiesFileHandler
at weblogic.utils.classloaders.
GenericClassLoader.findLocalClass(GenericClassLoader.java:297)
Question(s):
(1) What am I possibly doing wrong? Why can't it find my PropertiesFileHandler class?
(2) Is the location (c:/etc/error.properties) of my properties file suitable or should it be inside MyDomain directory?
(3) Is there a default directory or just simple configuration area that WebLogic loads properties files which are accessible to any application that runs in WebLogic?
Got it working... The issue was that I had it set up as Web Project rather than a Java EE Utility Project in Oracle Enterprise Edition for Eclipse.
As a web project, it was putting .class files inside WEB-INF/classes instead of APP-INF.
Also, needed to put error.properties inside my actual domain.
C:\Oracle\Middleware\user_projects\domains\MyDomain
In regards to my own question:
Is there a default directory or just simple configuration area that WebLogic loads properties files which are accessible to any application that runs in WebLogic?
If -Dweblogic.ext.dirs is not set, it defaults to $DOMAIN/lib;$WL_HOME/common/lib/ext;$WL_HOME/server/lib/ext
So if you store error.properties in $DOMAIN/lib it will be on the CLASSPATH and you should be able to load it using getResourceAsStream("error.properties")
这篇关于DeploymentException&在WebLogic Admin Server 11g上找不到类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!