不能在Glassfish 3.1.2上使用CDI进入WAB

时间:2012-03-22 18:17:23

标签: java glassfish glassfish-3 cdi

我想用JSF页面实现OSGI包 - WAB文件,它可以使用CDI。这是Managed bean的代码。我删除了faces-config.xml文件的内容(为了使用JSF 2.0和CDI)

package com.DX_57.SM_57;
/* include default packages for Beans */
import java.io.Serializable;
import javax.enterprise.context.SessionScoped;
// or import javax.faces.bean.SessionScoped;
import javax.inject.Named;
/* include SQL Packages */
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.HashMap;
import javax.annotation.ManagedBean;
import javax.annotation.PostConstruct;
import javax.sql.DataSource;
import javax.annotation.Resource;
import javax.faces.bean.ViewScoped;
import javax.faces.context.FacesContext;
import javax.inject.Inject;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
// or import javax.faces.bean.ManagedBean;   

import org.glassfish.osgicdi.OSGiService;

@ManagedBean("ApplicationController")
@ViewScoped
public class Application implements Serializable {

    /* This Hash Map will be used to store setting and value */
    private HashMap<String, String> settingsMap = null;    

    public Application(){     
    }   

    /* Call the Oracle JDBC Connection driver */
    @Resource(name = "jdbc/Oracle")
    private DataSource ds;


    /* Hash Map
     * Send this hash map with the settings and values to the JSF page
     */
    public HashMap<String, String> getsettings(){
        return settingsMap;        
    }

    /* Get a Hash Map with settings and values. The table is genarated right 
     * after the constructor is initialized. 
     */
    @PostConstruct
    public void initSettings() throws SQLException
    {        
        settingsMap = new HashMap<String, String>();

        if(ds == null) {
                throw new SQLException("Can't get data source");
        }
        /* Initialize a connection to Oracle */
        Connection conn = ds.getConnection(); 

        if(conn == null) {
                throw new SQLException("Can't get database connection");
        }
        /* With SQL statement get all settings and values */
        PreparedStatement ps = conn.prepareStatement("SELECT * from GLOBALSETTINGS");

        try
        {
            //get data from database        
            ResultSet result = ps.executeQuery();
            while (result.next())
            {
               /* Put the the data from Oracle into Hash Map */
               settingsMap.put(result.getString("SettingName"), result.getString("SettingValue"));
            }            
        }
        finally
        {
            ps.close();
            conn.close();         
        }        
    }

    /* JSF returns automatically the updated values into the HashMap */

    /* Update Settings Values */
    public void updateDBSettings() throws SQLException {

            String SQL_Statement = null;

            if (ds == null) throw new SQLException();      
        Connection conn = ds.getConnection();
            if (conn == null) throw new SQLException();      

    try {
        conn.setAutoCommit(false);
        boolean committed = false;
            try {  
                   /* Insert the new settings values with one SQL statement */
                   SQL_Statement = "UPDATE GLOBALSETTINGS " +
                                        "SET \"SettingValue\" = " +
                                          "CASE " +
                                            "WHEN \"SettingName\" = 'SessionTTL' THEN ? " +
                                            "WHEN \"SettingName\" = 'MaxUsersActive' THEN ? " +
                                          "END " +
                                   "WHERE \"SettingName\"  IN ('SessionTTL', 'MaxUsersActive')";

                   /* Execute the SQL statement */
                   PreparedStatement updateQuery = conn.prepareStatement(SQL_Statement);
                   updateQuery.setString(1, settingsMap.get("SessionTTL"));
                   updateQuery.setString(2, settingsMap.get("MaxUsersActive"));

                   updateQuery.executeQuery();                                                         
                   conn.commit();
                   committed = true;
               } finally {
                   if (!committed) conn.rollback();
                   }
            }
            finally {
            /* Release the resource after all SQL queries are executed */
            conn.close();                
            }  
       /* Refresh Hash Map
        * Get again settings from Oracle
        */
        initSettings();
     }    


}

当我在Glassfish 3.1.2上部署Bundle时,我得到了这个错误堆栈:

