2016-04-01 10 views
2

aşağıdaki koşullarla JSPs ve WildFly 9.0.2.Final kullanıyorum:Wilfly hata oluştu çalışan uygulama --java.lang.ClassNotFoundException: javax.naming.InitialContext

  1. A JSP dosyasında () test.jsp Test.java dosyasına erişiyor.

  2. Test.java dosya testclient.jar bir parçasıdır ve bir modül olarak fırlatıldı.

  3. test.jsp dosya Test.earbir parçasıdır ve başarıyla dağıtıldıktan ancak test.jsp gelen Test.java dosyaya erişen şu hata oluştu:

    09:50:35,036 ERROR [io.undertow.request] (default task-1) UT005023: Exception handling request to /test/test.jsp: javax.servlet.ServletException: java.lang.NoClassDefFoundError: javax/naming/InitialContext 
    at org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:848) 
    at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:777) 
    at org.apache.jsp.test_jsp._jspService(test_jsp.java:70) 
    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:69) 
    Caused by: java.lang.NoClassDefFoundError: javax/naming/InitialContext 
    at com.testmodule.pojo.Test.getDbConnection(Test.java:12) 
    at org.apache.jsp.test_jsp._jspService(test_jsp.java:58) 
    ... 34 more 
    Caused by: java.lang.ClassNotFoundException: javax.naming.InitialContext from [Module "testclient:main" from local module loader @707f7052 (finder: local module finder @11028347 (roots: /wildfly-9.0.2.Final/modules,/wildfly-9.0.2.Final/modules/system/layers/base))] 
    at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:205) 
    at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:455) 
    at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:404) 
    

test.jsp dosyasının içeriği, numaralı testten alınmıştır.:

<%@page import="com.testmodule.pojo.Test"%> 
<% try { 
    System.out.println(" Going to call getDbConnection method of 'Test' class. This 'Test' class shall be " 
     +" part of testclient.jar. testclient.jar shall be deployed as a module --- module add --name=testclient --resources=~/Downloads/lib/test/testclient.jar"); 
    System.out.println("This file test.jsp shall be present in test.ear...'jboss-deployment-structure.xml' shall be present in " 
     +" in META-INF directory of test.ear with entry as -- <dependencies><module name=\"testclient\" export=\"true\" /> </dependencies>"); 
    new Test().getDbConnection(); 
} catch(Exception e){ 
    e.printStackTrace(); 
} %> 

Ve bunlar testclient.jar yılında Test.java mevcut içeriği şunlardır: javax.api:

package com.testmodule.pojo; 

import java.util.Properties; 
import javax.naming.Context; 
import javax.naming.InitialContext; 

public class Test { 
    public void getDbConnection(){ 
     try{ 
      Context context = new InitialContext(new Properties()); 
     } catch(Exception e){} 
    } 
} 
+0

Acutally sizin module.xml için

<dependencies> <module name="javax.api"/> </dependencies> 

eklemek için> lib. Ayrıca testclient.jar erişen birçok diğer uygulama olduğu gibi, ben her savaş arşivinin lib testclient.jar koymak zorundayım bu yaklaşım için giderseniz ... jboss 5.xi genellikle $ JBOSS_HOME içinde testclient.jar koymak/sunucu/varsayılan/istemci dizini, böylece her savaş arşivi tarafından erişilebiliyor.Nasıl bu wildfly9.0.2final içinde yapmak için. –

cevap

1

Sana modülüne bir bağımlılık eklemek gerek. > Test.war - -> WEB-INF -

deneyin i test.ear içine testclient.jar koymak istemiyorum

İlgili konular