weblogic需要配置war文件部署

时间:2016-08-15 12:14:30

标签: java maven tomcat weblogic12c

我有一个简单的Web应用程序,它使用JNDI查找项目中定义的资源。

enter image description here

我使用类来访问我的资源

import javax.jcr.Repository;
import javax.jcr.RepositoryException;
import javax.jcr.Session;
import javax.jcr.SimpleCredentials;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;

public class SessionFactory {

    public static Session getSession() throws RepositoryException, NamingException {

        InitialContext ctx = new InitialContext();
        Context env = (Context) ctx.lookup("java:comp/env");
        Repository repo = (Repository) env.lookup("jcr/repository");
        return repo.login(new SimpleCredentials("admin", "".toCharArray()));
    }
}

bootstrap.properties

repository.name=java:comp/env/jcr/repository
jndi.enabled=true
jndi.name=jcr/repository

的web.xml

<!DOCTYPE web-app PUBLIC
        "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
        "http://java.sun.com/dtd/web-app_2_3.dtd" >

<web-app>
    <display-name>Archetype Created Web Application</display-name>
    <servlet>
        <description>This servlet provides other servlets and jsps a common way to
            access the repository. The repository can be accessed via JNDI, RMI or
            Webdav.
        </description>
        <servlet-name>Repository</servlet-name>
        <servlet-class>org.apache.jackrabbit.j2ee.RepositoryAccessServlet</servlet-class>
        <init-param>
            <description>Property file that hold the same initialization properties
                than the init-params below. If a parameter is specified in both places
                the one in the bootstrap-config wins.
            </description>
            <param-name>bootstrap-config</param-name>
            <param-value>WEB-INF/repository/bootstrap.properties</param-value>
        </init-param>
        <load-on-startup>3</load-on-startup>
    </servlet>
    <servlet>
        <description>The webdav servlet that connects HTTP request to the
            repository.
        </description>
        <servlet-name>Webdav</servlet-name>
        <servlet-class>org.apache.jackrabbit.j2ee.SimpleWebdavServlet</servlet-class>
        <init-param>
            <description>defines the prefix for spooling resources out of the
                repository.
            </description>
            <param-name>resource-path-prefix</param-name>
            <param-value>/repository</param-value>
        </init-param>
        <init-param>
            <description>Defines various dav-resource configuration parameters.
            </description>
            <param-name>resource-config</param-name>
            <param-value>/WEB-INF/repository/config.xml</param-value>
        </init-param>
        <load-on-startup>4</load-on-startup>
    </servlet>
    <servlet>
        <description>The webdav servlet that connects HTTP request to the
            repository.
        </description>
        <servlet-name>JCRWebdavServer</servlet-name>
        <servlet-class>org.apache.jackrabbit.j2ee.JCRWebdavServerServlet</servlet-class>
        <init-param>
            <description>defines the prefix for spooling resources out of the
                repository.
            </description>
            <param-name>resource-path-prefix</param-name>
            <param-value>/server</param-value>
        </init-param>
        <load-on-startup>5</load-on-startup>
    </servlet>
    <servlet>
        <servlet-name>RMI</servlet-name>
        <servlet-class>org.apache.jackrabbit.servlet.remote.RemoteBindingServlet</servlet-class>
    </servlet>
    <servlet>
        <description>Downloads binary data from repository</description>
        <display-name>Repository Download Servlet</display-name>
        <servlet-name>RepositoryDownloadServlet</servlet-name>
        <servlet-class>com.ctp.jcr.sample.webapp.RepositoryDownloadServlet</servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>Webdav</servlet-name>
        <url-pattern>/repository/*</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
        <servlet-name>JCRWebdavServer</servlet-name>
        <url-pattern>/server/*</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
        <servlet-name>RMI</servlet-name>
        <url-pattern>/rmi</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
        <servlet-name>RepositoryDownloadServlet</servlet-name>
        <url-pattern>/content/*</url-pattern>
    </servlet-mapping>

    <resource-ref>
        <description>JCR Repository</description>
        <res-ref-name>jcr/repository</res-ref-name>
        <res-type>javax.jcr.Repository</res-type>
        <res-auth>Container</res-auth>
    </resource-ref>
</web-app>

weblogic.xml中

<?xml version="1.0" encoding="UTF-8" ?>
<weblogic-web-app
        xmlns="http://xmlns.oracle.com/weblogic/weblogic-web-app"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="
        http://xmlns.oracle.com/weblogic/weblogic-web-app http://http://www.oracle.com/technology/weblogic/weblogic-web-app/1.1/weblogic-web-app.xsd">
</weblogic-web-app>

context.xml中

<?xml version="1.0" encoding="UTF-8" ?>
<Context>
    <Resource name="jcr/repository"
              auth="Container"
              type="javax.jcr.Repository"
              factory="org.apache.jackrabbit.core.jndi.BindableRepositoryFactory"
              configFilePath="E:/code/jackrabbit-tutorial/repository/config/repository.xml"
              repHomeDir="E:/code/jackrabbit-tutorial/repository" />
</Context>

它在Apache Tomcat上得到了很好的部署,但在weblogic上失败了!

javax.naming.LinkException:[root异常是javax.naming.NameNotFoundException:尝试查找&#39; jcr.repository&#39;没有找到子上下文&#39; jcr&#39;。已解决&#39;&#39 ;;剩余名称&#39; jcr / repository&#39;];链接剩余名称:&#39; jcr / repository&#39;

0 个答案:

没有答案