[#|2012-03-22T16:26:08.873+0200|INFO|glassfish3.1.2|org.glassfish.osgijavaeebase|_ThreadID=211;_ThreadName=Thread-2;|Deleted /tmp/osgiapp5412956867041511002|#]

[#|2012-03-22T16:26:08.874+0200|INFO|glassfish3.1.2|org.glassfish.osgijavaeebase|_ThreadID=211;_ThreadName=Thread-2;|Undeployed bundle com.DX_57.SM_57 [701]|#]

[#|2012-03-22T16:26:08.875+0200|INFO|glassfish3.1.2|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=211;_ThreadName=Thread-2;|Stopped com.DX_57.SM_57 [701]|#]

[#|2012-03-22T16:26:08.886+0200|INFO|glassfish3.1.2|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=211;_ThreadName=Thread-2;|Uninstalled com.DX_57.SM_57 [701]|#]

[#|2012-03-22T16:26:09.223+0200|INFO|glassfish3.1.2|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=211;_ThreadName=Thread-2;|Installed com.DX_57.SM_57 [702] from reference:file:/opt/glassfish3/glassfish/domains/domain1/applications/SM_57-1.0-SNAPSHOT/|#]

[#|2012-03-22T16:26:09.234+0200|INFO|glassfish3.1.2|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=211;_ThreadName=Thread-2;|Started com.DX_57.SM_57 [702]|#]

[#|2012-03-22T16:26:09.297+0200|INFO|glassfish3.1.2|javax.enterprise.system.tools.admin.org.glassfish.deployment.admin|_ThreadID=211;_ThreadName=Thread-2;|SM_57-1.0-SNAPSHOT was successfully deployed in 485 milliseconds.|#]

[#|2012-03-22T16:26:09.507+0200|INFO|glassfish3.1.2|org.glassfish.osgijavaeebase|_ThreadID=63;_ThreadName=Thread-2;|Expanded at file:/tmp/osgiapp966382129527287676/|#]

[#|2012-03-22T16:26:09.848+0200|WARNING|glassfish3.1.2|javax.enterprise.system.core.org.glassfish.kernel.event|_ThreadID=63;_ThreadName=Thread-2;|Exception while dispatching an event
java.lang.RuntimeException: Error binding ManagedBean com.DX_57.SM_57.Database with name = DatabaseController
    at com.sun.enterprise.container.common.impl.managedbean.ManagedBeanManagerImpl.loadManagedBeans(ManagedBeanManagerImpl.java:277)
    at com.sun.enterprise.container.common.impl.managedbean.ManagedBeanManagerImpl.loadManagedBeans(ManagedBeanManagerImpl.java:204)
    at com.sun.enterprise.container.common.impl.managedbean.ManagedBeanManagerImpl.event(ManagedBeanManagerImpl.java:134)
    at org.glassfish.kernel.event.EventsImpl.send(EventsImpl.java:128)
    at org.glassfish.internal.data.ApplicationInfo.load(ApplicationInfo.java:277)
    at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:460)
    at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:240)
    at org.glassfish.osgijavaeebase.OSGiDeploymentRequest.deploy(OSGiDeploymentRequest.java:183)
    at org.glassfish.osgijavaeebase.OSGiDeploymentRequest.execute(OSGiDeploymentRequest.java:118)
    at org.glassfish.osgijavaeebase.AbstractOSGiDeployer.deploy(AbstractOSGiDeployer.java:121)
    at org.glassfish.osgijavaeebase.OSGiContainer.deploy(OSGiContainer.java:154)
    at org.glassfish.osgijavaeebase.JavaEEExtender.deploy(JavaEEExtender.java:107)
    at org.glassfish.osgijavaeebase.JavaEEExtender.access$200(JavaEEExtender.java:61)
    at org.glassfish.osgijavaeebase.JavaEEExtender$HybridBundleTrackerCustomizer$1.call(JavaEEExtender.java:151)
    at org.glassfish.osgijavaeebase.JavaEEExtender$HybridBundleTrackerCustomizer$1.call(JavaEEExtender.java:148)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
    at java.util.concurrent.FutureTask.run(FutureTask.java:166)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
    at java.lang.Thread.run(Thread.java:722)
Caused by: java.lang.RuntimeException: Could not invoke defineClass!
    at com.sun.ejb.containers.EjbOptionalIntfGenerator.makeClass(EjbOptionalIntfGenerator.java:446)
    at com.sun.ejb.containers.EjbOptionalIntfGenerator.access$200(EjbOptionalIntfGenerator.java:62)
    at com.sun.ejb.containers.EjbOptionalIntfGenerator$1.run(EjbOptionalIntfGenerator.java:97)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.sun.ejb.containers.EjbOptionalIntfGenerator.loadClass(EjbOptionalIntfGenerator.java:94)
    at com.sun.ejb.containers.interceptors.JavaEEInterceptorBuilderFactoryImpl.createBuilder(JavaEEInterceptorBuilderFactoryImpl.java:97)
    at com.sun.enterprise.container.common.impl.managedbean.ManagedBeanManagerImpl.loadManagedBeans(ManagedBeanManagerImpl.java:256)
    ... 19 more
Caused by: java.lang.reflect.InvocationTargetException
    at sun.reflect.GeneratedMethodAccessor60.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:601)
    at com.sun.ejb.containers.EjbOptionalIntfGenerator.makeClass(EjbOptionalIntfGenerator.java:443)
    ... 25 more
Caused by: java.lang.NoClassDefFoundError: com/sun/ejb/containers/OptionalLocalInterfaceProvider
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:791)
    ... 29 more
Caused by: java.lang.ClassNotFoundException: com.sun.ejb.containers.OptionalLocalInterfaceProvider not found by com.DX_57.SM_57 [702]
    at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1460)
    at org.apache.felix.framework.BundleWiringImpl.access$400(BundleWiringImpl.java:72)
    at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:1843)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
    ... 31 more
|#]

[#|2012-03-22T16:26:10.438+0200|INFO|glassfish3.1.2|org.glassfish.osgiweb|_ThreadID=63;_ThreadName=Thread-2;|total number of classes with faces annotation = 0|#]

[#|2012-03-22T16:26:10.451+0200|SEVERE|glassfish3.1.2|org.apache.catalina.core.ContainerBase|_ThreadID=63;_ThreadName=Thread-2;|ContainerBase.addChild: start: 
org.apache.catalina.LifecycleException: java.lang.IllegalArgumentException: javax.servlet.ServletException: com.sun.enterprise.container.common.spi.util.InjectionException: Error creating managed object for class: class org.jboss.weld.servlet.WeldListener
    at org.apache.catalina.core.StandardContext.start(StandardContext.java:5332)
    at com.sun.enterprise.web.WebModule.start(WebModule.java:498)
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:917)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:901)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:733)
    at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:2018)
    at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:1669)
    at com.sun.enterprise.web.WebApplication.start(WebApplication.java:109)
    at org.glassfish.internal.data.EngineRef.start(EngineRef.java:130)
    at org.glassfish.internal.data.ModuleInfo.start(ModuleInfo.java:269)
    at org.glassfish.internal.data.ApplicationInfo.start(ApplicationInfo.java:301)
    at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:461)
    at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:240)
    at org.glassfish.osgijavaeebase.OSGiDeploymentRequest.deploy(OSGiDeploymentRequest.java:183)
    at org.glassfish.osgijavaeebase.OSGiDeploymentRequest.execute(OSGiDeploymentRequest.java:118)
    at org.glassfish.osgijavaeebase.AbstractOSGiDeployer.deploy(AbstractOSGiDeployer.java:121)
    at org.glassfish.osgijavaeebase.OSGiContainer.deploy(OSGiContainer.java:154)
    at org.glassfish.osgijavaeebase.JavaEEExtender.deploy(JavaEEExtender.java:107)
    at org.glassfish.osgijavaeebase.JavaEEExtender.access$200(JavaEEExtender.java:61)
    at org.glassfish.osgijavaeebase.JavaEEExtender$HybridBundleTrackerCustomizer$1.call(JavaEEExtender.java:151)
    at org.glassfish.osgijavaeebase.JavaEEExtender$HybridBundleTrackerCustomizer$1.call(JavaEEExtender.java:148)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
    at java.util.concurrent.FutureTask.run(FutureTask.java:166)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
    at java.lang.Thread.run(Thread.java:722)
