Zulfuqar Aliyev
Zulfuqar Aliyev

Reputation: 241

How can I add jar file to project instead of adding to Tomcat lib folder?

Via this github project, I store Tomcat sessions in Redis: https://github.com/chexagon/redis-session-manager

And in src/webapp/META-INF/context.xml file I added new commands:

<Manager className="com.crimsonhexagon.rsm.redisson.SingleServerSessionManager"
             endpoint="redis://localhost:6379"
             sessionKeyPrefix="_ib_"
             saveOnChange="false"
             forceSaveAfterRequest="false"
             dirtyOnMutation="false"
             ignorePattern=".*\\.(ico|png|gif|jpg|jpeg|swf|css|js)$"
             maxSessionAttributeSize="-1"
             maxSessionSize="-1"
             allowOversizedSessions="false"
             connectionPoolSize="100"
             database="0"
             timeout="60000"
             pingTimeout="1000"
             retryAttempts="20"
             retryInterval="1000"
    />

If jar file is in Tomcat lib folder, then everything is fine. But in production if I add jar to lib folder it causes errors. Is there any other way for solving this problem? Can I change context.xml in such way that when I will deploy project, manager className will be able found relevant class? P.S. There are some examples but I couldn't catch the sense: Adding external resources to class-path in Tomcat 8

If someone can enlighten me, I will be grateful. Thanks in advance

Upvotes: 1

Views: 190

Answers (1)

Zulfuqar Aliyev
Zulfuqar Aliyev

Reputation: 241

I could find solving. There is a plugin in maven for deploying war file. With this plugin it is possible to add files to war file. For example, I created folder which is named redis and add into it jar file. Then I added plugin:

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>3.2.2</version>
                <configuration>
                    <webResources>
                        <resource>
                            <!-- this is relative to the pom.xml directory -->
                            <directory>redis</directory>
                            <targetPath>WEB-INF/lib</targetPath>
                        </resource>
                    </webResources>
                </configuration>
            </plugin>

Upvotes: 1

Related Questions