0

In my local machine my rest API run perfectly. But i hosted in the server. Then when i call a post method it return error. But GET method working perfectly. Both methods working in my local computer. This is my error

Following is my POM.xml

<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.0</modelVersion>
    <groupId>com.Mobios</groupId>
    <artifactId>DigitalWallet</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>war</packaging>

    <dependencies>
        <!-- https://mvnrepository.com/artifact/org.springframework/spring-context -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>5.0.9.RELEASE</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/org.springframework/spring-webmvc -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
            <version>5.0.9.RELEASE</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/org.springframework/spring-tx -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-tx</artifactId>
            <version>5.0.9.RELEASE</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/javax.servlet/javax.servlet-api -->
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <version>3.1.0</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind -->
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
            <version>2.9.6</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/org.springframework/spring-orm -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-orm</artifactId>
            <version>5.0.9.RELEASE</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.hibernate/hibernate-core -->
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-core</artifactId>
            <version>5.3.6.Final</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/javax.validation/validation-api -->
        <dependency>
            <groupId>javax.validation</groupId>
            <artifactId>validation-api</artifactId>
            <version>2.0.1.Final</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.hibernate.validator/hibernate-validator -->
        <dependency>
            <groupId>org.hibernate.validator</groupId>
            <artifactId>hibernate-validator</artifactId>
            <version>6.0.12.Final</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java -->
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>8.0.12</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/log4j/log4j -->
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.17</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/com.thetransactioncompany/cors-filter -->
        <dependency>
            <groupId>com.thetransactioncompany</groupId>
            <artifactId>cors-filter</artifactId>
            <version>2.6</version>
        </dependency>
    </dependencies>
    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-war-plugin</artifactId>
                    <version>3.2.2</version>
                    <configuration>
                        <warSourceDirectory>src/main/webapp</warSourceDirectory>
                        <failOnMissingWebXml>false</failOnMissingWebXml>
                    </configuration>
                </plugin>

                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>3.2</version>
                    <configuration>
                        <source>1.8</source>
                        <target>1.8</target>
                    </configuration>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>
</project>

And this is my method

@RequestMapping(value = "/origin/sendcredit/", method = RequestMethod.POST)
    // @Transactional(rollbackFor = DWException.class)
    public String addSubCredit(
            @RequestBody AddMoneyToOriginVM sendCreditToOriginVM/* ,@RequestParam("hashedValue") String hashedValue */,
            HttpServletResponse response) throws Exception {
        // checkPlainAndHashed.check("ascc","cdscwc");
//      Log4JUtil.logger.info("SendCredit|Start|Transaction=" + sendCreditToOriginVM.toString() + "|"
//              + sendCreditToOriginVM.getSender_mobile_number() + " to "
//              + sendCreditToOriginVM.getReceiver_mobile_number() + " amount " + sendCreditToOriginVM.getAmount() + "|"
//              + sendCreditToOriginVM.getTransaction_Type_id());
        String Text = "";
        try {
            String receiver = sendCreditToOriginVM.getReceiver_mobile_number();
            String sender = sendCreditToOriginVM.getSender_mobile_number();

            int pin = sendCreditToOriginVM.getSender_pin();
            double amount = sendCreditToOriginVM.getAmount();
            try {
                Origin dbReceiver = originService.findByNumber(receiver);
                Origin dbSender = originService.findByNumber(sender);
                if (originService.findByNumberAndPin(sender, pin) != null) {
                    double a = Double.parseDouble(encodeDecode.Decode(dbSender.getWallet().getAmount()));
                    if (a < amount) {
                        throw new InsufficientBalanceException();
                    } else {
                        if (dbReceiver == null) {
                            OriginVM newOrigin = new OriginVM();
                            newOrigin.setMobile_number(receiver);
                            newOrigin.setOrigin_types_id(3);
                            newOrigin.setSuper_mobile_number(sender);
                            newOrigin.setStatus_id(1);
                            newOrigin.setSuper_pin(pin);
                            newOrigin.setWallet_amount(amount);
                            newOrigin.setMembership_types_id(5);
                            newOrigin.setTransaction_Type_id(1);
                            addOrigin(newOrigin, response);

                        } else {
                            SaveTransaction(dbSender, dbReceiver, amount, 2, "Debit", "Credit");
                        }
                        dbReceiver = originService.findByNumber(receiver);
                        dbSender = originService.findByNumber(sender);
                        try {
                            Text = "0|Transaction Successfull"
                                    + encodeDecode.Decode(String.valueOf(dbReceiver.getWallet().getAmount())) + "|"
                                    + encodeDecode.Decode(String.valueOf(dbSender.getWallet().getAmount()));
                        } catch (Exception e) {

                            throw new RuntimeException("Roll Me Back");
                        }

                        Log4JUtil.logger.info("SendCredit|End|Transaction=" + sendCreditToOriginVM.toString() + "|"
                                + sendCreditToOriginVM.getSender_mobile_number() + " to "
                                + sendCreditToOriginVM.getReceiver_mobile_number() + " amount "
                                + sendCreditToOriginVM.getAmount() + "|"
                                + sendCreditToOriginVM.getTransaction_Type_id());
                    }
                } else {
                    throw new AgentValidationFailedException();
                }
            } catch (DWException exp) {
                throw exp;
            }
        } catch (DWException ex) {
//          Log4JUtil.logger.info("Origine|Exception|Transaction=" + sendCreditToOriginVM.toString() + "|"
//                  + sendCreditToOriginVM.getSender_mobile_number() + " to "
//                  + sendCreditToOriginVM.getReceiver_mobile_number() + " amount " + sendCreditToOriginVM.getAmount()
//                  + "|" + ex.toString());
            response.sendError(ex.getErrorCode(), ex.getErrorMessage());
        }
        return Text;
    }