Caused by: java.lang.IllegalArgumentException: javax.servlet.ServletException: com.sun.enterprise.container.common.spi.util.InjectionException: Error creating managed object for class: class org.jboss.weld.servlet.WeldListener
    at org.apache.catalina.core.StandardContext.addListener(StandardContext.java:2743)
    at org.apache.catalina.core.StandardContext.addApplicationListener(StandardContext.java:1966)
    at com.sun.enterprise.web.TomcatDeploymentConfig.configureApplicationListener(TomcatDeploymentConfig.java:235)
    at com.sun.enterprise.web.TomcatDeploymentConfig.configureWebModule(TomcatDeploymentConfig.java:94)
    at com.sun.enterprise.web.WebModuleContextConfig.start(WebModuleContextConfig.java:274)
    at com.sun.enterprise.web.WebModuleContextConfig.lifecycleEvent(WebModuleContextConfig.java:172)
    at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:149)
    at org.apache.catalina.core.StandardContext.start(StandardContext.java:5329)
    ... 25 more
Caused by: javax.servlet.ServletException: com.sun.enterprise.container.common.spi.util.InjectionException: Error creating managed object for class: class org.jboss.weld.servlet.WeldListener
    at org.apache.catalina.core.StandardContext.createListener(StandardContext.java:2853)
    at org.apache.catalina.core.StandardContext.loadListener(StandardContext.java:4806)
    at com.sun.enterprise.web.WebModule.loadListener(WebModule.java:1599)
    at org.apache.catalina.core.StandardContext.addListener(StandardContext.java:2740)
    ... 32 more
