springboot项目部署到weblogic异常


问题背景 :

一个项目要用weblgic部署,开发时没注意。提供war给到客户,访问直接403,本地是正常运行的,放到tomcat运行访问也ok。

本地搭建weblogic环境,还原了错误,找了好久原因,记录一下。

网络参考 : 如何优雅的在weblogic上部署spring-boot

环境 :

  IDE :IntelliJ IDEA 2019.3

  JDK :1.6.0_31

  weblogic :10.3.6(运行jdk也是设为的1.6)

错误截图:

 具体异常文字

com.bea.wcp.sip.engine.server.setup.SipAnnotationParsingException:
at com.bea.wcp.sip.engine.server.setup.SipAnnotationData.(SipAnnotationData.java:155)
at com.bea.wcp.sip.util.DeploymentUtil.getOrCreateAnnotationData(DeploymentUtil.java:70)
at com.bea.wcp.sip.util.DeploymentUtil.isSipModule(DeploymentUtil.java:96)
at com.bea.wcp.sip.engine.server.SipServerTailModule$1.visit(SipServerTailModule.java:127)
at com.bea.wcp.sip.engine.server.SipServerTailModule.visitAllContexts(SipServerTailModule.java:112)
Truncated. see log file for complete stacktrace
Caused By: java.lang.ArrayStoreException: sun.reflect.annotation.TypeNotPresentExceptionProxy
at sun.reflect.annotation.AnnotationParser.parseClassArray(AnnotationParser.java:653)
at sun.reflect.annotation.AnnotationParser.parseArray(AnnotationParser.java:460)
at sun.reflect.annotation.AnnotationParser.parseMemberValue(AnnotationParser.java:286)
at sun.reflect.annotation.AnnotationParser.parseAnnotation(AnnotationParser.java:222)
at sun.reflect.annotation.AnnotationParser.parseAnnotations2(AnnotationParser.java:69)
Truncated. see log file for complete stacktrace。

操作步骤 :

1、增加web.xml

内容如下,主要修改 com.xxx.DemoApplication 为你启动类的位置就行。

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" 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/web-app_2_5.xsd">

    <context-param>
        <param-name>contextConfigLocationparam-name>
        <param-value>com.xxx.DemoApplicationparam-value>
    context-param>

    <listener>
        <listener-class>org.springframework.boot.legacy.context.web.SpringBootContextLoaderListenerlistener-class>
    listener>

    <filter>
        <filter-name>metricFilterfilter-name>
        <filter-class>org.springframework.web.filter.DelegatingFilterProxyfilter-class>
    filter>

    <filter-mapping>
        <filter-name>metricFilterfilter-name>
        <url-pattern>/*url-pattern>
    filter-mapping>

    <servlet>
        <servlet-name>appServletservlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServletservlet-class>
        <init-param>
            <param-name>contextAttributeparam-name>
            <param-value>org.springframework.web.context.WebApplicationContext.ROOTparam-value>
        init-param>
        <load-on-startup>1load-on-startup>
    servlet>

    <servlet-mapping>
        <servlet-name>appServletservlet-name>
        <url-pattern>/url-pattern>
    servlet-mapping>

web-app>

2、增加 weblogic.xml

 然后选择你的weblogic版本

<?xml version="1.0" encoding="UTF-8"?>
<wls:weblogic-web-app
xmlns:wls="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://xmlns.oracle.com/weblogic/weblogic-web-app/1.4/weblogic-web-app.xsd">
<wls:context-root>/cesAppwls:context-root>
<wls:container-descriptor>
    <wls:prefer-application-packages>
        <wls:package-name>org.slf4j.*wls:package-name>
        <wls:package-name>org.springframework.*wls:package-name>
    wls:prefer-application-packages>
wls:container-descriptor>
wls:weblogic-web-app>

3、pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0modelVersion>

    <groupId>com.boostrdev.legacy.weblogicgroupId>
    <artifactId>spring-boot-legacy-weblogicartifactId>
    <version>0.0.1-SNAPSHOTversion>
    <packaging>warpackaging>

    <name>Spring Boot Legacy WebLogicname>
    <description>Demo project for deploying a Spring Boot to a legacy (10.3.5) weblogic environment using servlet 2.5description>

    <properties>
        
        <spring.version>4.2.5.RELEASEspring.version>
        <spring.boot.version>1.1.12.RELEASEspring.boot.version>
    properties>

    <parent>
        <groupId>org.springframework.bootgroupId>
        <artifactId>spring-boot-starter-parentartifactId>
        
        <version>1.1.12.RELEASEversion>
    parent>

    <dependencies>
        <dependency>
            <groupId>org.springframework.bootgroupId>
            <artifactId>spring-boot-legacyartifactId>
            <version>1.0.2.RELEASEversion>
        dependency>

        <dependency>
            <groupId>org.springframework.bootgroupId>
            <artifactId>spring-boot-starter-webartifactId>
        dependency>

        <dependency>
            <groupId>org.springframework.bootgroupId>
            <artifactId>spring-boot-starter-tomcatartifactId>
            <scope>providedscope>
        dependency>

        <dependency>
            <groupId>javax.servletgroupId>
            <artifactId>servlet-apiartifactId>
            <version>2.5version>
            <scope>testscope>
        dependency>

        <dependency>
            <groupId>org.springframework.bootgroupId>
            <artifactId>spring-boot-starter-testartifactId>
            <scope>testscope>
        dependency>

        <dependency>
            <groupId>org.springframeworkgroupId>
            <artifactId>spring-webartifactId>
            <version>${spring.version}version>
        dependency>
    dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.pluginsgroupId>
                <artifactId>maven-war-pluginartifactId>
                <configuration>
                    <attachClasses>trueattachClasses>
                    <archive>
                        <manifestEntries>
                            <Weblogic-Application-Version>${project.version}Weblogic-Application-Version>
                        manifestEntries>
                        <manifest>
                            <addClasspath>trueaddClasspath>
                            <addClasspath>lib/addClasspath>
                        manifest>
                    archive>
                    <webResources>
                        <resource>
                            <directory>${project.basedir}/src/main/resources/staticdirectory>
                        resource>
                        <resource>
                            <directory>${project.basedir}/src/main/webappdirectory>
                        resource>
                    webResources>
                    <warName>${project.artifactId}warName>
                configuration>
            plugin>

            <plugin>
                <groupId>org.springframework.bootgroupId>
                <artifactId>spring-boot-maven-pluginartifactId>
                <version>${spring.boot.version}version>
                <configuration>
                    <classifier>BOOTclassifier>
                configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>repackagegoal>
                        goals>
                    execution>
                executions>
            plugin>
        plugins>
    build>


project>

然后在上面pom文件加上原项目的依赖

4、打包

选择菜单Build->BuildArtifacts->xxx:war->Build构建完的war包默认在target目录下xxx.war

至此,将输出的war部署到weblogc正常启动与访问。

加油,每天都是元气满满的一天。

相关