Dynamic Plug-in Java Version

72 views
Skip to first unread message

frank.li

unread,
Oct 6, 2015, 6:55:32 PM10/6/15
to dotCMS User Group
Hi,

I met the UrlOsgiClassLoader.java:212 problem again.

I would like to know if I build the dynamic plug-in using Java 1.7 + gradlew 1.8, can  I deploy it on Java 1.8 version + tomcat 8 dotCMS?
I have this question because the build can be deployed on Java 1.7 + tomcat 8 environment, but not java 1.8 + tomcat 8


Here is the execption:
 Error injecting context for overriding
java.lang.NullPointerException
    at com.dotmarketing.osgi.UrlOsgiClassLoader.reload(UrlOsgiClassLoader.java:212)
    at com.dotmarketing.osgi.UrlOsgiClassLoader.reload(UrlOsgiClassLoader.java:97)
    at com.dotmarketing.osgi.GenericBundleActivator.injectContext(GenericBundleActivator.java:293)
    at com.dotmarketing.osgi.GenericBundleActivator.injectContext(GenericBundleActivator.java:250)
    at com.dotmarketing.osgi.GenericBundleActivator.publishBundleServices(GenericBundleActivator.java:133)
    at com.dotmarketing.osgi.cookie.Activator.start(Activator.java:14)
    at com.dotcms.repackage.org.apache.felix.framework.util.SecureAction.startActivator(SecureAction.java:645)
    at com.dotcms.repackage.org.apache.felix.framework.Felix.activateBundle(Felix.java:2146)
    at com.dotcms.repackage.org.apache.felix.framework.Felix.startBundle(Felix.java:2064)
    at com.dotcms.repackage.org.apache.felix.framework.BundleImpl.start(BundleImpl.java:955)
    at com.dotcms.repackage.org.apache.felix.fileinstall.internal.DirectoryWatcher.process(DirectoryWatcher.java:1175)
    at com.dotcms.repackage.org.apache.felix.fileinstall.internal.DirectoryWatcher.process(DirectoryWatcher.java:1153)
    at com.dotcms.repackage.org.apache.felix.fileinstall.internal.DirectoryWatcher.process(DirectoryWatcher.java:458)
    at com.dotcms.repackage.org.apache.felix.fileinstall.internal.DirectoryWatcher.run(DirectoryWatcher.java:263)
    at com.dotcms.repackage.org.apache.felix.framework.Felix.activateBundle(Felix.java:2196)
    at com.dotcms.repackage.org.apache.felix.framework.Felix.startBundle(Felix.java:2064)
    at com.dotcms.repackage.org.apache.felix.framework.BundleImpl.start(BundleImpl.java:955)
    at com.dotcms.repackage.org.apache.felix.fileinstall.internal.DirectoryWatcher.process(DirectoryWatcher.java:1175)
    at com.dotcms.repackage.org.apache.felix.fileinstall.internal.DirectoryWatcher.process(DirectoryWatcher.java:1153)
    at com.dotcms.repackage.org.apache.felix.fileinstall.internal.DirectoryWatcher.process(DirectoryWatcher.java:458)
    at com.dotcms.repackage.org.apache.felix.fileinstall.internal.DirectoryWatcher.run(DirectoryWatcher.java:263)

Jason Tesser

unread,
Oct 6, 2015, 7:31:48 PM10/6/15
to dotCMS User Group

I have used it on Java 8 but maybe something about your java 8 environment. 


--
You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dotcms+un...@googlegroups.com.
To post to this group, send email to dot...@googlegroups.com.
Visit this group at http://groups.google.com/group/dotcms.
For more options, visit https://groups.google.com/d/optout.

Frank

unread,
Oct 6, 2015, 8:21:35 PM10/6/15
to dot...@googlegroups.com
Thanks Jason,

I found some clues, but problem still there.

if I comment this line
publishBundleServices(context);
in the following class file, it will be deployed successfully, but override
does not work.
this only happened in java 1.8 + tomcat 8, not java 1.7 + tomcat 8(comment
or not, both will work).

hope someone can give me a further instruction.

Thanks a lot.


public class Activator extends GenericBundleActivator {

@SuppressWarnings ("unchecked")
public void start ( BundleContext context ) throws Exception {
//Initializing services...
initializeServices( context );
publishBundleServices(context);
}

public void stop ( BundleContext context ) throws Exception {
unpublishBundleServices();
}

}



--
View this message in context: http://forumarchive.dotcms.com/Dynamic-Plug-in-Java-Version-tp5729694p5729696.html
Sent from the dotCMS Users Group mailing list archive at Nabble.com.

frank.li

unread,
Oct 6, 2015, 8:33:09 PM10/6/15
to dotCMS User Group


On Tuesday, October 6, 2015 at 8:21:35 PM UTC-4, frank.li wrote:
Thanks Jason,

  Oh: this is related to class override.
 