Caused by: com.sun.enterprise.container.common.spi.util.InjectionException: Error creating managed object for class: class org.jboss.weld.servlet.WeldListener
    at com.sun.enterprise.container.common.impl.util.InjectionManagerImpl.createManagedObject(InjectionManagerImpl.java:315)
    at com.sun.enterprise.web.WebContainer.createListenerInstance(WebContainer.java:761)
    at com.sun.enterprise.web.WebModule.createListenerInstance(WebModule.java:1987)
    at org.apache.catalina.core.StandardContext.createListener(StandardContext.java:2851)
    ... 35 more
Caused by: java.lang.NullPointerException
    at com.sun.enterprise.container.common.impl.managedbean.ManagedBeanManagerImpl.createManagedBean(ManagedBeanManagerImpl.java:477)
    at com.sun.enterprise.container.common.impl.managedbean.ManagedBeanManagerImpl.createManagedBean(ManagedBeanManagerImpl.java:420)
    at com.sun.enterprise.container.common.impl.util.InjectionManagerImpl.createManagedObject(InjectionManagerImpl.java:299)
    ... 38 more
|#]

[#|2012-03-22T16:26:10.453+0200|WARNING|glassfish3.1.2|javax.enterprise.system.container.web.com.sun.enterprise.web|_ThreadID=63;_ThreadName=Thread-2;|java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: java.lang.IllegalArgumentException: javax.servlet.ServletException: com.sun.enterprise.container.common.spi.util.InjectionException: Error creating managed object for class: class org.jboss.weld.servlet.WeldListener
java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: java.lang.IllegalArgumentException: javax.servlet.ServletException: com.sun.enterprise.container.common.spi.util.InjectionException: Error creating managed object for class: class org.jboss.weld.servlet.WeldListener
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:921)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:901)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:733)
    at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:2018)
    at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:1669)
    at com.sun.enterprise.web.WebApplication.start(WebApplication.java:109)
    at org.glassfish.internal.data.EngineRef.start(EngineRef.java:130)
    at org.glassfish.internal.data.ModuleInfo.start(ModuleInfo.java:269)
    at org.glassfish.internal.data.ApplicationInfo.start(ApplicationInfo.java:301)
    at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:461)
    at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:240)
    at org.glassfish.osgijavaeebase.OSGiDeploymentRequest.deploy(OSGiDeploymentRequest.java:183)
    at org.glassfish.osgijavaeebase.OSGiDeploymentRequest.execute(OSGiDeploymentRequest.java:118)
    at org.glassfish.osgijavaeebase.AbstractOSGiDeployer.deploy(AbstractOSGiDeployer.java:121)
    at org.glassfish.osgijavaeebase.OSGiContainer.deploy(OSGiContainer.java:154)
    at org.glassfish.osgijavaeebase.JavaEEExtender.deploy(JavaEEExtender.java:107)
    at org.glassfish.osgijavaeebase.JavaEEExtender.access$200(JavaEEExtender.java:61)
    at org.glassfish.osgijavaeebase.JavaEEExtender$HybridBundleTrackerCustomizer$1.call(JavaEEExtender.java:151)
    at org.glassfish.osgijavaeebase.JavaEEExtender$HybridBundleTrackerCustomizer$1.call(JavaEEExtender.java:148)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
    at java.util.concurrent.FutureTask.run(FutureTask.java:166)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
    at java.lang.Thread.run(Thread.java:722)
