部署异常 &在 WebLogic 管理服务器 11g 上找不到类

发布于 2024-11-18 08:53:10 字数 4292 浏览 3 评论 0原文

相关: 将外部属性文件加载到在 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("\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;
        }
     }

 }

在 PropertiesDemoEAR/EarContent/META-INF/weblogic-application.xml 内,

我以声明方式添加了以下侦听器:

<?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>

对单击 PropertiesDemoEAR / Export / EAR file / Destination:

C:\Oracle\Middleware\user_projects\domains\MyDomain\autodeploy

当我运行时通过 Eclipse 运行 WebLogic 11g,我在控制台中收到此错误消息:

 [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)

问题:

(1) 我可能做错了什么?为什么它找不到我的 PropertiesFileHandler 类?

(2) 我的属性文件的位置 (c:/etc/error.properties) 合适还是应该位于 MyDomain 目录内?

(3) 是否有一个默认目录或只是简单的配置区域,WebLogic 会加载可供在 WebLogic 中运行的任何应用程序访问的属性文件?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

不奢求什么 2024-11-25 08:53:10

尝试确保该类位于部署应用程序的计算机的 /lib 文件夹中。

Try making sure that the class is in the /lib folder for the machine where the application is being deployed.

阳光下的泡沫是彩色的 2024-11-25 08:53:10

让它工作了...问题是我在 Oracle Enterprise Edition for Eclipse 中将其设置为 Web 项目而不是 Java EE 实用程序项目。

作为一个 Web 项目,它将 .class 文件放入 WEB-INF/classes 而不是 APP-INF 中。

另外,需要将 error.properties 放入我的实际域中。

C:\Oracle\Middleware\user_projects\domains\MyDomain

关于我自己的问题:

WebLogic 是否有一个默认目录或只是简单的配置区域来加载在 WebLogic 中运行的任何应用程序都可以访问的属性文件?

如果未设置 -Dweblogic.ext.dirs,则默认为 $DOMAIN/lib;$WL_HOME/common/lib/ext;$WL_HOME/server/lib/ext

因此,如果您将 error.properties 存储在 $DOMAIN/lib 中,它将位于 CLASSPATH 上,您应该能够使用 getResourceAsStream("error.properties") 加载它

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")

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文