Falzone, Chris

unread,
Oct 7, 2015, 9:46:42 AM10/7/15
to dot...@googlegroups.com
Well you cannot compile the classes and create jar in 1.7 jdk and then deploy it to a server running against 1.8 java.  That would certainly cause issues.  Have you tried compiling against 1.8 and then deploying?  

--
You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dotcms+un...@googlegroups.com.
To post to this group, send email to dot...@googlegroups.com.
Visit this group at http://groups.google.com/group/dotcms.
For more options, visit https://groups.google.com/d/optout.



--

Christopher Falzone

Interactive Developer


A Q U E N T

Digital, Creative, and Marketing Talent


aquent.com

cfal...@aquent.com

Jason Tesser

unread,
Oct 7, 2015, 9:48:02 AM10/7/15
to dot...@googlegroups.com
That could be it Chris but in his case I think it has to do with his environment and the JDK instrumentation 

frank.li

unread,
Oct 7, 2015, 9:22:20 PM10/7/15
to dotCMS User Group
Hi Chris,

Thank you for your reply.
I have installed same jdk vesion which is runing on dotCMS server ("1.8.0_60").
I ran "gradlew jar", deployed the jar file, problem still there(same error message).

do you have any other idea?
Thanks again.

Frank

frank.li

unread,
Oct 7, 2015, 11:09:12 PM10/7/15
to dotCMS User Group
Hi Chris,

I have upgrade my build environment and dotCMS servers to Java 1.8.

There are two dotCMS servers.
one is Java1.8 + Tocmat 8 + dotCMS 3.2.2, the dynamic plugin file can be deployed and run properly on this.
but the same file can not be deployed and run on the server with Java1.8 + Tocmat 8 + dotCMS 3.2.4

Tomorrow, I will upgrade 3.2.2 to 3.2.4 and do another test.

Frank

pawankum...@gmail.com

unread,
Oct 8, 2015, 8:29:14 AM10/8/15
to dotCMS User Group
Hi Chris,
             I want to call the post method of my dynamic plugin via following client side view:
    

<form   action="/app/spring/examplecontroller" method='post'>
                                <div class='new-row'>
                                    <select class='form-control' name="hotelName">
                                        <option>Select Your Hotel</option>
                                        <option>The Leela Palace,Bangalore</option>
                                    </select>
                                </div>
                                <div class='new-row'>
                                    <div class='in-bl-2'>
                                        <input type='text' class='form-control chk-in' placeholder='25-09-2015' name="chkInDate"/>
                                    </div>
                                    <div class='in-bl-2'>
                                        <input type='text' class='form-control chk-out' placeholder='27-09-2015' name="chkInOutDate" />
                                    </div>
                                </div>
                                <div class='new-row'>
                                    <div class='in-bl-3'>
                                        <select class='form-control' name="rooms">
                                            <option>Rooms</option>
                                            <option>1</option>
                                        </select>
                                    </div>
                                    <div class='in-bl-3'>
                                        <select class='form-control' name="adults">
                                            <option>Adults</option>
                                            <option>2</option>
                                        </select>
                                    </div>
                                    <div class='in-bl-3'>
                                        <select class='form-control' name="childrens">
                                            <option>Children</option>
                                             <option>1</option>
                                        </select>
                                    </div>
                                </div>
                                <div class='new-row'>
                                    <input type='submit' class='btn' value='Check Availability' />
                                </div>
                            </form>

   I uploaded my dynamic plugin, it is working correct but the problem is , when I call the POST method , it is being called along with the call GET method 3 times in total repeatative 4 times the request is going how to control that method , here is my controller and giving the messages regarding GET method,
package com.dotmarketing.osgi.spring;

import com.dotmarketing.util.Logger;

import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;

/**
 * Created by Jonathan Gamba
 * Date: 6/18/12
 */

@EnableWebMvc
@Configuration
@RequestMapping ("/examplecontroller")
@Controller
public class ExampleController {

    @RequestMapping(method = RequestMethod.GET, produces={"application/json","application/xml"}, consumes="text/html")
    public ModelAndView helloWorld() {
        Logger.info( this.getClass(), "Received request to hello" );
        String myMessage = "Hello World,GET Spring 3.1 and dotCMS!";
        // This will resolve to /application/spring/helloworld.dot, and put the String myMessage in the map with key "message"
        return new ModelAndView("helloworld", "msg", myMessage);
    }

 @RequestMapping(method = RequestMethod.POST,produces={"application/json","application/xml"}, consumes="text/html")
    public String helloWorldPost(Model model) {
        Logger.info( this.getClass(), "Received request  to hello1" );
        String myMessage = "Hello World,POST Spring 3.1 and dotCMS!1";
        // This will resolve to /application/spring/helloworld.dot, and put the String myMessage in the map with key "message"
         model.addAttribute("msg",myMessage);
        return "helloworld";
    }