This is Server Java version openjdk version "1.8.0_191" OpenJDK Runtime Environment (build 1.8.0_191-b12) OpenJDK 64-Bit Server VM (build 25.191-b12, mixed mode)

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
K Rajitha
  • 306
  • 7
  • 24
  • https://stackoverflow.com/questions/45493099/mule-noclassdeffounderror-could-not-initialize-class-java-time-zone-zonerules – Sudhir Ojha Oct 23 '18 at 10:14
  • 1
    FWIW, don't use `double` for monetary values. Rounding errors will shoot you in your foot, sooner or later. – Gyro Gearless Oct 23 '18 at 10:19
  • will it affect to this problem? – K Rajitha Oct 23 '18 at 10:25
  • *"will it affect to this problem?"* Tip: Add @GyroGearless (or whoever, the `@` is important) to *notify* the person of a new comment. – Andrew Thompson Oct 23 '18 at 10:28
  • https://stackoverflow.com/questions/1401111/noclassdeffounderror-could-not-initialize-class-error – Michael Wiles Oct 23 '18 at 10:30
  • will it affect to this problem? @Gyro Gearless – K Rajitha Oct 23 '18 at 10:31
  • Nope, just a side note :-) – Gyro Gearless Oct 23 '18 at 10:33
  • possible dublicate of [NoClassDefFoundError: Could not initialize class java.time.zone.ZoneRulesProvider](https://stackoverflow.com/questions/45493099/mule-noclassdeffounderror-could-not-initialize-class-java-time-zone-zonerules?noredirect=1&lq=1) – T A Oct 23 '18 at 10:39
  • No not duplicate. Because that doesn't solve my issue. As i mentioned server running java jdk version is 1.8 openjdk version "1.8.0_191" OpenJDK Runtime Environment (build 1.8.0_191-b12) OpenJDK 64-Bit Server VM (build 25.191-b12, mixed mode) @T A – K Rajitha Oct 23 '18 at 10:58
  • Restarting the Server solved my issue. I think server failed to fetch the all .class files. But after restart everything work perfect. – K Rajitha Oct 29 '18 at 04:54

0 Answers0