|#]

[#|2012-03-22T16:26:10.455+0200|SEVERE|glassfish3.1.2|org.glassfish.osgijavaeebase|_ThreadID=63;_ThreadName=Thread-2;|Exception while invoking class com.sun.enterprise.web.WebApplication start method
java.lang.Exception: java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: java.lang.IllegalArgumentException: javax.servlet.ServletException: com.sun.enterprise.container.common.spi.util.InjectionException: Error creating managed object for class: class org.jboss.weld.servlet.WeldListener
    at com.sun.enterprise.web.WebApplication.start(WebApplication.java:138)
    at org.glassfish.internal.data.EngineRef.start(EngineRef.java:130)
    at org.glassfish.internal.data.ModuleInfo.start(ModuleInfo.java:269)
    at org.glassfish.internal.data.ApplicationInfo.start(ApplicationInfo.java:301)
    at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:461)
    at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:240)
    at org.glassfish.osgijavaeebase.OSGiDeploymentRequest.deploy(OSGiDeploymentRequest.java:183)
    at org.glassfish.osgijavaeebase.OSGiDeploymentRequest.execute(OSGiDeploymentRequest.java:118)
    at org.glassfish.osgijavaeebase.AbstractOSGiDeployer.deploy(AbstractOSGiDeployer.java:121)
    at org.glassfish.osgijavaeebase.OSGiContainer.deploy(OSGiContainer.java:154)
    at org.glassfish.osgijavaeebase.JavaEEExtender.deploy(JavaEEExtender.java:107)
    at org.glassfish.osgijavaeebase.JavaEEExtender.access$200(JavaEEExtender.java:61)
    at org.glassfish.osgijavaeebase.JavaEEExtender$HybridBundleTrackerCustomizer$1.call(JavaEEExtender.java:151)
    at org.glassfish.osgijavaeebase.JavaEEExtender$HybridBundleTrackerCustomizer$1.call(JavaEEExtender.java:148)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
    at java.util.concurrent.FutureTask.run(FutureTask.java:166)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
    at java.lang.Thread.run(Thread.java:722)
|#]