    @RequestMapping(value = "/{userName}", method = RequestMethod.GET)
    public String getHello(@PathVariable String userName, Model model) {

        Logger.info( this.getClass(), "Received request to hello user" );

        // set the message
        String aMessage = (userName != null)
                ? "Hello EDIT " + userName + ", welcome to Spring  3.1 and dotCMS!  "
                : "Hello Total Stranger, welcome to Spring  3.1 and dotCMS!  ";

        // Attach message to the Model
        model.addAttribute("message", aMessage);

        // This will resolve to /application/spring/helloworld.dot
        return "helloworld";
    }

}


  here is the log file generated;-
2015-10-08 11:47:08,741 INFO  com.dotmarketing.business.DotGuavaCacheAdministratorImpl - ***     Building Cache : csscache, size:100, toDisk:true,Concurrency:32
2015-10-08 11:56:43,578 INFO  com.dotmarketing.osgi.spring.ExampleController - Received request  to hello1
2015-10-08 11:56:43,686 INFO  com.dotmarketing.osgi.spring.ExampleController - Received request to hello
2015-10-08 11:56:43,900 INFO  com.dotmarketing.osgi.spring.ExampleController - Received request to hello
2015-10-08 11:56:43,900 INFO  com.dotmarketing.osgi.spring.ExampleController - Received request to hello
2015-10-08 11:59:00,662 INFO  com.dotmarketing.osgi.spring.ExampleController - Received request  to hello1
2015-10-08 11:59:00,736 INFO  com.dotmarketing.osgi.spring.ExampleController - Received request to hello
2015-10-08 11:59:00,957 INFO  com.dotmarketing.osgi.spring.ExampleController - Received request to hello
2015-10-08 11:59:00,960 INFO  com.dotmarketing.osgi.spring.ExampleController - Received request to hello
2015-10-08 12:00:41,037 INFO  com.dotmarketing.osgi.spring.ExampleController - Received request  to hello1
2015-10-08 12:00:41,114 INFO  com.dotmarketing.osgi.spring.ExampleController - Received request to hello
2015-10-08 12:00:41,410 INFO  com.dotmarketing.osgi.spring.ExampleController - Received request to hello
2015-10-08 12:00:41,411 INFO  com.dotmarketing.osgi.spring.ExampleController - Received request to hello
2015-10-08 12:01:03,205 INFO  com.dotmarketing.osgi.spring.ExampleController - Received request  to hello1
2015-10-08 12:01:03,290 INFO  com.dotmarketing.osgi.spring.ExampleController - Received request to hello
2015-10-08 12:01:03,500 INFO  com.dotmarketing.osgi.spring.ExampleController - Received request to hello
2015-10-08 12:01:03,500 INFO  com.dotmarketing.osgi.spring.ExampleController - Received request to hello
2015-10-08 12:01:41,897 INFO  com.dotmarketing.osgi.spring.ExampleController - Received request  to hello1
2015-10-08 12:01:41,969 INFO  com.dotmarketing.osgi.spring.ExampleController - Received request to hello
2015-10-08 12:01:42,145 INFO  com.dotmarketing.osgi.spring.ExampleController - Received request to hello
2015-10-08 12:01:42,145 INFO  com.dotmarketing.osgi.spring.ExampleController - Received request to hello
2015-10-08 12:09:44,543 INFO  com.dotmarketing.business.ajax.PermissionAjax - ##=> permissionMap: {inode=5e6aaea0-60f7-4c07-82e9-34cdcac67972, roleId=654b0931-1027-41f7-ad4d-173115ed8ec1, permission=15, id=12490, type=individual, isBitPermission=true}
2015-10-08 12:09:44,543 INFO  com.dotmarketing.business.ajax.PermissionAjax - ##=> permissionMap: {inode=5e6aaea0-60f7-4c07-82e9-34cdcac67972, roleId=999cd6bf-5cef-4729-8543-696086143884, permission=1, id=12442, type=individual, isBitPermission=true}

Falzone, Chris

unread,
Oct 8, 2015, 8:46:45 AM10/8/15
to dot...@googlegroups.com
The reason you see three times is because you are doing it in the dotCMS Page Editor, logged in.  In the page editor it will render every page 3 times, once for each view of the page (Live/Preview/Edit).  So that is totally expected.  I am not familiar enough with sprint to know why it would also be calling your post and get methods each time you submit the form.  

frank.li

unread,
Oct 9, 2015, 11:43:56 AM10/9/15
to dotCMS User Group
Thanks everybody.

I found the problem.
when I solved the "Tomcat – java.lang.OutOfMemoryError: PermGen space" issue, I put a new file "setenv.sh" in the "tomcat-8.0.18/bin" directory.
removed this file, dynamic plug-in would be Ok.

Frank


Reply all
Reply to author
Forward
0 new messages