[#|2012-03-22T16:26:10.455+0200|SEVERE|glassfish3.1.2|javax.enterprise.system.core.com.sun.enterprise.v3.server|_ThreadID=63;_ThreadName=Thread-2;|Exception while loading the app|#]

[#|2012-03-22T16:26:10.493+0200|INFO|glassfish3.1.2|org.glassfish.osgijavaeebase|_ThreadID=63;_ThreadName=Thread-2;|Deleted /tmp/osgiapp966382129527287676|#]

[#|2012-03-22T16:26:10.494+0200|SEVERE|glassfish3.1.2|org.glassfish.osgijavaeebase|_ThreadID=63;_ThreadName=Thread-2;|Failed while deploying bundle com.DX_57.SM_57 [702]|#]

[#|2012-03-22T16:26:10.495+0200|INFO|glassfish3.1.2|org.glassfish.osgiweb|_ThreadID=63;_ThreadName=Thread-2;|Removed bundle 702 against context path /SM_57-1.0-SNAPSHOT |#]

[#|2012-03-22T16:26:10.500+0200|WARNING|glassfish3.1.2|org.glassfish.osgijavaeebase|_ThreadID=63;_ThreadName=Thread-2;|Failed to deploy bundle com.DX_57.SM_57 [702]
org.glassfish.osgijavaeebase.DeploymentException: Deployment of com.DX_57.SM_57 [702] failed because of following reason: Failed while deploying bundle com.DX_57.SM_57 [702] : java.lang.RuntimeException: Failed to deploy bundle [ com.DX_57.SM_57 [702] ], root cause: Exception while loading the app
    at org.glassfish.osgijavaeebase.AbstractOSGiDeployer.deploy(AbstractOSGiDeployer.java:125)
    at org.glassfish.osgijavaeebase.OSGiContainer.deploy(OSGiContainer.java:154)
    at org.glassfish.osgijavaeebase.JavaEEExtender.deploy(JavaEEExtender.java:107)
    at org.glassfish.osgijavaeebase.JavaEEExtender.access$200(JavaEEExtender.java:61)
    at org.glassfish.osgijavaeebase.JavaEEExtender$HybridBundleTrackerCustomizer$1.call(JavaEEExtender.java:151)
    at org.glassfish.osgijavaeebase.JavaEEExtender$HybridBundleTrackerCustomizer$1.call(JavaEEExtender.java:148)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
    at java.util.concurrent.FutureTask.run(FutureTask.java:166)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
    at java.lang.Thread.run(Thread.java:722)
Caused by: java.lang.RuntimeException: Failed to deploy bundle [ com.DX_57.SM_57 [702] ], root cause: Exception while loading the app
    at org.glassfish.osgijavaeebase.OSGiDeploymentRequest.deploy(OSGiDeploymentRequest.java:196)
    at org.glassfish.osgijavaeebase.OSGiDeploymentRequest.execute(OSGiDeploymentRequest.java:118)
    at org.glassfish.osgijavaeebase.AbstractOSGiDeployer.deploy(AbstractOSGiDeployer.java:121)
    ... 10 more
Caused by: java.lang.Exception: java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: java.lang.IllegalArgumentException: javax.servlet.ServletException: com.sun.enterprise.container.common.spi.util.InjectionException: Error creating managed object for class: class org.jboss.weld.servlet.WeldListener
    at com.sun.enterprise.web.WebApplication.start(WebApplication.java:138)
    at org.glassfish.internal.data.EngineRef.start(EngineRef.java:130)
    at org.glassfish.internal.data.ModuleInfo.start(ModuleInfo.java:269)
    at org.glassfish.internal.data.ApplicationInfo.start(ApplicationInfo.java:301)
    at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:461)
    at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:240)
    at org.glassfish.osgijavaeebase.OSGiDeploymentRequest.deploy(OSGiDeploymentRequest.java:183)
    ... 12 more
|#]

[#|2012-03-22T16:26:28.576+0200|INFO|glassfish3.1.2|null|_ThreadID=45;_ThreadName=Thread-2;|Domain Pinged: stable.glassfish.org|#]

我还在Glassfish上发现了这个错误:http://java.net/jira/browse/GLASSFISH-15225

我可以解决这个问题吗?有什么选择? 如果您愿意,我可以提供完整的源代码。

祝福

编辑这是breans.xml文件洞察WEB-INF的内容:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/beans_1_0.xsd">
</beans>

3 个答案:

答案 0 :(得分:2)

您的类路径下的META-INF目录中是否有beans.xml?

答案 1 :(得分:2)

如果这是一个OSGi包,并且不是war,ear,jar或rar,它可能不会被选为有效的bean存档。规范中没有任何内容需要拾取OSGi包。如果是,那将是供应商加入他们的CDI集成。

如果您希望看到此集成,请访问cdi-dev@jboss.org列表并向EG询问并等待他们的回复。

答案 2 :(得分:1)

我刚开始使用JSF并将其作为WAB部署到Glassfish 3.1.2。

我已经能够使用@Inject @OSGiService注释来使用CDI来获取OSGi服务。我是整个CDI的新手,但它似乎对OSGi类型的服务工作得很好。